test: Add 2 basic networking tests

We create temporary CNI networking configurations and run 2
functional tests:

- Verify that the networking namespace interface has a valid CIDR
- Ping the networking namespace interface from the host

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Samuel Ortiz 2016-12-17 12:29:27 +01:00
parent c525459000
commit 4c702fb60c
No known key found for this signature in database
GPG key ID: 8A803CDD4F566C4A
2 changed files with 118 additions and 1 deletions

45
test/network.bats Normal file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env bats
load helpers
@test "Check for valid pod netns CIDR" {
# 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
prepare_network_conf $POD_CIDR
start_ocid
run ocic pod run --config "$TESTDATA"/sandbox_config.json
echo "$output"
[ "$status" -eq 0 ]
pod_id="$output"
check_pod_cidr $pod_id
cleanup_pods
cleanup_network_conf
stop_ocid
}
@test "Ping pod netns from the host" {
# 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
prepare_network_conf $POD_CIDR
start_ocid
run ocic pod run --config "$TESTDATA"/sandbox_config.json
echo "$output"
[ "$status" -eq 0 ]
pod_id="$output"
ping_pod $pod_id
cleanup_pods
cleanup_network_conf
stop_ocid
}