Skip to content

Commit

Permalink
Merge pull request #9 from yuravk/almalinux
Browse files Browse the repository at this point in the history
Make up2date with CentOS / Integration SIG / compose-tests
  • Loading branch information
andrewlukoshko authored Sep 24, 2024
2 parents 54920e6 + 52014a0 commit a1a6449
Show file tree
Hide file tree
Showing 96 changed files with 280 additions and 806 deletions.
41 changes: 37 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ lint:
- tmt lint --failed-only
- find . -name '*.sh' -not -path "*/legacy/*" | xargs -n 1 shellcheck --severity=error --shell=bash


extract-changes:
stage: changes
image: docker.io/bitnami/git:latest
Expand All @@ -27,16 +28,48 @@ extract-changes:
paths:
- changed-tests-regex.log

validate-only-changed-tests-cs9:
stage: validate
image: quay.io/testing-farm/cli:latest
script:
- |
testing-farm request \
--git-ref $CI_MERGE_REQUEST_REF_PATH \
--git-url $CI_MERGE_REQUEST_PROJECT_URL \
--context distro=centos-stream-9 \
--compose CentOS-Stream-9 \
--test-filter "$(cat changed-tests-regex.log)"
validate-cs9:
stage: validate
image: quay.io/testing-farm/cli:latest
when: manual
script:
- testing-farm request --git-ref $CI_MERGE_REQUEST_REF_PATH --git-url $CI_MERGE_REQUEST_PROJECT_URL --compose CentOS-Stream-9 --test-filter "$(cat changed-tests-regex.log)"
- |
testing-farm request \
--git-ref $CI_MERGE_REQUEST_REF_PATH \
--git-url $CI_MERGE_REQUEST_PROJECT_URL \
--context distro=centos-stream-9 \
--compose CentOS-Stream-9
validate-only-changed-tests-cs10:
stage: validate
image: quay.io/testing-farm/cli:latest
script:
- |
testing-farm request \
--git-ref $CI_MERGE_REQUEST_REF_PATH \
--git-url $CI_MERGE_REQUEST_PROJECT_URL \
--context distro=centos-stream-10 \
--compose CentOS-Stream-10 \
--test-filter "$(cat changed-tests-regex.log)"
validate-cs10:
stage: validate
image: quay.io/testing-farm/cli:latest
when: manual
script:
- testing-farm request --git-ref $CI_MERGE_REQUEST_REF_PATH --git-url $CI_MERGE_REQUEST_PROJECT_URL --compose CentOS-Stream-10 --test-filter "$(cat changed-tests-regex.log)"
- |
testing-farm request \
--git-ref $CI_MERGE_REQUEST_REF_PATH \
--git-url $CI_MERGE_REQUEST_PROJECT_URL \
--context distro=centos-stream-10 \
--compose CentOS-Stream-10
38 changes: 16 additions & 22 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# Quick Start

On Centos Stream 9 as `root`:

Requirements:

```sh
tmt -vvv -c distro=centos-stream-9 run --all provision --how=local
dnf install tmt+all
```

In order to run it with the `SKIP_QA_HARNESS=0` off (default as `1`):
Run all tests on centos-stream-9:

```sh
tmt -vvv -c distro=centos-stream-9 run -e SKIP_QA_HARNESS=0 --all provision --how=local
tmt -vv -c distro=centos-stream-9 run -a provision --how=virtual --image centos-stream-9 prepare --how=install --package=epel-release
```

or
Run only one test on centos-stream-9:

```sh
tmt -vvv -c distro=centos-stream-9 run -e SKIP_QA_HARNESS=$(host repo.centos.qa > /dev/null; echo $?) --all provision --how=local
tmt -vv -c distro=centos-stream-9 run -a provision --how=virtual --image centos-stream-9 prepare --how=install --package=epel-release test --name /tests/sysstat
```

These commands will provision a local VM using libvirt from a centos-stream-9 image, copy the tests from the local directory into it, run them, and rsync the results from the VM to your machine on the directory `/var/tmp/tmt`.


# Directory Structure

