Skip to content

Commit

Permalink
tests/int/ps: randomize container name
Browse files Browse the repository at this point in the history
Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Mar 22, 2023
1 parent dccfd01 commit ef66b17
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions tests/integration/ps.bats
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ load helpers

function setup() {
setup_busybox
id=ct-${RANDOM}
# if [ -v RUNC_USE_SYSTEMD ]; then
# update_config '.linux.cgroupsPath |= ":runc:test_busybox-'${RANDOM}'"'
# fi
}

function teardown() {
Expand All @@ -14,14 +18,12 @@ function teardown() {
# ps is not supported, it requires cgroups
requires root

# start busybox detached
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
runc run -d --console-socket "$CONSOLE_SOCKET" $id
[ "$status" -eq 0 ]

# check state
testcontainer test_busybox running
testcontainer $id running

runc ps test_busybox
runc ps $id
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]]
[[ "${lines[1]}" == *"$(id -un 2>/dev/null)"*[0-9]* ]]
Expand All @@ -31,14 +33,12 @@ function teardown() {
# ps is not supported, it requires cgroups
requires root

# start busybox detached
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
runc run -d --console-socket "$CONSOLE_SOCKET" $id
[ "$status" -eq 0 ]

# check state
testcontainer test_busybox running
testcontainer $id running

runc ps -f json test_busybox
runc ps -f json $id
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ [0-9]+ ]]
}
Expand All @@ -47,14 +47,12 @@ function teardown() {
# ps is not supported, it requires cgroups
requires root

# start busybox detached
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
runc run -d --console-socket "$CONSOLE_SOCKET" $id
[ "$status" -eq 0 ]

# check state
testcontainer test_busybox running
testcontainer $id running

runc ps test_busybox -e -x
runc ps $id -e -x
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]]
[[ "${lines[1]}" =~ [0-9]+ ]]
Expand All @@ -65,20 +63,18 @@ function teardown() {
[ $EUID -ne 0 ] && requires rootless_cgroup
set_cgroups_path

# start busybox detached
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
runc run -d --console-socket "$CONSOLE_SOCKET" $id
[ "$status" -eq 0 ]

# check state
testcontainer test_busybox running
testcontainer $id running

runc ps test_busybox
runc ps $id
[ "$status" -eq 0 ]

runc kill test_busybox KILL
runc kill $id KILL
[ "$status" -eq 0 ]
wait_for_container 10 1 test_busybox stopped
wait_for_container 10 1 $id stopped

runc ps test_busybox
runc ps $id
[ "$status" -eq 0 ]
}

0 comments on commit ef66b17

Please sign in to comment.