Skip to content

Commit

Permalink
Don't allocate tty, makes docker exec hang
Browse files Browse the repository at this point in the history
Also:
- Add PGCONNECT_TIMEOUT to psql.sh
- Fix expected psql output in the test scripts
  • Loading branch information
oyvindhagberg committed Sep 25, 2023
1 parent 0ce98ca commit 839142d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions ci/docker/psql.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
I="-i "
I="-it "
if [[ "$*" == *"-c"* ]]; then
I=""
fi
docker exec $I -t docker_postgres_1 psql -U nivlheim -h localhost -d nivlheim "$@"
docker exec $I -e PGCONNECT_TIMEOUT=30 docker_postgres_1 psql -U nivlheim -h localhost -d nivlheim "$@"
2 changes: 1 addition & 1 deletion tests/test_cert_handling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ docker run --rm --network host -v clientvar:/var nivlheimclient --debug > $tempd

# Verify the certificate chain
chain=$($PSQL --no-align -t -c "SELECT certid,first,previous FROM certificates ORDER BY certid")
expect=$(echo -e "1|1|\r\n2|1|1\r\n3|1|2\r\n")
expect=$(echo -e "1|1|\n2|1|1\n3|1|2\n")
if [[ "$chain" != "$expect" ]]; then
echo "Certificate chain differs from expected value:"
echo "$chain"
Expand Down
7 changes: 5 additions & 2 deletions tests/test_clones.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
echo "------------ Testing cloned machines ------------"
set -e
cd `dirname $0`
PSQL=../ci/docker/psql.sh

function printlogs() {
echo "------- access_log -------------------------------"
Expand All @@ -34,6 +35,9 @@ function finish {
}
trap finish EXIT

# The following line is not necessary when running on a GitHub runner, but when running locally you might keep a server between runs
$PSQL -c "delete from files; delete from hostinfo; delete from certificates; ALTER SEQUENCE certificates_certid_seq RESTART WITH 1;"

# Whitelist the private network address ranges
curl -sS -X POST 'http://localhost:4040/api/v2/settings/ipranges' -d 'ipRange=192.168.0.0/16'
curl -sS -X POST 'http://localhost:4040/api/v2/settings/ipranges' -d 'ipRange=172.16.0.0/12'
Expand Down Expand Up @@ -93,9 +97,8 @@ if docker exec docker_nivlheimweb_1 grep "cgi:error" /var/log/httpd/error_log |
fi

# Check that the database table contains 1 cert which is revoked
PSQL=../ci/docker/psql.sh
chain=$($PSQL -X --no-align -t -c "SELECT certid,revoked,first FROM certificates ORDER BY certid")
expect=$(echo -e "1|t|1\r\n")
expect=$(echo -e "1|t|1\n")
if [[ "$chain" != "$expect" ]]; then
echo "The certificate list differ from expectation:"
$PSQL -e -X -c "SELECT certid,revoked,first FROM certificates ORDER BY certid"
Expand Down

0 comments on commit 839142d

Please sign in to comment.