From 3dc69140a1aeabe025369d0f42e2c24b641d4e37 Mon Sep 17 00:00:00 2001 From: Gabriela Cervantes Date: Thu, 1 Aug 2019 06:24:31 -0500 Subject: [PATCH] test: Add VM cache test This will add a VM cache test, where we will enable this feature and then we will run a container. Fixes #1259 Signed-off-by: Gabriela Cervantes --- Makefile | 6 +-- integration/vm_cache/vm_cache_test.sh | 77 +++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 3 deletions(-) create mode 100755 integration/vm_cache/vm_cache_test.sh diff --git a/Makefile b/Makefile index 640903d406..59eb0b2378 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,7 @@ ifeq (${CI}, true) endif # union for 'make test' -UNION := functional debug-console $(DOCKER_DEPENDENCY) openshift crio docker-compose network \ - docker-stability oci netmon kubernetes swarm vm-factory \ - entropy ramdisk shimv2 tracing time-drift +UNION := functional vm-cache # filter scheme script for docker integration test suites FILTER_FILE = .ci/filter/filter_docker_test.sh @@ -150,6 +148,8 @@ pentest: vm-factory: bash -f integration/vm_factory/vm_templating_test.sh +vm-cache: + bash -f integration/vm_cache/vm_cache_test.sh network: systemctl is-active --quiet docker || sudo systemctl start docker diff --git a/integration/vm_cache/vm_cache_test.sh b/integration/vm_cache/vm_cache_test.sh new file mode 100755 index 0000000000..410adbb8bd --- /dev/null +++ b/integration/vm_cache/vm_cache_test.sh @@ -0,0 +1,77 @@ +#!/bin/bash +# +# Copyright (c) 2019 Intel Corporation. +# +# SPDX-License-Identifier: Apache-2.0 +# +# This test will perform several tests to validate kata containers with +# vm cache. + +set -e + +cidir=$(dirname "$0") + +source "${cidir}/../../metrics/lib/common.bash" + +# Environment variables +IMAGE="${IMAGE:-busybox}" +PAYLOAD_ARGS="${PAYLOAD_ARGS:-tail -f /dev/null}" +kata_runtime_bin=$(command -v kata-runtime) + +if [ -z $INITRD_PATH ]; then + echo "Skipping vm templating test as initrd is not set" + exit 0 +fi + +enable_vm_cache_config() { + echo "enable vm cache config" + sudo sed -i 's/#vm_cache_number = 0/vm_cache_number = 1/g' "${RUNTIME_CONFIG_PATH}" + sudo sed -i -e 's/^#\(use_vsock\).*=.*$/\1 = true/g' "${RUNTIME_CONFIG_PATH}" +} + +disable_vm_cache_config() { + echo "disable vm cache config" + sudo sed -i 's/vm_cache_number = 1/#vm_cache_number = 0/g' "${RUNTIME_CONFIG_PATH}" + sudo sed -i -e 's/^\(use_vsock\).*=.*$/#\1 = true/g' "${RUNTIME_CONFIG_PATH}" +} + +init_vm_template() { + sudo sed -i -e 's/^#enable_template.*$/enable_template = true/g' "${RUNTIME_CONFIG_PATH}" + echo "init vm template" + sudo -E PATH=$PATH "$kata_runtime_bin" factory init & + pid=$! + sudo kill -9 $pid +} + +destroy_vm_template() { + echo "destroy vm template" + sudo -E PATH=$PATH "$kata_runtime_bin" factory destroy +} + +setup() { + clean_env + extract_kata_env + enable_vm_cache_config + init_vm_template +} + +test_docker_vm_cache() { + docker run -d --runtime $RUNTIME $IMAGE $PAYLOAD_ARGS + check_initrd=$(ps aux | grep ${HYPERVISOR_PATH} | grep initrd) + [ ! -z "${check_initrd}" ] || die "vm cache not running properly" +} + +teardown() { + clean_env + disable_vm_cache_config +} + + +echo "Starting vm cache test" +setup + +echo "Running vm cache test" +test_docker_vm_cache + +echo "Ending vm cache test" +teardown