Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Added initial support for tmt #3473

Merged
merged 2 commits into from
Dec 9, 2024
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
2 changes: 1 addition & 1 deletion .cockpit-ci/run
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
10 changes: 5 additions & 5 deletions integration-tests/run → cockpit-tests/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# like this:
#
# $ export TEST_OS=rhel-8-4
# $ ./integration-tests/run prepare
# $ ./integration-tests/check-subscriptions -v -j1 -t
# $ ./cockpit-tests/run prepare
# $ ./cockpit-tests/check-subscriptions -v -j1 -t
#
# You need a couple of things installed for that. At least Python 3,
# a Chromium browser, and libvirtd. See
Expand All @@ -20,7 +20,7 @@ ifeq ($(TEST_OS),)
TEST_OS = rhel-8-4
endif
export TEST_OS
SUB_MAN_COCKPIT=$(CURDIR)/integration-tests/submancockpit
SUB_MAN_COCKPIT=$(CURDIR)/cockpit-tests/submancockpit
VM_IMAGE=$(SUB_MAN_COCKPIT)/test/images/$(TEST_OS).qcow2
SUBMAN_TAR=$(CURDIR)/dist/subscription-manager.tar.gz
SMBEXT_TAR=$(CURDIR)/dist/subscription-manager-build-extra.tar.gz
Expand All @@ -45,7 +45,7 @@ $(SUBMAN_TAR):
$(SMBEXT_TAR):
tar czf $(SMBEXT_TAR) build_ext

$(VM_IMAGE): $(SUB_MAN_COCKPIT) $(SUBMAN_TAR) $(SMBEXT_TAR) integration-tests/vm.install
$(VM_IMAGE): $(SUB_MAN_COCKPIT) $(SUBMAN_TAR) $(SMBEXT_TAR) cockpit-tests/vm.install
rm -f $(VM_IMAGE)
# setup the test image from subscription-manager-cockpit without
# a custom subscription-manager, which will be installed manually
Expand All @@ -54,7 +54,7 @@ $(VM_IMAGE): $(SUB_MAN_COCKPIT) $(SUBMAN_TAR) $(SMBEXT_TAR) integration-tests/vm
cd $(SUB_MAN_COCKPIT) && bots/image-customize -v $(TEST_OS) \
-u $(SUBMAN_TAR):/var/tmp/ \
-u $(SMBEXT_TAR):/var/tmp/ \
-s ../../integration-tests/vm.install
-s ../../cockpit-tests/vm.install

$(SUB_MAN_COCKPIT):
git clone --quiet https://github.com/candlepin/subscription-manager-cockpit.git $(SUB_MAN_COCKPIT)
Expand Down
File renamed without changes.
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