Skip to content

Commit daec692

Browse files
authored
Qmctl tests (#831)
Closes: https://issues.redhat.com/browse/VROOM-28614 Signed-off-by: Artiom Divak <[email protected]>
1 parent 647e56c commit daec692

File tree

9 files changed

+128
-1
lines changed

9 files changed

+128
-1
lines changed

plans/e2e/kvm-tier-0.fmf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ summary: Kvm Tier 0 - QM sanity test
22

33
discover:
44
how: fmf
5-
filter: 'tier:0&tag:kvm'
5+
filter: 'tier:0&tag:kvm|tier:0&tag:qmctl-test'
66

77
prepare+:
88
- name: Enable copr and install rpms
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
output: This is the file to copy
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is the file to copy

tests/qmctl-test/main.fmf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
summary: Test plan for QMCTL using TMT
2+
test: ./test_qmctl.sh
3+
duration: 10m
4+
tag: qmctl-test
5+
tier: 0
6+
framework: shell
7+
id: 9b3f962e-758a-473b-b8ea-540a177b9134

tests/qmctl-test/scripts/qmctl_cp.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. ../e2e/lib/utils
5+
6+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
7+
8+
python3 $QMCTL_SCRIPT cp ./files/file-to-copy.txt qm:/tmp
9+
10+
expected_output_file="./files/file-to-check-cp.txt"
11+
actual_output_temp_file=$(mktemp)
12+
13+
python3 $QMCTL_SCRIPT exec cat /tmp/file-to-copy.txt > "$actual_output_temp_file"
14+
15+
if diff "$actual_output_temp_file" "$expected_output_file" > /dev/null; then
16+
info_message "The output matches the content of '$expected_output_file'."
17+
info_message "PASS: qmctl cp command executed successfully"
18+
exit 0
19+
else
20+
echo "FAIL: The output does NOT match the content of '$expected_output_file'."
21+
exit 1
22+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. ../e2e/lib/utils
5+
6+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
7+
8+
if python3 $QMCTL_SCRIPT exec podman ps -a | grep -q "alpine-podman"; then
9+
echo "FAIL: podman named alpine-container already exists"
10+
exit 1
11+
fi
12+
13+
python3 $QMCTL_SCRIPT exec podman run -d --name alpine-podman alpine tail -f /dev/null
14+
15+
if ! python3 $QMCTL_SCRIPT exec podman ps -a | grep -q "alpine-podman"; then
16+
echo "FAIL: podman container was not created"
17+
exit 1
18+
fi
19+
20+
info_message "PASS: qmctl exec command executed successfully"
21+
exit 0
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. ../e2e/lib/utils
5+
6+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
7+
8+
tmp_file="/tmp/file-execin.txt"
9+
if python3 $QMCTL_SCRIPT execin alpine-podman ls -la /tmp/ | grep -q $tmp_file; then
10+
echo "FAIL: The file /tmp/file-execin.txt already exists"
11+
exit 1
12+
fi
13+
14+
python3 $QMCTL_SCRIPT execin alpine-podman touch /tmp/file-execin.txt
15+
16+
if ! python3 $QMCTL_SCRIPT execin alpine-podman cat /tmp/file-execin.txt; then
17+
echo "FAIL: The file /tmp/file-execin.txt was not created"
18+
exit 1
19+
fi
20+
21+
info_message "PASS: qmctl execin command executed successfully"
22+
exit 0
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. ../e2e/lib/utils
5+
6+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
7+
8+
expected_output_file="/usr/share/containers/systemd/qm.container"
9+
actual_output_temp_file=$(mktemp)
10+
11+
python3 $QMCTL_SCRIPT show > "$actual_output_temp_file"
12+
13+
if diff "$actual_output_temp_file" "$expected_output_file" > /dev/null; then
14+
info_message "The output matches the content of '$expected_output_file'."
15+
info_message "PASS: qmctl show command executed successfully"
16+
exit 0
17+
else
18+
echo "FAIL: The output does NOT match the content of '$expected_output_file'."
19+
exit 1
20+
fi

tests/qmctl-test/test_qmctl.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# shellcheck disable=SC1091
4+
. ../e2e/lib/utils
5+
6+
info_message "Running qmctl command..."
7+
8+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
9+
10+
if [ ! -f "$QMCTL_SCRIPT" ]; then
11+
echo "FAIL: qmctl script not found at $QMCTL_SCRIPT"
12+
exit 1
13+
fi
14+
15+
if ! ./scripts/qmctl_show.sh ; then
16+
echo "FAIL: qmctl show failed."
17+
exit 1
18+
fi
19+
20+
if ! ./scripts/qmctl_exec.sh; then
21+
echo "FAIL: qmctl exec failed."
22+
exit 1
23+
fi
24+
25+
if ! ./scripts/qmctl_execin.sh; then
26+
echo "FAIL: qmctl execin failed."
27+
exit 1
28+
fi
29+
30+
if ! ./scripts/qmctl_cp.sh; then
31+
echo "FAIL: qmctl cp failed."
32+
exit 1
33+
fi

0 commit comments

Comments
 (0)