Skip to content

Commit

Permalink
test(postgres): set socketDir with empty listen_addresses
Browse files Browse the repository at this point in the history
Test a postgres service with socketDir set and empty listen_addresses.
  • Loading branch information
johnhampton committed Apr 14, 2024
1 parent e4d8770 commit 0922b13
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nix/postgres/postgres_test.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@
}
];
};
services.postgres."pg3" = {
enable = true;
socketDir = "./test/new/socket/path2";
listen_addresses = "";
initialDatabases = [
{
name = "test-db";
}
];
};
# avoid both the processes trying to create `data` directory at the same time
settings.processes."pg2-init".depends_on."pg1-init".condition = "process_completed_successfully";
settings.processes."pg3-init".depends_on."pg2-init".condition = "process_completed_successfully";
settings.processes.test =
let
cfg = config.services.postgres."pg1";
Expand All @@ -37,12 +48,16 @@
# schemas test
echo "SELECT * from users where user_name = 'test_user';" | psql -h 127.0.0.1 -p 5433 -d sample-db | grep -q test_user
# listen_addresses test
echo "SELECT 1 FROM pg_database where datname = 'test-db';" | psql -h "$(readlink -f ${config.services.postgres.pg3.socketDir})" -d postgres | grep -q 1
'';
name = "postgres-test";
};
depends_on = {
"pg1".condition = "process_healthy";
"pg2".condition = "process_healthy";
"pg3".condition = "process_healthy";
};
};
}

0 comments on commit 0922b13

Please sign in to comment.