Commit 10cf9336 authored by Profpatsch's avatar Profpatsch

containers/postgres: working integration test

parent fc39d50e
......@@ -109,9 +109,11 @@ in {
# TODO: this is a bit long, refactor!
dockerConfig =
let
dockerCmd = "/bin/postgres";
dbDir = "/database";
dockerImage =
let
dbDir = "/database";
uidGid = 999;
uidGidStr = toString uidGid;
description = ''
......@@ -134,7 +136,7 @@ in {
# docker config (see docker image spec)
config = {
User = "postgres";
Cmd = [ "/bin/postgres" ];
Cmd = [ dockerCmd ];
Env = [
"PGDATA=${dbDir}"
];
......@@ -177,15 +179,27 @@ in {
};
testScript =
let image = config.generated.dockerImages.sanghaPostgres;
let
image = config.generated.dockerImages.sanghaPostgres;
hba_file = let cd = connectionData; in pkgs.writeText "pg_hba.conf" ''
host ${cd.DbName} ${cd.User} 0.0.0.0/0 trust
'';
in ''
startAll;
$server->waitForUnit("docker.service");
$server->succeed("docker load -i ${image}");
$server->succeed("docker run --detach=true --network=host ${image.imageName}:${image.imageTag}");
$server->succeed("docker run --detach=true --network=host "
. "--volume=${hba_file}:/conf/pg_hba.conf "
. "${image.imageName}:${image.imageTag} "
. "${dockerCmd} "
. "-D ${dbDir} "
. "-c'data_directory=${dbDir}' "
. "-c'hba_file=/conf/pg_hba.conf' ");
$server->waitForOpenPort(${toString connectionData.Port});
$client->execute("echo 'trying to connect to postgres docker server'");
$client->succeed("${pkgs.telnet}/bin/telnet server");
$client->succeed('systemd-cat ${pkgs.postgresql}/bin/psql --host=server '
. '--username=${connectionData.User} '
. '--dbname=${connectionData.DbName} '
. '--command=\'\dt\' ');
'';
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment