2016-03-15 03:55:05 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
function setup() {
|
|
|
|
teardown_running_container_inroot test_box1 $HELLO_BUNDLE
|
|
|
|
teardown_running_container_inroot test_box2 $HELLO_BUNDLE
|
|
|
|
teardown_running_container_inroot test_box3 $HELLO_BUNDLE
|
|
|
|
teardown_busybox
|
|
|
|
setup_busybox
|
|
|
|
}
|
|
|
|
|
|
|
|
function teardown() {
|
|
|
|
teardown_running_container_inroot test_box1 $HELLO_BUNDLE
|
|
|
|
teardown_running_container_inroot test_box2 $HELLO_BUNDLE
|
|
|
|
teardown_running_container_inroot test_box3 $HELLO_BUNDLE
|
|
|
|
teardown_busybox
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "list" {
|
2016-05-14 06:49:45 +08:00
|
|
|
# run a few busyboxes detached
|
2016-09-06 20:40:01 +08:00
|
|
|
ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_box1
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
2016-09-06 20:40:01 +08:00
|
|
|
ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_box2
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
2016-09-06 20:40:01 +08:00
|
|
|
ROOT=$HELLO_BUNDLE runc run -d --console-socket $CONSOLE_SOCKET test_box3
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
2016-05-09 21:06:42 +08:00
|
|
|
ROOT=$HELLO_BUNDLE runc list
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ ${lines[0]} =~ ID\ +PID\ +STATUS\ +BUNDLE\ +CREATED+ ]]
|
|
|
|
[[ "${lines[1]}" == *"test_box1"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]]
|
|
|
|
[[ "${lines[2]}" == *"test_box2"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]]
|
|
|
|
[[ "${lines[3]}" == *"test_box3"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
2016-10-20 11:21:23 +08:00
|
|
|
ROOT=$HELLO_BUNDLE runc list -q
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "${lines[0]}" == "test_box1" ]]
|
|
|
|
[[ "${lines[1]}" == "test_box2" ]]
|
|
|
|
[[ "${lines[2]}" == "test_box3" ]]
|
|
|
|
|
2016-05-09 21:06:42 +08:00
|
|
|
ROOT=$HELLO_BUNDLE runc list --format table
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ ${lines[0]} =~ ID\ +PID\ +STATUS\ +BUNDLE\ +CREATED+ ]]
|
|
|
|
[[ "${lines[1]}" == *"test_box1"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]]
|
|
|
|
[[ "${lines[2]}" == *"test_box2"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]]
|
|
|
|
[[ "${lines[3]}" == *"test_box3"*[0-9]*"running"*$BUSYBOX_BUNDLE*[0-9]* ]]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
2016-05-09 21:06:42 +08:00
|
|
|
ROOT=$HELLO_BUNDLE runc list --format json
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2016-09-16 01:53:14 +08:00
|
|
|
[[ "${lines[0]}" == [\[][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box1\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$BUSYBOX_BUNDLE*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}]* ]]
|
|
|
|
[[ "${lines[0]}" == *[,][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box2\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$BUSYBOX_BUNDLE*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}]* ]]
|
|
|
|
[[ "${lines[0]}" == *[,][\{]"\"ociVersion\""[:]"\""*[0-9][\.]*[0-9][\.]*[0-9]*"\""[,]"\"id\""[:]"\"test_box3\""[,]"\"pid\""[:]*[0-9][,]"\"status\""[:]*"\"running\""[,]"\"bundle\""[:]*$BUSYBOX_BUNDLE*[,]"\"rootfs\""[:]"\""*"\""[,]"\"created\""[:]*[0-9]*[\}][\]] ]]
|
2016-03-15 03:55:05 +08:00
|
|
|
}
|