Skip to content

Commit

Permalink
tests: Enable macvlan and ipvlan tests
Browse files Browse the repository at this point in the history
Now that macvlan and ipvlan has been merged
kata-containers/runtime#852 and
kata-containers/runtime#506, we
can enable the test to run in our CI.

Fixes kata-containers#899

Signed-off-by: Gabriela Cervantes <[email protected]>
  • Loading branch information
GabyCT committed Nov 13, 2018
1 parent ccaee02 commit 6c8674a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
TIMEOUT := 60

# union for 'make test'
UNION := functional docker crio docker-compose netmon docker-stability openshift kubernetes swarm vm-factory entropy ramdisk
UNION := functional docker crio docker-compose network netmon docker-stability openshift kubernetes swarm vm-factory entropy ramdisk

# skipped test suites for docker integration tests
SKIP :=
Expand Down Expand Up @@ -93,6 +93,7 @@ vm-factory:


network:
systemctl is-active --quiet docker || sudo systemctl start docker
bash -f .ci/install_bats.sh
bats integration/network/macvlan/macvlan_driver.bats
bats integration/network/ipvlan/ipvlan_driver.bats
Expand Down
23 changes: 18 additions & 5 deletions integration/network/ipvlan/ipvlan_driver.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#

load "${BATS_TEST_DIRNAME}/../../../lib/common.bash"
source "/etc/os-release" || "source /usr/lib/os-release"

# Environment variables
IMAGE="debian"
Expand All @@ -19,6 +20,9 @@ PACKET_NUMBER="5"
PAYLOAD="tail -f /dev/null"

setup() {
issue="https://github.com/kata-containers/runtime/issues/906"
[ "${ID}" == "centos" ] && skip "test not working with ${ID} see: ${issue}"

clean_env

# Check that processes are not running
Expand Down Expand Up @@ -51,6 +55,9 @@ setup() {
}

@test "ping container with ipvlan driver with mode l2" {
issue="https://github.com/kata-containers/runtime/issues/906"
[ "${ID}" == "centos" ] && skip "test not working with ${ID} see: ${issue}"

NETWORK_NAME="ipvlan2"
NETWORK_MODE="l2"

Expand All @@ -60,18 +67,21 @@ setup() {

# Run the first container
docker run -d --runtime=kata-runtime --network=${NETWORK_NAME} --ip=${FIRST_IP} \
--name=${FIRST_CONTAINER_NAME} --runtime=runc ${IMAGE} sh -c ${PAYLOAD}
--name=${FIRST_CONTAINER_NAME} --runtime=runc ${IMAGE} ${PAYLOAD}

# Run the second container
docker run -d --runtime=kata-runtime --network=${NETWORK_NAME} --ip=${SECOND_IP} \
--name=${SECOND_CONTAINER_NAME} --runtime=runc ${IMAGE} sh -c ${PAYLOAD}
--name=${SECOND_CONTAINER_NAME} --runtime=runc ${IMAGE} ${PAYLOAD}

# Ping to the first container
run docker exec ${SECOND_CONTAINER_NAME} sh -c "ping -c ${PACKET_NUMBER} ${FIRST_IP}"
[ "$status" -eq 0 ]
}

@test "ping container with ipvlan driver with mode l3" {
issue="https://github.com/kata-containers/runtime/issues/906"
[ "${ID}" == "centos" ] && skip "test not working with ${ID} see: ${issue}"

NETWORK_NAME="ipvlan3"
NETWORK_MODE="l3"

Expand All @@ -81,18 +91,21 @@ setup() {

# Run the first container
docker run -d --runtime=kata-runtime --network=${NETWORK_NAME} --ip=${FIRST_IP} \
--name=${FIRST_CONTAINER_NAME} --runtime=runc ${IMAGE} sh -c ${PAYLOAD}
--name=${FIRST_CONTAINER_NAME} --runtime=runc ${IMAGE} ${PAYLOAD}

# Run the second container
docker run -d --runtime=kata-runtime --network=${NETWORK_NAME} --ip=${SECOND_IP} \
--name=${SECOND_CONTAINER_NAME} --runtime=runc ${IMAGE} sh -c ${PAYLOAD}
--name=${SECOND_CONTAINER_NAME} --runtime=runc ${IMAGE} ${PAYLOAD}

# Ping to the first container
run docker exec ${SECOND_CONTAINER_NAME} sh -c "ping -c ${PACKET_NUMBER} ${FIRST_IP}"
[ "$status" -eq 0 ]
}

teardown() {
issue="https://github.com/kata-containers/runtime/issues/906"
[ "${ID}" == "centos" ] && skip "test not working with ${ID} see: ${issue}"

clean_env

# Remove network
Expand All @@ -101,7 +114,7 @@ teardown() {
# Remove experimental flag
check_which_flag=$(grep -c -x '{"experimental":true}' $docker_configuration_file)
if [ $check_which_flag -eq 1 ]; then
rm -f $docker_configuration_path
rm -rf $docker_configuration_path
else
sed -i 's|"experimental": true,||' $docker_configuration_file
fi
Expand Down
16 changes: 14 additions & 2 deletions integration/network/macvlan/macvlan_driver.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#

load "${BATS_TEST_DIRNAME}/../../../lib/common.bash"
source "/etc/os-release" || "source /usr/lib/os-release"

# Image for macvlan testing
IMAGE="debian"
Expand All @@ -18,8 +19,13 @@ FIRST_CONTAINER_NAME="containerA"
SECOND_CONTAINER_NAME="containerB"
# Number of packets
PACKET_NUMBER="5"
# PAYLOAD
PAYLOAD_ARGS="tail -f /dev/null"

setup () {
issue="https://github.com/kata-containers/runtime/issues/905"
[ "${ID}" == "centos" ] && skip "test not working with ${ID} see: ${issue}"

clean_env

# Check that processes are not running
Expand All @@ -29,14 +35,17 @@ setup () {
}

@test "ping container with macvlan driver" {
issue="https://github.com/kata-containers/runtime/issues/905"
[ "${ID}" == "centos" ] && skip "test not working with ${ID} see: ${issue}"

# Create network
docker network create -d ${NETWORK_DRIVER} ${NETWORK_NAME}

# Run the first container
docker run -d --runtime=${RUNTIME} --network=${NETWORK_NAME} --name=${FIRST_CONTAINER_NAME} ${IMAGE} sh -c "tail -f /dev/null"
docker run -d --runtime=${RUNTIME} --network=${NETWORK_NAME} --name=${FIRST_CONTAINER_NAME} ${IMAGE} ${PAYLOAD_ARGS}

# Verify ip address
ip_address=$(docker inspect --format "{{.NetworkSettings.IPAddress}}" ${FIRST_CONTAINER_NAME})
ip_address=$(docker inspect --format "{{.NetworkSettings.Networks.$NETWORK_NAME.IPAddress}}" ${FIRST_CONTAINER_NAME})
if [ -z "$ip_address" ]; then
echo >&2 "ERROR: Container ip address not found"
exit 1
Expand All @@ -48,6 +57,9 @@ setup () {
}

teardown() {
issue="https://github.com/kata-containers/runtime/issues/905"
[ "${ID}" == "centos" ] && skip "test not working with ${ID} see: ${issue}"

# Remove network
docker network rm ${NETWORK_NAME}

Expand Down

0 comments on commit 6c8674a

Please sign in to comment.