Skip to content

Commit

Permalink
test: Add VM cache test
Browse files Browse the repository at this point in the history
This will add a VM cache test, where we will enable this
feature and then we will run a container.

Fixes kata-containers#1259

Signed-off-by: Gabriela Cervantes <[email protected]>
  • Loading branch information
GabyCT committed Aug 5, 2019
1 parent 968dc63 commit 3dc6914
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
77 changes: 77 additions & 0 deletions integration/vm_cache/vm_cache_test.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3dc6914

Please sign in to comment.