Skip to content

Commit 6025ec4

Browse files
committed
Container tests (#5)
1 parent 2b9336b commit 6025ec4

File tree

8 files changed

+177
-9
lines changed

8 files changed

+177
-9
lines changed

.github/workflows/testing-farm.yaml

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Run tests on Testing Farm
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ master, container-tests ]
66
pull_request_target:
77
types: [opened, synchronize, reopened]
88

@@ -22,7 +22,7 @@ jobs:
2222
ref: "refs/pull/${{ github.event.issue.number }}/head"
2323

2424
- name: Test init on Fedora VM
25-
uses: sclorg/testing-farm-as-github-action@v4
25+
uses: sclorg/testing-farm-as-github-action@main
2626
with:
2727
api_key: ${{ secrets.TESTING_FARM_API_TOKEN }}
2828
compose: Fedora-Rawhide
@@ -46,7 +46,7 @@ jobs:
4646
ref: "refs/pull/${{ github.event.issue.number }}/head"
4747

4848
- name: Test upgrade on Fedora VM
49-
uses: sclorg/testing-farm-as-github-action@v4
49+
uses: sclorg/testing-farm-as-github-action@main
5050
with:
5151
api_key: ${{ secrets.TESTING_FARM_API_TOKEN }}
5252
compose: Fedora-Rawhide
@@ -55,3 +55,49 @@ jobs:
5555
pull_request_status_name: "Fedora upgrade test"
5656
update_pull_request_status: "true"
5757
create_github_summary: "true"
58+
container-test-init:
59+
runs-on: ubuntu-latest
60+
61+
permissions:
62+
contents: read
63+
pull-requests: write
64+
statuses: write
65+
66+
steps:
67+
- name: Checkout repository
68+
uses: actions/checkout@v4
69+
70+
- name: Test init on Fedora container
71+
uses: sclorg/testing-farm-as-github-action@main
72+
with:
73+
api_key: ${{ secrets.TESTING_FARM_API_TOKEN }}
74+
compose: null
75+
tmt_path: "tmt"
76+
tmt_plan_regex: "container-fedora-init"
77+
pull_request_status_name: "Fedora container init test"
78+
update_pull_request_status: "true"
79+
create_github_summary: "true"
80+
container-test-upgrade:
81+
runs-on: ubuntu-latest
82+
83+
permissions:
84+
contents: read
85+
pull-requests: write
86+
statuses: write
87+
88+
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v4
91+
92+
- name: Test upgrade on Fedora container
93+
uses: sclorg/testing-farm-as-github-action@main
94+
with:
95+
api_key: ${{ secrets.TESTING_FARM_API_TOKEN }}
96+
compose: null
97+
tmt_path: "tmt"
98+
tmt_plan_regex: "container-fedora-upgrade"
99+
pull_request_status_name: "Fedora container upgrade test"
100+
update_pull_request_status: "true"
101+
create_github_summary: "true"
102+
103+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: /plans/fedora-init-container
2+
summary: Run init test in a fedora container environment
3+
provision:
4+
how: container
5+
image: fedora:latest
6+
discover:
7+
how: fmf
8+
filter: tag:container-init-fedora
9+
execute:
10+
how: tmt
11+
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: /plans/fedora-upgrade-container
2+
summary: Run upgrade test in a fedora container environment
3+
provision:
4+
how: container
5+
image: fedora
6+
discover:
7+
how: fmf
8+
filter: tag:fedora-upgrade-container
9+
execute:
10+
how: tmt
11+
12+

tmt/plans/fedora-init.fmf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: /plans/fedora
1+
name: /plans/fedora-init
22
summary: Run tests in a fedora virtual machine environment
33
discover:
44
how: fmf

tmt/tests/container/sanity/init/init.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ cd repo
55
git fetch origin "$TESTING_FARM_GIT_REF"
66
git checkout FETCH_HEAD
77

