test: restructure dir layout
Attempt to clarify the structure of our tests. Each test case is now encapsulated in a script in `test/cases`. Each of these scripts should be runnable on a pristine machine and be independent of each other. It is up to the test-orchestractor to decide if they should be run consequtively instance, or in parallel on separate instances. Each script can execute several tests and call whatever helper binaries is desired. However, each case should be assumed to always run as one.
This commit is contained in:
parent
d7247e2878
commit
3c7f61c322
48 changed files with 31 additions and 33 deletions
|
|
@ -16,7 +16,7 @@ func GetOsbuildCommand(store, outputDirectory string) *exec.Cmd {
|
|||
|
||||
func GetImageInfoCommand(imagePath string) *exec.Cmd {
|
||||
return exec.Command(
|
||||
"/usr/libexec/osbuild-composer/image-info",
|
||||
"/usr/libexec/osbuild-composer-test/image-info",
|
||||
imagePath,
|
||||
)
|
||||
}
|
||||
|
|
@ -29,7 +29,7 @@ var TestPaths = struct {
|
|||
MetaData string
|
||||
AzureDeploymentTemplate string
|
||||
}{
|
||||
ImageInfo: "/usr/libexec/osbuild-composer/image-info",
|
||||
ImageInfo: "/usr/libexec/osbuild-composer-test/image-info",
|
||||
PrivateKey: "/usr/share/tests/osbuild-composer/keyring/id_rsa",
|
||||
TestCasesDirectory: "/usr/share/tests/osbuild-composer/cases",
|
||||
UserData: "/usr/share/tests/osbuild-composer/cloud-init/user-data",
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import (
|
|||
func TestDistro_Manifest(t *testing.T) {
|
||||
distro_test_common.TestDistro_Manifest(
|
||||
t,
|
||||
"../../test/data/cases/",
|
||||
"../../test/data/manifests/",
|
||||
"*",
|
||||
fedora32.New(), fedora33.New(), rhel8.New(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ func TestImageType_BasePackages(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDistro_Manifest(t *testing.T) {
|
||||
distro_test_common.TestDistro_Manifest(t, "../../../test/data/cases/", "fedora_32*", fedora32.New())
|
||||
distro_test_common.TestDistro_Manifest(t, "../../../test/data/manifests/", "fedora_32*", fedora32.New())
|
||||
}
|
||||
|
||||
func TestFedora32_ListArches(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ func TestImageType_BasePackages(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDistro_Manifest(t *testing.T) {
|
||||
distro_test_common.TestDistro_Manifest(t, "../../../test/data/cases/", "fedora_33*", fedora33.New())
|
||||
distro_test_common.TestDistro_Manifest(t, "../../../test/data/manifests/", "fedora_33*", fedora33.New())
|
||||
}
|
||||
|
||||
func TestFedora33_ListArches(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ func TestImageType_BasePackages(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestDistro_Manifest(t *testing.T) {
|
||||
distro_test_common.TestDistro_Manifest(t, "../../../test/data/cases/", "rhel_8*", rhel8.New())
|
||||
distro_test_common.TestDistro_Manifest(t, "../../../test/data/manifests/", "rhel_8*", rhel8.New())
|
||||
}
|
||||
|
||||
func TestRhel8_ListArches(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -169,17 +169,18 @@ install -m 0755 -vd %{buildroot}%{_l
|
|||
|
||||
%if %{with tests} || 0%{?rhel}
|
||||
|
||||
install -m 0755 -vd %{buildroot}%{_libexecdir}/osbuild-composer-test
|
||||
install -m 0755 -vp _bin/osbuild-composer-cli-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp _bin/osbuild-weldr-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp _bin/osbuild-dnf-json-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp _bin/osbuild-image-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp _bin/osbuild-auth-tests %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp _bin/cloud-cleaner %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp tools/image-info %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp tools/run-koji-container.sh %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vp tools/koji-compose.py %{buildroot}%{_libexecdir}/osbuild-composer-test/
|
||||
install -m 0755 -vd %{buildroot}%{_libexecdir}/tests/osbuild-composer
|
||||
install -m 0755 -vp _bin/osbuild-composer-cli-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/
|
||||
install -m 0755 -vp _bin/osbuild-weldr-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/
|
||||
install -m 0755 -vp _bin/osbuild-dnf-json-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/
|
||||
install -m 0755 -vp _bin/osbuild-image-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/
|
||||
install -m 0755 -vp _bin/osbuild-auth-tests %{buildroot}%{_libexecdir}/tests/osbuild-composer/
|
||||
install -m 0755 -vp test/cmd/* %{buildroot}%{_libexecdir}/tests/osbuild-composer/
|
||||
install -m 0755 -vp _bin/cloud-cleaner %{buildroot}%{_libexecdir}/osbuild-composer/
|
||||
install -m 0755 -vp tools/image-info %{buildroot}%{_libexecdir}/osbuild-composer/
|
||||
install -m 0755 -vp tools/run-koji-container.sh %{buildroot}%{_libexecdir}/osbuild-composer/
|
||||
install -m 0755 -vp tools/koji-compose.py %{buildroot}%{_libexecdir}/osbuild-composer/
|
||||
install -m 0755 -vp test/cases/* %{buildroot}%{_libexecdir}/tests/osbuild-composer/
|
||||
|
||||
install -m 0755 -vd %{buildroot}%{_datadir}/tests/osbuild-composer/ansible
|
||||
install -m 0644 -vp test/data/ansible/* %{buildroot}%{_datadir}/tests/osbuild-composer/ansible/
|
||||
|
|
@ -199,8 +200,8 @@ install -m 0600 -vp test/data/ca/worker-key.pem %{buildroot}%{_d
|
|||
install -m 0644 -vp test/data/ca/client-crt.pem %{buildroot}%{_datadir}/tests/osbuild-composer/ca/
|
||||
install -m 0644 -vp test/data/ca/client-key.pem %{buildroot}%{_datadir}/tests/osbuild-composer/ca/
|
||||
|
||||
install -m 0755 -vd %{buildroot}%{_datadir}/tests/osbuild-composer/cases
|
||||
install -m 0644 -vp test/data/cases/* %{buildroot}%{_datadir}/tests/osbuild-composer/cases/
|
||||
install -m 0755 -vd %{buildroot}%{_datadir}/tests/osbuild-composer/manifests
|
||||
install -m 0644 -vp test/data/manifests/* %{buildroot}%{_datadir}/tests/osbuild-composer/manifests/
|
||||
|
||||
install -m 0755 -vd %{buildroot}%{_datadir}/tests/osbuild-composer/cloud-init
|
||||
install -m 0644 -vp test/data/cloud-init/* %{buildroot}%{_datadir}/tests/osbuild-composer/cloud-init/
|
||||
|
|
@ -338,12 +339,9 @@ Requires: edk2-aarch64
|
|||
Integration tests to be run on a pristine-dedicated system to test the osbuild-composer package.
|
||||
|
||||
%files tests
|
||||
%{_libexecdir}/osbuild-composer-test/
|
||||
%{_libexecdir}/tests/osbuild-composer/
|
||||
%{_datadir}/tests/osbuild-composer/
|
||||
%{_libexecdir}/osbuild-composer/cloud-cleaner
|
||||
%{_libexecdir}/osbuild-composer/image-info
|
||||
%{_libexecdir}/osbuild-composer/run-koji-container.sh
|
||||
%{_libexecdir}/osbuild-composer/koji-compose.py
|
||||
|
||||
%endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
CLEANER_CMD="env $(cat "$AZURE_CREDS") BRANCH_NAME=$BRANCH_NAME BUILD_ID=$BUILD_ID DISTRO_CODE=$DISTRO_CODE /usr/libexec/osbuild-composer/cloud-cleaner"
|
||||
CLEANER_CMD="env $(cat "$AZURE_CREDS") BRANCH_NAME=$BRANCH_NAME BUILD_ID=$BUILD_ID DISTRO_CODE=$DISTRO_CODE /usr/libexec/osbuild-composer-test/cloud-cleaner"
|
||||
|
||||
echo "🧹 Running the cloud cleaner"
|
||||
$CLEANER_CMD
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ in a dedicated RPM: osbulid-composer-tests, and they are meant to be installed
|
|||
onto a pristine system and executed from there, rather than executed from a
|
||||
git checkout.
|
||||
|
||||
Some tests are written as golang binaries, found in `cmd/*-test/`, and others
|
||||
are written as scripts and found in `test/cmd/`. Either way, they are installed
|
||||
into `/usr/libexec/tests/osbuild-composer/`, and any supporting test-data is
|
||||
installed into `/usr/share/tests/osbuild-composer/`.
|
||||
Test cases are found in `test/cases`. They are intended to be independent of
|
||||
each other and they are installed into `/usr/libexec/tests/osbuild-composer/`,
|
||||
with any supporting test-data in `/usr/share/tests/osbuild-composer/`, and
|
||||
helper binaries in `/usr/libexec/osbuild-composer-test/`.
|
||||
|
||||
Provisioning and orchestration of test-systems, as well as configuring what
|
||||
distros, versions and architectures to test against is out of scope of the
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
set -euo pipefail
|
||||
|
||||
WORKING_DIRECTORY=/usr/libexec/osbuild-composer
|
||||
TESTS_PATH=/usr/libexec/tests/osbuild-composer
|
||||
TESTS_PATH=/usr/libexec/osbuild-composer-test
|
||||
|
||||
PASSED_TESTS=()
|
||||
FAILED_TESTS=()
|
||||
|
|
@ -6,8 +6,8 @@ source /etc/os-release
|
|||
ARCH=$(uname -m)
|
||||
|
||||
WORKING_DIRECTORY=/usr/libexec/osbuild-composer
|
||||
IMAGE_TEST_CASE_RUNNER=/usr/libexec/tests/osbuild-composer/osbuild-image-tests
|
||||
IMAGE_TEST_CASES_PATH=/usr/share/tests/osbuild-composer/cases
|
||||
IMAGE_TEST_CASE_RUNNER=/usr/libexec/osbuild-composer-test/osbuild-image-tests
|
||||
IMAGE_TEST_CASES_PATH=/usr/share/tests/osbuild-composer/manifests
|
||||
|
||||
PASSED_TESTS=()
|
||||
FAILED_TESTS=()
|
||||
|
|
@ -25,7 +25,7 @@ if [[ $ID == rhel ]]; then
|
|||
fi
|
||||
|
||||
greenprint "Starting containers"
|
||||
sudo /usr/libexec/osbuild-composer/run-koji-container.sh start
|
||||
sudo /usr/libexec/osbuild-composer-test/run-koji-container.sh start
|
||||
|
||||
greenprint "Copying custom worker config"
|
||||
sudo mkdir -p /etc/osbuild-worker
|
||||
|
|
@ -60,14 +60,14 @@ greenprint "Creating Koji task"
|
|||
koji --server=http://localhost:8080/kojihub --user kojiadmin --password kojipass --authtype=password make-task image
|
||||
|
||||
greenprint "Pushing compose to Koji"
|
||||
sudo /usr/libexec/osbuild-composer/koji-compose.py "${ID}-${VERSION_ID%.*}"
|
||||
sudo /usr/libexec/osbuild-composer-test/koji-compose.py "${ID}-${VERSION_ID%.*}"
|
||||
|
||||
greenprint "Show Koji task"
|
||||
koji --server=http://localhost:8080/kojihub taskinfo 1
|
||||
koji --server=http://localhost:8080/kojihub buildinfo 1
|
||||
|
||||
greenprint "Stopping containers"
|
||||
sudo /usr/libexec/osbuild-composer/run-koji-container.sh stop
|
||||
sudo /usr/libexec/osbuild-composer-test/run-koji-container.sh stop
|
||||
|
||||
greenprint "Removing generated CA cert"
|
||||
sudo rm \
|
||||
Loading…
Add table
Add a link
Reference in a new issue