Skip to content

Commit d8aff04

Browse files
committed
Qmctl tests
Closes: https://issues.redhat.com/browse/VROOM-28614 Signed-off-by: Artiom Divak <[email protected]>
1 parent b4b399c commit d8aff04

File tree

10 files changed

+234
-0
lines changed

10 files changed

+234
-0
lines changed

plans/e2e/qmctl-test.fmf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
summary: Test plan for QMCTL using TMT
2+
3+
discover:
4+
how: fmf
5+
filter: 'tag:qmctl-test'
6+
7+
prepare+:
8+
- name: Set qmctl environment
9+
how: shell
10+
script: |
11+
cd tests/qmctl-test
12+
./test_qmctl.sh
13+
14+
execute:
15+
how: tmt
16+
17+
report:
18+
how: junit
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
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[Install]
2+
WantedBy=default.target
3+
4+
[Service]
5+
# It's recommended to use systemd drop-in to override the
6+
# systemd settings. See QM manpage for an example.
7+
# CPUWeight: This setting controls the CPU controller for qm.
8+
# Delegate: Turns on delegation of further resource control
9+
# partitioning to processes of the unit.
10+
# IOWeight: Set the overall block I/O weight for qm.
11+
# ManagedOOMSwap=auto|kill: Specifies how systemd-oomd.service will act on qm.
12+
# QM cgroup, pass directly to systemd and handled by it,
13+
# please refer to `man systemd.resource-control` for details.
14+
CPUWeight=idle
15+
Delegate=true
16+
IOWeight=50
17+
ManagedOOMSwap=kill
18+
19+
# MemoryMax
20+
# -----------
21+
# Default is infinity - sets no upper bound on memory usage, allowing the
22+
# service to consume as much memory as the system allows, just like
23+
# MemoryMax=0 or omitting it.
24+
MemoryMax=infinity
25+
26+
# MemoryHigh
27+
# -----------
28+
# Default is infinity - Disables the soft memory limit, meaning no throttling
29+
# will occur due to high memory usage, similar to MemoryHigh=0 or
30+
# omitting it.
31+
MemoryHigh=infinity
32+
MemorySwapMax=0
33+
34+
# Containers within the qm contain default set OOMScoreAdj to 750
35+
OOMScoreAdjust=500
36+
Restart=always
37+
# qm.service is a toplevel cgroup, so CPUWeight is relative to all other cgroups in that
38+
# parent (such as user.slice and system.slice), otherwise the CPUWeight of qm.service
39+
# is only compared to the other children of its parent.
40+
Slice=-.slice
41+
Environment=ROOTFS=/usr/lib/qm/rootfs
42+
Environment=RWETCFS=/etc/qm
43+
Environment=RWVARFS=/var/qm
44+
LimitNOFILE=65536
45+
TasksMax=50%
46+
47+
[Container]
48+
# AddCapability
49+
# -------------
50+
# Add these capabilities, in addition to the default Podman capability set, to the container.
51+
# If set to all, grants all capabilities to the container, increasing flexibility but significantly
52+
# reducing security.
53+
# For details see: https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html#addcapability
54+
AddCapability=all
55+
56+
SecurityLabelNested=true
57+
SeccompProfile=/usr/share/qm/seccomp-no-rt.json
58+
59+
# PidsLimit
60+
# ---------
61+
# Disables the PID limit for the container by setting it to -1.
62+
# Without a limit, the container can spawn unlimited processes, potentially exhausting system resources.
63+
# For details see: https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html#pidslimit
64+
PidsLimit=-1
65+
66+
# Comment DropCapability this will allow FFI Tools to surpass their defaults.
67+
DropCapability=sys_resource
68+
69+
AddDevice=-/dev/kvm
70+
AddDevice=-/dev/fuse
71+
ContainerName=qm
72+
Exec=/sbin/init
73+
Network=private
74+
75+
# ReadOnly
76+
# --------
77+
# Makes the container's filesystem read-only, enhancing security by preventing modifications.
78+
ReadOnly=true
79+
80+
# TmpFS flags
81+
ReadOnlyTmpfs=false
82+
Mount=type=tmpfs,tmpfs-size=512M,destination=/tmp
83+
Mount=type=tmpfs,tmpfs-size=512M,destination=/run
84+
Mount=type=tmpfs,destination=/dev/shm
85+
86+
# Rootfs
87+
# ------
88+
# Defines the root filesystem location for QM partition.
89+
# By default the '${ROOTFS}' variable points to /usr/lib/qm/rootfs.
90+
# For details see: https://docs.podman.io/en/latest/markdown/podman-systemd.unit.5.html#rootfs
91+
#
92+
Rootfs=${ROOTFS}
93+
94+
SecurityLabelNested=true
95+
SecurityLabelFileType=qm_file_t
96+
SecurityLabelLevel=s0
97+
SecurityLabelType=qm_t
98+
# WIP - Github Issue#367
99+
# See https://github.com/containers/qm/issues/367 for more info.
100+
# Timezone=local
101+
Environment=TZ
102+
Volume=${RWETCFS}:/etc
103+
Volume=${RWVARFS}:/var
104+

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: 20m
4+
tag: qmctl-test
5+
order: 70
6+
framework: shell
7+
id: 9b3f962e-758a-473b-b8ea-540a177b9134

