From 610ceaa7f1373b01631159ebbb671d34ec5c3f0f Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Thu, 7 Dec 2023 11:15:39 +0100 Subject: [PATCH] feat: basic integration testing with tmt Introduce a minimal setup for integration tests of insights-client. The tests are written using pytest and an helper plugin for insights-client and other Red Hat client tools [1]. The tests are wrapped as single "integration" test for tmt [2], which makes it possible to run them automatically e.g. in testing-farm. There is a simple test added to show how the setup for the tests works. [1] https://github.com/ptoscano/pytest-client-tools/ [2] https://github.com/teemtee/tmt/ Signed-off-by: Pino Toscano --- .fmf/version | 1 + integration-tests/requirements.txt | 1 + integration-tests/test_version.py | 4 ++++ systemtest/plans/main.fmf | 6 ++++++ systemtest/tests/integration/main.fmf | 3 +++ systemtest/tests/integration/test.sh | 17 +++++++++++++++++ 6 files changed, 32 insertions(+) create mode 100644 .fmf/version create mode 100644 integration-tests/requirements.txt create mode 100644 integration-tests/test_version.py create mode 100644 systemtest/plans/main.fmf create mode 100644 systemtest/tests/integration/main.fmf create mode 100755 systemtest/tests/integration/test.sh diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 000000000..d00491fd7 --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/integration-tests/requirements.txt b/integration-tests/requirements.txt new file mode 100644 index 000000000..5dba47273 --- /dev/null +++ b/integration-tests/requirements.txt @@ -0,0 +1 @@ +git+https://github.com/ptoscano/pytest-client-tools@main diff --git a/integration-tests/test_version.py b/integration-tests/test_version.py new file mode 100644 index 000000000..9c4788ca8 --- /dev/null +++ b/integration-tests/test_version.py @@ -0,0 +1,4 @@ +def test_version(insights_client): + proc = insights_client.run("--version") + assert b"Client: " in proc.stdout + assert b"Core: " in proc.stdout diff --git a/systemtest/plans/main.fmf b/systemtest/plans/main.fmf new file mode 100644 index 000000000..bff4ce054 --- /dev/null +++ b/systemtest/plans/main.fmf @@ -0,0 +1,6 @@ +summary: rhc test suite +discover: + how: fmf + +execute: + how: tmt diff --git a/systemtest/tests/integration/main.fmf b/systemtest/tests/integration/main.fmf new file mode 100644 index 000000000..da3260633 --- /dev/null +++ b/systemtest/tests/integration/main.fmf @@ -0,0 +1,3 @@ +summary: Runs tmt tests +test: ./test.sh +duration: 10m diff --git a/systemtest/tests/integration/test.sh b/systemtest/tests/integration/test.sh new file mode 100755 index 000000000..2f6e4170d --- /dev/null +++ b/systemtest/tests/integration/test.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -eu +set -x + +# get to project root +cd ../../../ + +dnf --setopt install_weak_deps=False install -y \ + podman git-core python3-pip python3-pytest + +python3 -m venv venv +# shellcheck disable=SC1091 +. venv/bin/activate + +pip install -r integration-tests/requirements.txt + +pytest -v integration-tests