Compare commits
27 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b7e8de26c | ||
|
|
a2bd981032 | ||
|
|
a2eef8062b | ||
|
|
e0dc694125 | ||
|
|
5157eada71 | ||
|
|
fcb7466f35 | ||
|
|
f3e435ec35 | ||
|
|
b4193a89b7 | ||
|
|
14eb0cd14c | ||
|
|
9c069c4141 | ||
|
|
1ae18a54f9 | ||
|
|
058779a5d5 | ||
|
|
fa7e7e5dec | ||
|
|
8161155280 | ||
|
|
9362e1ab03 | ||
|
|
1e402a48e3 | ||
|
|
c0f73c53af | ||
|
|
e7715dc4ea | ||
|
|
c3172dfc8f | ||
|
|
7575406d3a | ||
|
|
9fe61a6e45 | ||
|
|
b7e34e62a9 | ||
|
|
966765906b | ||
|
|
036b9515cb | ||
|
|
0c4a8d07ca | ||
|
|
9e73316a6c | ||
|
|
21ae3f4ea0 |
17 changed files with 357 additions and 549 deletions
102
Dockerfile
102
Dockerfile
|
|
@ -1,41 +1,88 @@
|
||||||
|
# Container artifact for the PostgreSQL module
|
||||||
|
|
||||||
|
# This should probably rather be something like...:
|
||||||
|
# FROM registry.fedoraproject.org/module-base-runtime:26
|
||||||
|
# ...and probably would:
|
||||||
|
# - not have any repositories configured
|
||||||
|
# - need a shared-userspace module repo enabled
|
||||||
FROM baseruntime/baseruntime:latest
|
FROM baseruntime/baseruntime:latest
|
||||||
|
|
||||||
# PostgreSQL image for OpenShift.
|
# PostgreSQL container image
|
||||||
|
# Exposed ports:
|
||||||
|
# * 5432/tcp - postgres
|
||||||
# Volumes:
|
# Volumes:
|
||||||
# * /var/lib/psql/data - Database cluster for PostgreSQL
|
# * /var/lib/psql/data - Database cluster for PostgreSQL
|
||||||
# Environment:
|
|
||||||
# * $POSTGRESQL_USER - Database user name
|
|
||||||
# * $POSTGRESQL_PASSWORD - User's password
|
|
||||||
# * $POSTGRESQL_DATABASE - Name of the database to create
|
|
||||||
# * $POSTGRESQL_ADMIN_PASSWORD (Optional) - Password for the 'postgres'
|
|
||||||
# PostgreSQL administrative account
|
|
||||||
|
|
||||||
ENV POSTGRESQL_VERSION=9.5 \
|
|
||||||
|
ENV NAME=postgresql \
|
||||||
|
VERSION=0 \
|
||||||
|
RELEASE=1 \
|
||||||
|
ARCH=x86_64 \
|
||||||
|
LANG=C.UTF-8 \
|
||||||
|
LC_ALL=C.UTF-8 \
|
||||||
|
POSTGRESQL_VERSION=9.6 \
|
||||||
HOME=/var/lib/pgsql \
|
HOME=/var/lib/pgsql \
|
||||||
PGUSER=postgres
|
PGUSER=postgres \
|
||||||
|
POSTGRESQL_MODULE_HASH=d87b0b15567e47f3
|
||||||
|
|
||||||
LABEL io.k8s.description="PostgreSQL is an advanced Object-Relational database management system" \
|
LABEL summary = "PostgreSQL is an object-relational DBMS." \
|
||||||
io.k8s.display-name="PostgreSQL 9.5" \
|
name = "$FGC/$NAME" \
|
||||||
io.openshift.expose-services="5432:postgresql" \
|
version = "$VERSION" \
|
||||||
io.openshift.tags="database,postgresql,postgresql95" \
|
release="$RELEASE.$DISTTAG" \
|
||||||
com.redhat.component="postgresql" \
|
architecture = "$ARCH" \
|
||||||
maintainer="Pavel Raiskup <praiskup@redhat.com>" \
|
maintainer = "Nils Philippsen <nils@redhat.com>" \
|
||||||
name="$FCG/postgresql" \
|
description = "PostgreSQL is an advanced Object-Relational database management system (DBMS). This container contains the programs needed to create and run a PostgreSQL server, which will in turn allow you to create and maintain PostgreSQL databases." \
|
||||||
version="0" \
|
vendor="Fedora Project" \
|
||||||
release="1.$DISTTAG" \
|
com.redhat.component="$NAME" \
|
||||||
architecture="x86_64" \
|
org.fedoraproject.component="postgresql" \
|
||||||
usage="Run without arguments to get usage info." \
|
authoritative-source-url="registry.fedoraproject.org" \
|
||||||
help="/help.1"
|
usage="docker run -v <dbroot_path>:/var/lib/pgsql:Z -p 5432:5432 -e POSTGRESQL_USER=<user> -e POSTGRESQL_PASSWORD=<password> -e POSTGRESQL_DATABASE=<database> modularitycontainers/postgresql" \
|
||||||
|
io.k8s.description = "PostgreSQL is an advanced Object-Relational database management system (DBMS). This container contains the programs needed to create and run a PostgreSQL server, which will in turn allow you to create and maintain PostgreSQL databases." \
|
||||||
|
io.k8s.display-name="PostgreSQL ${POSTGRESQL_VERSION}" \
|
||||||
|
io.openshift.tags="database,postgresql,postgresql96" \
|
||||||
|
io.openshift.expose-services="5432/tcp:postgres"
|
||||||
|
|
||||||
EXPOSE 5432
|
EXPOSE 5432
|
||||||
|
|
||||||
ADD root /
|
ADD root /
|
||||||
|
|
||||||
COPY repos/* /etc/yum.repos.d/
|
COPY module-postgresql.repo.in /tmp/module-postgresql.repo.in
|
||||||
|
COPY run_tests.sh /usr/bin/run_tests.sh
|
||||||
|
|
||||||
RUN microdnf --nodocs --enablerepo postgresql install -y postgresql postgresql-server postgresql-contrib && \
|
# Install the postgresql server component.
|
||||||
microdnf --nodocs --enablerepo fedora install -y rsync tar gettext bind-utils nss_wrapper findutils python && \
|
#
|
||||||
microdnf clean all && \
|
# This image must forever use UID 26 for postgres user so our volumes are
|
||||||
|
# safe in the future. This should *never* change, the last test is there
|
||||||
|
# to make sure of that.
|
||||||
|
|
||||||
|
# Notes about the below:
|
||||||
|
# - first sed cmd: don't ask
|
||||||
|
# - rpm -e ... microdnf install systemd: workaround to missing
|
||||||
|
# microdnf downgrade/distro-sync
|
||||||
|
# - Update packages so everything available is current
|
||||||
|
# - Need to have charset files, disable normal repo(s), enable module repo(s)
|
||||||
|
# ORCHESTRATION:
|
||||||
|
# - Newer versions of the shared-userspace module are supposed to have
|
||||||
|
# findutils, not there yet
|
||||||
|
# - gettext: /usr/bin/envsubst
|
||||||
|
# - no working python module yet
|
||||||
|
|
||||||
|
RUN \
|
||||||
|
sed -i 's|/jkaluza/|/ralph/|g' /etc/yum.repos.d/build.repo && \
|
||||||
|
rpm -e --justdb --nodeps systemd-libs && \
|
||||||
|
microdnf install -y --setopt=tsflags=nodocs systemd && \
|
||||||
|
# microdnf update -y --setopt=tsflags=nodocs && \
|
||||||
|
# microdnf install -y glibc-locale-source && \
|
||||||
|
microdnf install -y findutils && \
|
||||||
|
microdnf install -y gettext && \
|
||||||
|
# microdnf install -y nss_wrapper && \
|
||||||
|
# microdnf install -y /usr/bin/python && \
|
||||||
|
sed 's|@POSTGRESQL_MODULE_HASH@|'${POSTGRESQL_MODULE_HASH}'|g; s|${basearch}|'${ARCH}'|g' < /tmp/module-postgresql.repo.in > /etc/yum.repos.d/module-postgresql.repo && rm -f /tmp/module-postgresql.repo.in && \
|
||||||
|
INSTALL_PKGS="postgresql postgresql-server" && \
|
||||||
|
microdnf install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
|
||||||
|
rpm -V $INSTALL_PKGS && \
|
||||||
|
microdnf -y clean all && \
|
||||||
|
# localedef -f UTF-8 -i en_US en_US.UTF-8 && \
|
||||||
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
|
test "$(id postgres)" = "uid=26(postgres) gid=26(postgres) groups=26(postgres)" && \
|
||||||
mkdir -p /var/lib/pgsql/data && \
|
mkdir -p /var/lib/pgsql/data && \
|
||||||
/usr/libexec/fix-permissions /var/lib/pgsql && \
|
/usr/libexec/fix-permissions /var/lib/pgsql && \
|
||||||
|
|
@ -44,8 +91,9 @@ RUN microdnf --nodocs --enablerepo postgresql install -y postgresql postgresql-
|
||||||
# Get prefix path and path to scripts rather than hard-code them in scripts
|
# Get prefix path and path to scripts rather than hard-code them in scripts
|
||||||
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
|
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/postgresql
|
||||||
|
|
||||||
VOLUME ["/var/lib/pgsql/data"]
|
VOLUME ["/var/lib/pgsql"]
|
||||||
|
|
||||||
USER 26
|
USER 26
|
||||||
|
|
||||||
|
ENTRYPOINT ["container-entrypoint"]
|
||||||
CMD ["run-postgresql"]
|
CMD ["run-postgresql"]
|
||||||
|
|
|
||||||
4
Makefile
4
Makefile
|
|
@ -1,4 +1,4 @@
|
||||||
IMAGE_NAME = postgresql
|
IMAGE_NAME = modularitycontainers/postgresql
|
||||||
|
|
||||||
MODULEMDURL=file://postgresql.yaml
|
MODULEMDURL=file://postgresql.yaml
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@ build:
|
||||||
docker build --tag=$(IMAGE_NAME) .
|
docker build --tag=$(IMAGE_NAME) .
|
||||||
|
|
||||||
run: build
|
run: build
|
||||||
docker run -d $(IMAGE_NAME)
|
docker run -it -p 80:80 $(IMAGE_NAME)
|
||||||
|
|
||||||
test: build
|
test: build
|
||||||
cd tests; MODULE=docker MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all
|
cd tests; MODULE=docker MODULEMD=$(MODULEMDURL) URL="docker=$(IMAGE_NAME)" make all
|
||||||
|
|
|
||||||
41
README.md
Normal file
41
README.md
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
# PostgreSQL
|
||||||
|
|
||||||
|
PostgreSQL is an object-relational Database Management System.
|
||||||
|
|
||||||
|
This is based on the SCL container image for version 9.5 at:
|
||||||
|
|
||||||
|
https://github.com/sclorg/postgresql-container
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
You must either specify the following environment variables:
|
||||||
|
|
||||||
|
* POSTGRESQL_USER
|
||||||
|
* POSTGRESQL_PASSWORD
|
||||||
|
* POSTGRESQL_DATABASE
|
||||||
|
|
||||||
|
Or the following environment variable:
|
||||||
|
|
||||||
|
* POSTGRESQL_ADMIN_PASSWORD
|
||||||
|
|
||||||
|
Or both.
|
||||||
|
|
||||||
|
Optional settings:
|
||||||
|
|
||||||
|
* POSTGRESQL_MAX_CONNECTIONS (default: 100)
|
||||||
|
* POSTGRESQL_MAX_PREPARED_TRANSACTIONS (default: 0)
|
||||||
|
* POSTGRESQL_SHARED_BUFFERS (default: 32MB)
|
||||||
|
|
||||||
|
## Running in docker
|
||||||
|
|
||||||
|
```
|
||||||
|
docker run -v <dbroot_path>:/var/lib/pgsql:Z -p 5432:5432 -e POSTGRESQL_USER=<user> -e POSTGRESQL_PASSWORD=<password> -e POSTGRESQL_DATABASE=<database> modularitycontainers/postgresql
|
||||||
|
```
|
||||||
|
|
||||||
|
Substitute these placeholders with real values:
|
||||||
|
|
||||||
|
* `dbroot_path` - path to the database root on the host which should be mounted
|
||||||
|
on `/var/lib/pgsql` in the container. Note that the `postgres` user (uid 26)
|
||||||
|
needs to be able to read and write in that directory.
|
||||||
|
* `user`, `password`, `database` - details with which a database and user
|
||||||
|
should be created if the database cluster directory isn't initialized yet.
|
||||||
5
module-postgresql.repo.in
Normal file
5
module-postgresql.repo.in
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[module-postgresql]
|
||||||
|
name=Repository for the PostgreSQL module
|
||||||
|
baseurl=https://kojipkgs.fedoraproject.org/repos/module-@POSTGRESQL_MODULE_HASH@-build/latest/${basearch}/
|
||||||
|
enabled=1
|
||||||
|
gpgcheck=0
|
||||||
|
|
@ -1,41 +1,81 @@
|
||||||
document: modulemd
|
document: modulemd
|
||||||
version: 1
|
version: 1
|
||||||
data:
|
data:
|
||||||
summary: postgresql module
|
# name, stream, version are filled in by the build system
|
||||||
description: This postgresql module has been generated.
|
#name: ""
|
||||||
|
#stream: ""
|
||||||
|
#version: 0
|
||||||
|
summary: 'The programs needed to create and run a PostgreSQL server'
|
||||||
|
description: |-
|
||||||
|
PostgreSQL is an advanced Object-Relational database management system
|
||||||
|
(DBMS). The postgresql-server package contains the programs needed to
|
||||||
|
create and run a PostgreSQL server, which will in turn allow you to create
|
||||||
|
and maintain PostgreSQL databases.
|
||||||
license:
|
license:
|
||||||
module: [ MIT ]
|
module:
|
||||||
|
- MIT
|
||||||
|
content:
|
||||||
|
- PostgreSQL
|
||||||
dependencies:
|
dependencies:
|
||||||
buildrequires:
|
buildrequires:
|
||||||
bootstrap: master
|
base-runtime: f26
|
||||||
|
common-build-dependencies: f26
|
||||||
|
common-build-dependencies-bootstrap: f26
|
||||||
|
shared-userspace: f26
|
||||||
|
perl: f26
|
||||||
requires:
|
requires:
|
||||||
platform: master
|
base-runtime: f26
|
||||||
references:
|
|
||||||
community: https://docs.pagure.org/modularity/
|
|
||||||
documentation: https://github.com/modularity-modules/postgresql
|
|
||||||
tracker: https://github.com/modularity-modules/postgresql
|
|
||||||
api:
|
api:
|
||||||
rpms:
|
rpms:
|
||||||
- postgresql
|
- postgresql
|
||||||
profiles:
|
profiles:
|
||||||
default:
|
default:
|
||||||
rpms:
|
rpms:
|
||||||
- postgresql-server
|
- postgresql-server
|
||||||
server:
|
|
||||||
rpms:
|
|
||||||
- postgresql-server
|
|
||||||
client:
|
client:
|
||||||
rpms:
|
rpms:
|
||||||
- postgresql
|
- postgresql
|
||||||
filter: {}
|
filter: {}
|
||||||
components:
|
components:
|
||||||
rpms:
|
rpms:
|
||||||
# postgresql-10.0-3.fc28
|
# part of base-runtime:
|
||||||
postgresql:
|
# gettext
|
||||||
rationale: Generated.
|
# part of common-build-dependencies:
|
||||||
ref: 07894e0da4b994092abd0084fba982e075ccf3f3
|
# autoconf(uuid), multilib-rpm-config, docbook-utils
|
||||||
# uuid-1.6.2-39.fc27
|
# part of shared-userspace:
|
||||||
|
# docbook-dtds, docbook-style-dsssl, libxslt, perl-SGMLSpm, python2, tcl
|
||||||
|
oniguruma:
|
||||||
|
rationale: 'Build dependency (for slang)'
|
||||||
|
ref: f26
|
||||||
|
perl-Data-UUID:
|
||||||
|
rationale: 'Build dependency (for uuid)'
|
||||||
|
ref: f26
|
||||||
|
rsh:
|
||||||
|
rationale: 'Build dependency (for lynx)'
|
||||||
|
ref: f26
|
||||||
|
telnet:
|
||||||
|
rationale: 'Build dependency (for lynx)'
|
||||||
|
ref: f26
|
||||||
|
slang:
|
||||||
|
buildorder: 1
|
||||||
|
rationale: 'Build dependency (for lynx)'
|
||||||
|
ref: f26
|
||||||
uuid:
|
uuid:
|
||||||
rationale: Generated.
|
buildorder: 1
|
||||||
ref: 43c916caff937bdf8a97ded1abff3e01df4895f4
|
rationale: 'Build dependency (for postgresql).'
|
||||||
|
ref: f26
|
||||||
|
lynx:
|
||||||
|
buildorder: 2
|
||||||
|
rationale: >-
|
||||||
|
Build dependency (for postgresql),
|
||||||
|
ref: f26
|
||||||
|
postgresql:
|
||||||
|
buildorder: 3
|
||||||
|
rationale: 'The API we want to provide.'
|
||||||
|
# This branch doesn't BR: systemtap(-devel), elinks which pulls in
|
||||||
|
# loads of other junk
|
||||||
|
ref: private-f27-modules
|
||||||
|
tcl-pgtcl:
|
||||||
|
buildorder: 4
|
||||||
|
rationale: 'Runtime dependency (for postgresql-pltcl)'
|
||||||
|
ref: f26
|
||||||
|
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
[fedora]
|
|
||||||
name=fedora
|
|
||||||
baseurl=https://mirrors.nic.cz/fedora/linux/development/26/Everything/x86_64/os/
|
|
||||||
enabled=0
|
|
||||||
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
[postgresql]
|
|
||||||
name=postgresql
|
|
||||||
baseurl=https://kojipkgs.fedoraproject.org/repos/module-5a0a295c9673c2a1/latest/x86_64/
|
|
||||||
enabled=0
|
|
||||||
190
root/help.1
190
root/help.1
|
|
@ -1,190 +0,0 @@
|
||||||
.\"t
|
|
||||||
.\" WARNING: Do not edit this file manually, it is generated from README.md automatically.
|
|
||||||
.\"
|
|
||||||
.\"t
|
|
||||||
.\" Automatically generated by Pandoc 1.16.0.2
|
|
||||||
.\"
|
|
||||||
.TH "POSTGRESQL\-95\-RHEL7" "1" "February 22, 2017" "Container Image Pages" ""
|
|
||||||
.hy
|
|
||||||
.SH PostgreSQL Docker image
|
|
||||||
.PP
|
|
||||||
This repository contains Dockerfiles for PostgreSQL images for general
|
|
||||||
usage and OpenShift.
|
|
||||||
Users can choose between RHEL and CentOS based images.
|
|
||||||
.SS Environment variables and volumes
|
|
||||||
.PP
|
|
||||||
The image recognizes the following environment variables that you can
|
|
||||||
set during initialization by passing \f[C]\-e\ VAR=VALUE\f[] to the
|
|
||||||
Docker run command.
|
|
||||||
.PP
|
|
||||||
.TS
|
|
||||||
tab(@);
|
|
||||||
lw(26.7n) lw(43.3n).
|
|
||||||
T{
|
|
||||||
Variable name
|
|
||||||
T}@T{
|
|
||||||
Description
|
|
||||||
T}
|
|
||||||
_
|
|
||||||
T{
|
|
||||||
\f[C]POSTGRESQL_USER\f[]
|
|
||||||
T}@T{
|
|
||||||
User name for PostgreSQL account to be created
|
|
||||||
T}
|
|
||||||
T{
|
|
||||||
\f[C]POSTGRESQL_PASSWORD\f[]
|
|
||||||
T}@T{
|
|
||||||
Password for the user account
|
|
||||||
T}
|
|
||||||
T{
|
|
||||||
\f[C]POSTGRESQL_DATABASE\f[]
|
|
||||||
T}@T{
|
|
||||||
Database name
|
|
||||||
T}
|
|
||||||
T{
|
|
||||||
\f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
|
|
||||||
T}@T{
|
|
||||||
Password for the \f[C]postgres\f[] admin account (optional)
|
|
||||||
T}
|
|
||||||
.TE
|
|
||||||
.PP
|
|
||||||
The following environment variables influence the PostgreSQL
|
|
||||||
configuration file.
|
|
||||||
They are all optional.
|
|
||||||
.PP
|
|
||||||
.TS
|
|
||||||
tab(@);
|
|
||||||
lw(15.7n) lw(37.6n) lw(16.7n).
|
|
||||||
T{
|
|
||||||
Variable name
|
|
||||||
T}@T{
|
|
||||||
Description
|
|
||||||
T}@T{
|
|
||||||
Default
|
|
||||||
T}
|
|
||||||
_
|
|
||||||
T{
|
|
||||||
\f[C]POSTGRESQL_MAX_CONNECTIONS\f[]
|
|
||||||
T}@T{
|
|
||||||
The maximum number of client connections allowed
|
|
||||||
T}@T{
|
|
||||||
100
|
|
||||||
T}
|
|
||||||
T{
|
|
||||||
\f[C]POSTGRESQL_MAX_PREPARED_TRANSACTIONS\f[]
|
|
||||||
T}@T{
|
|
||||||
Sets the maximum number of transactions that can be in the "prepared"
|
|
||||||
state.
|
|
||||||
If you are using prepared transactions, you will probably want this to
|
|
||||||
be at least as large as max_connections
|
|
||||||
T}@T{
|
|
||||||
0
|
|
||||||
T}
|
|
||||||
T{
|
|
||||||
\f[C]POSTGRESQL_SHARED_BUFFERS\f[]
|
|
||||||
T}@T{
|
|
||||||
Sets how much memory is dedicated to PostgreSQL to use for caching data
|
|
||||||
T}@T{
|
|
||||||
32M
|
|
||||||
T}
|
|
||||||
T{
|
|
||||||
\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[]
|
|
||||||
T}@T{
|
|
||||||
Set to an estimate of how much memory is available for disk caching by
|
|
||||||
the operating system and within the database itself
|
|
||||||
T}@T{
|
|
||||||
128M
|
|
||||||
T}
|
|
||||||
.TE
|
|
||||||
.PP
|
|
||||||
You can also set the following mount points by passing the
|
|
||||||
\f[C]\-v\ /host:/container\f[] flag to Docker.
|
|
||||||
.PP
|
|
||||||
.TS
|
|
||||||
tab(@);
|
|
||||||
l l.
|
|
||||||
T{
|
|
||||||
Volume mount point
|
|
||||||
T}@T{
|
|
||||||
Description
|
|
||||||
T}
|
|
||||||
_
|
|
||||||
T{
|
|
||||||
\f[C]/var/lib/pgsql/data\f[]
|
|
||||||
T}@T{
|
|
||||||
PostgreSQL database cluster directory
|
|
||||||
T}
|
|
||||||
.TE
|
|
||||||
.PP
|
|
||||||
\f[B]Notice: When mouting a directory from the host into the container,
|
|
||||||
ensure that the mounted directory has the appropriate permissions and
|
|
||||||
that the owner and group of the directory matches the user UID or name
|
|
||||||
which is running inside the container.\f[]
|
|
||||||
.SS Usage
|
|
||||||
.PP
|
|
||||||
For this, we will assume that you are using the
|
|
||||||
\f[C]openshift/postgresql\-92\-centos7\f[] image.
|
|
||||||
If you want to set only the mandatory environment variables and not
|
|
||||||
store the database in a host directory, execute the following command:
|
|
||||||
.IP
|
|
||||||
.nf
|
|
||||||
\f[C]
|
|
||||||
$\ docker\ run\ \-d\ \-\-name\ postgresql_database\ \-e\ POSTGRESQL_USER=user\ \-e\ POSTGRESQL_PASSWORD=pass\ \-e\ POSTGRESQL_DATABASE=db\ \-p\ 5432:5432\ openshift/postgresql\-92\-centos7
|
|
||||||
\f[]
|
|
||||||
.fi
|
|
||||||
.PP
|
|
||||||
This will create a container named \f[C]postgresql_database\f[] running
|
|
||||||
PostgreSQL with database \f[C]db\f[] and user with credentials
|
|
||||||
\f[C]user:pass\f[].
|
|
||||||
Port 5432 will be exposed and mapped to the host.
|
|
||||||
If you want your database to be persistent across container executions,
|
|
||||||
also add a \f[C]\-v\ /host/db/path:/var/lib/pgsql/data\f[] argument.
|
|
||||||
This will be the PostgreSQL database cluster directory.
|
|
||||||
.PP
|
|
||||||
If the database cluster directory is not initialized, the entrypoint
|
|
||||||
script will first run
|
|
||||||
\f[C]initdb\f[] (http://www.postgresql.org/docs/9.2/static/app-initdb.html)
|
|
||||||
and setup necessary database users and passwords.
|
|
||||||
After the database is initialized, or if it was already present,
|
|
||||||
\f[C]postgres\f[] (http://www.postgresql.org/docs/9.2/static/app-postgres.html)
|
|
||||||
is executed and will run as PID 1.
|
|
||||||
You can stop the detached container by running
|
|
||||||
\f[C]docker\ stop\ postgresql_database\f[].
|
|
||||||
.SS PostgreSQL auto\-tuning
|
|
||||||
.PP
|
|
||||||
When the PostgreSQL image is run with the \f[C]\-\-memory\f[] parameter
|
|
||||||
set and if there are no values provided for
|
|
||||||
\f[C]POSTGRESQL_SHARED_BUFFERS\f[] and
|
|
||||||
\f[C]POSTGRESQL_EFFECTIVE_CACHE_SIZE\f[] those values are automatically
|
|
||||||
calculated based on the value provided in the \f[C]\-\-memory\f[]
|
|
||||||
parameter.
|
|
||||||
.PP
|
|
||||||
The values are calculated based on the
|
|
||||||
upstream (https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server)
|
|
||||||
formulas.
|
|
||||||
For the \f[C]shared_buffers\f[] we use 1/4 of given memory and for the
|
|
||||||
\f[C]effective_cache_size\f[] we set the value to 1/2 of the given
|
|
||||||
memory.
|
|
||||||
.SS PostgreSQL admin account
|
|
||||||
.PP
|
|
||||||
The admin account \f[C]postgres\f[] has no password set by default, only
|
|
||||||
allowing local connections.
|
|
||||||
You can set it by setting the \f[C]POSTGRESQL_ADMIN_PASSWORD\f[]
|
|
||||||
environment variable when initializing your container.
|
|
||||||
This will allow you to login to the \f[C]postgres\f[] account remotely.
|
|
||||||
Local connections will still not require a password.
|
|
||||||
.SS Changing passwords
|
|
||||||
.PP
|
|
||||||
Since passwords are part of the image configuration, the only supported
|
|
||||||
method to change passwords for the database user
|
|
||||||
(\f[C]POSTGRESQL_USER\f[]) and \f[C]postgres\f[] admin user is by
|
|
||||||
changing the environment variables \f[C]POSTGRESQL_PASSWORD\f[] and
|
|
||||||
\f[C]POSTGRESQL_ADMIN_PASSWORD\f[], respectively.
|
|
||||||
.PP
|
|
||||||
Changing database passwords through SQL statements or any way other than
|
|
||||||
through the environment variables aforementioned will cause a mismatch
|
|
||||||
between the values stored in the variables and the actual passwords.
|
|
||||||
Whenever a database container starts it will reset the passwords to the
|
|
||||||
values stored in the environment variables.
|
|
||||||
.SH AUTHORS
|
|
||||||
Red Hat.
|
|
||||||
|
|
@ -1,92 +1,99 @@
|
||||||
#!/usr/bin/python
|
#!/bin/bash
|
||||||
|
|
||||||
"""
|
# Script for parsing cgroup information
|
||||||
Script for parsing cgroup information
|
#
|
||||||
|
# This script will read some limits from the cgroup system and parse
|
||||||
|
# them, printing out "VARIABLE=VALUE" on each line for every limit that is
|
||||||
|
# successfully read. Output of this script can be directly fed into
|
||||||
|
# bash's export command. Recommended usage from a bash script:
|
||||||
|
#
|
||||||
|
# set -o errexit
|
||||||
|
# export_vars=$(cgroup-limits) ; export $export_vars
|
||||||
|
#
|
||||||
|
# Variables currently supported:
|
||||||
|
# MAX_MEMORY_LIMIT_IN_BYTES
|
||||||
|
# Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
|
||||||
|
# currently a constant value of 9223372036854775807.
|
||||||
|
# MEMORY_LIMIT_IN_BYTES
|
||||||
|
# Maximum amount of user memory in bytes. If this value is set
|
||||||
|
# to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
|
||||||
|
# there is no limit set. The value is taken from
|
||||||
|
# /sys/fs/cgroup/memory/memory.limit_in_bytes
|
||||||
|
# RAM_SIZE_IN_BYTES
|
||||||
|
# Available memory in bytes. The value is taken from /proc/meminfo.
|
||||||
|
# NUMBER_OF_CORES
|
||||||
|
# Number of detected CPU cores that can be used. This value is
|
||||||
|
# calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
|
||||||
|
# NO_MEMORY_LIMIT
|
||||||
|
# Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
|
||||||
|
# can act as if no memory limit was set. Undefined otherwise.
|
||||||
|
|
||||||
This script will read some limits from the cgroup system and parse
|
get_memory_limit() {
|
||||||
them, printing out "VARIABLE=VALUE" on each line for every limit that is
|
local limit="$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)"
|
||||||
successfully read. Output of this script can be directly fed into
|
if [ $? -eq 0 ]; then
|
||||||
bash's export command. Recommended usage from a bash script:
|
echo "$limit"
|
||||||
|
else
|
||||||
|
echo "Warning: Can't detect memory limit from cgroups" >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
set -o errexit
|
get_meminfo_ram_size() {
|
||||||
export_vars=$(cgroup-limits) ; export $export_vars
|
local limit="$(cat /proc/meminfo | while read key val unit rest; do if [ "$key" = "MemTotal:" ]; then echo "$val $unit"; break; fi; done)"
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
local val="${limit/ *}"
|
||||||
|
local unit="${limit/* }"
|
||||||
|
case "$unit" in
|
||||||
|
kB)
|
||||||
|
val=$(($val * 1024))
|
||||||
|
;;
|
||||||
|
MB)
|
||||||
|
val=$(($val * 1024 * 1024))
|
||||||
|
;;
|
||||||
|
GB)
|
||||||
|
val=$(($val * 1024 * 1024 * 1024))
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "$val"
|
||||||
|
else
|
||||||
|
echo "Warning: Can't detect RAM site from /proc/meminfo." >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
Variables currently supported:
|
get_number_of_cores() {
|
||||||
MAX_MEMORY_LIMIT_IN_BYTES
|
local core_count=0
|
||||||
Maximum possible limit MEMORY_LIMIT_IN_BYTES can have. This is
|
local group
|
||||||
currently constant value of 9223372036854775807.
|
local sysfs_cpus="$(cat /sys/fs/cgroup/cpuset/cpuset.cpus)"
|
||||||
MEMORY_LIMIT_IN_BYTES
|
|
||||||
Maximum amount of user memory in bytes. If this value is set
|
|
||||||
to the same value as MAX_MEMORY_LIMIT_IN_BYTES, it means that
|
|
||||||
there is no limit set. The value is taken from
|
|
||||||
/sys/fs/cgroup/memory/memory.limit_in_bytes
|
|
||||||
NUMBER_OF_CORES
|
|
||||||
Number of detected CPU cores that can be used. This value is
|
|
||||||
calculated from /sys/fs/cgroup/cpuset/cpuset.cpus
|
|
||||||
NO_MEMORY_LIMIT
|
|
||||||
Set to "true" if MEMORY_LIMIT_IN_BYTES is so high that the caller
|
|
||||||
can act as if no memory limit was set. Undefined otherwise.
|
|
||||||
"""
|
|
||||||
|
|
||||||
from __future__ import print_function
|
if [ $? -eq 0 ]; then
|
||||||
import sys
|
for group in ${sysfs_cpus//,/ }; do
|
||||||
|
local from="${group%-*}"
|
||||||
|
local to="${group#*-}"
|
||||||
|
core_count=$(($core_count + $to - $from + 1))
|
||||||
|
done
|
||||||
|
echo "$core_count"
|
||||||
|
else
|
||||||
|
echo "Warning: Can't detect number of CPU cores from cgroups" >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
MAX_MEMORY_LIMIT_IN_BYTES=9223372036854775807
|
||||||
|
MEMORY_LIMIT_IN_BYTES="$(get_memory_limit)"
|
||||||
|
RAM_SIZE_IN_BYTES="$(get_meminfo_ram_size)"
|
||||||
|
NUMBER_OF_CORES="$(get_number_of_cores)"
|
||||||
|
|
||||||
def _read_file(path):
|
echo "MAX_MEMORY_LIMIT_IN_BYTES=$MAX_MEMORY_LIMIT_IN_BYTES"
|
||||||
try:
|
|
||||||
with open(path, 'r') as f:
|
|
||||||
return f.read().strip()
|
|
||||||
except IOError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
if [ -n "$MEMORY_LIMIT_IN_BYTES" ]; then
|
||||||
|
echo "MEMORY_LIMIT_IN_BYTES=$MEMORY_LIMIT_IN_BYTES"
|
||||||
|
if [ "$MEMORY_LIMIT_IN_BYTES" -ge "$MAX_MEMORY_LIMIT_IN_BYTES" ]; then
|
||||||
|
echo "NO_MEMORY_LIMIT=true"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
def get_memory_limit():
|
if [ -n "$RAM_SIZE_IN_BYTES" ]; then
|
||||||
"""
|
echo "RAM_SIZE_IN_BYTES=$RAM_SIZE_IN_BYTES"
|
||||||
Read memory limit, in bytes.
|
fi
|
||||||
"""
|
|
||||||
|
|
||||||
limit = _read_file('/sys/fs/cgroup/memory/memory.limit_in_bytes')
|
if [ -n "$NUMBER_OF_CORES" ]; then
|
||||||
if limit is None or not limit.isdigit():
|
echo "NUMBER_OF_CORES=$NUMBER_OF_CORES"
|
||||||
print("Warning: Can't detect memory limit from cgroups",
|
fi
|
||||||
file=sys.stderr)
|
|
||||||
return None
|
|
||||||
return int(limit)
|
|
||||||
|
|
||||||
|
|
||||||
def get_number_of_cores():
|
|
||||||
"""
|
|
||||||
Read number of CPU cores.
|
|
||||||
"""
|
|
||||||
|
|
||||||
core_count = 0
|
|
||||||
|
|
||||||
line = _read_file('/sys/fs/cgroup/cpuset/cpuset.cpus')
|
|
||||||
if line is None:
|
|
||||||
print("Warning: Can't detect number of CPU cores from cgroups",
|
|
||||||
file=sys.stderr)
|
|
||||||
return None
|
|
||||||
|
|
||||||
for group in line.split(','):
|
|
||||||
core_ids = list(map(int, group.split('-')))
|
|
||||||
if len(core_ids) == 2:
|
|
||||||
core_count += core_ids[1] - core_ids[0] + 1
|
|
||||||
else:
|
|
||||||
core_count += 1
|
|
||||||
|
|
||||||
return core_count
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
env_vars = {
|
|
||||||
"MAX_MEMORY_LIMIT_IN_BYTES": 9223372036854775807,
|
|
||||||
"MEMORY_LIMIT_IN_BYTES": get_memory_limit(),
|
|
||||||
"NUMBER_OF_CORES": get_number_of_cores()
|
|
||||||
}
|
|
||||||
|
|
||||||
env_vars = {k: v for k, v in env_vars.items() if v is not None}
|
|
||||||
|
|
||||||
if env_vars.get("MEMORY_LIMIT_IN_BYTES", 0) >= 92233720368547:
|
|
||||||
env_vars["NO_MEMORY_LIMIT"] = "true"
|
|
||||||
|
|
||||||
for key, value in env_vars.items():
|
|
||||||
print("{0}={1}".format(key, value))
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Fix permissions on the given directory to allow group read/write of
|
# Fix permissions on the given directory to allow group read/write of
|
||||||
# regular files and execute of directories.
|
# regular files and execute of directories.
|
||||||
find "$1" -exec chown postgres {} \;
|
find "$1" -exec chown postgres {} \;
|
||||||
find "$1" -exec chgrp 0 {} \;
|
find "$1" -exec chgrp 0 {} \;
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,19 @@ export POSTGRESQL_MAX_PREPARED_TRANSACTIONS=${POSTGRESQL_MAX_PREPARED_TRANSACTIO
|
||||||
# limits are set).
|
# limits are set).
|
||||||
# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
|
# Users can still override this by setting the POSTGRESQL_SHARED_BUFFERS
|
||||||
# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
|
# and POSTGRESQL_EFFECTIVE_CACHE_SIZE variables.
|
||||||
if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES}" ]]; then
|
if [[ "${NO_MEMORY_LIMIT:-}" == "true" || -z "${MEMORY_LIMIT_IN_BYTES:-}" || -z "${RAM_SIZE_IN_BYTES:-}" ]]; then
|
||||||
export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
|
export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-32MB}
|
||||||
export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
|
export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-128MB}
|
||||||
else
|
else
|
||||||
|
if [ "$MEMORY_LIMIT_IN_BYTES" -gt "$RAM_SIZE_IN_BYTES" ]; then
|
||||||
|
mem_limit="$RAM_SIZE_IN_BYTES"
|
||||||
|
else
|
||||||
|
mem_limit="$MEMORY_LIMIT_IN_BYTES"
|
||||||
|
fi
|
||||||
# Use 1/4 of given memory for shared buffers
|
# Use 1/4 of given memory for shared buffers
|
||||||
shared_buffers_computed="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/4))MB"
|
shared_buffers_computed="$(($mem_limit/1024/1024/4))MB"
|
||||||
# Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
|
# Setting effective_cache_size to 1/2 of total memory would be a normal conservative setting,
|
||||||
effective_cache="$(($MEMORY_LIMIT_IN_BYTES/1024/1024/2))MB"
|
effective_cache="$(($mem_limit/1024/1024/2))MB"
|
||||||
export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
|
export POSTGRESQL_SHARED_BUFFERS=${POSTGRESQL_SHARED_BUFFERS:-$shared_buffers_computed}
|
||||||
export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
|
export POSTGRESQL_EFFECTIVE_CACHE_SIZE=${POSTGRESQL_EFFECTIVE_CACHE_SIZE:-$effective_cache}
|
||||||
fi
|
fi
|
||||||
|
|
@ -126,7 +131,7 @@ function generate_passwd_file() {
|
||||||
export GROUP_ID=$(id -g)
|
export GROUP_ID=$(id -g)
|
||||||
grep -v ^postgres /etc/passwd > "$HOME/passwd"
|
grep -v ^postgres /etc/passwd > "$HOME/passwd"
|
||||||
echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
|
echo "postgres:x:${USER_ID}:${GROUP_ID}:PostgreSQL Server:${HOME}:/bin/bash" >> "$HOME/passwd"
|
||||||
export LD_PRELOAD=libnss_wrapper.so
|
#export LD_PRELOAD=libnss_wrapper.so
|
||||||
export NSS_WRAPPER_PASSWD=${HOME}/passwd
|
export NSS_WRAPPER_PASSWD=${HOME}/passwd
|
||||||
export NSS_WRAPPER_GROUP=/etc/group
|
export NSS_WRAPPER_GROUP=/etc/group
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,66 @@
|
||||||
document: modularity-testing
|
document: modularity-testing
|
||||||
version: 1
|
version: 1
|
||||||
name: postgresql
|
name: postgresql
|
||||||
modulemd-url: https://src.fedoraproject.org/cgit/modules/postgresql.git/plain/postgresql.yaml
|
modulemd-url: https://src.fedoraproject.org/cgit/modules/postgresql.git/tree/postgresql.yaml?h=f26
|
||||||
service:
|
service:
|
||||||
port: 5432
|
port: 5432
|
||||||
|
packages:
|
||||||
|
rpms:
|
||||||
|
- postgresql-server
|
||||||
|
# seq
|
||||||
|
- coreutils
|
||||||
|
testdependecies:
|
||||||
|
rpms:
|
||||||
|
- postgresql
|
||||||
|
- systemd
|
||||||
module:
|
module:
|
||||||
docker:
|
docker:
|
||||||
start: "docker run -it -e POSTGRESQL_USER=user -e POSTGRESQL_PASSWORD=p -e POSTGRESQL_DATABASE=db -e LC_ALL=C -p 5432:5432"
|
start: "docker run -it -p 5432:5432 -e POSTGRESQL_USER=mtftest -e POSTGRESQL_PASSWORD=mtftest -e POSTGRESQL_DATABASE=mtftest"
|
||||||
container: postgresql
|
labels:
|
||||||
|
description: "PostgreSQL is an advanced Object-Relational database management system (DBMS)."
|
||||||
|
io.k8s.description: "PostgreSQL is an advanced Object-Relational database management system (DBMS)."
|
||||||
|
source: https://github.com/container-images/postgresql.git
|
||||||
|
container: docker.io/modularitycontainers/postgresql
|
||||||
rpm:
|
rpm:
|
||||||
start: run-postgresql
|
setup: postgresql-setup initdb
|
||||||
|
start: systemctl start postgresql
|
||||||
|
stop: systemctl stop postgresql
|
||||||
|
status: systemctl status postgresql
|
||||||
repos:
|
repos:
|
||||||
- http://mirror.vutbr.cz/fedora/releases/26/Everything/x86_64/os/
|
- https://kojipkgs.fedoraproject.org/compose/latest-Fedora-Modular-26/compose/Server/x86_64/os/
|
||||||
|
test:
|
||||||
|
process_running:
|
||||||
|
- |
|
||||||
|
up=0
|
||||||
|
for i in `seq 20`; do
|
||||||
|
echo "Checking for /usr/bin/postgres process... ($i)"
|
||||||
|
if ls /proc/*/exe -alh 2>/dev/null | grep /usr/bin/postgres; then
|
||||||
|
echo "Found."
|
||||||
|
up=1
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
test "$up" -ne 0
|
||||||
|
testhost:
|
||||||
|
db_usable:
|
||||||
|
- |
|
||||||
|
export PGPASSWORD=mtftest
|
||||||
|
PSQL="psql -h localhost -U mtftest -q"
|
||||||
|
up=0
|
||||||
|
for i in `seq 20`; do
|
||||||
|
echo "Pinging PostgreSQL ($i)"
|
||||||
|
if $PSQL -c "" >&/dev/null; then
|
||||||
|
up=1
|
||||||
|
break
|
||||||
|
else
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$up" -eq 1 ]; then
|
||||||
|
$PSQL -f test.sql | egrep "anything|something"
|
||||||
|
else
|
||||||
|
echo "Unable to connect to database." >&2
|
||||||
|
false
|
||||||
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This Modularity Testing Framework helps you to write tests for modules
|
|
||||||
# Copyright (C) 2017 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# he Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
#
|
|
||||||
# Authors: Jan Scotka <jscotka@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
from avocado import main
|
|
||||||
from moduleframework import module_framework
|
|
||||||
|
|
||||||
|
|
||||||
class ExampleRpmValidation(module_framework.AvocadoTest):
|
|
||||||
"""
|
|
||||||
:avocado: enable
|
|
||||||
"""
|
|
||||||
fhs_base_paths = [
|
|
||||||
'/bin',
|
|
||||||
'/boot',
|
|
||||||
'/dev',
|
|
||||||
'/etc',
|
|
||||||
'/home',
|
|
||||||
'/lib',
|
|
||||||
'/lib64',
|
|
||||||
'/media',
|
|
||||||
'/mnt',
|
|
||||||
'/opt',
|
|
||||||
'/proc',
|
|
||||||
'/root',
|
|
||||||
'/run',
|
|
||||||
'/sbin',
|
|
||||||
'/sys',
|
|
||||||
'/srv',
|
|
||||||
'/tmp',
|
|
||||||
'/usr/bin'
|
|
||||||
]
|
|
||||||
|
|
||||||
def testPaths(self):
|
|
||||||
self.start()
|
|
||||||
for directory in self.fhs_base_paths:
|
|
||||||
self.run("test -d %s" % directory)
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This Modularity Testing Framework helps you to write tests for modules
|
|
||||||
# Copyright (C) 2017 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# he Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
#
|
|
||||||
# Authors: Rado Pitonak <rpitonak@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
from avocado import main
|
|
||||||
from avocado.core import exceptions
|
|
||||||
from moduleframework import module_framework
|
|
||||||
|
|
||||||
|
|
||||||
class SanityCheck1(module_framework.AvocadoTest):
|
|
||||||
"""
|
|
||||||
:avocado: enable
|
|
||||||
"""
|
|
||||||
|
|
||||||
def test1(self):
|
|
||||||
self.start()
|
|
||||||
self.run("ls / | grep bin")
|
|
||||||
|
|
||||||
# check if perl is installed in the right version.
|
|
||||||
def test2PostgresVersion(self):
|
|
||||||
postgresVersion = "9.6"
|
|
||||||
self.start()
|
|
||||||
self.run("postgres --version | grep " + postgresVersion)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This Modularity Testing Framework helps you to write tests for modules
|
|
||||||
# Copyright (C) 2017 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# he Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
#
|
|
||||||
# Authors: Rado Pitonak <rpitonak@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
from avocado import main
|
|
||||||
from avocado.core import exceptions
|
|
||||||
from moduleframework import module_framework
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
class SanityCheck2(module_framework.AvocadoTest):
|
|
||||||
"""
|
|
||||||
:avocado: enable
|
|
||||||
"""
|
|
||||||
|
|
||||||
def testConnectToDB(self):
|
|
||||||
self.start()
|
|
||||||
time.sleep(5)
|
|
||||||
self.run("psql -U $POSTGRESQL_USER -d $POSTGRESQL_DATABASE -c 'SELECT 1'")
|
|
||||||
|
|
||||||
def testCreateTable(self):
|
|
||||||
self.start()
|
|
||||||
time.sleep(5)
|
|
||||||
self.run("psql -U $POSTGRESQL_USER -d $POSTGRESQL_DATABASE -c 'CREATE TABLE mytable(ID INT PRIMARY KEY NOT NULL);'")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
#!/usr/bin/python
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# This Modularity Testing Framework helps you to write tests for modules
|
|
||||||
# Copyright (C) 2017 Red Hat, Inc.
|
|
||||||
#
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# he Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
#
|
|
||||||
# Authors: Jan Scotka <jscotka@redhat.com>
|
|
||||||
#
|
|
||||||
|
|
||||||
from moduleframework import module_framework
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
class simpleTests(module_framework.AvocadoTest):
|
|
||||||
"""
|
|
||||||
:avocado: enable
|
|
||||||
"""
|
|
||||||
|
|
||||||
def testPath(self):
|
|
||||||
print ">>>>>>>>>>>>>> ", module_framework.__file__
|
|
||||||
print ">>>>>>>>>>>>>> ", __file__
|
|
||||||
|
|
||||||
def testAssertIn(self):
|
|
||||||
self.start()
|
|
||||||
self.assertIn("sbin", self.run("ls /").stdout)
|
|
||||||
|
|
||||||
def testInsideModule(self):
|
|
||||||
self.start()
|
|
||||||
self.assertEqual("a", self.run("echo a").stdout.strip())
|
|
||||||
|
|
||||||
def testCommandOnHost(self):
|
|
||||||
self.start()
|
|
||||||
self.assertEqual("a", self.runHost("echo a").stdout.strip())
|
|
||||||
5
tests/test.sql
Normal file
5
tests/test.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
CREATE TABLE mtftest (id SERIAL NOT NULL, anything VARCHAR(255) NOT NULL);
|
||||||
|
|
||||||
|
INSERT INTO mtftest (anything) VALUES ('something');
|
||||||
|
|
||||||
|
SELECT anything FROM mtftest;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue