2016-09-28 19:54:57 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
function teardown() {
|
|
|
|
cleanup_test
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "ctr remove" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-09-28 19:54:57 +00:00
|
|
|
echo "$output"
|
2016-10-02 08:13:00 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2016-09-28 19:54:57 +00:00
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
2016-09-28 19:54:57 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2016-09-28 19:54:57 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr remove --id "$ctr_id"
|
2016-09-28 19:54:57 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod stop --id "$pod_id"
|
2016-09-28 19:54:57 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod_id"
|
2016-09-28 19:54:57 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2016-10-08 12:57:45 +00:00
|
|
|
cleanup_ctrs
|
2016-09-28 19:54:57 +00:00
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-09-28 19:54:57 +00:00
|
|
|
}
|
2016-09-29 20:33:47 +00:00
|
|
|
|
|
|
|
@test "ctr lifecycle" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
2016-10-02 08:13:00 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2016-09-29 20:33:47 +00:00
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod list
|
2016-09-30 19:24:16 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list
|
2016-09-30 19:24:16 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr status --id "$ctr_id"
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr status --id "$ctr_id"
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list
|
2016-09-30 19:24:16 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr stop --id "$ctr_id"
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr status --id "$ctr_id"
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list
|
2016-09-30 19:24:16 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr remove --id "$ctr_id"
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list
|
2016-09-30 19:24:16 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod stop --id "$pod_id"
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod list
|
2016-09-30 19:24:16 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list
|
2016-09-30 19:24:16 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod_id"
|
2016-09-29 20:33:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod list
|
2016-09-30 19:24:16 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list
|
2016-09-30 19:24:16 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2016-10-08 12:57:45 +00:00
|
|
|
cleanup_ctrs
|
2016-09-29 20:33:47 +00:00
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-09-29 20:33:47 +00:00
|
|
|
}
|
2016-10-13 08:50:51 +00:00
|
|
|
|
2017-03-22 12:07:15 +00:00
|
|
|
@test "ctr logging" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod list
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
# Create a new container.
|
2017-05-12 13:36:15 +00:00
|
|
|
newconfig=$(mktemp --tmpdir crio-config.XXXXXX.json)
|
2017-03-22 12:07:15 +00:00
|
|
|
cp "$TESTDATA"/container_config_logging.json "$newconfig"
|
2017-04-11 22:13:26 +00:00
|
|
|
sed -i 's|"%shellcommand%"|"echo here is some output \&\& echo and some from stderr >\&2"|' "$newconfig"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$newconfig" --pod "$pod_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr stop --id "$ctr_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
# Ignore errors on stop.
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr status --id "$ctr_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr remove --id "$ctr_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
# Check that the output is what we expect.
|
2017-04-11 22:13:26 +00:00
|
|
|
logpath="$DEFAULT_LOG_PATH/$pod_id/$ctr_id.log"
|
|
|
|
[ -f "$logpath" ]
|
|
|
|
echo "$logpath :: $(cat "$logpath")"
|
|
|
|
grep -E "^[^\n]+ stdout here is some output$" "$logpath"
|
|
|
|
grep -E "^[^\n]+ stderr and some from stderr$" "$logpath"
|
2017-03-22 12:07:15 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod stop --id "$pod_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2017-03-22 12:07:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "ctr logging [tty=true]" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod list
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
# Create a new container.
|
2017-05-12 13:36:15 +00:00
|
|
|
newconfig=$(mktemp --tmpdir crio-config.XXXXXX.json)
|
2017-03-22 12:07:15 +00:00
|
|
|
cp "$TESTDATA"/container_config_logging.json "$newconfig"
|
2017-04-11 22:13:26 +00:00
|
|
|
sed -i 's|"%shellcommand%"|"echo here is some output"|' "$newconfig"
|
2017-03-22 12:07:15 +00:00
|
|
|
sed -i 's|"tty": false,|"tty": true,|' "$newconfig"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$newconfig" --pod "$pod_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr stop --id "$ctr_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
# Ignore errors on stop.
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr status --id "$ctr_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr remove --id "$ctr_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
# Check that the output is what we expect.
|
2017-04-11 22:13:26 +00:00
|
|
|
logpath="$DEFAULT_LOG_PATH/$pod_id/$ctr_id.log"
|
|
|
|
[ -f "$logpath" ]
|
|
|
|
echo "$logpath :: $(cat "$logpath")"
|
|
|
|
grep -E "^[^\n]+ stdout here is some output$" "$logpath"
|
2017-03-22 12:07:15 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod stop --id "$pod_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod_id"
|
2017-03-22 12:07:15 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2017-03-22 12:07:15 +00:00
|
|
|
}
|
|
|
|
|
2016-10-13 08:50:51 +00:00
|
|
|
# regression test for #127
|
|
|
|
@test "ctrs status for a pod" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-10-13 08:50:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
2016-10-13 08:50:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --quiet
|
2016-10-13 08:50:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "${output}" != "" ]]
|
|
|
|
|
|
|
|
printf '%s\n' "$output" | while IFS= read -r id
|
|
|
|
do
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr status --id "$id"
|
2016-10-13 08:50:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
done
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-10-13 08:50:51 +00:00
|
|
|
}
|
|
|
|
|
2016-10-13 17:06:27 +00:00
|
|
|
@test "ctr list filtering" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json --name pod1
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod1_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod1_id"
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr1_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr1_id"
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json --name pod2
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod2_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod2_id"
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr2_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json --name pod3
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod3_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod3_id"
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr3_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr3_id"
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr stop --id "$ctr3_id"
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --id "$ctr1_id" --quiet
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr1_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --id "${ctr1_id:0:4}" --quiet
|
2016-12-06 11:16:22 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr1_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --id "$ctr2_id" --pod "$pod2_id" --quiet
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr2_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --id "$ctr2_id" --pod "$pod3_id" --quiet
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" == "" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --state created --quiet
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr2_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --state running --quiet
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr1_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --state stopped --quiet
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr3_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --pod "$pod1_id" --quiet
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr1_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --pod "$pod2_id" --quiet
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr2_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --pod "$pod3_id" --quiet
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr3_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod1_id"
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod2_id"
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod3_id"
|
2016-10-13 17:06:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-10-13 17:06:27 +00:00
|
|
|
}
|
2016-10-14 16:58:09 +00:00
|
|
|
|
|
|
|
@test "ctr list label filtering" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-10-14 16:58:09 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id" --name ctr1 --label "a=b" --label "c=d" --label "e=f"
|
2016-10-14 16:58:09 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr1_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id" --name ctr2 --label "a=b" --label "c=d"
|
2016-10-14 19:06:10 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr2_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id" --name ctr3 --label "a=b"
|
2016-10-14 19:06:10 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr3_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --label "tier=backend" --label "a=b" --label "c=d" --label "e=f" --quiet
|
2016-10-14 16:58:09 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr1_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --label "tier=frontend" --quiet
|
2016-10-14 16:58:09 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" == "" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --label "a=b" --label "c=d" --quiet
|
2016-10-14 19:06:10 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr1_id" ]]
|
|
|
|
[[ "$output" =~ "$ctr2_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --label "a=b" --quiet
|
2016-10-14 19:06:10 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" != "" ]]
|
|
|
|
[[ "$output" =~ "$ctr1_id" ]]
|
|
|
|
[[ "$output" =~ "$ctr2_id" ]]
|
|
|
|
[[ "$output" =~ "$ctr3_id" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod_id"
|
2016-10-14 16:58:09 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-10-14 16:58:09 +00:00
|
|
|
}
|
2016-10-27 06:24:27 +00:00
|
|
|
|
|
|
|
@test "ctr metadata in list & status" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-10-27 06:24:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_config.json --pod "$pod_id"
|
2016-10-27 06:24:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr list --id "$ctr_id"
|
2016-10-27 06:24:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
# TODO: expected value should not hard coded here
|
|
|
|
[[ "$output" =~ "Name: container1" ]]
|
|
|
|
[[ "$output" =~ "Attempt: 1" ]]
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr status --id "$ctr_id"
|
2016-10-27 06:24:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
# TODO: expected value should not hard coded here
|
|
|
|
[[ "$output" =~ "Name: container1" ]]
|
|
|
|
[[ "$output" =~ "Attempt: 1" ]]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-10-27 06:24:27 +00:00
|
|
|
}
|
2016-11-18 22:58:47 +00:00
|
|
|
|
|
|
|
@test "ctr execsync" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-11-18 22:58:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
2016-11-18 22:58:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2016-11-18 22:58:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr execsync --id "$ctr_id" echo HELLO
|
2016-11-18 22:58:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ "HELLO" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr execsync --id "$ctr_id" --timeout 1 sleep 10
|
2016-11-18 22:58:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[[ "$output" =~ "command timed out" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod_id"
|
2016-11-18 22:58:47 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-11-18 22:58:47 +00:00
|
|
|
}
|
2016-11-24 09:57:10 +00:00
|
|
|
|
2017-05-10 20:36:51 +00:00
|
|
|
@test "ctr device add" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2017-05-10 20:36:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis_device.json --pod "$pod_id"
|
2017-05-10 20:36:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2017-05-10 20:36:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr execsync --id "$ctr_id" ls /dev/mynull
|
2017-05-10 20:36:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ "/dev/mynull" ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod_id"
|
2017-05-10 20:36:51 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2017-05-10 20:36:51 +00:00
|
|
|
}
|
|
|
|
|
2016-11-24 09:57:10 +00:00
|
|
|
@test "ctr execsync failure" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-11-24 09:57:10 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
2016-11-24 09:57:10 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2016-11-24 09:57:10 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr execsync --id "$ctr_id" doesnotexist
|
2016-11-24 09:57:10 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -ne 0 ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-11-24 09:57:10 +00:00
|
|
|
}
|
2016-12-06 11:39:38 +00:00
|
|
|
|
2017-04-11 22:13:26 +00:00
|
|
|
@test "ctr execsync exit code" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr execsync --id "$ctr_id" false
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" =~ "Exit code: 1" ]]
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2017-04-11 22:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "ctr execsync std{out,err}" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr execsync --id "$ctr_id" "echo hello0 stdout"
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" == *"$(printf "Stdout:\nhello0 stdout")"* ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr execsync --id "$ctr_id" "echo hello1 stderr >&2"
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" == *"$(printf "Stderr:\nhello1 stderr")"* ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr execsync --id "$ctr_id" "echo hello2 stderr >&2; echo hello3 stdout"
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "$output" == *"$(printf "Stderr:\nhello2 stderr")"* ]]
|
|
|
|
[[ "$output" == *"$(printf "Stdout:\nhello3 stdout")"* ]]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod remove --id "$pod_id"
|
2017-04-11 22:13:26 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2017-04-11 22:13:26 +00:00
|
|
|
}
|
|
|
|
|
2016-12-06 11:39:38 +00:00
|
|
|
@test "ctr stop idempotent" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-12-06 11:39:38 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
2016-12-06 11:39:38 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr start --id "$ctr_id"
|
2016-12-06 11:39:38 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr stop --id "$ctr_id"
|
2016-12-06 11:39:38 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl ctr stop --id "$ctr_id"
|
2016-12-06 11:39:38 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-12-06 11:39:38 +00:00
|
|
|
}
|
2017-05-12 16:20:34 +00:00
|
|
|
|
|
|
|
@test "ctr caps drop" {
|
2017-05-15 20:03:05 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2017-05-12 16:20:34 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
capsconfig=$(cat "$TESTDATA"/container_config.json | python -c 'import json,sys;obj=json.load(sys.stdin);obj["linux"]["security_context"]["capabilities"] = {u"add_capabilities": [], u"drop_capabilities": [u"mknod", u"kill", u"sys_chroot", u"setuid", u"setgid"]}; json.dump(obj, sys.stdout)')
|
|
|
|
echo "$capsconfig" > "$TESTDIR"/container_config_caps.json
|
2017-05-15 20:03:05 +00:00
|
|
|
run crioctl ctr create --config "$TESTDIR"/container_config_caps.json --pod "$pod_id"
|
2017-05-12 16:20:34 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
2017-05-15 20:03:05 +00:00
|
|
|
stop_crio
|
2017-05-12 16:20:34 +00:00
|
|
|
}
|
2017-05-22 15:19:49 +00:00
|
|
|
|
|
|
|
@test "run ctr with image with Config.Volumes" {
|
|
|
|
start_crio
|
|
|
|
run crioctl image pull gcr.io/k8s-testimages/redis:e2e
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
volumesconfig=$(cat "$TESTDATA"/container_redis.json | python -c 'import json,sys;obj=json.load(sys.stdin);obj["image"]["image"] = "gcr.io/k8s-testimages/redis:e2e"; json.dump(obj, sys.stdout)')
|
|
|
|
echo "$volumesconfig" > "$TESTDIR"/container_config_volumes.json
|
|
|
|
run crioctl ctr create --config "$TESTDIR"/container_config_volumes.json --pod "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
cleanup_ctrs
|
|
|
|
cleanup_pods
|
|
|
|
stop_crio
|
|
|
|
}
|