Files
kata-containers/src/runtime/virtcontainers/factory/cache/cache_test.go
Penny Zheng 1099a28830 kata 2.0: delete use_vsock option and proxy abstraction
With kata containers moving to 2.0, (hybrid-)vsock will be the only
way to directly communicate between host and agent.
And kata-proxy as additional component to handle the multiplexing on
serial port is also no longer needed.
Cleaning up related unit tests, and also add another mock socket type
`MockHybridVSock` to deal with ttrpc-based hybrid-vsock mock server.

Fixes: #389

Signed-off-by: Penny Zheng penny.zheng@arm.com
2020-07-16 04:20:02 +00:00

52 lines
1.0 KiB
Go

// Copyright (c) 2018 HyperHQ Inc.
//
// SPDX-License-Identifier: Apache-2.0
//
package cache
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/factory/direct"
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/persist/fs"
)
func TestTemplateFactory(t *testing.T) {
assert := assert.New(t)
testDir := fs.MockStorageRootPath()
defer fs.MockStorageDestroy()
hyperConfig := vc.HypervisorConfig{
KernelPath: testDir,
ImagePath: testDir,
}
vmConfig := vc.VMConfig{
HypervisorType: vc.MockHypervisor,
HypervisorConfig: hyperConfig,
}
ctx := vc.WithNewAgentFunc(context.Background(), vc.NewMockAgent)
// New
f := New(ctx, 2, direct.New(ctx, vmConfig))
// Config
assert.Equal(f.Config(), vmConfig)
// GetBaseVM
vm, err := f.GetBaseVM(ctx, vmConfig)
assert.Nil(err)
err = vm.Stop()
assert.Nil(err)
// CloseFactory
f.CloseFactory(ctx)
}