Skip to content

Commit

Permalink
Merge pull request kata-containers#592 from chavafg/topic/vsocks-support
Browse files Browse the repository at this point in the history
Add vsock test
  • Loading branch information
Julio Montes authored Aug 22, 2018
2 parents f4f4df9 + 04f4907 commit d65d0e1
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .ci/install_runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export SYSCONFDIR=/etc
# Artifacts (kernel + image) live below here
export SHAREDIR=/usr/share

USE_VSOCK="${USE_VSOCK:-no}"

runtime_config_path="${SYSCONFDIR}/kata-containers/configuration.toml"

PKGDEFAULTSDIR="${SHAREDIR}/defaults/kata-containers"
Expand Down Expand Up @@ -56,6 +58,20 @@ else
sudo sed -i -e '/^initrd =/d' ${runtime_config_path}
fi

if [ "$USE_VSOCK" == "yes" ]; then
echo "Configure use of VSOCK in ${runtime_config_path}"
sudo sed -i -e 's/^#use_vsock.*/use_vsock = true/' "${runtime_config_path}"

vsock_module="vhost_vsock"
echo "Check if ${vsock_module} is loaded"
if lsmod | grep -q "$vsock_module" &> /dev/null ; then
echo "Module ${vsock_module} is already loaded"
else
echo "Load ${vsock_module} module"
sudo modprobe "${vsock_module}"
fi
fi

echo "Add runtime as a new/default Docker runtime. Docker version \"$(docker --version)\" could change according to updates."
docker_options="-D --add-runtime kata-runtime=/usr/local/bin/kata-runtime"

Expand Down
1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type hypervisor struct {
Debug bool `toml:"enable_debug"`
DisableNestingChecks bool `toml:"disable_nesting_checks"`
EnableIOThreads bool `toml:"enable_iothreads"`
Vsock bool `toml:"use_vsock"`
}

type proxy struct {
Expand Down
46 changes: 46 additions & 0 deletions integration/docker/vsock_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) 2018 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0

package docker

import (
. "github.com/kata-containers/tests"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var _ = Describe("vsock test", func() {
var (
args []string
name string
exitCode int
)

BeforeEach(func() {
name = randomDockerName()
})

AfterEach(func() {
Expect(RemoveDockerContainer(name)).To(BeTrue())
Expect(ExistDockerContainer(name)).NotTo(BeTrue())
})

Context("when using vsock", func() {
It("should not create a kata-proxy process", func() {
if !KataConfig.Hypervisor[DefaultHypervisor].Vsock {
Skip("Use of vsock not enabled")
}
args = []string{"--name", name, "-d", Image, "top"}
_, _, exitCode = dockerRun(args...)
Expect(exitCode).To(Equal(0))

ctrID, _, exitCode := dockerInspect("--format", "{{.Id}}", name)
Expect(exitCode).To(Equal(0))

// Check no kata-proxy process is running
Expect(ProxyRunning(ctrID)).To(BeFalse())

})
})
})
25 changes: 22 additions & 3 deletions integration/stability/soak_parallel_rm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ VC_POD_DIR="${VC_POD_DIR:-/var/lib/vc/sbs}"
# then just set this to a very large number
MAX_CONTAINERS="${MAX_CONTAINERS:-110}"

check_vsock_active() {
vsock_configured=$($RUNTIME_PATH kata-env | awk '/UseVSock/ {print $3}')
vsock_supported=$($RUNTIME_PATH kata-env | awk '/SupportVSock/ {print $3}')
if [ "$vsock_configured" == true ] && [ "$vsock_supported" == true ]; then
return 0
else
return 1
fi
}

count_containers() {
docker ps -qa | wc -l
}
Expand All @@ -64,9 +74,18 @@ check_all_running() {
if (( $check_kata_components )); then
# Check we have one proxy per container
how_many_proxys=$(pgrep -a -f ${PROXY_PATH} | wc -l)
if (( ${how_many_running} != ${how_many_proxys} )); then
echo "Wrong number of proxys running (${how_many_running} containers, ${how_many_proxys} proxys) - stopping"
((goterror++))
if check_vsock_active; then
if (( ${how_many_proxys} != 0 )); then
echo "Wrong number of proxys running (${how_many_running} containers, ${how_many_proxys} proxys)"
echo "When using vsocks, the number of proxies should be Zero - stopping"
((goterror++))
fi

else
if (( ${how_many_running} != ${how_many_proxys} )); then
echo "Wrong number of proxys running (${how_many_running} containers, ${how_many_proxys} proxys) - stopping"
((goterror++))
fi
fi

# check we have the right number of shims
Expand Down

0 comments on commit d65d0e1

Please sign in to comment.