Skip to content

Commit e12715d

Browse files
committed
Add container upgrade test
1 parent 50a49f8 commit e12715d

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
summary: Postgresql-setup upgrade test in a fedora rawhide container
2+
require:
3+
- make
4+
- m4
5+
- docbook-utils
6+
- help2man
7+
- elinks
8+
- postgresql-server
9+
- coreutils
10+
- autoconf
11+
- automake
12+
- autoconf-archive
13+
- git
14+
test: ./upgrade.sh
15+
framework: shell
16+
duration: 10m
17+
tag: fedora-container-upgrade
18+
19+
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/bin/bash
2+
# prep
3+
git clone "$REPO_URL" repo
4+
cd repo
5+
git fetch origin "$PR_HEAD"
6+
git checkout FETCH_HEAD
7+
8+
grep -q systemd /proc/1/comm
9+
echo "Return value CONTAINER: $?"
10+
11+
# setup
12+
autoreconf -vfi
13+
./configure --prefix=/usr
14+
make
15+
16+
# initialization
17+
./bin/postgresql-setup --init
18+
19+
# start postgresql and check if it's running
20+
PGDATA=/var/lib/pgsql/data
21+
LOGFILE=/var/lib/pgsql/logfile
22+
su - postgres -c "
23+
/usr/bin/pg_ctl -D $PGDATA -l $LOGFILE -o \"-c unix_socket_directories=/tmp\" start
24+
/usr/bin/pg_ctl -D $PGDATA status && echo \"PostgreSQL is running\" || { echo \"PostgreSQL is NOT running\"; exit 1; }
25+
"
26+
27+
# insert data
28+
su - postgres -c "
29+
echo \"User switched\";
30+
31+
createdb -h /tmp testdb;
32+
psql -h /tmp -U postgres -d testdb -c \"create table users (id serial primary key, name text)\";
33+
psql -h /tmp -U postgres -d testdb -c \"insert into users (name) values ('Alice'), ('Bob'), ('Celine')\"
34+
"
35+
su - postgres -c '
36+
psql -h /tmp -U postgres -d testdb -c "select * from users"
37+
' > expected.txt
38+
39+
echo "Expected:"
40+
cat expected.txt
41+
42+
test $(wc -l < expected.txt) -gt 0 || { echo "ERROR: expected.txt is empty!"; exit 1; }
43+
44+
# uninstall postgresql
45+
dnf -y remove postgresql-server postgresql-private-libs postgresql libicu
46+
47+
# install postgresql17
48+
dnf -y install postgresql17-upgrade
49+
50+
# run --upgrade
51+
./bin/postgresql-setup --upgrade
52+
53+
su - postgres -c "
54+
/usr/bin/pg_ctl -D $PGDATA -l $LOGFILE -o \"-c unix_socket_directories=/tmp\" start
55+
/usr/bin/pg_ctl -D $PGDATA status && echo \"PostgreSQL is running\" || { echo \"PostgreSQL is NOT running\"; exit 1; }
56+
"
57+
58+
su - postgres -c '
59+
psql -h /tmp -U postgres -d testdb -c "select * from users"
60+
' > actual.txt
61+
62+
echo "Actual:"
63+
cat actual.txt
64+
65+
diff -q expected.txt actual.txt && echo "Actual and expected outputs match" || { echo "Actual and expected outputs differ"; exit 1; }
66+

0 commit comments

Comments
 (0)