Skip to content
Open
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
86 changes: 86 additions & 0 deletions .github/workflows/testing-farm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,89 @@ jobs:
update_pull_request_status: "true"
create_github_summary: "true"
variables: "REPO_URL=${{ github.server_url }}/${{ github.repository }};PR_HEAD=${{ github.event.pull_request.head.sha }};"
container-test-init:
runs-on: ubuntu-latest


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

steps:
- name: Get User Permission
id: checkAccess
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check User Permission
if: steps.checkAccess.outputs.require-result == 'false'
run: |
echo "${{ github.triggering_actor }} does not have permissions on this repo."
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
exit 1

- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Test init on Fedora container
uses: sclorg/testing-farm-as-github-action@main
with:
api_key: ${{ secrets.TESTING_FARM_API_TOKEN }}
compose: null
tmt_path: "tmt"
tmt_plan_regex: "fedora-container-init"
pull_request_status_name: "Fedora container init test"
update_pull_request_status: "true"
create_github_summary: "true"
variables: "REPO_URL=${{ github.server_url }}/${{ github.repository }};PR_HEAD=${{ github.event.pull_request.head.sha }};"

container-test-upgrade:
runs-on: ubuntu-latest

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

steps:
- name: Get User Permission
id: checkAccess
uses: actions-cool/check-user-permission@v2
with:
require: write
username: ${{ github.triggering_actor }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Check User Permission
if: steps.checkAccess.outputs.require-result == 'false'
run: |
echo "${{ github.triggering_actor }} does not have permissions on this repo."
echo "Current permission level is ${{ steps.checkAccess.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
exit 1

- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Test upgrade on Fedora container
uses: sclorg/testing-farm-as-github-action@main
with:
api_key: ${{ secrets.TESTING_FARM_API_TOKEN }}
compose: null
tmt_path: "tmt"
tmt_plan_regex: "fedora-container-upgrade"
pull_request_status_name: "Fedora container upgrade test"
update_pull_request_status: "true"
create_github_summary: "true"
variables: "REPO_URL=${{ github.server_url }}/${{ github.repository }};PR_HEAD=${{ github.event.pull_request.head.sha }};"
12 changes: 12 additions & 0 deletions tmt/plans/fedora-container-init.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: /plans/fedora-init-container
summary: Run init test in a fedora container environment
provision:
how: container
image: fedora:latest
discover:
how: fmf
filter: tag:fedora-container-init
execute:
how: tmt


12 changes: 12 additions & 0 deletions tmt/plans/fedora-container-upgrade.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: /plans/fedora-upgrade-container
summary: Run upgrade test in a fedora container environment
provision:
how: container
image: fedora
discover:
how: fmf
filter: tag:fedora-container-upgrade
execute:
how: tmt


8 changes: 7 additions & 1 deletion tmt/tests/container/sanity/init/init.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
# prep
set -x
git clone "$REPO_URL" repo
cd repo
git fetch origin "$PR_HEAD"
Expand All @@ -16,11 +17,16 @@ make
# initialization
./bin/postgresql-setup --init

# create socket directory
mkdir -p /var/run/postgresql
chown postgres:postgres /var/run/postgresql
chmod 2775 /var/run/postgresql

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

2 changes: 1 addition & 1 deletion tmt/tests/container/sanity/init/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ require:
test: ./init.sh
framework: shell
duration: 10m
tag: container-init-fedora
tag: fedora-container-init
contact: [email protected]

19 changes: 19 additions & 0 deletions tmt/tests/container/sanity/upgrade/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
summary: Postgresql-setup upgrade test in a fedora rawhide container
require:
- make
- m4
- docbook-utils
- help2man
- elinks
- postgresql-server
- coreutils
- autoconf
- automake
- autoconf-archive
- git
test: ./upgrade.sh
framework: shell
duration: 10m
tag: fedora-container-upgrade
contact: [email protected]

72 changes: 72 additions & 0 deletions tmt/tests/container/sanity/upgrade/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash
set -x
# prep
git clone "$REPO_URL" repo
cd repo
git fetch origin "$PR_HEAD"
git checkout FETCH_HEAD

grep -q systemd /proc/1/comm
echo "Return value CONTAINER: $?"

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

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

# Create unix_socket directory
mkdir -p /var/run/postgresql
chown postgres:postgres /var/run/postgresql
chmod 2775 /var/run/postgresql

# start postgresql and check if it's running
PGDATA=/var/lib/pgsql/data
LOGFILE=/var/lib/pgsql/logfile
su - postgres -c "
/usr/bin/pg_ctl -D $PGDATA -l $LOGFILE start
/usr/bin/pg_ctl -D $PGDATA status && 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

test $(wc -l < expected.txt) -gt 0 || { echo "ERROR: expected.txt is empty!"; exit 1; }

# 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

su - postgres -c "
/usr/bin/pg_ctl -D $PGDATA -l $LOGFILE start
/usr/bin/pg_ctl -D $PGDATA status && 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; }

Loading