Expand Down Expand Up @@ -51,27 +52,20 @@ tmt lint
find ./tests/yourtest/ -name '*.sh' | xargs -n 1 shellcheck --severity=warning --shell=bash
```

You should be able to run your tests by simply cd'ing into them and running the shell scripts. Example:

```sh
cd tests/podman
./test.sh
```

You can also run them using the `tmt` tool. Example of how to run `podman` with `tmt` directly on your machine.
You should be able to run your tests individually as follow:

```sh
tmt -vv -c distro=centos-stream-9 run -a provision --how=local test --name /podman
tmt -vv -c distro=centos-stream-9 run -a provision --how=virtual --image centos-stream-9 prepare --how=install --package=epel-release test --name /tests/yourtest
```

Test outputs will be in the default temp `tmt` folder, e.g. `/var/tmp/tmt`. If you pass `-vv` to the command as in the example above, you will get the full path to the output of each test. For example:

```yaml
report
how: display
pass /tests/podman
output.txt: /var/tmp/tmt/run-1/plans/execute/data/guest/default-0/tests/podman-1/output.txt
journal.txt: /var/tmp/tmt/run-1/plans/execute/data/guest/default-0/tests/podman-1/journal.txt
pass /tests/yourtest
output.txt: /var/tmp/tmt/run-1/plans/execute/data/guest/default-0/tests/yourteset-1/output.txt
journal.txt: /var/tmp/tmt/run-1/plans/execute/data/guest/default-0/tests/yourteset-1/journal.txt
summary: 1 test passed
```
Expand Down Expand Up @@ -107,7 +101,7 @@ TODO: define the tiers and what tiers a test should go into.

The legacy tests contains variable that are EL distro specific. These variables are defined in the `legacy.fmf` file. In order to run those tests in another EL distro, you would need to override them. You can do it in two different ways:

A) Passing them in the command line, for example, running the test locally:
A) Passing them in the command line, for example:

```sh
tmt -vvv -c distro=centos-stream-9 run \
Expand All @@ -117,7 +111,7 @@ tmt -vvv -c distro=centos-stream-9 run \
-e kernel_sb_token="ELdistro Secure Boot Signing" \
-e key_template="ELdistro %s signing key" \
-e firefox_start_page="www.eldistro.org" \
--all provision --how=local
--all provision --how=connect --guest=192.168.210.10 --user=somedefaultuser --become
```

B) Defining a new plan importing `compose-tests`
Expand All @@ -142,5 +136,5 @@ In order to run only a set of tests on the different EL distro, you can use `tmt

```sh
# Run tests that their name start with `/legacy/p_`
tmt -vv -c distro=centos-stream-9 run -a provision --how=local test --name '/legacy/p_.*'
tmt -vv -c distro=centos-stream-9 run -a provision --how=connect --guest=192.168.210.10 --user=somedefaultuser --become test --name '/legacy/p_.*'
```
2 changes: 1 addition & 1 deletion tests/curl/server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

case $1 in
start)
python3 -m http.server > /dev/null 2>&1 &
python3 -m http.server --bind localhost &
server_pid=$!
echo "Starting with PID: $server_pid"
echo "$server_pid" > server.pid
Expand Down
10 changes: 10 additions & 0 deletions tests/freeradius/authorize
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
DEFAULT Framed-Protocol == PPP
Framed-Protocol = PPP,
Framed-Compression = Van-Jacobson-TCP-IP
DEFAULT Hint == "CSLIP"
Framed-Protocol = SLIP,
Framed-Compression = Van-Jacobson-TCP-IP
DEFAULT Hint == "SLIP"
Framed-Protocol = SLIP

user Cleartext-Password := "password"
4 changes: 4 additions & 0 deletions tests/freeradius/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
summary: freeradius smoke test
description: Verify that freeradius works
test: ./test.sh
framework: beakerlib
33 changes: 33 additions & 0 deletions tests/freeradius/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
. /usr/share/beakerlib/beakerlib.sh || exit 1

rlJournalStart

rlPhaseStartSetup
rlRun "dnf install -y freeradius freeradius-utils"
rlRun "pushd /etc/raddb/certs/"
rlRun "make"
rlRun "chown root:radiusd *"
rlRun "popd"
rlRun "cp -f ./authorize /etc/raddb/mods-config/files/authorize"
rlRun "chown root:radiusd /etc/raddb/mods-config/files/authorize"
rlServiceStop radiusd
rlServiceStart radiusd
rlPhaseEnd

rlPhaseStartTest "Verifying successful authentication"
rlRun -s 'echo "User-Name=user,User-Password=password" | radclient -x localhost:1812 auth testing123' 0 'auth with valid creds'
rlAssertNotGrep "Access-Reject" $rlRun_LOG
rlPhaseEnd

rlPhaseStartTest "Verifying failed authentication"
rlRun -s 'echo "User-Name=user2,User-Password=password2" | radclient -x localhost:1812 auth testing123' 1 'auth with bad creds'
rlAssertGrep "Access-Reject" $rlRun_LOG
rlPhaseEnd

