|
| 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