diff --git a/.github/workflows/testing-farm.yaml b/.github/workflows/testing-farm.yaml new file mode 100644 index 0000000..d2d8fc2 --- /dev/null +++ b/.github/workflows/testing-farm.yaml @@ -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" + diff --git a/tmt/.fmf/root b/tmt/.fmf/root new file mode 100644 index 0000000..e69de29 diff --git a/tmt/.fmf/version b/tmt/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/tmt/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/tmt/plans/fedora-init.fmf b/tmt/plans/fedora-init.fmf new file mode 100644 index 0000000..e387013 --- /dev/null +++ b/tmt/plans/fedora-init.fmf @@ -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 + diff --git a/tmt/plans/fedora-upgrade.fmf b/tmt/plans/fedora-upgrade.fmf new file mode 100644 index 0000000..21d6431 --- /dev/null +++ b/tmt/plans/fedora-upgrade.fmf @@ -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 + diff --git a/tmt/tests/container/sanity/init/init.sh b/tmt/tests/container/sanity/init/init.sh new file mode 100755 index 0000000..afef6b9 --- /dev/null +++ b/tmt/tests/container/sanity/init/init.sh @@ -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; } diff --git a/tmt/tests/container/sanity/init/main.fmf b/tmt/tests/container/sanity/init/main.fmf new file mode 100644 index 0000000..4f63a78 --- /dev/null +++ b/tmt/tests/container/sanity/init/main.fmf @@ -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 + diff --git a/tmt/tests/virtual/sanity/init/.testinfo.tmt b/tmt/tests/virtual/sanity/init/.testinfo.tmt new file mode 100644 index 0000000..9872eee --- /dev/null +++ b/tmt/tests/virtual/sanity/init/.testinfo.tmt @@ -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 diff --git a/tmt/tests/virtual/sanity/init/init.sh b/tmt/tests/virtual/sanity/init/init.sh new file mode 100755 index 0000000..9cb1502 --- /dev/null +++ b/tmt/tests/virtual/sanity/init/init.sh @@ -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; } diff --git a/tmt/tests/virtual/sanity/init/main.fmf b/tmt/tests/virtual/sanity/init/main.fmf new file mode 100644 index 0000000..97a02a9 --- /dev/null +++ b/tmt/tests/virtual/sanity/init/main.fmf @@ -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 + diff --git a/tmt/tests/virtual/sanity/upgrade/main.fmf b/tmt/tests/virtual/sanity/upgrade/main.fmf new file mode 100644 index 0000000..14c144d --- /dev/null +++ b/tmt/tests/virtual/sanity/upgrade/main.fmf @@ -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 + diff --git a/tmt/tests/virtual/sanity/upgrade/upgrade.sh b/tmt/tests/virtual/sanity/upgrade/upgrade.sh new file mode 100755 index 0000000..9d3277b --- /dev/null +++ b/tmt/tests/virtual/sanity/upgrade/upgrade.sh @@ -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; } + + + + + +