Skip to content

Commit

Permalink
feat: Add initial support for tmt
Browse files Browse the repository at this point in the history
* Card ID: CCT-741
* Added basic configuration for tmt
  - subscription-manager is installed from COPR build
  - Python virtual environment is created
  - Install testing framework
  - Some simple smoke test is run (busctl calls RHSM D-Bus method)
  • Loading branch information
jirihnidek authored and m-horky committed Dec 9, 2024
1 parent 71c526e commit 5365981
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .packit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,29 @@ jobs:
targets:
- centos-stream-10
- fedora-all

# - job: tests
# trigger: pull_request
# identifier: "unit/centos-stream"
# targets:
# - centos-stream-10
# labels:
# - unit
# tf_extra_params:
# environments:
# - artifacts:
# - type: repository-file
# id: https://copr.fedorainfracloud.org/coprs/g/yggdrasil/latest/repo/centos-stream-$releasever/group_yggdrasil-latest-centos-stream-$releasever.repo

- job: tests
trigger: pull_request
identifier: "unit/fedora"
targets:
- fedora-all
labels:
- unit
tf_extra_params:
environments:
- artifacts:
- type: repository-file
id: https://copr.fedorainfracloud.org/coprs/g/yggdrasil/latest/repo/fedora-$releasever/group_yggdrasil-latest-fedora-$releasever.repo
Empty file added integration-tests/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions integration-tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
git+https://github.com/ptoscano/pytest-client-tools@main
pyyaml
sh
24 changes: 24 additions & 0 deletions integration-tests/test_consumer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
This Python module contains integration tests for rhc.
It uses pytest-client-tools Python module.More information about this
module could be found: https://github.com/ptoscano/pytest-client-tools/
"""

import contextlib
import sh


def test_busctl_get_consumer_uuid():
"""
Simple smoke test using busctl CLI tool. It tries to call simple D-Bus method.
"""
with contextlib.suppress(Exception):
sh.busctl(
"call",
"com.redhat.RHSM1",
"/com/redhat/RHSM1/Consumer",
"com.redhat.RHSM1.Consumer",
"GetUuid",
"s",
'""',
)
1 change: 1 addition & 0 deletions systemtest/.fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
16 changes: 16 additions & 0 deletions systemtest/copr-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/bash -eux
dnf install -y dnf-plugins-core

# Determine the repo needed from copr
source /etc/os-release

if [ "$ID" == "centos" ]; then
ID='centos-stream'
fi
VERSION_MAJOR=$(echo "${VERSION_ID}" | cut -d '.' -f 1)
COPR_REPO="${ID}-${VERSION_MAJOR}-$(uname -m)"

# Install subscription-manager from COPR repository
dnf remove -y --noautoremove subscription-manager
dnf copr -y enable packit/candlepin-subscription-manager-"${ghprbPullId}" "${COPR_REPO}"
dnf install -y subscription-manager --disablerepo=* --enablerepo=*subscription-manager*
5 changes: 5 additions & 0 deletions systemtest/plans/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
summary: rhsm test suite
discover:
how: fmf
execute:
how: tmt
3 changes: 3 additions & 0 deletions systemtest/tests/integration/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
summary: Runs tmt tests
test: ./test.sh
duration: 1h
31 changes: 31 additions & 0 deletions systemtest/tests/integration/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash
set -ux

# get to project root
cd ../../../

# Check for GitHub pull request ID and install build if needed.
# This is for the downstream PR jobs.
[ -z "${ghprbPullId+x}" ] || ./systemtest/copr-setup.sh

dnf --setopt install_weak_deps=False install -y \
podman git-core python3-pip python3-pytest logrotate

python3 -m venv venv
# shellcheck disable=SC1091
. venv/bin/activate

# Install requirements for integration tests
pip install -r integration-tests/requirements.txt

# Run all integration tests
pytest --junit-xml=./junit.xml -v integration-tests
retval=$?

# Copy artifacts of integration tests
if [ -d "$TMT_PLAN_DATA" ]; then
cp ./junit.xml "$TMT_PLAN_DATA/junit.xml"
fi

# Return exit code of integration tests
exit $retval

0 comments on commit 5365981

Please sign in to comment.