mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 12:14:48 +00:00
hypervisor: update tests based on createSandbox->CreateVM change
Fixup a couple of broken tests. Signed-off-by: Eric Ernst <eric_ernst@apple.com>
This commit is contained in:
parent
f434bcbf6c
commit
a72bed5b34
@ -211,7 +211,7 @@ func TestAcrnGetSandboxConsole(t *testing.T) {
|
|||||||
assert.Equal(proto, consoleProtoUnix)
|
assert.Equal(proto, consoleProtoUnix)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAcrnCreateSandbox(t *testing.T) {
|
func TestAcrnCreateVM(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
acrnConfig := newAcrnConfig()
|
acrnConfig := newAcrnConfig()
|
||||||
store, err := persist.GetDriver()
|
store, err := persist.GetDriver()
|
||||||
@ -235,7 +235,7 @@ func TestAcrnCreateSandbox(t *testing.T) {
|
|||||||
//set PID to 1 to ignore hypercall to get UUID and set a random UUID
|
//set PID to 1 to ignore hypercall to get UUID and set a random UUID
|
||||||
a.state.PID = 1
|
a.state.PID = 1
|
||||||
a.state.UUID = "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
|
a.state.UUID = "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
|
||||||
err = a.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = a.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Exactly(acrnConfig, a.config)
|
assert.Exactly(acrnConfig, a.config)
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,7 @@ func TestCloudHypervisorCleanupVM(t *testing.T) {
|
|||||||
assert.True(os.IsNotExist(err), "persist.GetDriver() unexpected error")
|
assert.True(os.IsNotExist(err), "persist.GetDriver() unexpected error")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClhCreateSandbox(t *testing.T) {
|
func TestClhCreateVM(t *testing.T) {
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
clhConfig, err := newClhConfig()
|
clhConfig, err := newClhConfig()
|
||||||
@ -248,7 +248,7 @@ func TestClhCreateSandbox(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
err = clh.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = clh.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Exactly(clhConfig, clh.config)
|
assert.Exactly(clhConfig, clh.config)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMockHypervisorCreateSandbox(t *testing.T) {
|
func TestMockHypervisorCreateVM(t *testing.T) {
|
||||||
var m *mockHypervisor
|
var m *mockHypervisor
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ func TestMockHypervisorCreateSandbox(t *testing.T) {
|
|||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
// wrong config
|
// wrong config
|
||||||
err := m.createSandbox(ctx, sandbox.config.ID, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err := m.CreateVM(ctx, sandbox.config.ID, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
|
|
||||||
sandbox.config.HypervisorConfig = HypervisorConfig{
|
sandbox.config.HypervisorConfig = HypervisorConfig{
|
||||||
@ -40,7 +40,7 @@ func TestMockHypervisorCreateSandbox(t *testing.T) {
|
|||||||
HypervisorPath: fmt.Sprintf("%s/%s", testDir, testHypervisor),
|
HypervisorPath: fmt.Sprintf("%s/%s", testDir, testHypervisor),
|
||||||
}
|
}
|
||||||
|
|
||||||
err = m.createSandbox(ctx, sandbox.config.ID, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = m.CreateVM(ctx, sandbox.config.ID, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ func TestQemuKernelParameters(t *testing.T) {
|
|||||||
testQemuKernelParameters(t, params, expectedOut, false)
|
testQemuKernelParameters(t, params, expectedOut, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQemuCreateSandbox(t *testing.T) {
|
func TestQemuCreateVM(t *testing.T) {
|
||||||
qemuConfig := newQemuConfig()
|
qemuConfig := newQemuConfig()
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
@ -98,13 +98,13 @@ func TestQemuCreateSandbox(t *testing.T) {
|
|||||||
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
|
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
|
||||||
assert.NoError(os.MkdirAll(parentDir, DirMode))
|
assert.NoError(os.MkdirAll(parentDir, DirMode))
|
||||||
|
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = q.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.NoError(os.RemoveAll(parentDir))
|
assert.NoError(os.RemoveAll(parentDir))
|
||||||
assert.Exactly(qemuConfig, q.config)
|
assert.Exactly(qemuConfig, q.config)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQemuCreateSandboxMissingParentDirFail(t *testing.T) {
|
func TestQemuCreateVMMissingParentDirFail(t *testing.T) {
|
||||||
qemuConfig := newQemuConfig()
|
qemuConfig := newQemuConfig()
|
||||||
assert := assert.New(t)
|
assert := assert.New(t)
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ func TestQemuCreateSandboxMissingParentDirFail(t *testing.T) {
|
|||||||
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
|
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
|
||||||
assert.NoError(os.RemoveAll(parentDir))
|
assert.NoError(os.RemoveAll(parentDir))
|
||||||
|
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = q.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ func TestQemuKnobs(t *testing.T) {
|
|||||||
q := &qemu{
|
q := &qemu{
|
||||||
store: sandbox.store,
|
store: sandbox.store,
|
||||||
}
|
}
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = q.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
assert.Equal(q.qemuConfig.Knobs.NoUserConfig, true)
|
assert.Equal(q.qemuConfig.Knobs.NoUserConfig, true)
|
||||||
@ -464,7 +464,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
store: sandbox.store,
|
store: sandbox.store,
|
||||||
}
|
}
|
||||||
sandbox.config.HypervisorConfig.SharedFS = config.VirtioFS
|
sandbox.config.HypervisorConfig.SharedFS = config.VirtioFS
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = q.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
|
|
||||||
assert.Equal(q.qemuConfig.Knobs.FileBackedMem, true)
|
assert.Equal(q.qemuConfig.Knobs.FileBackedMem, true)
|
||||||
@ -482,7 +482,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
sandbox.config.HypervisorConfig.SharedFS = config.VirtioFS
|
sandbox.config.HypervisorConfig.SharedFS = config.VirtioFS
|
||||||
sandbox.config.HypervisorConfig.MemoryPath = fallbackFileBackedMemDir
|
sandbox.config.HypervisorConfig.MemoryPath = fallbackFileBackedMemDir
|
||||||
|
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = q.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
|
|
||||||
expectErr := errors.New("VM templating has been enabled with either virtio-fs or file backed memory and this configuration will not work")
|
expectErr := errors.New("VM templating has been enabled with either virtio-fs or file backed memory and this configuration will not work")
|
||||||
assert.Equal(expectErr.Error(), err.Error())
|
assert.Equal(expectErr.Error(), err.Error())
|
||||||
@ -495,7 +495,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
store: sandbox.store,
|
store: sandbox.store,
|
||||||
}
|
}
|
||||||
sandbox.config.HypervisorConfig.FileBackedMemRootDir = "/tmp/xyzabc"
|
sandbox.config.HypervisorConfig.FileBackedMemRootDir = "/tmp/xyzabc"
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = q.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(q.qemuConfig.Knobs.FileBackedMem, false)
|
assert.Equal(q.qemuConfig.Knobs.FileBackedMem, false)
|
||||||
assert.Equal(q.qemuConfig.Knobs.MemShared, false)
|
assert.Equal(q.qemuConfig.Knobs.MemShared, false)
|
||||||
@ -510,7 +510,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
}
|
}
|
||||||
sandbox.config.HypervisorConfig.EnableVhostUserStore = true
|
sandbox.config.HypervisorConfig.EnableVhostUserStore = true
|
||||||
sandbox.config.HypervisorConfig.HugePages = true
|
sandbox.config.HypervisorConfig.HugePages = true
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = q.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
assert.NoError(err)
|
assert.NoError(err)
|
||||||
assert.Equal(q.qemuConfig.Knobs.MemShared, true)
|
assert.Equal(q.qemuConfig.Knobs.MemShared, true)
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ func TestQemuFileBackedMem(t *testing.T) {
|
|||||||
}
|
}
|
||||||
sandbox.config.HypervisorConfig.EnableVhostUserStore = true
|
sandbox.config.HypervisorConfig.EnableVhostUserStore = true
|
||||||
sandbox.config.HypervisorConfig.HugePages = false
|
sandbox.config.HypervisorConfig.HugePages = false
|
||||||
err = q.createSandbox(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
err = q.CreateVM(context.Background(), sandbox.id, NetworkNamespace{}, &sandbox.config.HypervisorConfig)
|
||||||
|
|
||||||
expectErr = errors.New("Vhost-user-blk/scsi is enabled without HugePages. This configuration will not work")
|
expectErr = errors.New("Vhost-user-blk/scsi is enabled without HugePages. This configuration will not work")
|
||||||
assert.Equal(expectErr.Error(), err.Error())
|
assert.Equal(expectErr.Error(), err.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user