Added ability to force test system id and version id

Related: #2000051
This commit is contained in:
Oliver Gutierrez 2021-09-14 13:47:38 +01:00
parent d5f960300f
commit d037151cc0
No known key found for this signature in database
GPG Key ID: C4D0A809DC608C15
3 changed files with 67 additions and 12 deletions

View File

@ -13,4 +13,6 @@
package: toolbox
environment:
PODMAN: /usr/bin/podman
TOOLBOX_TEST_SYSTEM_ID: rhel
TOOLBOX_TEST_VERSION_ID: 8.4
become: true

View File

@ -1,7 +1,7 @@
From c65a6e06e38bad6f1f1a1139953fc112f49def33 Mon Sep 17 00:00:00 2001
From a61da78628b59704739c546521057877c69f601c Mon Sep 17 00:00:00 2001
From: Oliver Gutierrez <ogutsua@gmail.com>
Date: Fri, 3 Sep 2021 12:04:24 +0100
Subject: [PATCH] Test fixes for gating
Date: Tue, 14 Sep 2021 13:41:17 +0100
Subject: [PATCH] Tests fixes for gating
diff --git a/test/system/002-help.bats b/test/system/002-help.bats
@ -20,7 +20,7 @@ index 4ff02c6..cca3da4 100644
run $TOOLBOX help
diff --git a/test/system/101-create.bats b/test/system/101-create.bats
index 3cc3eaf..63d4fcb 100644
index 3cc3eaf..937342a 100644
--- a/test/system/101-create.bats
+++ b/test/system/101-create.bats
@@ -5,6 +5,7 @@ load 'libs/bats-assert/load'
@ -31,6 +31,15 @@ index 3cc3eaf..63d4fcb 100644
cleanup_containers
}
@@ -13,7 +14,7 @@ teardown() {
}
-@test "create: Create the default container" {
+@test "create: Create the default container ($(get_system_id)-$(get_system_version))" {
pull_default_image
run $TOOLBOX -y create
@@ -62,7 +63,7 @@ teardown() {
assert_success
@ -89,10 +98,10 @@ index 0ef0ebe..b48f802 100644
}
diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash
index d59d661..89248fb 100644
index d59d661..3d465d3 100644
--- a/test/system/libs/helpers.bash
+++ b/test/system/libs/helpers.bash
@@ -8,8 +8,7 @@ readonly TOOLBOX=${TOOLBOX:-toolbox}
@@ -8,11 +8,10 @@ readonly TOOLBOX=${TOOLBOX:-toolbox}
readonly SKOPEO=$(command -v skopeo)
# Helpful globals
@ -101,20 +110,60 @@ index d59d661..89248fb 100644
+readonly IMAGE_CACHE_DIR="${BATS_RUN_TMPDIR}/image-cache"
# Images
declare -Ag IMAGES=([busybox]="docker.io/library/busybox" \
@@ -271,3 +270,11 @@ function get_system_version() {
-declare -Ag IMAGES=([busybox]="docker.io/library/busybox" \
+declare -Ag IMAGES=([busybox]="quay.io/toolbox_tests/busybox" \
[fedora]="registry.fedoraproject.org/fedora-toolbox" \
[rhel]="registry.access.redhat.com/ubi8")
echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1)
@@ -245,6 +244,7 @@ function find_os_release() {
# Returns the content of field ID in os-release
function get_system_id() {
+ if [[ -z ${TOOLBOX_TEST_SYSTEM_ID} ]]; then
local os_release
os_release="$(find_os_release)"
@@ -255,19 +255,34 @@ function get_system_id() {
fi
echo $(awk -F= '/ID/ {print $2}' $os_release | head -n 1)
+ else
+ echo ${TOOLBOX_TEST_SYSTEM_ID}
+ fi
}
# Returns the content of field VERSION_ID in os-release
function get_system_version() {
- local os_release
+ if [[ -z ${TOOLBOX_TEST_VERSION_ID} ]]; then
+ local os_release
- os_release="$(find_os_release)"
+ os_release="$(find_os_release)"
- if [[ -z "$os_release" ]]; then
- echo ""
- return
+ if [[ -z "$os_release" ]]; then
+ echo ""
+ return
+ fi
+
+ echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1)
+ else
+ echo ${TOOLBOX_TEST_VERSION_ID}
fi
+}
- echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1)
+
+# Setup the XDG_RUNTIME_DIR variable if not set
+function check_xdg_runtime_dir() {
+ if [[ -z "${XDG_RUNTIME_DIR}" ]]; then
+ export XDG_RUNTIME_DIR="/run/user/${UID}"
+ fi
+}
\ No newline at end of file
}
--
2.31.1

View File

@ -9,7 +9,7 @@ Version: 0.0.99.3
%global goipath github.com/containers/%{name}
%gometa
Release: 0.9.git660b6970e998%{?dist}
Release: 0.10.git660b6970e998%{?dist}
Summary: Unprivileged development environment
License: ASL 2.0
@ -115,6 +115,10 @@ install -m0644 %{SOURCE1} %{buildroot}%{_sysconfdir}/containers/%{name}.conf
%changelog
* Tue Sep 14 2021 Oliver Gutiérrez <ogutierrez@redhat.com> - 0.0.99.3-0.10.git660b6970e998
- Added ability to force test system id and version id
Related: #2000051
* Tue Sep 14 2021 Oliver Gutiérrez <ogutierrez@redhat.com> - 0.0.99.3-0.9.git660b6970e998
- Fixed test roles and changed default image path
Related: #2000051