2016-12-17 11:29:27 +00:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
@test "Check for valid pod netns CIDR" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-12-17 11:29:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
|
2017-08-04 11:13:19 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
|
|
|
|
|
|
|
check_pod_cidr $ctr_id
|
2016-12-17 11:29:27 +00:00
|
|
|
|
2017-08-04 11:13:19 +00:00
|
|
|
cleanup_ctrs
|
2016-12-17 11:29:27 +00:00
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-12-17 11:29:27 +00:00
|
|
|
}
|
|
|
|
|
2016-12-21 10:28:33 +00:00
|
|
|
@test "Ping pod from the host" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-12-17 11:29:27 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
|
2017-08-04 11:13:19 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
|
|
|
|
|
|
|
ping_pod $ctr_id
|
2016-12-17 11:29:27 +00:00
|
|
|
|
2017-08-04 11:13:19 +00:00
|
|
|
cleanup_ctrs
|
2016-12-17 11:29:27 +00:00
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-12-17 11:29:27 +00:00
|
|
|
}
|
2016-12-21 10:28:33 +00:00
|
|
|
|
|
|
|
@test "Ping pod from another pod" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2016-12-21 10:28:33 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod1_id="$output"
|
2017-08-04 11:13:19 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod1_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr1_id="$output"
|
2016-12-21 10:28:33 +00:00
|
|
|
|
|
|
|
temp_sandbox_conf cni_test
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
run crioctl pod run --config "$TESTDIR"/sandbox_config_cni_test.json
|
2016-12-21 10:28:33 +00:00
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod2_id="$output"
|
2017-08-04 11:13:19 +00:00
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_redis.json --pod "$pod2_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr2_id="$output"
|
2016-12-21 10:28:33 +00:00
|
|
|
|
2017-08-04 11:13:19 +00:00
|
|
|
ping_pod_from_pod $ctr1_id $ctr2_id
|
2016-12-21 10:28:33 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
2017-08-04 11:13:19 +00:00
|
|
|
ping_pod_from_pod $ctr2_id $ctr1_id
|
2016-12-21 10:28:33 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
2017-08-04 11:13:19 +00:00
|
|
|
cleanup_ctrs
|
2016-12-21 10:28:33 +00:00
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2016-12-21 10:28:33 +00:00
|
|
|
}
|
2017-05-04 16:41:15 +00:00
|
|
|
|
|
|
|
@test "Ensure correct CNI plugin namespace/name/container-id arguments" {
|
2017-05-12 13:36:15 +00:00
|
|
|
start_crio "" "" "" "prepare_plugin_test_args_network_conf"
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config.json
|
2017-05-04 16:41:15 +00:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
. /tmp/plugin_test_args.out
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
[ "$FOUND_CNI_CONTAINERID" != "redhat.test.crio" ]
|
2017-05-04 16:41:15 +00:00
|
|
|
[ "$FOUND_CNI_CONTAINERID" != "podsandbox1" ]
|
2017-05-12 13:36:15 +00:00
|
|
|
[ "$FOUND_K8S_POD_NAMESPACE" = "redhat.test.crio" ]
|
2017-05-04 16:41:15 +00:00
|
|
|
[ "$FOUND_K8S_POD_NAME" = "podsandbox1" ]
|
|
|
|
|
2017-08-31 09:19:13 +00:00
|
|
|
rm -rf /tmp/plugin_test_args.out
|
|
|
|
|
2017-05-04 16:41:15 +00:00
|
|
|
cleanup_pods
|
2017-05-12 13:36:15 +00:00
|
|
|
stop_crio
|
2017-05-04 16:41:15 +00:00
|
|
|
}
|
2017-06-17 00:41:54 +00:00
|
|
|
|
|
|
|
@test "Connect to pod hostport from the host" {
|
|
|
|
start_crio
|
|
|
|
run crioctl pod run --config "$TESTDATA"/sandbox_config_hostport.json
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
pod_id="$output"
|
|
|
|
|
|
|
|
get_host_ip
|
|
|
|
echo $host_ip
|
|
|
|
|
|
|
|
run crioctl ctr create --config "$TESTDATA"/container_config_hostport.json --pod "$pod_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
ctr_id="$output"
|
|
|
|
run crioctl ctr start --id "$ctr_id"
|
|
|
|
echo "$output"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run nc -w 5 $host_ip 4888
|
|
|
|
echo "$output"
|
|
|
|
[ "$output" = "crioctl_host" ]
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run crioctl ctr stop --id "$ctr_id"
|
|
|
|
echo "$output"
|
|
|
|
cleanup_pods
|
|
|
|
|
|
|
|
stop_crio
|
|
|
|
}
|