Skip to content

Commit

Permalink
Fix current run-test-e2e
Browse files Browse the repository at this point in the history
Currently tests are not using packit repo created by previous steps
Added an option for scripts --use-qm-copr to be used while running tests with
rhcontainerbot/qm, default is using packit rpms, triggered by scenario=manual parsed in context
scenario == manual

Signed-off-by: Yariv Rachmani <[email protected]>
  • Loading branch information
Yarboa committed Dec 19, 2023
1 parent 3019b2e commit 4eb618c
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 31 deletions.
2 changes: 0 additions & 2 deletions .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
trigger: pull_request
identifier: e2e-tiers
tmt_plan: /plans/e2e/tier-0
skip_build: true
targets:
- centos-stream-9-x86_64
tf_extra_params:
Expand All @@ -78,7 +77,6 @@ jobs:
trigger: pull_request
identifier: e2e-ffi
tmt_plan: /plans/e2e/ffi
skip_build: true
targets:
- centos-stream-9-x86_64
tf_extra_params:
Expand Down
2 changes: 1 addition & 1 deletion plans/e2e/ffi.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ adjust:
# qm-setup-from-gh-url, branch-qm option
script: |
cd tests/e2e
./set-ffi-env-e2e --branch-qm=main --qm-setup-from-gh-url=https://raw.githubusercontent.com/containers --set-qm-disk-part=yes
./set-ffi-env-e2e --set --set-qm-disk-part=yes
when: scenario == ffi and distro == centos-stream-9, fedora

execute:
Expand Down
43 changes: 25 additions & 18 deletions plans/e2e/tier-0.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,32 @@ provision:
how: local

adjust:
- when: scenario == manual
prepare+:
- name: Prepare Repos
how: shell
script: |
dnf install -y dnf-plugin-config-manager epel-release
dnf config-manager -y --set-enabled crb
dnf -y copr enable rhcontainerbot/qm centos-stream-9

- name: install repos
how: install
package:
- podman

- name: Set QM env
how: shell
script: |
cd tests/e2e
./run-test-e2e --skip-tests=yes
when: distro == centos-stream-9 or distro == fedora
- name: Prepare Repos
how: shell
order: 10
script: |
dnf copr enable -y rhcontainerbot/qm

- when: distro == centos-stream-9 or distro == fedora
prepare+:
- name: Prepare Repos
how: shell
script: |
dnf install -y dnf-plugin-config-manager epel-release
dnf config-manager -y --set-enabled crb

- name: install repos
how: install
package:
- podman

- name: Set QM env
how: shell
script: |
cd tests/e2e
./run-test-e2e --skip-tests=yes

execute:
how: tmt
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/lib/ContainerFile.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN dnf install -y \
epel-release

RUN dnf config-manager -y --set-enabled crb
RUN dnf -y copr enable rhcontainerbot/qm centos-stream-9
RUN dnf -y copr enable centos-stream-9
RUN dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo

RUN dnf install -y \
Expand Down
16 changes: 11 additions & 5 deletions tests/e2e/lib/container
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ imageID: ${IMAGE_ID}"

setup_node() {
local nodeID="${1}"

local use_qm_copr="${2}"
# copy control as template to node${number}
cp ./lib/ContainerFile.template ContainerFile.node"${nodeID}"
if_error_exit "failed to copy ContainerFile control template to node!"

if [ -n ${use_qm-copr} ]; then
sed 's/copr enable centos-stream-9/& rhcontainerbot\/qm /' -i ContainerFile.node"${nodeID}"
fi
# remove specific code from control mode (template)
sed -i '/start/,/end/d' ContainerFile.node"${nodeID}"
sed '/start/,/end/d' -i ContainerFile.node"${nodeID}"
if_error_exit "failed to sed ContainerFile node template!"
}

