mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-06 20:09:44 +00:00
Merge pull request #72 from jodh-intel/fix-lint-errors
Fix lint errors & get virtcontainers tests running
This commit is contained in:
commit
c8e0c2cc85
@ -1,99 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Copyright (c) 2018 Intel Corporation
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Perform static go tests.
|
|
||||||
|
|
||||||
function usage {
|
|
||||||
echo "Usage $0 [OPTIONS] [PACKAGES]"
|
|
||||||
echo "Perform static go checks on PACKAGES (./... by default)."
|
|
||||||
echo
|
|
||||||
echo "List of options:"
|
|
||||||
echo " -h, --help print this help"
|
|
||||||
echo " -n, --no-network do not access the network"
|
|
||||||
}
|
|
||||||
|
|
||||||
for i in "$@"; do
|
|
||||||
case $i in
|
|
||||||
-h|--help)
|
|
||||||
usage
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
-n|--no-network)
|
|
||||||
NONETWORK=1
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
args="$args $i"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
go_packages=$args
|
|
||||||
|
|
||||||
[ -z "$go_packages" ] && {
|
|
||||||
go_packages=$(go list ./... | grep -v vendor)
|
|
||||||
}
|
|
||||||
|
|
||||||
function install_package {
|
|
||||||
url="$1"
|
|
||||||
name=${url##*/}
|
|
||||||
|
|
||||||
if [ -n "$NONETWORK" ]; then
|
|
||||||
echo "Skipping updating package $name, no network access allowed"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo Updating $name...
|
|
||||||
go get -u $url
|
|
||||||
}
|
|
||||||
|
|
||||||
install_package github.com/fzipp/gocyclo
|
|
||||||
install_package github.com/client9/misspell/cmd/misspell
|
|
||||||
install_package github.com/golang/lint/golint
|
|
||||||
install_package github.com/gordonklaus/ineffassign
|
|
||||||
install_package github.com/opennota/check/cmd/structcheck
|
|
||||||
install_package honnef.co/go/tools/cmd/unused
|
|
||||||
install_package honnef.co/go/tools/cmd/staticcheck
|
|
||||||
|
|
||||||
echo Doing go static checks on packages: $go_packages
|
|
||||||
|
|
||||||
echo "Running misspell..."
|
|
||||||
go list -f '{{.Dir}}/*.go' $go_packages |\
|
|
||||||
xargs -I % bash -c "misspell -error %"
|
|
||||||
|
|
||||||
echo "Running go vet..."
|
|
||||||
go vet $go_packages
|
|
||||||
|
|
||||||
cmd="gofmt -s -d -l"
|
|
||||||
echo "Running gofmt..."
|
|
||||||
|
|
||||||
# Note: ignore git directory in case any refs end in ".go" too.
|
|
||||||
diff=$(find . -not -wholename '*/vendor/*' -not -wholename '*/.git/*' -name '*.go' | \
|
|
||||||
xargs $cmd)
|
|
||||||
if [ -n "$diff" -a $(echo "$diff" | wc -l) -ne 0 ]
|
|
||||||
then
|
|
||||||
echo 2>&1 "ERROR: '$cmd' found problems:"
|
|
||||||
echo 2>&1 "$diff"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Running cyclo..."
|
|
||||||
gocyclo -over 15 `go list -f '{{.Dir}}/*.go' $go_packages`
|
|
||||||
|
|
||||||
echo "Running golint..."
|
|
||||||
for p in $go_packages; do golint -set_exit_status $p; done
|
|
||||||
|
|
||||||
echo "Running ineffassign..."
|
|
||||||
go list -f '{{.Dir}}' $go_packages | xargs -L 1 ineffassign
|
|
||||||
|
|
||||||
for tool in structcheck unused staticcheck
|
|
||||||
do
|
|
||||||
echo "Running ${tool}..."
|
|
||||||
eval "$tool" "$go_packages"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "All Good!"
|
|
@ -14,3 +14,9 @@ clone_tests_repo
|
|||||||
pushd "${tests_repo_dir}"
|
pushd "${tests_repo_dir}"
|
||||||
.ci/setup.sh
|
.ci/setup.sh
|
||||||
popd
|
popd
|
||||||
|
|
||||||
|
echo "Setup virtcontainers environment"
|
||||||
|
chronic sudo -E PATH=$PATH bash -c "${cidir}/../virtcontainers/utils/virtcontainers-setup.sh"
|
||||||
|
|
||||||
|
echo "Install virtcontainers"
|
||||||
|
make -C "${cidir}/../virtcontainers" && chronic sudo make -C "${cidir}/../virtcontainers" install
|
||||||
|
@ -374,7 +374,7 @@ check-go-test: $(GENERATED_FILES)
|
|||||||
$(QUIET_TEST)$(MAKEFILE_DIR)/../.ci/go-test.sh
|
$(QUIET_TEST)$(MAKEFILE_DIR)/../.ci/go-test.sh
|
||||||
|
|
||||||
check-go-static:
|
check-go-static:
|
||||||
$(QUIET_CHECK)$(MAKEFILE_DIR)/../.ci/go-static-checks.sh $(GO_STATIC_CHECKS_ARGS)
|
$(QUIET_CHECK)$(MAKEFILE_DIR)/../.ci/static-checks.sh
|
||||||
$(QUIET_CHECK)$(MAKEFILE_DIR)/../.ci/go-no-os-exit.sh
|
$(QUIET_CHECK)$(MAKEFILE_DIR)/../.ci/go-no-os-exit.sh
|
||||||
|
|
||||||
coverage:
|
coverage:
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
@ -301,9 +301,9 @@ func TestCreateCLIFunctionCreateFail(t *testing.T) {
|
|||||||
func TestCreateInvalidArgs(t *testing.T) {
|
func TestCreateInvalidArgs(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
MockContainers: []*vcMock.Container{
|
MockContainers: []*vcmock.Container{
|
||||||
{MockID: testContainerID},
|
{MockID: testContainerID},
|
||||||
{MockID: testContainerID},
|
{MockID: testContainerID},
|
||||||
{MockID: testContainerID},
|
{MockID: testContainerID},
|
||||||
@ -401,7 +401,7 @@ func TestCreateInvalidConfigJSON(t *testing.T) {
|
|||||||
for detach := range []bool{true, false} {
|
for detach := range []bool{true, false} {
|
||||||
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
||||||
assert.Errorf(err, "%+v", detach)
|
assert.Errorf(err, "%+v", detach)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,7 +448,7 @@ func TestCreateInvalidContainerType(t *testing.T) {
|
|||||||
for detach := range []bool{true, false} {
|
for detach := range []bool{true, false} {
|
||||||
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
||||||
assert.Errorf(err, "%+v", detach)
|
assert.Errorf(err, "%+v", detach)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,16 +496,16 @@ func TestCreateContainerInvalid(t *testing.T) {
|
|||||||
for detach := range []bool{true, false} {
|
for detach := range []bool{true, false} {
|
||||||
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
||||||
assert.Errorf(err, "%+v", detach)
|
assert.Errorf(err, "%+v", detach)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateProcessCgroupsPathSuccessful(t *testing.T) {
|
func TestCreateProcessCgroupsPathSuccessful(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
MockContainers: []*vcMock.Container{
|
MockContainers: []*vcmock.Container{
|
||||||
{MockID: testContainerID},
|
{MockID: testContainerID},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -598,9 +598,9 @@ func TestCreateCreateCgroupsFilesFail(t *testing.T) {
|
|||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
MockContainers: []*vcMock.Container{
|
MockContainers: []*vcmock.Container{
|
||||||
{MockID: testContainerID},
|
{MockID: testContainerID},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -671,7 +671,7 @@ func TestCreateCreateCgroupsFilesFail(t *testing.T) {
|
|||||||
for detach := range []bool{true, false} {
|
for detach := range []bool{true, false} {
|
||||||
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
||||||
assert.Errorf(err, "%+v", detach)
|
assert.Errorf(err, "%+v", detach)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,9 +683,9 @@ func TestCreateCreateCreatePidFileFail(t *testing.T) {
|
|||||||
|
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
MockContainers: []*vcMock.Container{
|
MockContainers: []*vcmock.Container{
|
||||||
{MockID: testContainerID},
|
{MockID: testContainerID},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -747,16 +747,16 @@ func TestCreateCreateCreatePidFileFail(t *testing.T) {
|
|||||||
for detach := range []bool{true, false} {
|
for detach := range []bool{true, false} {
|
||||||
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
||||||
assert.Errorf(err, "%+v", detach)
|
assert.Errorf(err, "%+v", detach)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreate(t *testing.T) {
|
func TestCreate(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
MockContainers: []*vcMock.Container{
|
MockContainers: []*vcmock.Container{
|
||||||
{MockID: testContainerID},
|
{MockID: testContainerID},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -873,7 +873,7 @@ func TestCreateInvalidKernelParams(t *testing.T) {
|
|||||||
for detach := range []bool{true, false} {
|
for detach := range []bool{true, false} {
|
||||||
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
err := create(testContainerID, bundlePath, testConsole, pidFilePath, true, runtimeConfig)
|
||||||
assert.Errorf(err, "%+v", detach)
|
assert.Errorf(err, "%+v", detach)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -921,7 +921,7 @@ func TestCreateCreatePodPodConfigFail(t *testing.T) {
|
|||||||
|
|
||||||
_, err = createPod(spec, runtimeConfig, testContainerID, bundlePath, testConsole, true)
|
_, err = createPod(spec, runtimeConfig, testContainerID, bundlePath, testConsole, true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateCreatePodFail(t *testing.T) {
|
func TestCreateCreatePodFail(t *testing.T) {
|
||||||
@ -956,7 +956,7 @@ func TestCreateCreatePodFail(t *testing.T) {
|
|||||||
|
|
||||||
_, err = createPod(spec, runtimeConfig, testContainerID, bundlePath, testConsole, true)
|
_, err = createPod(spec, runtimeConfig, testContainerID, bundlePath, testConsole, true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateCreateContainerContainerConfigFail(t *testing.T) {
|
func TestCreateCreateContainerContainerConfigFail(t *testing.T) {
|
||||||
@ -998,7 +998,7 @@ func TestCreateCreateContainerContainerConfigFail(t *testing.T) {
|
|||||||
for _, disableOutput := range []bool{true, false} {
|
for _, disableOutput := range []bool{true, false} {
|
||||||
_, err = createContainer(spec, testContainerID, bundlePath, testConsole, disableOutput)
|
_, err = createContainer(spec, testContainerID, bundlePath, testConsole, disableOutput)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
assert.True(strings.Contains(err.Error(), containerType))
|
assert.True(strings.Contains(err.Error(), containerType))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1042,7 +1042,7 @@ func TestCreateCreateContainerFail(t *testing.T) {
|
|||||||
for _, disableOutput := range []bool{true, false} {
|
for _, disableOutput := range []bool{true, false} {
|
||||||
_, err = createContainer(spec, testContainerID, bundlePath, testConsole, disableOutput)
|
_, err = createContainer(spec, testContainerID, bundlePath, testConsole, disableOutput)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1055,7 +1055,7 @@ func TestCreateCreateContainer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testingImpl.CreateContainerFunc = func(podID string, containerConfig vc.ContainerConfig) (vc.VCPod, vc.VCContainer, error) {
|
testingImpl.CreateContainerFunc = func(podID string, containerConfig vc.ContainerConfig) (vc.VCPod, vc.VCContainer, error) {
|
||||||
return &vcMock.Pod{}, &vcMock.Container{}, nil
|
return &vcmock.Pod{}, &vcmock.Container{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -61,12 +61,12 @@ func TestDeleteInvalidContainer(t *testing.T) {
|
|||||||
// Missing container id
|
// Missing container id
|
||||||
err := delete("", false)
|
err := delete("", false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
// Mock Listpod error
|
// Mock Listpod error
|
||||||
err = delete(testContainerID, false)
|
err = delete(testContainerID, false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) {
|
testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) {
|
||||||
return []vc.PodStatus{}, nil
|
return []vc.PodStatus{}, nil
|
||||||
@ -79,13 +79,13 @@ func TestDeleteInvalidContainer(t *testing.T) {
|
|||||||
// Container missing in ListPod
|
// Container missing in ListPod
|
||||||
err = delete(testContainerID, false)
|
err = delete(testContainerID, false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteMissingContainerTypeAnnotation(t *testing.T) {
|
func TestDeleteMissingContainerTypeAnnotation(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,13 +109,13 @@ func TestDeleteMissingContainerTypeAnnotation(t *testing.T) {
|
|||||||
|
|
||||||
err := delete(pod.ID(), false)
|
err := delete(pod.ID(), false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteInvalidConfig(t *testing.T) {
|
func TestDeleteInvalidConfig(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ func TestDeleteInvalidConfig(t *testing.T) {
|
|||||||
|
|
||||||
err := delete(pod.ID(), false)
|
err := delete(pod.ID(), false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testConfigSetup(t *testing.T) string {
|
func testConfigSetup(t *testing.T) string {
|
||||||
@ -165,7 +165,7 @@ func testConfigSetup(t *testing.T) string {
|
|||||||
func TestDeletePod(t *testing.T) {
|
func TestDeletePod(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ func TestDeletePod(t *testing.T) {
|
|||||||
|
|
||||||
err = delete(pod.ID(), false)
|
err = delete(pod.ID(), false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.StopPodFunc = func(podID string) (vc.VCPod, error) {
|
testingImpl.StopPodFunc = func(podID string) (vc.VCPod, error) {
|
||||||
return pod, nil
|
return pod, nil
|
||||||
@ -211,7 +211,7 @@ func TestDeletePod(t *testing.T) {
|
|||||||
|
|
||||||
err = delete(pod.ID(), false)
|
err = delete(pod.ID(), false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.DeletePodFunc = func(podID string) (vc.VCPod, error) {
|
testingImpl.DeletePodFunc = func(podID string) (vc.VCPod, error) {
|
||||||
return pod, nil
|
return pod, nil
|
||||||
@ -228,7 +228,7 @@ func TestDeletePod(t *testing.T) {
|
|||||||
func TestDeleteInvalidContainerType(t *testing.T) {
|
func TestDeleteInvalidContainerType(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,13 +263,13 @@ func TestDeleteInvalidContainerType(t *testing.T) {
|
|||||||
// Delete an invalid container type
|
// Delete an invalid container type
|
||||||
err = delete(pod.ID(), false)
|
err = delete(pod.ID(), false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeletePodRunning(t *testing.T) {
|
func TestDeletePodRunning(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ func TestDeletePodRunning(t *testing.T) {
|
|||||||
// Delete on a running pod should fail
|
// Delete on a running pod should fail
|
||||||
err = delete(pod.ID(), false)
|
err = delete(pod.ID(), false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.StopPodFunc = func(podID string) (vc.VCPod, error) {
|
testingImpl.StopPodFunc = func(podID string) (vc.VCPod, error) {
|
||||||
return pod, nil
|
return pod, nil
|
||||||
@ -317,7 +317,7 @@ func TestDeletePodRunning(t *testing.T) {
|
|||||||
// Force delete a running pod
|
// Force delete a running pod
|
||||||
err = delete(pod.ID(), true)
|
err = delete(pod.ID(), true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.DeletePodFunc = func(podID string) (vc.VCPod, error) {
|
testingImpl.DeletePodFunc = func(podID string) (vc.VCPod, error) {
|
||||||
return pod, nil
|
return pod, nil
|
||||||
@ -334,11 +334,11 @@ func TestDeletePodRunning(t *testing.T) {
|
|||||||
func TestDeleteRunningContainer(t *testing.T) {
|
func TestDeleteRunningContainer(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
MockPod: pod,
|
MockPod: pod,
|
||||||
@ -376,12 +376,12 @@ func TestDeleteRunningContainer(t *testing.T) {
|
|||||||
// Delete on a running container should fail.
|
// Delete on a running container should fail.
|
||||||
err = delete(pod.MockContainers[0].ID(), false)
|
err = delete(pod.MockContainers[0].ID(), false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
// force delete
|
// force delete
|
||||||
err = delete(pod.MockContainers[0].ID(), true)
|
err = delete(pod.MockContainers[0].ID(), true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.StopContainerFunc = testStopContainerFuncReturnNil
|
testingImpl.StopContainerFunc = testStopContainerFuncReturnNil
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -390,10 +390,10 @@ func TestDeleteRunningContainer(t *testing.T) {
|
|||||||
|
|
||||||
err = delete(pod.MockContainers[0].ID(), true)
|
err = delete(pod.MockContainers[0].ID(), true)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.DeleteContainerFunc = func(podID, containerID string) (vc.VCContainer, error) {
|
testingImpl.DeleteContainerFunc = func(podID, containerID string) (vc.VCContainer, error) {
|
||||||
return &vcMock.Container{}, nil
|
return &vcmock.Container{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -407,11 +407,11 @@ func TestDeleteRunningContainer(t *testing.T) {
|
|||||||
func TestDeleteContainer(t *testing.T) {
|
func TestDeleteContainer(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
MockPod: pod,
|
MockPod: pod,
|
||||||
@ -448,7 +448,7 @@ func TestDeleteContainer(t *testing.T) {
|
|||||||
|
|
||||||
err = delete(pod.MockContainers[0].ID(), false)
|
err = delete(pod.MockContainers[0].ID(), false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.StopContainerFunc = testStopContainerFuncReturnNil
|
testingImpl.StopContainerFunc = testStopContainerFuncReturnNil
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -457,10 +457,10 @@ func TestDeleteContainer(t *testing.T) {
|
|||||||
|
|
||||||
err = delete(pod.MockContainers[0].ID(), false)
|
err = delete(pod.MockContainers[0].ID(), false)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.DeleteContainerFunc = func(podID, containerID string) (vc.VCContainer, error) {
|
testingImpl.DeleteContainerFunc = func(podID, containerID string) (vc.VCContainer, error) {
|
||||||
return &vcMock.Container{}, nil
|
return &vcmock.Container{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -485,7 +485,7 @@ func TestDeleteCLIFunction(t *testing.T) {
|
|||||||
// no container id in the Metadata
|
// no container id in the Metadata
|
||||||
err := fn(ctx)
|
err := fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError)
|
flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError)
|
||||||
flagSet.Parse([]string{"xyz"})
|
flagSet.Parse([]string{"xyz"})
|
||||||
@ -493,17 +493,17 @@ func TestDeleteCLIFunction(t *testing.T) {
|
|||||||
|
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDeleteCLIFunctionSuccess(t *testing.T) {
|
func TestDeleteCLIFunctionSuccess(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
MockPod: pod,
|
MockPod: pod,
|
||||||
@ -558,7 +558,7 @@ func TestDeleteCLIFunctionSuccess(t *testing.T) {
|
|||||||
|
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError)
|
flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError)
|
||||||
flagSet.Parse([]string{pod.ID()})
|
flagSet.Parse([]string{pod.ID()})
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -43,7 +43,7 @@ func TestExecCLIFunction(t *testing.T) {
|
|||||||
// no container-id in the Metadata
|
// no container-id in the Metadata
|
||||||
err := fn(ctx)
|
err := fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
// pass container-id
|
// pass container-id
|
||||||
flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError)
|
flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError)
|
||||||
@ -52,7 +52,7 @@ func TestExecCLIFunction(t *testing.T) {
|
|||||||
|
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecuteErrors(t *testing.T) {
|
func TestExecuteErrors(t *testing.T) {
|
||||||
@ -64,13 +64,13 @@ func TestExecuteErrors(t *testing.T) {
|
|||||||
// missing container id
|
// missing container id
|
||||||
err := execute(ctx)
|
err := execute(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
// ListPod error
|
// ListPod error
|
||||||
flagSet.Parse([]string{testContainerID})
|
flagSet.Parse([]string{testContainerID})
|
||||||
err = execute(ctx)
|
err = execute(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
// Config path missing in annotations
|
// Config path missing in annotations
|
||||||
annotations := map[string]string{
|
annotations := map[string]string{
|
||||||
@ -87,7 +87,7 @@ func TestExecuteErrors(t *testing.T) {
|
|||||||
|
|
||||||
err = execute(ctx)
|
err = execute(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
// Container not running
|
// Container not running
|
||||||
configPath := testConfigSetup(t)
|
configPath := testConfigSetup(t)
|
||||||
@ -109,7 +109,7 @@ func TestExecuteErrors(t *testing.T) {
|
|||||||
|
|
||||||
err = execute(ctx)
|
err = execute(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecuteErrorReadingProcessJson(t *testing.T) {
|
func TestExecuteErrorReadingProcessJson(t *testing.T) {
|
||||||
@ -154,7 +154,7 @@ func TestExecuteErrorReadingProcessJson(t *testing.T) {
|
|||||||
|
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecuteErrorOpeningConsole(t *testing.T) {
|
func TestExecuteErrorOpeningConsole(t *testing.T) {
|
||||||
@ -198,7 +198,7 @@ func TestExecuteErrorOpeningConsole(t *testing.T) {
|
|||||||
|
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testExecParamsSetup(t *testing.T, pidFilePath, consolePath string, detach bool) *flag.FlagSet {
|
func testExecParamsSetup(t *testing.T, pidFilePath, consolePath string, detach bool) *flag.FlagSet {
|
||||||
@ -260,10 +260,10 @@ func TestExecuteWithFlags(t *testing.T) {
|
|||||||
// EnterContainer error
|
// EnterContainer error
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.EnterContainerFunc = func(podID, containerID string, cmd vc.Cmd) (vc.VCPod, vc.VCContainer, *vc.Process, error) {
|
testingImpl.EnterContainerFunc = func(podID, containerID string, cmd vc.Cmd) (vc.VCPod, vc.VCContainer, *vc.Process, error) {
|
||||||
return &vcMock.Pod{}, &vcMock.Container{}, &vc.Process{}, nil
|
return &vcmock.Pod{}, &vcmock.Container{}, &vc.Process{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -274,7 +274,7 @@ func TestExecuteWithFlags(t *testing.T) {
|
|||||||
// Process not running error
|
// Process not running error
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
os.Remove(pidFilePath)
|
os.Remove(pidFilePath)
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ func TestExecuteWithFlags(t *testing.T) {
|
|||||||
|
|
||||||
vcProcess := vc.Process{}
|
vcProcess := vc.Process{}
|
||||||
vcProcess.Pid = command.Process.Pid
|
vcProcess.Pid = command.Process.Pid
|
||||||
return &vcMock.Pod{}, &vcMock.Container{}, &vcProcess, nil
|
return &vcmock.Pod{}, &vcmock.Container{}, &vcProcess, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -347,7 +347,7 @@ func TestExecuteWithFlagsDetached(t *testing.T) {
|
|||||||
|
|
||||||
vcProcess := vc.Process{}
|
vcProcess := vc.Process{}
|
||||||
vcProcess.Pid = command.Process.Pid
|
vcProcess.Pid = command.Process.Pid
|
||||||
return &vcMock.Pod{}, &vcMock.Container{}, &vcProcess, nil
|
return &vcmock.Pod{}, &vcmock.Container{}, &vcProcess, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -417,7 +417,7 @@ func TestExecuteWithInvalidProcessJson(t *testing.T) {
|
|||||||
|
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestExecuteWithValidProcessJson(t *testing.T) {
|
func TestExecuteWithValidProcessJson(t *testing.T) {
|
||||||
@ -499,7 +499,7 @@ func TestExecuteWithValidProcessJson(t *testing.T) {
|
|||||||
vcProcess := vc.Process{}
|
vcProcess := vc.Process{}
|
||||||
vcProcess.Pid = command.Process.Pid
|
vcProcess.Pid = command.Process.Pid
|
||||||
|
|
||||||
return &vcMock.Pod{}, &vcMock.Container{}, &vcProcess, nil
|
return &vcmock.Pod{}, &vcmock.Container{}, &vcProcess, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -572,7 +572,7 @@ func TestExecuteWithInvalidEnvironment(t *testing.T) {
|
|||||||
// vcAnnotations.EnvVars error due to incorrect environment
|
// vcAnnotations.EnvVars error due to incorrect environment
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenerateExecParams(t *testing.T) {
|
func TestGenerateExecParams(t *testing.T) {
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
testStopContainerFuncReturnNil = func(podID, containerID string) (vc.VCContainer, error) {
|
testStopContainerFuncReturnNil = func(podID, containerID string) (vc.VCContainer, error) {
|
||||||
return &vcMock.Container{}, nil
|
return &vcmock.Container{}, nil
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -395,7 +395,7 @@ func TestListGetContainersListPodFail(t *testing.T) {
|
|||||||
|
|
||||||
_, err = getContainers(ctx)
|
_, err = getContainers(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestListGetContainers(t *testing.T) {
|
func TestListGetContainers(t *testing.T) {
|
||||||
@ -433,7 +433,7 @@ func TestListGetContainers(t *testing.T) {
|
|||||||
func TestListGetContainersPodWithoutContainers(t *testing.T) {
|
func TestListGetContainersPodWithoutContainers(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,7 +477,7 @@ func TestListGetContainersPodWithContainer(t *testing.T) {
|
|||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
defer os.RemoveAll(tmpdir)
|
defer os.RemoveAll(tmpdir)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,7 +550,7 @@ func TestListCLIFunctionFormatFail(t *testing.T) {
|
|||||||
{"invalid", invalidFlags},
|
{"invalid", invalidFlags},
|
||||||
}
|
}
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -621,7 +621,7 @@ func TestListCLIFunctionFormatFail(t *testing.T) {
|
|||||||
|
|
||||||
// invalid output file
|
// invalid output file
|
||||||
assert.Error(err, d)
|
assert.Error(err, d)
|
||||||
assert.False(vcMock.IsMockError(err), d)
|
assert.False(vcmock.IsMockError(err), d)
|
||||||
|
|
||||||
output := filepath.Join(tmpdir, "output")
|
output := filepath.Join(tmpdir, "output")
|
||||||
f, err := os.OpenFile(output, os.O_WRONLY|os.O_CREATE, testFileMode)
|
f, err := os.OpenFile(output, os.O_WRONLY|os.O_CREATE, testFileMode)
|
||||||
@ -634,7 +634,7 @@ func TestListCLIFunctionFormatFail(t *testing.T) {
|
|||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
if d.format == "invalid" {
|
if d.format == "invalid" {
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err), d)
|
assert.False(vcmock.IsMockError(err), d)
|
||||||
} else {
|
} else {
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
}
|
}
|
||||||
@ -651,7 +651,7 @@ func TestListCLIFunctionQuiet(t *testing.T) {
|
|||||||
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
runtimeConfig, err := newTestRuntimeConfig(tmpdir, testConsole, true)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import (
|
|||||||
"github.com/dlespiau/covertool/pkg/cover"
|
"github.com/dlespiau/covertool/pkg/cover"
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
@ -62,7 +62,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// testingImpl is a concrete mock RVC implementation used for testing
|
// testingImpl is a concrete mock RVC implementation used for testing
|
||||||
var testingImpl = &vcMock.VCMock{}
|
var testingImpl = &vcmock.VCMock{}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if version == "" {
|
if version == "" {
|
||||||
|
@ -29,7 +29,7 @@ import (
|
|||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/opencontainers/runc/libcontainer/utils"
|
"github.com/opencontainers/runc/libcontainer/utils"
|
||||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -83,7 +83,7 @@ func TestGetContainerInfoContainerIDEmptyFailure(t *testing.T) {
|
|||||||
func TestGetContainerInfo(t *testing.T) {
|
func TestGetContainerInfo(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ func TestGetContainerInfo(t *testing.T) {
|
|||||||
func TestGetContainerInfoMismatch(t *testing.T) {
|
func TestGetContainerInfoMismatch(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ func TestValidCreateParamsContainerIDEmptyFailure(t *testing.T) {
|
|||||||
_, err := validCreateParams("", "")
|
_, err := validCreateParams("", "")
|
||||||
|
|
||||||
assert.Error(err, "This test should fail because containerID is empty")
|
assert.Error(err, "This test should fail because containerID is empty")
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetExistingContainerInfoContainerIDEmptyFailure(t *testing.T) {
|
func TestGetExistingContainerInfoContainerIDEmptyFailure(t *testing.T) {
|
||||||
@ -170,7 +170,7 @@ func TestValidCreateParamsContainerIDNotUnique(t *testing.T) {
|
|||||||
|
|
||||||
containerID := testContainerID + testContainerID
|
containerID := testContainerID + testContainerID
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ func TestValidCreateParamsContainerIDNotUnique(t *testing.T) {
|
|||||||
_, err := validCreateParams(testContainerID, "")
|
_, err := validCreateParams(testContainerID, "")
|
||||||
|
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidCreateParamsContainerIDNotUnique2(t *testing.T) {
|
func TestValidCreateParamsContainerIDNotUnique2(t *testing.T) {
|
||||||
@ -212,7 +212,7 @@ func TestValidCreateParamsContainerIDNotUnique2(t *testing.T) {
|
|||||||
|
|
||||||
containerID := testContainerID + testContainerID
|
containerID := testContainerID + testContainerID
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +238,7 @@ func TestValidCreateParamsContainerIDNotUnique2(t *testing.T) {
|
|||||||
|
|
||||||
_, err := validCreateParams(testContainerID, "")
|
_, err := validCreateParams(testContainerID, "")
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidCreateParamsInvalidBundle(t *testing.T) {
|
func TestValidCreateParamsInvalidBundle(t *testing.T) {
|
||||||
@ -261,7 +261,7 @@ func TestValidCreateParamsInvalidBundle(t *testing.T) {
|
|||||||
_, err = validCreateParams(testContainerID, bundlePath)
|
_, err = validCreateParams(testContainerID, bundlePath)
|
||||||
// bundle is ENOENT
|
// bundle is ENOENT
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestValidCreateParamsBundleIsAFile(t *testing.T) {
|
func TestValidCreateParamsBundleIsAFile(t *testing.T) {
|
||||||
@ -286,7 +286,7 @@ func TestValidCreateParamsBundleIsAFile(t *testing.T) {
|
|||||||
_, err = validCreateParams(testContainerID, bundlePath)
|
_, err = validCreateParams(testContainerID, bundlePath)
|
||||||
// bundle exists as a file, not a directory
|
// bundle exists as a file, not a directory
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testProcessCgroupsPath(t *testing.T, ociSpec oci.CompatOCISpec, expected []string) {
|
func testProcessCgroupsPath(t *testing.T, ociSpec oci.CompatOCISpec, expected []string) {
|
||||||
@ -565,7 +565,7 @@ func TestProcessCgroupsPathForResource(t *testing.T) {
|
|||||||
for _, isPod := range []bool{true, false} {
|
for _, isPod := range []bool{true, false} {
|
||||||
_, err := processCgroupsPathForResource(spec, "", isPod)
|
_, err := processCgroupsPathForResource(spec, "", isPod)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,17 +19,17 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testPausePodFuncReturnNil = func(podID string) (vc.VCPod, error) {
|
testPausePodFuncReturnNil = func(podID string) (vc.VCPod, error) {
|
||||||
return &vcMock.Pod{}, nil
|
return &vcmock.Pod{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
testResumePodFuncReturnNil = func(podID string) (vc.VCPod, error) {
|
testResumePodFuncReturnNil = func(podID string) (vc.VCPod, error) {
|
||||||
return &vcMock.Pod{}, nil
|
return &vcmock.Pod{}, nil
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -45,11 +45,11 @@ func TestPSCLIAction(t *testing.T) {
|
|||||||
func TestPSFailure(t *testing.T) {
|
func TestPSFailure(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: pod.ID(),
|
MockID: pod.ID(),
|
||||||
MockPod: pod,
|
MockPod: pod,
|
||||||
@ -89,11 +89,11 @@ func TestPSFailure(t *testing.T) {
|
|||||||
func TestPSSuccessful(t *testing.T) {
|
func TestPSSuccessful(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: pod.ID(),
|
MockID: pod.ID(),
|
||||||
MockPod: pod,
|
MockPod: pod,
|
||||||
|
@ -26,7 +26,7 @@ import (
|
|||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -67,9 +67,9 @@ func TestRunCliAction(t *testing.T) {
|
|||||||
func TestRunInvalidArgs(t *testing.T) {
|
func TestRunInvalidArgs(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
MockContainers: []*vcMock.Container{
|
MockContainers: []*vcmock.Container{
|
||||||
{MockID: testContainerID},
|
{MockID: testContainerID},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ type runContainerData struct {
|
|||||||
consolePath string
|
consolePath string
|
||||||
bundlePath string
|
bundlePath string
|
||||||
configJSON string
|
configJSON string
|
||||||
pod *vcMock.Pod
|
pod *vcmock.Pod
|
||||||
runtimeConfig oci.RuntimeConfig
|
runtimeConfig oci.RuntimeConfig
|
||||||
process *os.Process
|
process *os.Process
|
||||||
tmpDir string
|
tmpDir string
|
||||||
@ -196,11 +196,11 @@ func testRunContainerSetup(t *testing.T) runContainerData {
|
|||||||
configPath := filepath.Join(bundlePath, specConfig)
|
configPath := filepath.Join(bundlePath, specConfig)
|
||||||
|
|
||||||
// pod id and container id must be the same otherwise delete will not works
|
// pod id and container id must be the same otherwise delete will not works
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
MockPid: cmd.Process.Pid,
|
MockPid: cmd.Process.Pid,
|
||||||
@ -599,11 +599,11 @@ func TestRunContainerStartFailNoContainers(t *testing.T) {
|
|||||||
d := testRunContainerSetup(t)
|
d := testRunContainerSetup(t)
|
||||||
defer os.RemoveAll(d.tmpDir)
|
defer os.RemoveAll(d.tmpDir)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
MockPod: pod,
|
MockPod: pod,
|
||||||
@ -651,5 +651,5 @@ func TestRunContainerStartFailNoContainers(t *testing.T) {
|
|||||||
|
|
||||||
err := run(d.pod.ID(), d.bundlePath, d.consolePath, "", d.pidFilePath, false, d.runtimeConfig)
|
err := run(d.pod.ID(), d.bundlePath, d.consolePath, "", d.pidFilePath, false, d.runtimeConfig)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -31,12 +31,12 @@ func TestStartInvalidArgs(t *testing.T) {
|
|||||||
// Missing container id
|
// Missing container id
|
||||||
_, err := start("")
|
_, err := start("")
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
// Mock Listpod error
|
// Mock Listpod error
|
||||||
_, err = start(testContainerID)
|
_, err = start(testContainerID)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) {
|
testingImpl.ListPodFunc = func() ([]vc.PodStatus, error) {
|
||||||
return []vc.PodStatus{}, nil
|
return []vc.PodStatus{}, nil
|
||||||
@ -49,13 +49,13 @@ func TestStartInvalidArgs(t *testing.T) {
|
|||||||
// Container missing in ListPod
|
// Container missing in ListPod
|
||||||
_, err = start(testContainerID)
|
_, err = start(testContainerID)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStartPod(t *testing.T) {
|
func TestStartPod(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ func TestStartPod(t *testing.T) {
|
|||||||
|
|
||||||
_, err := start(pod.ID())
|
_, err := start(pod.ID())
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.StartPodFunc = func(podID string) (vc.VCPod, error) {
|
testingImpl.StartPodFunc = func(podID string) (vc.VCPod, error) {
|
||||||
return pod, nil
|
return pod, nil
|
||||||
@ -98,7 +98,7 @@ func TestStartPod(t *testing.T) {
|
|||||||
func TestStartMissingAnnotation(t *testing.T) {
|
func TestStartMissingAnnotation(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,17 +122,17 @@ func TestStartMissingAnnotation(t *testing.T) {
|
|||||||
|
|
||||||
_, err := start(pod.ID())
|
_, err := start(pod.ID())
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStartContainerSucessFailure(t *testing.T) {
|
func TestStartContainerSucessFailure(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
MockPod: pod,
|
MockPod: pod,
|
||||||
@ -161,7 +161,7 @@ func TestStartContainerSucessFailure(t *testing.T) {
|
|||||||
|
|
||||||
_, err := start(testContainerID)
|
_, err := start(testContainerID)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
|
|
||||||
testingImpl.StartContainerFunc = func(podID, containerID string) (vc.VCContainer, error) {
|
testingImpl.StartContainerFunc = func(podID, containerID string) (vc.VCContainer, error) {
|
||||||
return pod.MockContainers[0], nil
|
return pod.MockContainers[0], nil
|
||||||
@ -189,7 +189,7 @@ func TestStartCLIFunction(t *testing.T) {
|
|||||||
// no container id in the Metadata
|
// no container id in the Metadata
|
||||||
err := fn(ctx)
|
err := fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.False(vcMock.IsMockError(err))
|
assert.False(vcmock.IsMockError(err))
|
||||||
|
|
||||||
flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError)
|
flagSet = flag.NewFlagSet("container-id", flag.ContinueOnError)
|
||||||
flagSet.Parse([]string{"xyz"})
|
flagSet.Parse([]string{"xyz"})
|
||||||
@ -197,17 +197,17 @@ func TestStartCLIFunction(t *testing.T) {
|
|||||||
|
|
||||||
err = fn(ctx)
|
err = fn(ctx)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
assert.True(vcMock.IsMockError(err))
|
assert.True(vcmock.IsMockError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStartCLIFunctionSuccess(t *testing.T) {
|
func TestStartCLIFunctionSuccess(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testPodID,
|
MockID: testPodID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
MockPod: pod,
|
MockPod: pod,
|
||||||
|
@ -20,7 +20,7 @@ import (
|
|||||||
|
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
||||||
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
vcAnnotations "github.com/kata-containers/runtime/virtcontainers/pkg/annotations"
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/vcMock"
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
@ -49,11 +49,11 @@ func TestStateCliAction(t *testing.T) {
|
|||||||
func TestStateSuccessful(t *testing.T) {
|
func TestStateSuccessful(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
pod := &vcMock.Pod{
|
pod := &vcmock.Pod{
|
||||||
MockID: testContainerID,
|
MockID: testContainerID,
|
||||||
}
|
}
|
||||||
|
|
||||||
pod.MockContainers = []*vcMock.Container{
|
pod.MockContainers = []*vcmock.Container{
|
||||||
{
|
{
|
||||||
MockID: pod.ID(),
|
MockID: pod.ID(),
|
||||||
MockPod: pod,
|
MockPod: pod,
|
||||||
|
@ -279,6 +279,10 @@ func testGenerateCCProxySockDir() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCreatePodHyperstartAgentSuccessful(t *testing.T) {
|
func TestCreatePodHyperstartAgentSuccessful(t *testing.T) {
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
t.Skip(testDisabledAsNonRoot)
|
||||||
|
}
|
||||||
|
|
||||||
cleanUp()
|
cleanUp()
|
||||||
|
|
||||||
config := newTestPodConfigHyperstartAgent()
|
config := newTestPodConfigHyperstartAgent()
|
||||||
@ -308,6 +312,10 @@ func TestCreatePodHyperstartAgentSuccessful(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCreatePodKataAgentSuccessful(t *testing.T) {
|
func TestCreatePodKataAgentSuccessful(t *testing.T) {
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
t.Skip(testDisabledAsNonRoot)
|
||||||
|
}
|
||||||
|
|
||||||
cleanUp()
|
cleanUp()
|
||||||
|
|
||||||
config := newTestPodConfigKataAgent()
|
config := newTestPodConfigKataAgent()
|
||||||
@ -383,6 +391,10 @@ func TestDeletePodNoopAgentSuccessful(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeletePodHyperstartAgentSuccessful(t *testing.T) {
|
func TestDeletePodHyperstartAgentSuccessful(t *testing.T) {
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
t.Skip(testDisabledAsNonRoot)
|
||||||
|
}
|
||||||
|
|
||||||
cleanUp()
|
cleanUp()
|
||||||
|
|
||||||
config := newTestPodConfigHyperstartAgent()
|
config := newTestPodConfigHyperstartAgent()
|
||||||
@ -422,6 +434,10 @@ func TestDeletePodHyperstartAgentSuccessful(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDeletePodKataAgentSuccessful(t *testing.T) {
|
func TestDeletePodKataAgentSuccessful(t *testing.T) {
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
t.Skip(testDisabledAsNonRoot)
|
||||||
|
}
|
||||||
|
|
||||||
cleanUp()
|
cleanUp()
|
||||||
|
|
||||||
config := newTestPodConfigKataAgent()
|
config := newTestPodConfigKataAgent()
|
||||||
@ -527,6 +543,10 @@ func TestStartPodHyperstartAgentSuccessful(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStartPodKataAgentSuccessful(t *testing.T) {
|
func TestStartPodKataAgentSuccessful(t *testing.T) {
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
t.Skip(testDisabledAsNonRoot)
|
||||||
|
}
|
||||||
|
|
||||||
cleanUp()
|
cleanUp()
|
||||||
|
|
||||||
config := newTestPodConfigKataAgent()
|
config := newTestPodConfigKataAgent()
|
||||||
@ -685,6 +705,10 @@ func TestStopPodHyperstartAgentSuccessful(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestStopPodKataAgentSuccessful(t *testing.T) {
|
func TestStopPodKataAgentSuccessful(t *testing.T) {
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
t.Skip(testDisabledAsNonRoot)
|
||||||
|
}
|
||||||
|
|
||||||
cleanUp()
|
cleanUp()
|
||||||
|
|
||||||
config := newTestPodConfigKataAgent()
|
config := newTestPodConfigKataAgent()
|
||||||
@ -791,6 +815,10 @@ func TestRunPodHyperstartAgentSuccessful(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRunPodKataAgentSuccessful(t *testing.T) {
|
func TestRunPodKataAgentSuccessful(t *testing.T) {
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
t.Skip(testDisabledAsNonRoot)
|
||||||
|
}
|
||||||
|
|
||||||
cleanUp()
|
cleanUp()
|
||||||
|
|
||||||
config := newTestPodConfigKataAgent()
|
config := newTestPodConfigKataAgent()
|
||||||
|
@ -112,6 +112,6 @@ func TestAssetNew(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
a, err = newAsset(p, kernelAsset)
|
_, err = newAsset(p, kernelAsset)
|
||||||
assert.NotNil(err)
|
assert.NotNil(err)
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ type bridgeType string
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
pciBridge bridgeType = "pci"
|
pciBridge bridgeType = "pci"
|
||||||
pcieBridge = "pcie"
|
pcieBridge bridgeType = "pcie"
|
||||||
)
|
)
|
||||||
|
|
||||||
const pciBridgeMaxCapacity = 30
|
const pciBridgeMaxCapacity = 30
|
||||||
|
@ -37,7 +37,6 @@ const testContainer = "testContainer"
|
|||||||
var testCCShimPath = "/usr/bin/virtcontainers/bin/test/cc-shim"
|
var testCCShimPath = "/usr/bin/virtcontainers/bin/test/cc-shim"
|
||||||
var testProxyURL = "foo:///foo/clear-containers/proxy.sock"
|
var testProxyURL = "foo:///foo/clear-containers/proxy.sock"
|
||||||
var testWrongConsolePath = "/foo/wrong-console"
|
var testWrongConsolePath = "/foo/wrong-console"
|
||||||
var testConsolePath = "tty-console"
|
|
||||||
|
|
||||||
func getMockCCShimBinPath() string {
|
func getMockCCShimBinPath() string {
|
||||||
if DefaultMockCCShimBinPath == "" {
|
if DefaultMockCCShimBinPath == "" {
|
||||||
|
@ -22,7 +22,6 @@ import (
|
|||||||
|
|
||||||
// cnm is a network implementation for the CNM plugin.
|
// cnm is a network implementation for the CNM plugin.
|
||||||
type cnm struct {
|
type cnm struct {
|
||||||
config NetworkConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func cnmLogger() *logrus.Entry {
|
func cnmLogger() *logrus.Entry {
|
||||||
|
@ -1,30 +0,0 @@
|
|||||||
//
|
|
||||||
// Copyright (c) 2017 Intel Corporation
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
|
|
||||||
package virtcontainers
|
|
||||||
|
|
||||||
type mockAddr struct {
|
|
||||||
network string
|
|
||||||
ipAddr string
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m mockAddr) Network() string {
|
|
||||||
return m.network
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m mockAddr) String() string {
|
|
||||||
return m.ipAddr
|
|
||||||
}
|
|
@ -231,10 +231,6 @@ func (c *Container) storeProcess() error {
|
|||||||
return c.pod.storage.storeContainerProcess(c.podID, c.id, c.process)
|
return c.pod.storage.storeContainerProcess(c.podID, c.id, c.process)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) fetchProcess() (Process, error) {
|
|
||||||
return c.pod.storage.fetchContainerProcess(c.podID, c.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Container) storeMounts() error {
|
func (c *Container) storeMounts() error {
|
||||||
return c.pod.storage.storeContainerMounts(c.podID, c.id, c.mounts)
|
return c.pod.storage.storeContainerMounts(c.podID, c.id, c.mounts)
|
||||||
}
|
}
|
||||||
|
@ -193,6 +193,10 @@ func cleanupFakeRootfsSetup(testRawFile, loopDev, mntDir string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestContainerAddDriveDir(t *testing.T) {
|
func TestContainerAddDriveDir(t *testing.T) {
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
t.Skip(testDisabledAsNonRoot)
|
||||||
|
}
|
||||||
|
|
||||||
testRawFile, loopDev, fakeRootfs, err := testSetupFakeRootfs(t)
|
testRawFile, loopDev, fakeRootfs, err := testSetupFakeRootfs(t)
|
||||||
|
|
||||||
defer cleanupFakeRootfsSetup(testRawFile, loopDev, fakeRootfs)
|
defer cleanupFakeRootfsSetup(testRawFile, loopDev, fakeRootfs)
|
||||||
|
@ -46,13 +46,6 @@ var sysIOMMUPath = "/sys/kernel/iommu_groups"
|
|||||||
|
|
||||||
var sysDevPrefix = "/sys/dev"
|
var sysDevPrefix = "/sys/dev"
|
||||||
|
|
||||||
var blockPaths = []string{
|
|
||||||
"/dev/sd", //SCSI block device
|
|
||||||
"/dev/hd", //IDE block device
|
|
||||||
"/dev/vd", //Virtual Block device
|
|
||||||
"/dev/ida/", //Compaq Intelligent Drive Array devices
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
vfioPath = "/dev/vfio/"
|
vfioPath = "/dev/vfio/"
|
||||||
)
|
)
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
|
|
||||||
@ -860,28 +859,6 @@ var statusContainerCommand = cli.Command{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func startCCShim(process *vc.Process, shimPath, url string) error {
|
|
||||||
if process.Token == "" {
|
|
||||||
return fmt.Errorf("Token cannot be empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
if url == "" {
|
|
||||||
return fmt.Errorf("URL cannot be empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
if shimPath == "" {
|
|
||||||
return fmt.Errorf("Shim path cannot be empty")
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command(shimPath, "-t", process.Token, "-u", url)
|
|
||||||
cmd.Env = os.Environ()
|
|
||||||
cmd.Stdin = os.Stdin
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
|
|
||||||
return cmd.Run()
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cli.VersionFlag = cli.BoolFlag{
|
cli.VersionFlag = cli.BoolFlag{
|
||||||
Name: "version",
|
Name: "version",
|
||||||
|
@ -40,10 +40,6 @@ var defaultSharedDir = "/run/hyper/shared/pods/"
|
|||||||
var mountTag = "hyperShared"
|
var mountTag = "hyperShared"
|
||||||
var maxHostnameLen = 64
|
var maxHostnameLen = 64
|
||||||
|
|
||||||
const (
|
|
||||||
unixSocket = "unix"
|
|
||||||
)
|
|
||||||
|
|
||||||
// HyperConfig is a structure storing information needed for
|
// HyperConfig is a structure storing information needed for
|
||||||
// hyperstart agent initialization.
|
// hyperstart agent initialization.
|
||||||
type HyperConfig struct {
|
type HyperConfig struct {
|
||||||
@ -637,7 +633,7 @@ func (h *hyper) processListOneContainer(podID, cID string, options ProcessListOp
|
|||||||
func (h *hyper) connectProxyRetry(scheme, address string) (conn net.Conn, err error) {
|
func (h *hyper) connectProxyRetry(scheme, address string) (conn net.Conn, err error) {
|
||||||
attempt := 1
|
attempt := 1
|
||||||
|
|
||||||
timeoutSecs := time.Duration(waitForProxyTimeoutSecs * time.Second)
|
timeoutSecs := waitForProxyTimeoutSecs * time.Second
|
||||||
|
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
lastLogTime := startTime
|
lastLogTime := startTime
|
||||||
|
@ -68,13 +68,13 @@ const (
|
|||||||
netDev
|
netDev
|
||||||
|
|
||||||
// SerialDev is the serial device type.
|
// SerialDev is the serial device type.
|
||||||
serialDev
|
serialDev // nolint: varcheck,unused
|
||||||
|
|
||||||
// BlockDev is the block device type.
|
// BlockDev is the block device type.
|
||||||
blockDev
|
blockDev
|
||||||
|
|
||||||
// ConsoleDev is the console device type.
|
// ConsoleDev is the console device type.
|
||||||
consoleDev
|
consoleDev // nolint: varcheck,unused
|
||||||
|
|
||||||
// SerialPortDev is the serial port device type.
|
// SerialPortDev is the serial port device type.
|
||||||
serialPortDev
|
serialPortDev
|
||||||
@ -131,7 +131,7 @@ func newHypervisor(hType HypervisorType) (hypervisor, error) {
|
|||||||
func makeNameID(namedType string, id string) string {
|
func makeNameID(namedType string, id string) string {
|
||||||
nameID := fmt.Sprintf("%s-%s", namedType, id)
|
nameID := fmt.Sprintf("%s-%s", namedType, id)
|
||||||
if len(nameID) > maxDevIDSize {
|
if len(nameID) > maxDevIDSize {
|
||||||
nameID = string(nameID[:maxDevIDSize])
|
nameID = nameID[:maxDevIDSize]
|
||||||
}
|
}
|
||||||
|
|
||||||
return nameID
|
return nameID
|
||||||
@ -145,6 +145,12 @@ type Param struct {
|
|||||||
|
|
||||||
// HypervisorConfig is the hypervisor configuration.
|
// HypervisorConfig is the hypervisor configuration.
|
||||||
type HypervisorConfig struct {
|
type HypervisorConfig struct {
|
||||||
|
// KernelParams are additional guest kernel parameters.
|
||||||
|
KernelParams []Param
|
||||||
|
|
||||||
|
// HypervisorParams are additional hypervisor parameters.
|
||||||
|
HypervisorParams []Param
|
||||||
|
|
||||||
// KernelPath is the guest kernel host path.
|
// KernelPath is the guest kernel host path.
|
||||||
KernelPath string
|
KernelPath string
|
||||||
|
|
||||||
@ -160,26 +166,19 @@ type HypervisorConfig struct {
|
|||||||
// HypervisorPath is the hypervisor executable host path.
|
// HypervisorPath is the hypervisor executable host path.
|
||||||
HypervisorPath string
|
HypervisorPath string
|
||||||
|
|
||||||
// DisableBlockDeviceUse disallows a block device from being used.
|
|
||||||
DisableBlockDeviceUse bool
|
|
||||||
|
|
||||||
// BlockDeviceDriver specifies the driver to be used for block device
|
// BlockDeviceDriver specifies the driver to be used for block device
|
||||||
// either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver
|
// either VirtioSCSI or VirtioBlock with the default driver being defaultBlockDriver
|
||||||
BlockDeviceDriver string
|
BlockDeviceDriver string
|
||||||
|
|
||||||
// KernelParams are additional guest kernel parameters.
|
|
||||||
KernelParams []Param
|
|
||||||
|
|
||||||
// HypervisorParams are additional hypervisor parameters.
|
|
||||||
HypervisorParams []Param
|
|
||||||
|
|
||||||
// HypervisorMachineType specifies the type of machine being
|
// HypervisorMachineType specifies the type of machine being
|
||||||
// emulated.
|
// emulated.
|
||||||
HypervisorMachineType string
|
HypervisorMachineType string
|
||||||
|
|
||||||
// Debug changes the default hypervisor and kernel parameters to
|
// customAssets is a map of assets.
|
||||||
// enable debug output where available.
|
// Each value in that map takes precedence over the configured assets.
|
||||||
Debug bool
|
// For example, if there is a value for the "kernel" key in this map,
|
||||||
|
// it will be used for the pod's kernel path instead of KernelPath.
|
||||||
|
customAssets map[assetType]*asset
|
||||||
|
|
||||||
// DefaultVCPUs specifies default number of vCPUs for the VM.
|
// DefaultVCPUs specifies default number of vCPUs for the VM.
|
||||||
DefaultVCPUs uint32
|
DefaultVCPUs uint32
|
||||||
@ -195,6 +194,13 @@ type HypervisorConfig struct {
|
|||||||
// Bridges can be used to hot plug devices
|
// Bridges can be used to hot plug devices
|
||||||
DefaultBridges uint32
|
DefaultBridges uint32
|
||||||
|
|
||||||
|
// DisableBlockDeviceUse disallows a block device from being used.
|
||||||
|
DisableBlockDeviceUse bool
|
||||||
|
|
||||||
|
// Debug changes the default hypervisor and kernel parameters to
|
||||||
|
// enable debug output where available.
|
||||||
|
Debug bool
|
||||||
|
|
||||||
// MemPrealloc specifies if the memory should be pre-allocated
|
// MemPrealloc specifies if the memory should be pre-allocated
|
||||||
MemPrealloc bool
|
MemPrealloc bool
|
||||||
|
|
||||||
@ -212,12 +218,6 @@ type HypervisorConfig struct {
|
|||||||
// DisableNestingChecks is used to override customizations performed
|
// DisableNestingChecks is used to override customizations performed
|
||||||
// when running on top of another VMM.
|
// when running on top of another VMM.
|
||||||
DisableNestingChecks bool
|
DisableNestingChecks bool
|
||||||
|
|
||||||
// customAssets is a map of assets.
|
|
||||||
// Each value in that map takes precedence over the configured assets.
|
|
||||||
// For example, if there is a value for the "kernel" key in this map,
|
|
||||||
// it will be used for the pod's kernel path instead of KernelPath.
|
|
||||||
customAssets map[assetType]*asset
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (conf *HypervisorConfig) valid() (bool, error) {
|
func (conf *HypervisorConfig) valid() (bool, error) {
|
||||||
|
@ -515,21 +515,6 @@ func (k *kataAgent) stopPod(pod Pod) error {
|
|||||||
return k.proxy.stop(pod, k.state.ProxyPid)
|
return k.proxy.stop(pod, k.state.ProxyPid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func appendStorageFromMounts(storage []*grpc.Storage, mounts []*Mount) []*grpc.Storage {
|
|
||||||
for _, m := range mounts {
|
|
||||||
s := &grpc.Storage{
|
|
||||||
Source: m.Source,
|
|
||||||
MountPoint: m.Destination,
|
|
||||||
Fstype: m.Type,
|
|
||||||
Options: m.Options,
|
|
||||||
}
|
|
||||||
|
|
||||||
storage = append(storage, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
return storage
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k *kataAgent) replaceOCIMountSource(spec *specs.Spec, guestMounts []Mount) error {
|
func (k *kataAgent) replaceOCIMountSource(spec *specs.Spec, guestMounts []Mount) error {
|
||||||
ociMounts := spec.Mounts
|
ociMounts := spec.Mounts
|
||||||
|
|
||||||
@ -770,11 +755,7 @@ func (k *kataAgent) stopContainer(pod Pod, c Container) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := bindUnmountContainerRootfs(kataHostSharedDir, pod.id, c.id); err != nil {
|
return bindUnmountContainerRootfs(kataHostSharedDir, pod.id, c.id)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) killContainer(pod Pod, c Container, signal syscall.Signal, all bool) error {
|
func (k *kataAgent) killContainer(pod Pod, c Container, signal syscall.Signal, all bool) error {
|
||||||
|
@ -24,9 +24,9 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
|
||||||
gpb "github.com/gogo/protobuf/types"
|
gpb "github.com/gogo/protobuf/types"
|
||||||
pb "github.com/kata-containers/agent/protocols/grpc"
|
pb "github.com/kata-containers/agent/protocols/grpc"
|
||||||
|
"github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
@ -29,9 +29,6 @@ import (
|
|||||||
. "github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
. "github.com/kata-containers/runtime/virtcontainers/pkg/mock"
|
||||||
)
|
)
|
||||||
|
|
||||||
// These tests don't care about the format of the container ID
|
|
||||||
const testKataContainer = "testContainer"
|
|
||||||
|
|
||||||
var testKataShimPath = "/usr/bin/virtcontainers/bin/test/kata-shim"
|
var testKataShimPath = "/usr/bin/virtcontainers/bin/test/kata-shim"
|
||||||
var testKataShimProxyURL = "foo:///foo/kata-containers/proxy.sock"
|
var testKataShimProxyURL = "foo:///foo/kata-containers/proxy.sock"
|
||||||
|
|
||||||
|
@ -25,19 +25,10 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var rootfsDir = "rootfs"
|
var rootfsDir = "rootfs"
|
||||||
|
|
||||||
func mountLogger() *logrus.Entry {
|
|
||||||
return virtLog.WithField("subsystem", "mount")
|
|
||||||
}
|
|
||||||
|
|
||||||
// These mounts need to be created by the agent within the VM
|
|
||||||
var systemMounts = []string{"/proc", "/dev", "/dev/pts", "/dev/shm", "/dev/mqueue", "/sys", "/sys/fs/cgroup"}
|
|
||||||
|
|
||||||
var systemMountPrefixes = []string{"/proc", "/dev", "/sys"}
|
var systemMountPrefixes = []string{"/proc", "/dev", "/sys"}
|
||||||
|
|
||||||
func isSystemMount(m string) bool {
|
func isSystemMount(m string) bool {
|
||||||
|
@ -453,7 +453,6 @@ func (n NetworkNamespace) MarshalJSON() ([]byte, error) {
|
|||||||
// UnmarshalJSON is the custom NetworkNamespace unmarshalling routine.
|
// UnmarshalJSON is the custom NetworkNamespace unmarshalling routine.
|
||||||
// This is needed for unmarshalling the Endpoints interfaces array.
|
// This is needed for unmarshalling the Endpoints interfaces array.
|
||||||
func (n *NetworkNamespace) UnmarshalJSON(b []byte) error {
|
func (n *NetworkNamespace) UnmarshalJSON(b []byte) error {
|
||||||
type tmp NetworkNamespace
|
|
||||||
var s struct {
|
var s struct {
|
||||||
NetNsPath string
|
NetNsPath string
|
||||||
NetNsCreated bool
|
NetNsCreated bool
|
||||||
@ -1081,15 +1080,6 @@ func createNetNS() (string, error) {
|
|||||||
return n.Path(), nil
|
return n.Path(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setNetNS(netNSPath string) error {
|
|
||||||
n, err := ns.GetNS(netNSPath)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return n.Set()
|
|
||||||
}
|
|
||||||
|
|
||||||
// doNetNS is free from any call to a go routine, and it calls
|
// doNetNS is free from any call to a go routine, and it calls
|
||||||
// into runtime.LockOSThread(), meaning it won't be executed in a
|
// into runtime.LockOSThread(), meaning it won't be executed in a
|
||||||
// different thread than the one expected by the caller.
|
// different thread than the one expected by the caller.
|
||||||
|
@ -309,6 +309,10 @@ func TestCreateVirtualNetworkEndpointInvalidArgs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestIsPhysicalIface(t *testing.T) {
|
func TestIsPhysicalIface(t *testing.T) {
|
||||||
|
if os.Geteuid() != 0 {
|
||||||
|
t.Skip(testDisabledAsNonRoot)
|
||||||
|
}
|
||||||
|
|
||||||
testNetIface := "testIface0"
|
testNetIface := "testIface0"
|
||||||
testMTU := 1500
|
testMTU := 1500
|
||||||
testMACAddr := "00:00:00:00:00:01"
|
testMACAddr := "00:00:00:00:00:01"
|
||||||
|
@ -20,8 +20,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
var testNoProxyVMURL = "vmURL"
|
|
||||||
|
|
||||||
func TestNoProxyStart(t *testing.T) {
|
func TestNoProxyStart(t *testing.T) {
|
||||||
pod := Pod{
|
pod := Pod{
|
||||||
agent: newAgent(NoopAgentType),
|
agent: newAgent(NoopAgentType),
|
||||||
|
@ -345,7 +345,7 @@ func (h *Hyperstart) WriteCtlMessage(conn net.Conn, m *DecodedMessage) error {
|
|||||||
return fmt.Errorf("message too long %d", length)
|
return fmt.Errorf("message too long %d", length)
|
||||||
}
|
}
|
||||||
msg := make([]byte, length)
|
msg := make([]byte, length)
|
||||||
binary.BigEndian.PutUint32(msg[:], uint32(m.Code))
|
binary.BigEndian.PutUint32(msg[:], m.Code)
|
||||||
binary.BigEndian.PutUint32(msg[CtlHdrLenOffset:], uint32(length))
|
binary.BigEndian.PutUint32(msg[CtlHdrLenOffset:], uint32(length))
|
||||||
copy(msg[CtlHdrSize:], m.Message)
|
copy(msg[CtlHdrSize:], m.Message)
|
||||||
|
|
||||||
@ -485,7 +485,7 @@ func (h *Hyperstart) WaitForPAE(containerID, processID string) (*PAECommand, err
|
|||||||
msg := <-channel
|
msg := <-channel
|
||||||
|
|
||||||
var paeData PAECommand
|
var paeData PAECommand
|
||||||
err = json.Unmarshal(msg.Message, paeData)
|
err = json.Unmarshal(msg.Message, &paeData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ func (h *Hyperstart) SendIo(seq uint64, data []byte) {
|
|||||||
|
|
||||||
h.logf("io: <-- writing %d bytes for seq %d\n", len(data), seq)
|
h.logf("io: <-- writing %d bytes for seq %d\n", len(data), seq)
|
||||||
|
|
||||||
binary.BigEndian.PutUint64(header[:], uint64(seq))
|
binary.BigEndian.PutUint64(header[:], seq)
|
||||||
binary.BigEndian.PutUint32(header[8:], uint32(length))
|
binary.BigEndian.PutUint32(header[8:], uint32(length))
|
||||||
h.writeIo(header)
|
h.writeIo(header)
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ func (m *multicast) buildEventID(containerID, processID string) string {
|
|||||||
func (m *multicast) sendEvent(msg *DecodedMessage) error {
|
func (m *multicast) sendEvent(msg *DecodedMessage) error {
|
||||||
var paeData PAECommand
|
var paeData PAECommand
|
||||||
|
|
||||||
err := json.Unmarshal(msg.Message, paeData)
|
err := json.Unmarshal(msg.Message, &paeData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -168,28 +168,34 @@ type Capabilities struct {
|
|||||||
|
|
||||||
// Process describes a process running on a container inside a pod.
|
// Process describes a process running on a container inside a pod.
|
||||||
type Process struct {
|
type Process struct {
|
||||||
User string `json:"user,omitempty"`
|
// Args specifies the binary and arguments for the application to execute.
|
||||||
Group string `json:"group,omitempty"`
|
Args []string `json:"args"`
|
||||||
|
|
||||||
|
// Rlimits specifies rlimit options to apply to the process.
|
||||||
|
Rlimits []Rlimit `json:"rlimits,omitempty"`
|
||||||
|
|
||||||
|
// Envs populates the process environment for the process.
|
||||||
|
Envs []EnvironmentVar `json:"envs,omitempty"`
|
||||||
|
|
||||||
AdditionalGroups []string `json:"additionalGroups,omitempty"`
|
AdditionalGroups []string `json:"additionalGroups,omitempty"`
|
||||||
// Terminal creates an interactive terminal for the process.
|
|
||||||
Terminal bool `json:"terminal"`
|
// Workdir is the current working directory for the process and must be
|
||||||
|
// relative to the container's root.
|
||||||
|
Workdir string `json:"workdir"`
|
||||||
|
|
||||||
|
User string `json:"user,omitempty"`
|
||||||
|
Group string `json:"group,omitempty"`
|
||||||
// Sequeue number for stdin and stdout
|
// Sequeue number for stdin and stdout
|
||||||
Stdio uint64 `json:"stdio,omitempty"`
|
Stdio uint64 `json:"stdio,omitempty"`
|
||||||
// Sequeue number for stderr if it is not shared with stdout
|
// Sequeue number for stderr if it is not shared with stdout
|
||||||
Stderr uint64 `json:"stderr,omitempty"`
|
Stderr uint64 `json:"stderr,omitempty"`
|
||||||
// Args specifies the binary and arguments for the application to execute.
|
|
||||||
Args []string `json:"args"`
|
|
||||||
// Envs populates the process environment for the process.
|
|
||||||
Envs []EnvironmentVar `json:"envs,omitempty"`
|
|
||||||
// Workdir is the current working directory for the process and must be
|
|
||||||
// relative to the container's root.
|
|
||||||
Workdir string `json:"workdir"`
|
|
||||||
// Rlimits specifies rlimit options to apply to the process.
|
|
||||||
Rlimits []Rlimit `json:"rlimits,omitempty"`
|
|
||||||
// NoNewPrivileges indicates that the process should not gain any additional privileges
|
// NoNewPrivileges indicates that the process should not gain any additional privileges
|
||||||
|
Capabilities Capabilities `json:"capabilities"`
|
||||||
|
|
||||||
NoNewPrivileges bool `json:"noNewPrivileges"`
|
NoNewPrivileges bool `json:"noNewPrivileges"`
|
||||||
// Capabilities specifies the sets of capabilities for the process(es) inside the container.
|
// Capabilities specifies the sets of capabilities for the process(es) inside the container.
|
||||||
Capabilities Capabilities `json:"capabilities"`
|
// Terminal creates an interactive terminal for the process.
|
||||||
|
Terminal bool `json:"terminal"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SystemMountsInfo describes additional information for system mounts that the agent
|
// SystemMountsInfo describes additional information for system mounts that the agent
|
||||||
|
@ -27,7 +27,6 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
const testContainerid = "123456789"
|
|
||||||
const testToken = "pF56IaDpuax6hihJ5PneB8JypqmOvjkqY-wKGVYqgIM="
|
const testToken = "pF56IaDpuax6hihJ5PneB8JypqmOvjkqY-wKGVYqgIM="
|
||||||
|
|
||||||
// CCProxyMock is an object mocking clearcontainers Proxy
|
// CCProxyMock is an object mocking clearcontainers Proxy
|
||||||
@ -73,10 +72,6 @@ func (proxy *CCProxyMock) GetProxyToken() string {
|
|||||||
return proxy.token
|
return proxy.token
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSignalList() []ShimSignal {
|
|
||||||
return make([]ShimSignal, 0, 5)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetLastStdinStream returns the last received stdin stream
|
// GetLastStdinStream returns the last received stdin stream
|
||||||
func (proxy *CCProxyMock) GetLastStdinStream() []byte {
|
func (proxy *CCProxyMock) GetLastStdinStream() []byte {
|
||||||
return proxy.lastStdinStream
|
return proxy.lastStdinStream
|
||||||
@ -375,13 +370,6 @@ type FrameKey struct {
|
|||||||
opcode int
|
opcode int
|
||||||
}
|
}
|
||||||
|
|
||||||
func newFrameKey(frameType api.FrameType, opcode int) FrameKey {
|
|
||||||
return FrameKey{
|
|
||||||
ftype: frameType,
|
|
||||||
opcode: opcode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type ccProxyProtocol struct {
|
type ccProxyProtocol struct {
|
||||||
cmdHandlers map[FrameKey]ccProxyProtocolHandler
|
cmdHandlers map[FrameKey]ccProxyProtocolHandler
|
||||||
}
|
}
|
||||||
@ -429,7 +417,7 @@ func (proto *ccProxyProtocol) handleCommand(ctx *clientCtx, cmd *api.Frame) *api
|
|||||||
|
|
||||||
// cmd.Header.Opcode is guaranteed to be within the right bounds by
|
// cmd.Header.Opcode is guaranteed to be within the right bounds by
|
||||||
// ReadFrame().
|
// ReadFrame().
|
||||||
handler := proto.cmdHandlers[FrameKey{cmd.Header.Type, int(cmd.Header.Opcode)}]
|
handler := proto.cmdHandlers[FrameKey{cmd.Header.Type, cmd.Header.Opcode}]
|
||||||
|
|
||||||
handler(cmd.Payload, ctx.userData, &hr)
|
handler(cmd.Payload, ctx.userData, &hr)
|
||||||
if hr.err != nil {
|
if hr.err != nil {
|
||||||
|
@ -52,10 +52,10 @@ type NSType string
|
|||||||
// without multithreading issues.
|
// without multithreading issues.
|
||||||
const (
|
const (
|
||||||
NSTypeCGroup NSType = "cgroup"
|
NSTypeCGroup NSType = "cgroup"
|
||||||
NSTypeIPC = "ipc"
|
NSTypeIPC NSType = "ipc"
|
||||||
NSTypeNet = "net"
|
NSTypeNet NSType = "net"
|
||||||
NSTypePID = "pid"
|
NSTypePID NSType = "pid"
|
||||||
NSTypeUTS = "uts"
|
NSTypeUTS NSType = "uts"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CloneFlagsTable is exported so that consumers of this package don't need
|
// CloneFlagsTable is exported so that consumers of this package don't need
|
||||||
|
@ -31,10 +31,7 @@ import (
|
|||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const testPID = 12345
|
||||||
testPID = 12345
|
|
||||||
testNSPath = "/foo/bar/ns"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestGetNSPathFromPID(t *testing.T) {
|
func TestGetNSPathFromPID(t *testing.T) {
|
||||||
for nsType := range CloneFlagsTable {
|
for nsType := range CloneFlagsTable {
|
||||||
|
@ -133,7 +133,7 @@ func (u UUID) String() string {
|
|||||||
clkSeqLow := u[9]
|
clkSeqLow := u[9]
|
||||||
buf := make([]byte, 8)
|
buf := make([]byte, 8)
|
||||||
copy(buf[2:], u[10:])
|
copy(buf[2:], u[10:])
|
||||||
node := uint64(binary.BigEndian.Uint64(buf))
|
node := binary.BigEndian.Uint64(buf)
|
||||||
|
|
||||||
return fmt.Sprintf("%08x-%04x-%04x-%02x%02x-%012x",
|
return fmt.Sprintf("%08x-%04x-%04x-%02x%02x-%012x",
|
||||||
timeLow, timeMid, timeHi, clkSeqHi, clkSeqLow, node)
|
timeLow, timeMid, timeHi, clkSeqHi, clkSeqLow, node)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package vcMock
|
package vcmock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
@ -22,7 +22,7 @@
|
|||||||
// well-known format. Callers can detect this scenario by calling
|
// well-known format. Callers can detect this scenario by calling
|
||||||
// IsMockError().
|
// IsMockError().
|
||||||
|
|
||||||
package vcMock
|
package vcmock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -34,7 +34,7 @@ import (
|
|||||||
|
|
||||||
// mockErrorPrefix is a string that all errors returned by the mock
|
// mockErrorPrefix is a string that all errors returned by the mock
|
||||||
// implementation itself will contain as a prefix.
|
// implementation itself will contain as a prefix.
|
||||||
const mockErrorPrefix = "vcMock forced failure"
|
const mockErrorPrefix = "vcmock forced failure"
|
||||||
|
|
||||||
// SetLogger implements the VC function of the same name.
|
// SetLogger implements the VC function of the same name.
|
||||||
func (m *VCMock) SetLogger(logger logrus.FieldLogger) {
|
func (m *VCMock) SetLogger(logger logrus.FieldLogger) {
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package vcMock
|
package vcmock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"reflect"
|
"reflect"
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package vcMock
|
package vcmock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
vc "github.com/kata-containers/runtime/virtcontainers"
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package vcMock
|
package vcmock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"syscall"
|
"syscall"
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
package vcMock
|
package vcmock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
@ -274,9 +274,9 @@ type LinuxCapabilities struct {
|
|||||||
|
|
||||||
// Cmd represents a command to execute in a running container.
|
// Cmd represents a command to execute in a running container.
|
||||||
type Cmd struct {
|
type Cmd struct {
|
||||||
Args []string
|
Args []string
|
||||||
Envs []EnvVar
|
Envs []EnvVar
|
||||||
WorkDir string
|
SupplementaryGroups []string
|
||||||
|
|
||||||
// Note that these fields *MUST* remain as strings.
|
// Note that these fields *MUST* remain as strings.
|
||||||
//
|
//
|
||||||
@ -300,15 +300,15 @@ type Cmd struct {
|
|||||||
// all the user and group mapping is handled by the container manager
|
// all the user and group mapping is handled by the container manager
|
||||||
// and specified to the runtime in terms of UID/GID's in the
|
// and specified to the runtime in terms of UID/GID's in the
|
||||||
// configuration file generated by the container manager.
|
// configuration file generated by the container manager.
|
||||||
User string
|
User string
|
||||||
PrimaryGroup string
|
PrimaryGroup string
|
||||||
SupplementaryGroups []string
|
WorkDir string
|
||||||
|
Console string
|
||||||
|
Capabilities LinuxCapabilities
|
||||||
|
|
||||||
Interactive bool
|
Interactive bool
|
||||||
Console string
|
|
||||||
Detach bool
|
Detach bool
|
||||||
NoNewPrivileges bool
|
NoNewPrivileges bool
|
||||||
Capabilities LinuxCapabilities
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resources describes VM resources configuration.
|
// Resources describes VM resources configuration.
|
||||||
@ -466,8 +466,6 @@ type Pod struct {
|
|||||||
|
|
||||||
networkNS NetworkNamespace
|
networkNS NetworkNamespace
|
||||||
|
|
||||||
lockFile *os.File
|
|
||||||
|
|
||||||
annotationsLock *sync.RWMutex
|
annotationsLock *sync.RWMutex
|
||||||
|
|
||||||
wg *sync.WaitGroup
|
wg *sync.WaitGroup
|
||||||
|
@ -1263,11 +1263,6 @@ func TestFindContainerSuccess(t *testing.T) {
|
|||||||
assert.True(t, c == pod.containers[0], "Container pointers should point to the same address")
|
assert.True(t, c == pod.containers[0], "Container pointers should point to the same address")
|
||||||
}
|
}
|
||||||
|
|
||||||
func testRemoveContainerFailure(t *testing.T, pod *Pod, cid string) {
|
|
||||||
err := pod.removeContainer(cid)
|
|
||||||
assert.NotNil(t, err, "Should have returned an error")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestRemoveContainerPodNilFailure(t *testing.T) {
|
func TestRemoveContainerPodNilFailure(t *testing.T) {
|
||||||
testFindContainerFailure(t, nil, testContainerID)
|
testFindContainerFailure(t, nil, testContainerID)
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ProxyConfig is a structure storing information needed from any
|
// ProxyConfig is a structure storing information needed from any
|
||||||
@ -60,10 +59,6 @@ const (
|
|||||||
waitForProxyTimeoutSecs = 5.0
|
waitForProxyTimeoutSecs = 5.0
|
||||||
)
|
)
|
||||||
|
|
||||||
func proxyLogger() *logrus.Entry {
|
|
||||||
return virtLog.WithField("subsystem", "proxy")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set sets a proxy type based on the input string.
|
// Set sets a proxy type based on the input string.
|
||||||
func (pType *ProxyType) Set(value string) error {
|
func (pType *ProxyType) Set(value string) error {
|
||||||
switch value {
|
switch value {
|
||||||
|
@ -24,8 +24,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/kata-containers/runtime/virtcontainers/pkg/uuid"
|
|
||||||
govmmQemu "github.com/intel/govmm/qemu"
|
govmmQemu "github.com/intel/govmm/qemu"
|
||||||
|
"github.com/kata-containers/runtime/virtcontainers/pkg/uuid"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -559,19 +559,6 @@ func (q *qemu) addDeviceToBridge(ID string) (string, string, error) {
|
|||||||
return "", "", err
|
return "", "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *qemu) removeDeviceFromBridge(ID string) error {
|
|
||||||
var err error
|
|
||||||
for _, b := range q.state.Bridges {
|
|
||||||
err = b.removeDevice(ID)
|
|
||||||
if err == nil {
|
|
||||||
// device was removed correctly
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error {
|
func (q *qemu) hotplugBlockDevice(drive Drive, op operation) error {
|
||||||
defer func(qemu *qemu) {
|
defer func(qemu *qemu) {
|
||||||
if q.qmpMonitorCh.qmp != nil {
|
if q.qmpMonitorCh.qmp != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user