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

ffi: Adding sysctl test case. #448

Merged
merged 1 commit into from
Jun 2, 2024
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
6 changes: 6 additions & 0 deletions tests/ffi/sysctl/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
summary: Executing sysctl inside nested container running on top of QM
test: /bin/bash ./test.sh
duration: 20m
tag: ffi
framework: shell
id: f615d356-9bf9-4de2-a007-7a99eca2bc48
32 changes: 32 additions & 0 deletions tests/ffi/sysctl/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash -euvx

# shellcheck disable=SC1091

. ../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

# Download ffi-tools container and push ffi-tools image into QM registry
prepare_images

# Run the ffi-tools container in qm vm
run_container_in_qm ffi-qm

# Get numbers of sysctl permission denied
weiwang-linda marked this conversation as resolved.
Show resolved Hide resolved
sysctl_num=$(podman exec qm /bin/bash -c \
"podman exec ffi-qm ./setsysctl 2>&1" | grep -c "sysctl: permission denied on key")

# We execute 'X' sysctl call(s) inside a nested container running in a QM environment
# to determine if changes are allowed, which should be denied for:
# - Network subsystem
# - Virtual memory subsystem
SYSCTL_DENIED_COUNT=5
if [ $sysctl_num -eq "${SYSCTL_DENIED_COUNT}" ];then
info_message "Attempt to change OS level are denied successfully inside QM container."
exit 0
fi
Loading