Skip to content

Commit 7835b16

Browse files
hhorakroot
authored and
root
committed
Fix pagila RPM url and wait patiently for the server start
Previous epel7 mirror URL does not work after RHEL7 EOL, but the same RPM is still available in koji. A test for a correct download should hopefully make the download failure easier to debug in the future. The check functions did not actually wait when the first podman exec failed, so in case the server was not up soon, the check failed too early. It is ok to wait for the server a bit, so let's repeat the podman exec with psql until it succeeds or 30s pass.
1 parent 510b694 commit 7835b16

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

Diff for: test/pagila.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ die() { echo "$*" >&2 ; exit 1; }
77
test -z "$CID" && die "Please specify \$CID variable"
88
# test -d common || die "Please run me from git root directory"
99

10-
pagila_mirror=https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/
10+
pagila_koji=https://kojipkgs.fedoraproject.org//packages/pagila/0.10.1/3.el7/noarch/
1111
pagila_base="pagila-0.10.1-3.el7.noarch.rpm"
12-
pagila=$pagila_mirror$pagila_base
12+
pagila=$pagila_koji$pagila_base
1313
pagila_file="$PWD/postgresql-container-pagila.sql"
1414
pagila_sha256sum=b968d9498d866bff8f47d9e50edf49feeff108d4164bff2aa167dc3eae802701
1515

@@ -20,7 +20,7 @@ pagila_sha256sum=b968d9498d866bff8f47d9e50edf49feeff108d4164bff2aa167dc3eae80270
2020
test ! -f "$pagila_file" || exit 0
2121

2222
set -o pipefail
23-
curl -s "$pagila" > "$pagila_base"
23+
curl -s "$pagila" > "$pagila_base" || die "ERROR: Could not download $pagila"
2424
for file in ./usr/share/pagila/pagila-schema.sql \
2525
./usr/share/pagila/pagila-data.sql \
2626
./usr/share/pagila/pagila-insert-data.sql ; \

Diff for: test/pg-test-lib.sh

+20-9
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,19 @@ data_pagila_check ()
5454
2'
5555
# Deliberately moving heredoc into the container, otherwise it does not work
5656
# in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
57-
local output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
57+
SECONDS=15
58+
local output
59+
while [ $SECONDS -gt 0 ] ; do
60+
output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
5861
select count(*) from information_schema.tables where table_schema = 'public';
5962
select count(*) from information_schema.triggers;
6063
select count(*) from staff;
61-
EOF"
64+
EOF" 2>/dev/null || :
6265
)
63-
test "$exp_output" = "$output" \
64-
|| error "Unexpected output: '$output', expected: '$exp_output'"
66+
test "$exp_output" = "$output" && return
67+
sleep 1
68+
done
69+
error "Unexpected output: '$output', expected: '$exp_output', and/or we waited too long"
6570
}
6671

6772
data_empty_create ()
@@ -82,11 +87,17 @@ data_empty_check ()
8287
3'
8388
# Deliberately moving heredoc into the container, otherwise it does not work
8489
# in podman 1.6.x due to https://bugzilla.redhat.com/show_bug.cgi?id=1827324
85-
local output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
90+
SECONDS=15
91+
local output
92+
while [ $SECONDS -gt 0 ] ; do
93+
output=$(docker exec -i "$CID" bash -c "psql -tA <<EOF
8694
select * from blah order by id;
87-
EOF"
95+
EOF" 2>/dev/null || :
8896
)
89-
test "$exp_output" = "$output" || error "Unexpected output '$output'"
97+
test "$exp_output" = "$output" && return
98+
sleep 1
99+
done
100+
error "Unexpected output '$output', expected: '$exp_output', and/or we waited too long"
90101
}
91102

92103
# wait_for_postgres CID
@@ -105,9 +116,9 @@ wait_for_postgres ()
105116
output=$(docker exec -i "$cid" bash -c \
106117
"psql -h localhost -tA -c 'select 1;' 2>/dev/null || :")
107118
case $output in
108-
1*) return ;;
119+
1*) debug "server up" ; return ;;
109120
"") ;;
110-
*) echo "$output" ; false ;;
121+
*) debug "server down" ; echo "$output" ; false ;;
111122
esac
112123
sleep 1
113124
counter=$(( counter + 1 ))

Diff for: test/run_upgrade_test

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ background_container ()
2929
{
3030
CID=$(eval "docker run -d $2 $1 $3")
3131
test -n "$CID"
32+
info "Started container $CID" >&2
3233
}
3334

3435
# run_server DATADIR IMAGE_ID DOCKER_ARGS

0 commit comments

Comments
 (0)