add test for container/pod metadata in status/list APIs
Signed-off-by: HaoZhang <crazykev@zju.edu.cn>
This commit is contained in:
parent
ca59eaf1a4
commit
018c4db06d
5 changed files with 116 additions and 3 deletions
|
@ -292,3 +292,38 @@ function teardown() {
|
|||
cleanup_pods
|
||||
stop_ocid
|
||||
}
|
||||
|
||||
@test "ctr metadata in list & status" {
|
||||
# this test requires docker, thus it can't yet be run in a container
|
||||
if [ "$TRAVIS" = "true" ]; then # instead of $TRAVIS, add a function is_containerized to skip here
|
||||
skip "cannot yet run this test in a container, use sudo make localintegration"
|
||||
fi
|
||||
|
||||
start_ocid
|
||||
run ocic pod create --config "$TESTDATA"/sandbox_config.json
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
pod_id="$output"
|
||||
run ocic ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
ctr_id="$output"
|
||||
|
||||
run ocic ctr list --id "$ctr_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
# TODO: expected value should not hard coded here
|
||||
[[ "$output" =~ "Name: container1" ]]
|
||||
[[ "$output" =~ "Attempt: 1" ]]
|
||||
|
||||
run ocic ctr status --id "$ctr_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
# TODO: expected value should not hard coded here
|
||||
[[ "$output" =~ "Name: container1" ]]
|
||||
[[ "$output" =~ "Attempt: 1" ]]
|
||||
|
||||
cleanup_ctrs
|
||||
cleanup_pods
|
||||
stop_ocid
|
||||
}
|
||||
|
|
|
@ -152,4 +152,38 @@ function teardown() {
|
|||
[ "$status" -eq 0 ]
|
||||
cleanup_pods
|
||||
stop_ocid
|
||||
}
|
||||
}
|
||||
|
||||
@test "pod metadata in list & status" {
|
||||
# this test requires docker, thus it can't yet be run in a container
|
||||
if [ "$TRAVIS" = "true" ]; then # instead of $TRAVIS, add a function is_containerized to skip here
|
||||
skip "cannot yet run this test in a container, use sudo make localintegration"
|
||||
fi
|
||||
|
||||
start_ocid
|
||||
run ocic pod create --config "$TESTDATA"/sandbox_config.json
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
pod_id="$output"
|
||||
|
||||
run ocic pod list --id "$pod_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
# TODO: expected value should not hard coded here
|
||||
[[ "$output" =~ "Name: podsandbox1" ]]
|
||||
[[ "$output" =~ "UID: redhat-test-ocid" ]]
|
||||
[[ "$output" =~ "Namespace: redhat.test.ocid" ]]
|
||||
[[ "$output" =~ "Attempt: 1" ]]
|
||||
|
||||
run ocic pod status --id "$pod_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
# TODO: expected value should not hard coded here
|
||||
[[ "$output" =~ "Name: podsandbox1" ]]
|
||||
[[ "$output" =~ "UID: redhat-test-ocid" ]]
|
||||
[[ "$output" =~ "Namespace: redhat.test.ocid" ]]
|
||||
[[ "$output" =~ "Attempt: 1" ]]
|
||||
|
||||
cleanup_pods
|
||||
stop_ocid
|
||||
}
|
||||
|
|
|
@ -18,11 +18,31 @@ function teardown() {
|
|||
[ "$status" -eq 0 ]
|
||||
pod_id="$output"
|
||||
|
||||
run ocic pod list --id "$pod_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
pod_list_info="$output"
|
||||
|
||||
run ocic pod status --id "$pod_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
pod_status_info="$output"
|
||||
|
||||
run ocic ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
ctr_id="$output"
|
||||
|
||||
run ocic ctr list --id "$ctr_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
ctr_list_info="$output"
|
||||
|
||||
run ocic ctr status --id "$ctr_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
ctr_status_info="$output"
|
||||
|
||||
stop_ocid
|
||||
|
||||
start_ocid
|
||||
|
@ -32,12 +52,32 @@ function teardown() {
|
|||
[[ "${output}" != "" ]]
|
||||
[[ "${output}" =~ "${pod_id}" ]]
|
||||
|
||||
run ocic pod list --id "$pod_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "${output}" == "${pod_list_info}" ]]
|
||||
|
||||
run ocic pod status --id "$pod_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "${output}" == "${pod_status_info}" ]]
|
||||
|
||||
run ocic ctr list
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "${output}" != "" ]]
|
||||
[[ "${output}" =~ "${pod_id}" ]]
|
||||
|
||||
run ocic ctr list --id "$ctr_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "${output}" == "${ctr_list_info}" ]]
|
||||
|
||||
run ocic ctr status --id "$ctr_id"
|
||||
echo "$output"
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "${output}" == "${ctr_status_info}" ]]
|
||||
|
||||
cleanup_ctrs
|
||||
cleanup_pods
|
||||
stop_ocid
|
||||
|
|
3
test/testdata/container_config.json
vendored
3
test/testdata/container_config.json
vendored
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "container1"
|
||||
"name": "container1",
|
||||
"attempt": 1
|
||||
},
|
||||
"image": {
|
||||
"image": "docker://redis:latest"
|
||||
|
|
5
test/testdata/sandbox_config.json
vendored
5
test/testdata/sandbox_config.json
vendored
|
@ -1,6 +1,9 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "podsandbox1"
|
||||
"name": "podsandbox1",
|
||||
"uid": "redhat-test-ocid",
|
||||
"namespace": "redhat.test.ocid",
|
||||
"attempt": 1
|
||||
},
|
||||
"hostname": "ocic_host",
|
||||
"log_directory": ".",
|
||||
|
|
Loading…
Reference in a new issue