rlPhaseStartCleanup
rlServiceStop radiusd
rlRun "dnf remove -y freeradius freeradius-utils"
rlPhaseEnd

rlJournalEnd
6 changes: 1 addition & 5 deletions tests/legacy/0_common/30_dns_works.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#!/bin/bash

t_Log "Running $0 - testing to see if DNS works"
if [ $SKIP_QA_HARNESS -eq 1 ]; then
HOST=www.centos.org
else
HOST=repo.centos.qa
fi
HOST=www.centos.org

# its important we dont hit a dns record with a wildcard like centos.org
getent hosts $HOST >/dev/null
Expand Down
1 change: 1 addition & 0 deletions tests/legacy/0_common/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ summary: imported 0_common test set
description: 0_common imported as-is
test: ./test.sh
duration: 30m
enabled: true
15 changes: 0 additions & 15 deletions tests/legacy/p_amanda/0-install_amanda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,5 @@

t_Log "$0 - installing amanda system"


if (t_GetPkgRel basesystem | grep -q el5)
then
t_Log "This is a C5 system. Skipping."
t_CheckExitStatus 0
exit $PASS
fi

if (t_GetPkgRel basesystem | grep -q el9)
then
t_Log "This is a C9 system. Amanda not present. Skipping."
t_CheckExitStatus 0
exit $PASS
fi

t_InstallPackage amanda amanda-server amanda-client
id -u amandabackup &>/dev/null || useradd amandabackup
14 changes: 0 additions & 14 deletions tests/legacy/p_amanda/amanda-server_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
# Author: Christoph Galuschka <[email protected]>
t_Log "Running $0 - amanda server runs a simple task (backing up /etc)"

if (t_GetPkgRel basesystem | grep -q el5)
then
t_Log "This is a C5 system. Skipping."
t_CheckExitStatus 0
exit $PASS
fi

if (t_GetPkgRel basesystem | grep -q el9)
then
t_Log "This is a C9 system. Amanda not present. Skipping."
t_CheckExitStatus 0
exit $PASS
fi

ret_val=0

# Creating necessary directories
Expand Down
4 changes: 4 additions & 0 deletions tests/legacy/p_amanda/main.fmf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
summary: imported p_amanda test set
description: p_amanda imported as-is
test: ./test.sh
enabled: false
adjust:
when: distro == centos-8
enabled: true
15 changes: 0 additions & 15 deletions tests/legacy/p_anaconda/0-install_anaconda.sh

This file was deleted.

34 changes: 0 additions & 34 deletions tests/legacy/p_anaconda/anaconda_centos_patch.sh

This file was deleted.

3 changes: 0 additions & 3 deletions tests/legacy/p_anaconda/main.fmf

This file was deleted.

5 changes: 0 additions & 5 deletions tests/legacy/p_anaconda/test.sh

This file was deleted.

13 changes: 6 additions & 7 deletions tests/legacy/p_annobin/0-install_annobin.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/bash
# Author: Neal Gompa <[email protected]>

# Skip if older than CentOS 8
if [ "$centos_ver" -lt "8" ]; then
t_Log "annobin does not exist pre-c8 => SKIP"
exit 0
fi

# Install annobin and gcc
t_Log "Running $0 - installing annobin and gcc."

t_InstallPackage annobin redhat-rpm-config gcc gcc-c++
package=annobin
if [ "$centos_ver" -ge "10" ]; then
package=annobin-annocheck
fi

t_InstallPackage $package redhat-rpm-config gcc gcc-c++
6 changes: 0 additions & 6 deletions tests/legacy/p_annobin/10-test_annobin-gcc.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/bin/bash
# Author: Neal Gompa <[email protected]>

# Skip if older than CentOS 8
if [ "$centos_ver" -lt "8" ]; then
t_Log "annobin does not exist pre-c8 => SKIP"
exit 0
fi

# Run the test
t_Log "Running $0 - build a hello world program with gcc using annobin"

Expand Down
6 changes: 0 additions & 6 deletions tests/legacy/p_annobin/20-test_annobin-gcc-c++.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/bin/bash
# Author: Neal Gompa <[email protected]>

# Skip if older than CentOS 8
if [ "$centos_ver" -lt "8" ]; then
t_Log "annobin does not exist pre-c8 => SKIP"
exit 0
fi

# Run the test
t_Log "Running $0 - build a hello world program with gcc-c++ using annobin"

Expand Down
Loading

0 comments on commit a1a6449

Please sign in to comment.