Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/testing-farm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Run tests on Testing Farm

on:
push:
branches: [ master ]
pull_request:

jobs:
test-init:
runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: write
statuses: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test init on Fedora VM
uses: sclorg/testing-farm-as-github-action@v4
with:
api_key: ${{ secrets.TESTING_FARM_API_TOKEN }}
compose: Fedora-Rawhide
tmt_path: "tmt"
tmt_plan_regex: "fedora-init"
pull_request_status_name: "Fedora init test"
update_pull_request_status: "true"
create_github_summary: "true"
test-upgrade:
runs-on: ubuntu-latest

permissions:
contents: read
pull-requests: write
statuses: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test upgrade on Fedora VM
uses: sclorg/testing-farm-as-github-action@v4
with:
api_key: ${{ secrets.TESTING_FARM_API_TOKEN }}
compose: Fedora-Rawhide
tmt_path: "tmt"
tmt_plan_regex: "fedora-upgrade"
pull_request_status_name: "Fedora upgrade test"
update_pull_request_status: "true"
create_github_summary: "true"

Empty file added tmt/.fmf/root
Empty file.
1 change: 1 addition & 0 deletions tmt/.fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
8 changes: 8 additions & 0 deletions tmt/plans/fedora-init.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: /plans/fedora
summary: Run tests in a fedora virtual machine environment
discover:
how: fmf
filter: tag:fedora-init
execute:
how: tmt

9 changes: 9 additions & 0 deletions tmt/plans/fedora-upgrade.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: /plans/fedora
summary: Run tests in a fedora virtual machine environment
discover:
how: fmf
directory: tests/
filter: tag:fedora-upgrade
execute:
how: tmt

22 changes: 22 additions & 0 deletions tmt/tests/container/sanity/init/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# prep
git clone "$TESTING_FARM_GIT_URL" repo
cd repo
git fetch origin "$TESTING_FARM_GIT_REF"
git checkout FETCH_HEAD

# setup
autoreconf -vfi
./configure --prefix=/usr
make

# initialization
./bin/postgresql-setup --init

# start postgresql
PGDATA=/var/lib/pgsql/data
LOGFILE=/var/lib/pgsql/logfile
/usr/bin/pg_ctl -D $PGDATA -l $LOGFILE start

# check if it is running
pg_ctl -D $PGDATA status && echo "PostgreSQL is running" || { echo "PostgreSQL is NOT running"; exit 1; }
17 changes: 17 additions & 0 deletions tmt/tests/container/sanity/init/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
summary: Check whether the machine is a container
require:
- make
- m4
- docbook-utils
- help2man
- elinks
- postgresql-server
- coreutils
- autoconf
- automake
- autoconf-archive
- git
framework: shell
contact: ndavidov@redhat.com
test: ./init.sh

8 changes: 8 additions & 0 deletions tmt/tests/virtual/sanity/init/.testinfo.tmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Description: Sanity test for `postgresql-setup --initdb` command
Owner: ndavidov@redhat.com
RunFor:
RunTest: ./init.sh
Path: /mnt/tests/tests/virtual/sanity/init
Requires: make m4 docbook-utils help2man elinks postgresql-server coreutils autoconf automake autoconf-archive git
Requires:
TestTime: 5m
20 changes: 20 additions & 0 deletions tmt/tests/virtual/sanity/init/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# prep
git clone "$TESTING_FARM_GIT_URL" repo
cd repo
git fetch origin "$TESTING_FARM_GIT_REF"
git checkout FETCH_HEAD

# setup
autoreconf -vfi
./configure --prefix=/usr
make

# initialization
./bin/postgresql-setup --init

# start postgresql
systemctl start postgresql

# check if it is running
systemctl is-active postgresql && echo "PostgreSQL is running" || { echo "PostgreSQL is NOT running"; exit 1; }
19 changes: 19 additions & 0 deletions tmt/tests/virtual/sanity/init/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
summary: Sanity test for db initialization by postgresql-setup
require:
- make
- m4
- docbook-utils
- help2man
- elinks
- postgresql-server
- coreutils
- autoconf
- automake
- autoconf-archive
- git
framework: shell
contact: ndavidov@redhat.com
tag:
- fedora-init
test: ./init.sh

18 changes: 18 additions & 0 deletions tmt/tests/virtual/sanity/upgrade/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
summary: Sanity check for postgresql upgrade with postgresql-setup
require:
- make
- m4
- docbook-utils
- help2man
- elinks
- coreutils
- autoconf
- automake
- autoconf-archive
- git
framework: shell
contact: ndavidov@redhat.com
tag:
- fedora-upgrade
test: ./upgrade.sh

72 changes: 72 additions & 0 deletions tmt/tests/virtual/sanity/upgrade/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash
# prep
git clone "$TESTING_FARM_GIT_URL" repo
cd repo
git fetch origin "$TESTING_FARM_GIT_REF"
git checkout FETCH_HEAD
echo "Fedora release:"
cat /etc/fedora-release
dnf list -y postgresql* --available


# install postgresql16
dnf -y install postgresql16-server

# setup
autoreconf -vfi
./configure --prefix=/usr
make

# initialization
./bin/postgresql-setup --init

# start postgresql
systemctl start postgresql

# check if it is running
systemctl is-active postgresql && echo "PostgreSQL is running" || { echo "PostgreSQL is NOT running"; exit 1; }

# insert data
su - postgres -c "
echo \"User switched\";

createdb testdb;
psql -U postgres -d testdb -c \"create table users (id serial primary key, name text)\";
psql -U postgres -d testdb -c \"insert into users (name) values ('Alice'), ('Bob'), ('Celine')\"
"
su - postgres -c '
psql -U postgres -d testdb -c "select * from users"
' > expected.txt

echo "Expected:"
cat expected.txt

# uninstall postgresql
dnf -y remove postgresql-server postgresql-private-libs postgresql libicu

# install postgresql17
dnf -y install postgresql17-upgrade

# run --upgrade
./bin/postgresql-setup --upgrade

# restart postgresql
systemctl start postgresql

# check if it is running
systemctl is-active postgresql && echo "PostgreSQL is running" || { echo "PostgreSQL is NOT running"; exit 1; }

su - postgres -c '
psql -U postgres -d testdb -c "select * from users"
' > actual.txt

echo "Actual:"
cat actual.txt

diff -q expected.txt actual.txt && echo "Actual and expected outputs match" || { echo "Actual and expected outputs differ"; exit 1; }