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

Nested QM test to new fork #505

Merged
merged 1 commit into from
Aug 22, 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
9 changes: 9 additions & 0 deletions tests/ffi/qm_nested/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Title: Validate that nested containers work via QM.

Description: The purpose of this test script is to make sure that QM executing well the nested container via podman.

Input:

Expected result: PASS: Podman can successfully run a containter from within the QM (nested QM).

Jira: VROOM-19453
6 changes: 6 additions & 0 deletions tests/ffi/qm_nested/main.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
summary: Check that QM executing well the nested container via podman.
test: /bin/bash ./test.sh
duration: 20m
tag: ffi
framework: shell
id: 48f41863-b785-46f5-8ec6-6f9176af84de
62 changes: 62 additions & 0 deletions tests/ffi/qm_nested/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash -euvx

# shellcheck disable=SC1091
. ../common/prepare.sh

# init_ffi() uses functions from common.sh to init the env before tests.
init_ffi() {
disk_cleanup
prepare_test
reload_config
}

# Declare global variables and initialize to 0
NESTED_NAME=""
NESTED_STATUS=""

# Create nested container ffi-qm inside the QM.
# Function to create and start nested container ffi-qm, while executing podman commands from inside the QM container.
# Extract nested container's valuable information and store it inside the global variables for later use.
# Globals:
# NESTED_NAME: The nested container name in the QM container.
# NESTED_STATUS: The nested container status in the QM container.
create_nested() {
dougsland marked this conversation as resolved.
Show resolved Hide resolved
prepare_images
local nested_container_name="ffi-qm"
run_container_in_qm "${nested_container_name}"
NESTED_NAME=$(podman exec -it qm bash -c "podman inspect ${nested_container_name} --format '{{.Name}}'")
if_error_exit "An error occured: failed to extract Name parameter of container from inside of QM."
echo "Container name is: ${NESTED_NAME}"
NESTED_STATUS=$(podman exec -it qm bash -c "podman inspect --format='{{.State.Status}}' ${nested_container_name}")
if_error_exit "An error occured: failed to extract State parameter of container from inside of QM."
echo "Container $NESTED_NAME status is: ${NESTED_STATUS}"
}

# Function to check and verify that nested container fedora was created and is running inside the QM container.
# Globals:
# NESTED_NAME: The nested container name in the QM container.
# NESTED_STATUS: The nested container status in the QM container.
compare_values() {
local expected_nested_name="ffi-qm"
local expected_nested_status="running"

if [ "${NESTED_NAME}" == "" ] || [ "${NESTED_STATUS}" == "" ]; then
echo "FAIL: Failed to run the container inside QM."
exit 1
elif [[ "${NESTED_NAME}" != *"${expected_nested_name}"* ]]; then
echo "FAIL: The ${expected_nested_name} container had not been created inside QM."
exit 1
elif [[ "${NESTED_STATUS}" != *"${expected_nested_status}"* ]]; then
echo "FAIL: The container status is not ${expected_nested_status} inside QM."
dougsland marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi

echo "PASS: The container ${NESTED_NAME} is ${NESTED_STATUS} inside QM."
}

# Execute the functions
nsednev marked this conversation as resolved.
Show resolved Hide resolved
init_ffi
create_nested
compare_values

exit 0