Expand All @@ -97,11 +99,15 @@ create_qm_node() {

setup_node \
"${nodeID}" \
"${IP_CONTROL_MACHINE}"

"${USE_QM_COPR}"
# Add final instructions
echo "RUN dnf install qm -y &> /dev/null" >> ContainerFile.node"${nodeID}"

if [ -n "${QM_GH_URL}" ]; then
curl "${QM_GH_URL}" > /usr/share/qm/setup
chmod +x /usr/share/qm/setup
fi

# Execute qm setup
# Use --skip-systemctl true in podman build, systemd is not running
# Do not set --skip-systemctl inside running container with systemd in it.
Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/lib/systemd
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ ${container_target}:/tmp/container-${srv}.container"
eval "${cmd_cp_systemd_srv}"
if_error_exit "cannot copy container-${srv} to qm container"

# Find configuration file from service
target_service_file=$(podman exec ${container_target} systemctl show -P SourcePath qm.service)
# START: remove DropCapability to run nested container
podman exec -it ${container_target} sed -i '/^\s*DropCapability=sys_resource/ d' /etc/containers/systemd/qm.container
podman exec -it ${container_target} bash -c "sed -i '/^\s*DropCapability=sys_resource/ d' \"${target_service_file}\""
if_error_exit "unable to remove DropCapability=sys_resource in qm.container"

podman exec -it ${container_target} systemctl daemon-reload
Expand Down
12 changes: 11 additions & 1 deletion tests/e2e/run-test-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export BUILD_QM_FROM_GH_URL=""
export BUILD_BLUECHI_FROM_GH_URL=""
export BRANCH_BLUECHI=""
export BRANCH_QM=""
export USE_QM_COPR=""

# If no additional nodes are required, use 1
if [ -z "${NUMBER_OF_NODES}" ]; then
Expand All @@ -62,6 +63,7 @@ fi
ARGUMENT_LIST=(
"build-qm-from-gh-url"
"branch-qm"
"use-qm-copr"
"build-bluechi-from-gh-url"
"branch-bluechi"
"skip-tests"
Expand All @@ -79,7 +81,8 @@ Usage: ./run-test-e2e [OPTIONS]
Build QM from a specific GitHub URL, useful for testing new features
--branch-qm
Specify which branch the GitHub repo will be set. Requires --build-qm-from-gh-url
--use-qm-copr
Specify to install rpms from rhcontainerbot/qm copr
--number-of-nodes
Specify number of nodes. (default 1)
Expand All @@ -101,6 +104,7 @@ Examples:
--build-qm-from-gh-url=https://github.com/MYUSER/qm.git \\
--branch-bluechi=superfeature \\
--build-bluechi-from-gh-url=https://github.com/MYUSER/bluechi.git \\
--use-qm-copr=Y \\
EOF
exit 0
Expand Down Expand Up @@ -158,6 +162,12 @@ while [ $# -gt 0 ]; do
shift 2
;;

--use-qm-copr)
USE_QM_COPR="${2}"
shift 2
;;


--help)
usage
;;
Expand Down
19 changes: 17 additions & 2 deletions tests/e2e/set-ffi-env-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export BUILD_BLUECHI_FROM_GH_URL=""
export QM_GH_URL=""
export BRANCH_QM=""
export SET_QM_PART=""
export USE_QM_COPR=""

RED='\033[91m'
GRN='\033[92m'
Expand All @@ -56,6 +57,7 @@ ARGUMENT_LIST=(
"qm-setup-from-gh-url"
"branch-qm"
"set-qm-disk-part"
"use-qm-copr"
)

usage() {
Expand All @@ -74,16 +76,20 @@ Usage: ./set-ffi-env-e2e [OPTIONS]
--set-qm-disk-part
Specify if disk partition neede for /var/qm needed
--use-qm-copr
Specify to install rpms from rhcontainerbot/qm copr
Examples:
No args, it will install latest qm and bluechi from copr rpm repository
./set-ffi-env-e2e
Usee qm setup specific github url and select the branches
Use qm setup specific github url and select the branches
./set-ffi-env-e2e \\
--branch-qm=superfeature \\
--qm-setup-from-gh-url=https://raw.githubusercontent.com/MYUSER/ \\
--set-qm-disk-part=Y \\
--use-qm-copr=Y \\
EOF
exit 0
Expand Down Expand Up @@ -119,6 +125,11 @@ while [ $# -gt 0 ]; do
shift 2
;;

--use-qm-copr)
USE_QM_COPR="${2}"
shift 2
;;

--help)
usage
;;
Expand Down Expand Up @@ -159,7 +170,11 @@ install_qm_rpms() {
dnf install -y 'dnf-command(config-manager)'
dnf config-manager --set-enabled crb
dnf copr enable -y @centos-automotive-sig/bluechi-snapshot centos-stream-9-"${ARCH}"
dnf copr enable -y rhcontainerbot/qm centos-stream-9-"${ARCH}"
if [ -n "${USE_QM_COPR}" ]; then
dnf copr enable -y rhcontainerbot/qm
fi
dnf copr enable -y centos-stream-9-"${ARCH}"

dnf install -y qm bluechi-ctl bluechi podman hostname
}

Expand Down

0 comments on commit 4eb618c

Please sign in to comment.