File: pause.bats

package info (click to toggle)
runc 1.3.3%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 3,136 kB
  • sloc: sh: 2,298; ansic: 1,125; makefile: 229
file content (77 lines) | stat: -rw-r--r-- 1,536 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bats

load helpers

function setup() {
	setup_busybox
}

function teardown() {
	teardown_bundle
}

@test "runc pause and resume" {
	requires cgroups_freezer
	if [ $EUID -ne 0 ]; then
		requires rootless_cgroup
		set_cgroups_path
	fi

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

	testcontainer test_busybox running

	# pause busybox
	runc pause test_busybox
	[ "$status" -eq 0 ]

	# test state of busybox is paused
	testcontainer test_busybox paused

	# resume busybox
	runc resume test_busybox
	[ "$status" -eq 0 ]

	# test state of busybox is back to running
	testcontainer test_busybox running
}

@test "runc pause and resume with nonexist container" {
	requires cgroups_freezer
	if [ $EUID -ne 0 ]; then
		requires rootless_cgroup
		set_cgroups_path
	fi

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

	testcontainer test_busybox running

	# pause test_busybox and nonexistent container
	runc pause test_busybox
	[ "$status" -eq 0 ]
	runc pause nonexistent
	[ "$status" -ne 0 ]

	# test state of test_busybox is paused
	testcontainer test_busybox paused

	# resume test_busybox and nonexistent container
	runc resume test_busybox
	[ "$status" -eq 0 ]
	runc resume nonexistent
	[ "$status" -ne 0 ]

	# test state of test_busybox is back to running
	testcontainer test_busybox running

	# delete test_busybox
	runc delete --force test_busybox

	runc state test_busybox
	[ "$status" -ne 0 ]
}