Skip to content

Commit b338acc

Browse files
authored
Merge pull request #3826 from kolyshkin/ps-rootless
tests/int/ps: enable for rootless
2 parents c99e6c6 + f92057a commit b338acc

File tree

2 files changed

+21
-47
lines changed

2 files changed

+21
-47
lines changed

tests/integration/helpers.bash

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,12 @@ function set_parent_systemd_properties() {
184184
}
185185

186186
# Randomize cgroup path(s), and update cgroupsPath in config.json.
187-
# This function sets a few cgroup-related variables.
187+
# This function also sets a few cgroup-related variables that are used
188+
# by other cgroup-related functions.
189+
#
190+
# If this function is not called (and cgroupsPath is not set in config),
191+
# runc uses default container's cgroup path derived from the container's name
192+
# (except for rootless containers, that have no default cgroup path).
188193
#
189194
# Optional parameter $1 is a pod/parent name. If set, a parent/pod cgroup is
190195
# created, and variables $REL_PARENT_PATH and $SD_PARENT_NAME can be used to

tests/integration/ps.bats

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,75 +3,44 @@
33
load helpers
44

55
function setup() {
6+
# ps requires cgroups
7+
[ $EUID -ne 0 ] && requires rootless_cgroup
8+
69
setup_busybox
10+
11+
# Rootless does not have default cgroup path.
12+
[ $EUID -ne 0 ] && set_cgroups_path
13+
14+
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
15+
[ "$status" -eq 0 ]
16+
testcontainer test_busybox running
717
}
818

919
function teardown() {
1020
teardown_bundle
1121
}
1222

1323
@test "ps" {
14-
# ps is not supported, it requires cgroups
15-
requires root
16-
17-
# start busybox detached
18-
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
19-
[ "$status" -eq 0 ]
20-
21-
# check state
22-
testcontainer test_busybox running
23-
2424
runc ps test_busybox
2525
[ "$status" -eq 0 ]
26-
[[ ${lines[0]} =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]]
27-
[[ "${lines[1]}" == *"$(id -un 2>/dev/null)"*[0-9]* ]]
26+
[[ "$output" =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]]
27+
[[ "$output" == *"$(id -un 2>/dev/null)"*[0-9]* ]]
2828
}
2929

3030
@test "ps -f json" {
31-
# ps is not supported, it requires cgroups
32-
requires root
33-
34-
# start busybox detached
35-
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
36-
[ "$status" -eq 0 ]
37-
38-
# check state
39-
testcontainer test_busybox running
40-
4131
runc ps -f json test_busybox
4232
[ "$status" -eq 0 ]
43-
[[ ${lines[0]} =~ [0-9]+ ]]
33+
[[ "$output" =~ [0-9]+ ]]
4434
}
4535

4636
@test "ps -e -x" {
47-
# ps is not supported, it requires cgroups
48-
requires root
49-
50-
# start busybox detached
51-
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
52-
[ "$status" -eq 0 ]
53-
54-
# check state
55-
testcontainer test_busybox running
56-
5737
runc ps test_busybox -e -x
5838
[ "$status" -eq 0 ]
59-
[[ ${lines[0]} =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]]
60-
[[ "${lines[1]}" =~ [0-9]+ ]]
39+
[[ "$output" =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]]
40+
[[ "$output" =~ [0-9]+ ]]
6141
}
6242

6343
@test "ps after the container stopped" {
64-
# ps requires cgroups
65-
[ $EUID -ne 0 ] && requires rootless_cgroup
66-
set_cgroups_path
67-
68-
# start busybox detached
69-
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
70-
[ "$status" -eq 0 ]
71-
72-
# check state
73-
testcontainer test_busybox running
74-
7544
runc ps test_busybox
7645
[ "$status" -eq 0 ]
7746

0 commit comments

Comments
 (0)