Skip to content

Commit

Permalink
Merge pull request containers#460 from Yarboa/packit-fix
Browse files Browse the repository at this point in the history
test stability changes
  • Loading branch information
Yarboa committed Jul 17, 2024
2 parents 7856625 + e1df9b4 commit 6d83f9f
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 56 deletions.
1 change: 1 addition & 0 deletions tests/e2e/lib/container
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ file: ${container_file} tag: ${container_tag}"
# Execute the container
eval "$(podman run -d \
--privileged \
--tz local \
--network podmanDualStack \
--name "${container_name}" \
--hostname "${container_name}" \
Expand Down
44 changes: 21 additions & 23 deletions tests/ffi/common/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,31 @@
# shellcheck disable=SC1091
. ../../e2e/lib/utils

DROP_IN_DIR="/etc/containers/systemd/qm.container.d/"
export QM_HOST_REGISTRY_DIR="/var/qm/lib/containers/registry"
export QM_REGISTRY_DIR="/var/lib/containers/registry"

prepare_test() {
qm_service_file=$(systemctl show -P SourcePath qm)
#create backup file for qm unit file
qm_service_backup=$(mktemp -d -p /tmp)/qm.service
if_error_exit "cannot create temp dir under /tmp/"
exec_cmd "cp ${qm_service_file} ${qm_service_backup}"
# Remove 'DropCapability=sys_resource' enable nested container in QM
exec_cmd "sed -i 's|DropCapability=sys_resource|#DropCapability=sys_resource|' \
${qm_service_file}"
exec_cmd "restorecon -RFv /var/lib/containers"
# Create qm container custom config folder
exec_cmd "mkdir -p /etc/containers/systemd/qm.container.d"
# FIXME: This action should be performed if necessary through systemd drop-in files.
#
# # Changing QM score to 1000 to avoid full memory error on SoC
# if [[ -n "${PACKIT_COPR_PROJECT}" && "${PACKIT_COPR_PROJECT}" == "release" ]]; then
# exec_cmd "sed -i 's|OOMScoreAdjust.*|OOMScoreAdjust=1000|' ${qm_service_file}"
# fi
# Search variables for update file in qm.container
# qm_service_file=$(systemctl show -P SourcePath qm)
# Create qm container custom config folder for qm drop-in file.
# Use drop-in files to update qm_service_file
# please refer 'zcat $(man -w qm.8) | grep -i "^\.sh" | grep drop-in'
exec_cmd "mkdir -p ${DROP_IN_DIR}"
}

disk_cleanup() {
exec_cmd "systemctl stop qm"
exec_cmd "podman exec -it qm /bin/bash -c \"podman rmi -f --all\""
# Clean large size files created by tests inside qm part
remove_file=$(find /var/qm -size +2G)
exec_cmd "rm -f $remove_file"
remove_qm_custom_conf_files=$(find /etc/containers/systemd/qm.container.d -type f)
exec_cmd "rm -f $remove_qm_custom_conf_files"
exec_cmd "systemctl start qm"
exec_cmd "rm -rf $remove_file"
# Clean drop-in files used for tests
if test -d "${DROP_IN_DIR=}"; then
exec_cmd "rm -rf ${DROP_IN_DIR}"
fi
exec_cmd "systemctl daemon-reload"
exec_cmd "systemctl restart qm"
# Clean large size files created by tests inside host part
remove_file=$(find /root -size +1G)
exec_cmd "rm -f $remove_file"
}
Expand All @@ -46,7 +44,7 @@ prepare_images() {
exec_cmd "mkdir -p ${QM_HOST_REGISTRY_DIR}"
exec_cmd "podman push ${image_id} dir:${QM_HOST_REGISTRY_DIR}/tools-ffi:latest"
# Remove image to save /var space
exec_cmd "podman image rm -f ${image_id}"
exec_cmd "podman rmi -f ${image_id}"
fi
}

Expand Down
2 changes: 0 additions & 2 deletions tests/ffi/deny_sched_setattr/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# shellcheck source=tests/ffi/common/prepare.sh
. ../common/prepare.sh

export QM_HOST_REGISTRY_DIR="/var/qm/lib/containers/registry"
export QM_REGISTRY_DIR="/var/lib/containers/registry"
expected_result="sched_setattr failed: Operation not permitted"

disk_cleanup
Expand Down
4 changes: 1 addition & 3 deletions tests/ffi/deny_set_scheduler/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# shellcheck source=tests/ffi/common/prepare.sh
. ../common/prepare.sh

