2016-09-27 07:14:31 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
function teardown() {
|
|
|
|
cleanup_test
|
|
|
|
}
|
|
|
|
|
|
|
|
# PR#59
|
|
|
|
@test "pod release name on remove" {
|
2016-09-27 08:54:16 +00:00
|
|
|
# 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"
|
2016-09-27 08:40:33 +00:00
|
|
|
fi
|
2016-09-27 07:14:31 +00:00
|
|
|
|
|
|
|
start_ocid
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json
|
2016-09-27 08:40:33 +00:00
|
|
|
echo "$output"
|
2016-10-02 08:13:00 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2016-09-27 07:14:31 +00:00
|
|
|
id="$output"
|
|
|
|
run ocic pod stop --id "$id"
|
2016-10-02 08:13:00 +00:00
|
|
|
echo "$output"
|
2016-09-27 07:14:31 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2016-10-02 08:13:00 +00:00
|
|
|
echo "$output"
|
2016-09-27 07:14:31 +00:00
|
|
|
run ocic pod remove --id "$id"
|
2016-10-02 08:13:00 +00:00
|
|
|
echo "$output"
|
2016-09-27 07:14:31 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json
|
2016-09-27 18:36:17 +00:00
|
|
|
echo "$output"
|
2016-10-02 08:13:00 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2016-09-27 18:36:17 +00:00
|
|
|
id="$output"
|
|
|
|
run ocic pod stop --id "$id"
|
2016-10-02 08:13:00 +00:00
|
|
|
echo "$output"
|
2016-09-27 18:36:17 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run ocic pod remove --id "$id"
|
2016-10-02 08:13:00 +00:00
|
|
|
echo "$output"
|
2016-09-27 18:36:17 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2016-10-08 12:57:45 +00:00
|
|
|
cleanup_ctrs
|
2016-09-27 08:54:16 +00:00
|
|
|
cleanup_pods
|
2016-10-08 12:24:16 +00:00
|
|
|
stop_ocid
|
2016-09-27 07:14:31 +00:00
|
|
|
}
|
2016-09-28 20:15:57 +00:00
|
|
|
|
|
|
|
@test "pod remove" {
|
|
|
|
# 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
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json
|
2016-09-28 20:15:57 +00:00
|
|
|
echo "$output"
|
2016-10-02 08:13:00 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2016-09-28 20:15:57 +00:00
|
|
|
pod_id="$output"
|
|
|
|
run ocic ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
|
|
|
run ocic ctr start --id "$ctr_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run ocic pod remove --id "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2016-10-08 12:57:45 +00:00
|
|
|
cleanup_ctrs
|
2016-09-28 20:15:57 +00:00
|
|
|
cleanup_pods
|
2016-10-08 12:24:16 +00:00
|
|
|
stop_ocid
|
2016-09-28 20:15:57 +00:00
|
|
|
}
|
2016-10-17 19:51:21 +00:00
|
|
|
|
|
|
|
@test "pod list filtering" {
|
|
|
|
# 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
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json -name pod1 --label "a=b" --label "c=d" --label "e=f"
|
2016-10-17 19:51:21 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod1_id="$output"
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json -name pod2 --label "a=b" --label "c=d"
|
2016-10-17 19:51:21 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod2_id="$output"
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json -name pod3 --label "a=b"
|
2016-10-17 19:51:21 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod3_id="$output"
|
|
|
|
run ocic pod list --label "a=b" --label "c=d" --label "e=f" --quiet
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod1_id" ]]
|
|
|
|
run ocic pod list --label "g=h" --quiet
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" == "" ]]
|
|
|
|
run ocic pod list --label "a=b" --label "c=d" --quiet
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod1_id" ]]
|
|
|
|
[[ "$output" =~ "$pod2_id" ]]
|
|
|
|
run ocic pod list --label "a=b" --quiet
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod1_id" ]]
|
|
|
|
[[ "$output" =~ "$pod2_id" ]]
|
|
|
|
[[ "$output" =~ "$pod3_id" ]]
|
|
|
|
run ocic pod list --id "$pod1_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod1_id" ]]
|
2016-12-06 11:12:52 +00:00
|
|
|
# filter by truncated id should work as well
|
|
|
|
run ocic pod list --id "${pod1_id:0:4}"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod1_id" ]]
|
2016-10-17 19:51:21 +00:00
|
|
|
run ocic pod list --id "$pod2_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod2_id" ]]
|
|
|
|
run ocic pod list --id "$pod3_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod3_id" ]]
|
|
|
|
run ocic pod list --id "$pod1_id" --label "a=b"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod1_id" ]]
|
|
|
|
run ocic pod list --id "$pod2_id" --label "a=b"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod2_id" ]]
|
|
|
|
run ocic pod list --id "$pod3_id" --label "a=b"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$pod3_id" ]]
|
|
|
|
run ocic pod list --id "$pod3_id" --label "c=d"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" == "" ]]
|
|
|
|
run ocic pod remove --id "$pod1_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run ocic pod remove --id "$pod2_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run ocic pod remove --id "$pod3_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
cleanup_pods
|
|
|
|
stop_ocid
|
2016-10-27 06:24:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json
|
2016-10-27 06:24:27 +00:00
|
|
|
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
|
|
|
|
}
|
2016-11-19 02:17:14 +00:00
|
|
|
|
|
|
|
@test "pass pod sysctls to runtime" {
|
|
|
|
# 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
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json
|
2016-11-19 02:17:14 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
|
|
|
|
run ocic ctr create --pod "$pod_id" --config "$TESTDATA"/container_redis.json
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
container_id="$output"
|
|
|
|
|
|
|
|
run ocic ctr start --id "$container_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
run ocic ctr execsync --id "$container_id" sysctl kernel.shm_rmid_forced
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ "kernel.shm_rmid_forced = 1" ]]
|
|
|
|
|
|
|
|
run ocic ctr execsync --id "$container_id" sysctl kernel.msgmax
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ "kernel.msgmax = 8192" ]]
|
|
|
|
|
|
|
|
run ocic ctr execsync --id "$container_id" sysctl net.ipv4.ip_local_port_range
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ "net.ipv4.ip_local_port_range = 1024 65000" ]]
|
|
|
|
|
|
|
|
cleanup_pods
|
|
|
|
stop_ocid
|
|
|
|
}
|
2016-12-06 11:39:38 +00:00
|
|
|
|
|
|
|
@test "pod stop idempotent" {
|
|
|
|
# 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
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json
|
2016-12-06 11:39:38 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
run ocic pod stop --id "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run ocic pod stop --id "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
|
|
|
stop_ocid
|
|
|
|
}
|
|
|
|
|
2016-12-08 23:43:25 +00:00
|
|
|
@test "pod remove idempotent" {
|
|
|
|
# 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
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json
|
2016-12-08 23:43:25 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
run ocic pod remove --id "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run ocic pod remove --id "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
|
|
|
stop_ocid
|
|
|
|
}
|
|
|
|
|
2016-12-06 11:39:38 +00:00
|
|
|
@test "pod stop idempotent with ctrs already stopped" {
|
|
|
|
# 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
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json
|
2016-12-06 11:39:38 +00:00
|
|
|
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 start --id "$ctr_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run ocic pod stop --id "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
|
|
|
stop_ocid
|
|
|
|
}
|
2016-12-09 10:56:25 +00:00
|
|
|
|
|
|
|
@test "restart ocid and still get pod 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
|
2016-12-14 17:15:37 +00:00
|
|
|
run ocic pod run --config "$TESTDATA"/sandbox_config.json
|
2016-12-09 10:56:25 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
run ocic pod stop --id "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
restart_ocid
|
|
|
|
run ocic pod status --id "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" != "" ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
|
|
|
stop_ocid
|
|
|
|
}
|