diff --git a/test/restore.bats b/test/restore.bats index c50344a1..1351cab5 100644 --- a/test/restore.bats +++ b/test/restore.bats @@ -77,3 +77,59 @@ function teardown() { cleanup_pods stop_crio } + +@test "crio restore with bad state" { + start_crio + run crioctl pod run --config "$TESTDATA"/sandbox_config.json + echo "$output" + [ "$status" -eq 0 ] + pod_id="$output" + + run crioctl pod status --id "$pod_id" + echo "$output" + [ "$status" -eq 0 ] + [[ "${output}" =~ "SANDBOX_READY" ]] + + run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id" + echo "$output" + [ "$status" -eq 0 ] + ctr_id="$output" + + run crioctl ctr status --id "$ctr_id" + echo "$output" + [ "$status" -eq 0 ] + [[ "${output}" =~ "CONTAINER_CREATED" ]] + + 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 list + echo "$output" + [ "$status" -eq 0 ] + [[ "${output}" != "" ]] + [[ "${output}" =~ "${pod_id}" ]] + + run crioctl pod status --id "$pod_id" + echo "$output" + [ "$status" -eq 0 ] + [[ "${output}" =~ "SANDBOX_NOTREADY" ]] + + run crioctl ctr list + echo "$output" + [ "$status" -eq 0 ] + [[ "${output}" != "" ]] + [[ "${output}" =~ "${ctr_id}" ]] + + run crioctl ctr status --id "$ctr_id" + echo "$output" + [ "$status" -eq 0 ] + [[ "${output}" =~ "CONTAINER_EXITED" ]] + [[ "${output}" =~ "Exit Code: 255" ]] + + cleanup_ctrs + cleanup_pods + stop_crio +}