export QM_HOST_REGISTRY_DIR="/var/qm/lib/containers/registry"
export QM_REGISTRY_DIR="/var/lib/containers/registry"
expected_result="Failed to set scheduler: Operation not permitted"

disk_cleanup
Expand All @@ -22,4 +20,4 @@ if [[ "${return_from_setscheduler}" =~ ${expected_result} ]]; then
else
info_message "set_scheduler() syscall can be executed in QM."
exit 1
fi
fi
4 changes: 3 additions & 1 deletion tests/ffi/disk/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
disk_cleanup
prepare_test

cat << EOF > /etc/containers/systemd/qm.container.d/oom.conf
cat << EOF > "${DROP_IN_DIR}"/oom.conf
[Service]
OOMScoreAdjust=
OOMScoreAdjust=1000
EOF

reload_config
prepare_images

exec_cmd "podman exec -it qm /bin/bash -c \
'podman run -d --replace --name ffi-qm \
Expand Down
2 changes: 1 addition & 1 deletion tests/ffi/memory/main.fmf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
summary: Test is calling systemd as stand alone test
test: /bin/bash ./test.sh
duration: 10m
duration: 15m
tag: ffi
framework: shell
id: fff26f33-a051-4d9e-aae2-97935e425273
17 changes: 8 additions & 9 deletions tests/ffi/memory/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@

. ../common/prepare.sh

export QM_HOST_REGISTRY_DIR="/var/qm/lib/containers/registry"
export QM_REGISTRY_DIR="/var/lib/containers/registry"

disk_cleanup
prepare_test

cat << EOF > "${DROP_IN_DIR}"/oom.conf
[Service]
OOMScoreAdjust=
OOMScoreAdjust=1000
EOF

reload_config
prepare_images

exec_cmd "podman run -d --rm --replace -d --name ffi-asil \
quay.io/centos-sig-automotive/ffi-tools:latest \
./ASIL/20_percent_memory_eat > /dev/null"
# Copy container image registry to /var/qm/lib/containers
image_id=$(podman images | grep quay.io/centos-sig-automotive/ffi-tools | awk -F " " '{print $3}')
if [ ! -d "${QM_HOST_REGISTRY_DIR}" ]; then
exec_cmd "mkdir -p ${QM_HOST_REGISTRY_DIR}"
exec_cmd "podman push ${image_id} dir:${QM_HOST_REGISTRY_DIR}/tools-ffi:latest"
fi

podman exec -it qm /bin/bash -c \
"podman run --replace --name ffi-qm dir:${QM_REGISTRY_DIR}/tools-ffi:latest \
Expand Down
3 changes: 0 additions & 3 deletions tests/ffi/modules/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

. ../common/prepare.sh

export QM_HOST_REGISTRY_DIR="/var/qm/lib/containers/registry"
export QM_REGISTRY_DIR="/var/lib/containers/registry"

disk_cleanup
prepare_test
reload_config
Expand Down
12 changes: 1 addition & 11 deletions tests/ffi/qm-oom-score-adj/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@

. ../common/prepare.sh

export QM_HOST_REGISTRY_DIR="/var/qm/lib/containers/registry"
export QM_REGISTRY_DIR="/var/lib/containers/registry"

disk_cleanup
prepare_test
prepare_images
reload_config

# Copy container image registry to /var/qm/lib/containers
image_id=$(podman images | grep quay.io/centos-sig-automotive/ffi-tools | awk -F " " '{print $3}')
if [ ! -d "${QM_HOST_REGISTRY_DIR}" ]; then
exec_cmd "mkdir -p ${QM_HOST_REGISTRY_DIR}"
exec_cmd "podman push ${image_id} dir:${QM_HOST_REGISTRY_DIR}/tools-ffi:latest"
fi

podman exec -it qm /bin/bash -c \
"podman run -d --replace --name ffi-qm dir:${QM_REGISTRY_DIR}/tools-ffi:latest \
/usr/bin/sleep infinity > /dev/null"
Expand Down
3 changes: 0 additions & 3 deletions tests/ffi/sysctl/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

. ../common/prepare.sh

export QM_HOST_REGISTRY_DIR="/var/qm/lib/containers/registry"
export QM_REGISTRY_DIR="/var/lib/containers/registry"

disk_cleanup
prepare_test
reload_config
Expand Down

0 comments on commit 6d83f9f

Please sign in to comment.