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 current run-test-e2e #291

Merged
merged 3 commits into from
Dec 22, 2023
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: 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
8 changes: 6 additions & 2 deletions plans/e2e/ffi.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ provision:
how: local

adjust:
- when: run == manual
environment+:
# Sample code to use manual packit repo
PACKIT_COPR_PROJECT: packit/containers-qm-291
- when: scenario == ffi and distro == centos-stream-9, fedora
prepare+:
- name: Install rpms
how: install
Expand All @@ -22,8 +27,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
when: scenario == ffi and distro == centos-stream-9, fedora
./set-ffi-env-e2e --set-qm-disk-part=yes

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

adjust:
- when: run == manual
environment+:
# Sample code to use manual packit repo
PACKIT_COPR_PROJECT: packit/containers-qm-291

- 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
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
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
18 changes: 11 additions & 7 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ INSTALLDIR="/usr/share/qm"
ROOTFS="/usr/lib/qm/rootfs"
RWETCFS="/etc/qm"
RWVARFS="/var/qm"
TMP_QM_IMG_DIR="tmp-img-dir"
TMP_QM_IMG_DIR="tmp.images"
AGENT_HOSTNAME="$(hostname)"
AGENTCONF="/etc/bluechi/agent.conf.d/agent.conf"
QM_CONTAINER_IDS=1000000000:1500000000
Expand Down Expand Up @@ -98,12 +98,16 @@ storage() {
touch "${ROOTFS}/var/lib/shared/overlay-images/images.lock" \
"${ROOTFS}/var/lib/shared/overlay-layers/layers.lock"

sed -e '/additionalimage.*/a "/var/lib/shared",' \
-e 's|^#.*transient_store.*|transient_store=true|g' \
"${ROOTFS}/usr/share/containers/storage.conf" \
> "${ROOTFS}/etc/containers/storage.conf"
sed -i "s|^#env = \[\]|env = \[\"TMPDIR=/var/${TMP_QM_IMG_DIR}\"\]|" \
"${ROOTFS}/usr/share/containers/containers.conf"
sed -e '/additionalimage.*/,/]/s/^#//g' \
-e '/additionalimages.*/{n;s/.*/\"\/var\/lib\/shared\",/;}' \
-e 's|^#.*transient_store.*|transient_store=true|g' \
/"${ROOTFS}/usr/share/containers/storage.conf" \
> "${ROOTFS}/etc/containers/storage.conf"

if ! grep -q "env" "${ROOTFS}/etc/containers/containers.conf"; then
echo "env = [\"TMPDIR=/var/${TMP_QM_IMG_DIR}\"]" \
>> "${ROOTFS}/etc/containers/containers.conf"
fi
fi
}

Expand Down
1 change: 0 additions & 1 deletion tests/e2e/lib/ContainerFile.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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 config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo

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

setup_node() {
local nodeID="${1}"
local use_copr_repo="${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_copr_repo}" ]; then
sed -e "/crb/a RUN dnf -y copr enable ${use_copr_repo} centos-stream-9" -i ContainerFile.node"${nodeID}"
if_error_exit "failed to sed ContainerFile node template!"
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 +101,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
13 changes: 12 additions & 1 deletion tests/e2e/run-test-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# along with this program; If not, see <http://www.gnu.org/licenses/>.
#
# Capture the start time

START_TIME=$(date +%s)
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )

Expand All @@ -38,6 +39,7 @@ export BUILD_QM_FROM_GH_URL=""
export BUILD_BLUECHI_FROM_GH_URL=""
export BRANCH_BLUECHI=""
export BRANCH_QM=""
export USE_QM_COPR="${PACKIT_COPR_PROJECT:-rhcontainerbot/qm}"

# If no additional nodes are required, use 1
if [ -z "${NUMBER_OF_NODES}" ]; then
Expand All @@ -62,6 +64,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 +82,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 +105,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 +163,12 @@ while [ $# -gt 0 ]; do
shift 2
;;

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


--help)
usage
;;
Expand Down
17 changes: 15 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="${PACKIT_COPR_PROJECT:-rhcontainerbot/qm}"

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,9 @@ 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 "${USE_QM_COPR}" centos-stream-9-"${ARCH}"
fi
dnf install -y qm bluechi-ctl bluechi podman hostname
}

Expand Down