8+
grep -q systemd /proc/1/comm
9+
echo "Return value CONTAINER: $?"
10+
811
# setup
912
autoreconf -vfi
1013
./configure --prefix=/usr
@@ -13,10 +16,11 @@ make
1316
# initialization
1417
./bin/postgresql-setup --init
1518

16-
# start postgresql
19+
# start postgresql and check if it's running
1720
PGDATA=/var/lib/pgsql/data
1821
LOGFILE=/var/lib/pgsql/logfile
22+
su - postgres -c "
1923
/usr/bin/pg_ctl -D $PGDATA -l $LOGFILE start
24+
pg_ctl -D $PGDATA status && echo \"PostgreSQL is running\" || { echo \"PostgreSQL is NOT running\"; exit 1; }
25+
"
2026

21-
# check if it is running
22-
pg_ctl -D $PGDATA status && echo "PostgreSQL is running" || { echo "PostgreSQL is NOT running"; exit 1; }

tmt/tests/container/sanity/init/main.fmf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
summary: Check whether the machine is a container
1+
summary: Postgresql-setup init test in a fedora rawhide container
22
require:
33
- make
44
- m4
@@ -11,7 +11,9 @@ require:
1111
- automake
1212
- autoconf-archive
1313
- git
14+
test: ./init.sh
1415
framework: shell
16+
duration: 10m
17+
tag: container-init-fedora
1518
16-
test: ./init.sh
1719

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-upgrade-container
18+
19+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/bash
2+
# prep
3+
git clone "$TESTING_FARM_GIT_URL" repo
4+
cd repo
5+
git fetch origin "$TESTING_FARM_GIT_REF"
6+
git checkout FETCH_HEAD
7+
8+
echo "Fedora release:"
9+
cat /etc/fedora-release
10+
11+
# install postgresql16
12+
dnf -y install postgresql16-server
13+
14+
# setup
15+
autoreconf -vfi
16+
./configure --prefix=/usr
17+
make
18+
19+
# initialization
20+
./bin/postgresql-setup --init
21+
22+
# start postgresql and check if it's running
23+
PGDATA=/var/lib/pgsql/data
24+
LOGFILE=/var/lib/pgsql/logfile
25+
su - postgres -c "
26+
/usr/bin/pg_ctl -D $PGDATA -l $LOGFILE start
27+
pg_ctl -D $PGDATA status && echo \"PostgreSQL is running\" || { echo \"PostgreSQL is NOT running\"; exit 1; }
28+
"
29+
30+
# insert data
31+
su - postgres -c "
32+
echo \"User switched\";
33+
34+
createdb testdb;
35+
psql -U postgres -d testdb -c \"create table users (id serial primary key, name text)\";
36+
psql -U postgres -d testdb -c \"insert into users (name) values ('Alice'), ('Bob'), ('Celine')\"
37+
"
38+
su - postgres -c '
39+
psql -U postgres -d testdb -c "select * from users"
40+
' > expected.txt
41+
42+
echo "Expected:"
43+
cat expected.txt
44+
45+
# uninstall postgresql
46+
dnf -y remove postgresql-server postgresql-private-libs postgresql libicu
47+
48+
# install postgresql17
49+
dnf -y install postgresql17-upgrade
50+
51+
# run --upgrade
52+
./bin/postgresql-setup --upgrade
53+
54+
# start postgresql and check if it's running
55+
su - postgres -c "
56+
/usr/bin/pg_ctl -D $PGDATA -l $LOGFILE start
57+
pg_ctl -D $PGDATA status && echo \"PostgreSQL is running\" || { echo \"PostgreSQL is NOT running\"; exit 1; }
58+
"
59+
60+
su - postgres -c '
61+
psql -U postgres -d testdb -c "select * from users"
62+
' > actual.txt
63+
64+
echo "Actual:"
65+
cat actual.txt
66+
67+
diff -q expected.txt actual.txt && echo "Actual and expected outputs match" || { echo "Actual and expected outputs differ"; exit 1; }
68+
69+
70+
71+
72+
73+

0 commit comments

Comments
 (0)