tests/qmctl-test/scripts/qmctl_cp.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
4+
5+
python3 $QMCTL_SCRIPT cp ./files/file-to-copy.txt qm:/tmp
6+
7+
expected_output_file="./files/file-to-check-cp.txt"
8+
actual_output_temp_file=$(mktemp)
9+
10+
python3 $QMCTL_SCRIPT exec cat /tmp/file-to-copy.txt > "$actual_output_temp_file"
11+
12+
if diff "$actual_output_temp_file" "$expected_output_file" > /dev/null; then
13+
echo "The output matches the content of '$expected_output_file'."
14+
exit 0
15+
else
16+
echo "The output does NOT match the content of '$expected_output_file'."
17+
diff "$actual_output_temp_file" "$expected_output_file"
18+
exit 1
19+
fi
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
4+
5+
if python3 $QMCTL_SCRIPT exec podman ps -a | grep -q "alpine-podman"; then
6+
echo "podman named alpine-container already exists"
7+
exit 1
8+
fi
9+
10+
python3 $QMCTL_SCRIPT exec podman run -d --name alpine-podman alpine tail -f /dev/null
11+
12+
if ! python3 $QMCTL_SCRIPT exec podman ps -a | grep -q "alpine-podman"; then
13+
echo "podman container was not created"
14+
exit 1
15+
fi
16+
17+
exit 0
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
4+
5+
tmp_file="/tmp/file-execin.txt"
6+
if python3 $QMCTL_SCRIPT execin alpine-podman ls -la /tmp/ | grep -q $tmp_file; then
7+
echo "The file /tmp/file-execin.txt already exists"
8+
exit 1
9+
fi
10+
11+
python3 $QMCTL_SCRIPT execin alpine-podman touch /tmp/file-execin.txt
12+
13+
if ! python3 $QMCTL_SCRIPT execin alpine-podman cat /tmp/file-execin.txt; then
14+
echo "The file /tmp/file-execin.txt was not created"
15+
exit 1
16+
fi
17+
exit 0
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
4+
5+
expected_output_file="./files/qmctl_show_expected.txt"
6+
actual_output_temp_file=$(mktemp)
7+
8+
python3 $QMCTL_SCRIPT show > "$actual_output_temp_file"
9+
10+
if diff "$actual_output_temp_file" "$expected_output_file" > /dev/null; then
11+
echo "The output matches the content of '$expected_output_file'."
12+
exit 0
13+
else
14+
echo "The output does NOT match the content of '$expected_output_file'."
15+
diff "$actual_output_temp_file" "$expected_output_file"
16+
exit 1
17+
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+
echo "Running qmctl command..."
4+
5+
QMCTL_SCRIPT="../../tools/qmctl/qmctl"
6+
7+
if [ ! -f "$QMCTL_SCRIPT" ]; then
8+
echo "Error: qmctl script not found at $QMCTL_SCRIPT"
9+
exit 1
10+
fi
11+
12+
sudo dnf install qm -y
13+
sudo ../../setup
14+
15+
if ! ./scripts/qmctl_show.sh ; then
16+
echo "qmctl show failed."
17+
exit 1
18+
fi
19+
20+
if ! ./scripts/qmctl_exec.sh; then
21+
echo "qmctl exec failed."
22+
exit 1
23+
fi
24+
25+
if ! ./scripts/qmctl_execin.sh; then
26+
echo "qmctl execin failed."
27+
exit 1
28+
fi
29+
30+
if ! ./scripts/qmctl_cp.sh; then
31+
echo "qmctl cp failed."
32+
exit 1
33+
fi

0 commit comments

Comments
 (0)