server: adhere to CRI for sandbox stop/remove

Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
Antonio Murdaca 2017-05-21 15:47:01 +02:00
parent 00444753e7
commit 9f68cb4507
No known key found for this signature in database
GPG key ID: B2BEAD150DE936B9
9 changed files with 226 additions and 30 deletions

View file

@ -367,12 +367,21 @@ function teardown() {
[ "$status" -eq 0 ]
[[ "$output" != "" ]]
[[ "$output" =~ "$ctr3_id" ]]
run crioctl pod stop --id "$pod1_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod1_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod stop --id "$pod2_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod2_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod stop --id "$pod3_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod3_id"
echo "$output"
[ "$status" -eq 0 ]
@ -421,6 +430,9 @@ function teardown() {
[[ "$output" =~ "$ctr1_id" ]]
[[ "$output" =~ "$ctr2_id" ]]
[[ "$output" =~ "$ctr3_id" ]]
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
@ -501,6 +513,9 @@ function teardown() {
run crioctl ctr execsync --id "$ctr_id" --timeout 1 sleep 10
echo "$output"
[[ "$output" =~ "command timed out" ]]
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
@ -526,6 +541,9 @@ function teardown() {
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" =~ "/dev/mynull" ]]
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
@ -606,7 +624,9 @@ function teardown() {
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" == *"$(printf "Stderr:\nthis goes to stderr")"* ]]
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]

View file

@ -247,7 +247,7 @@ function cleanup_ctrs() {
if [ "$output" != "" ]; then
printf '%s\n' "$output" | while IFS= read -r line
do
crioctl ctr stop --id "$line" || true
crioctl ctr stop --id "$line"
crioctl ctr remove --id "$line"
done
fi
@ -272,7 +272,7 @@ function cleanup_pods() {
if [ "$output" != "" ]; then
printf '%s\n' "$output" | while IFS= read -r line
do
crioctl pod stop --id "$line" || true
crioctl pod stop --id "$line"
crioctl pod remove --id "$line"
done
fi

View file

@ -16,7 +16,6 @@ function teardown() {
run crioctl pod stop --id "$id"
echo "$output"
[ "$status" -eq 0 ]
echo "$output"
run crioctl pod remove --id "$id"
echo "$output"
[ "$status" -eq 0 ]
@ -48,6 +47,9 @@ function teardown() {
run crioctl ctr start --id "$ctr_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
@ -155,12 +157,21 @@ function teardown() {
echo "$output"
[ "$status" -eq 0 ]
[[ "$output" == "" ]]
run crioctl pod stop --id "$pod1_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod1_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod stop --id "$pod2_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod2_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod stop --id "$pod3_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod3_id"
echo "$output"
[ "$status" -eq 0 ]
@ -256,6 +267,9 @@ function teardown() {
echo "$output"
[ "$status" -eq 0 ]
pod_id="$output"
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]

View file

@ -78,6 +78,131 @@ function teardown() {
stop_crio
}
@test "crio restore with bad state and pod stopped" {
start_crio
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output"
[ "$status" -eq 0 ]
pod_id="$output"
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
stop_crio
# simulate reboot with runc state going away
for i in $("$RUNTIME" list -q | xargs); do "$RUNTIME" delete -f $i; done
start_crio
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
cleanup_pods
stop_crio
}
@test "crio restore with bad state and ctr stopped" {
start_crio
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output"
[ "$status" -eq 0 ]
pod_id="$output"
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
ctr_id="$output"
run crioctl ctr stop --id "$ctr_id"
echo "$output"
[ "$status" -eq 0 ]
stop_crio
# simulate reboot with runc state going away
for i in $("$RUNTIME" list -q | xargs); do "$RUNTIME" delete -f $i; done
start_crio
run crioctl ctr stop --id "$ctr_id"
echo "$output"
[ "$status" -eq 0 ]
cleanup_ctrs
cleanup_pods
stop_crio
}
@test "crio restore with bad state and ctr removed" {
start_crio
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output"
[ "$status" -eq 0 ]
pod_id="$output"
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
ctr_id="$output"
run crioctl ctr stop --id "$ctr_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl ctr remove --id "$ctr_id"
echo "$output"
[ "$status" -eq 0 ]
stop_crio
# simulate reboot with runc state going away
for i in $("$RUNTIME" list -q | xargs); do "$RUNTIME" delete -f $i; done
start_crio
run crioctl ctr stop --id "$ctr_id"
echo "$output"
[ "$status" -eq 1 ]
[[ "${output}" =~ "not found" ]]
cleanup_ctrs
cleanup_pods
stop_crio
}
@test "crio restore with bad state and pod removed" {
start_crio
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
echo "$output"
[ "$status" -eq 0 ]
pod_id="$output"
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
stop_crio
# simulate reboot with runc state going away
for i in $("$RUNTIME" list -q | xargs); do "$RUNTIME" delete -f $i; done
start_crio
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
cleanup_pods
stop_crio
}
@test "crio restore with bad state" {
start_crio
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
@ -129,6 +254,13 @@ function teardown() {
[[ "${output}" =~ "CONTAINER_EXITED" ]]
[[ "${output}" =~ "Exit Code: 255" ]]
run crioctl pod stop --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
run crioctl pod remove --id "$pod_id"
echo "$output"
[ "$status" -eq 0 ]
cleanup_ctrs
cleanup_pods
stop_crio