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:
Eric Ernst 2021-10-22 14:58:37 -07:00
parent f434bcbf6c
commit a72bed5b34
4 changed files with 17 additions and 17 deletions

View File

@ -211,7 +211,7 @@ func TestAcrnGetSandboxConsole(t *testing.T) {
assert.Equal(proto, consoleProtoUnix)
}
func TestAcrnCreateSandbox(t *testing.T) {
func TestAcrnCreateVM(t *testing.T) {
assert := assert.New(t)
acrnConfig := newAcrnConfig()
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
a.state.PID = 1
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.Exactly(acrnConfig, a.config)
}

View File

@ -226,7 +226,7 @@ func TestCloudHypervisorCleanupVM(t *testing.T) {
assert.True(os.IsNotExist(err), "persist.GetDriver() unexpected error")
}
func TestClhCreateSandbox(t *testing.T) {
func TestClhCreateVM(t *testing.T) {
assert := assert.New(t)
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.Exactly(clhConfig, clh.config)
}

View File

@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/assert"
)
func TestMockHypervisorCreateSandbox(t *testing.T) {
func TestMockHypervisorCreateVM(t *testing.T) {
var m *mockHypervisor
assert := assert.New(t)
@ -31,7 +31,7 @@ func TestMockHypervisorCreateSandbox(t *testing.T) {
ctx := context.Background()
// 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)
sandbox.config.HypervisorConfig = HypervisorConfig{
@ -40,7 +40,7 @@ func TestMockHypervisorCreateSandbox(t *testing.T) {
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)
}

View File

@ -72,7 +72,7 @@ func TestQemuKernelParameters(t *testing.T) {
testQemuKernelParameters(t, params, expectedOut, false)
}
func TestQemuCreateSandbox(t *testing.T) {
func TestQemuCreateVM(t *testing.T) {
qemuConfig := newQemuConfig()
assert := assert.New(t)
@ -98,13 +98,13 @@ func TestQemuCreateSandbox(t *testing.T) {
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
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(os.RemoveAll(parentDir))
assert.Exactly(qemuConfig, q.config)
}
func TestQemuCreateSandboxMissingParentDirFail(t *testing.T) {
func TestQemuCreateVMMissingParentDirFail(t *testing.T) {
qemuConfig := newQemuConfig()
assert := assert.New(t)
@ -130,7 +130,7 @@ func TestQemuCreateSandboxMissingParentDirFail(t *testing.T) {
parentDir := filepath.Join(q.store.RunStoragePath(), sandbox.id)
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)
}
@ -195,7 +195,7 @@ func TestQemuKnobs(t *testing.T) {
q := &qemu{
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.Equal(q.qemuConfig.Knobs.NoUserConfig, true)
@ -464,7 +464,7 @@ func TestQemuFileBackedMem(t *testing.T) {
store: sandbox.store,
}
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.Equal(q.qemuConfig.Knobs.FileBackedMem, true)
@ -482,7 +482,7 @@ func TestQemuFileBackedMem(t *testing.T) {
sandbox.config.HypervisorConfig.SharedFS = config.VirtioFS
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")
assert.Equal(expectErr.Error(), err.Error())
@ -495,7 +495,7 @@ func TestQemuFileBackedMem(t *testing.T) {
store: sandbox.store,
}
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.Equal(q.qemuConfig.Knobs.FileBackedMem, 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.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.Equal(q.qemuConfig.Knobs.MemShared, true)
@ -523,7 +523,7 @@ func TestQemuFileBackedMem(t *testing.T) {
}
sandbox.config.HypervisorConfig.EnableVhostUserStore = true
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")
assert.Equal(expectErr.Error(), err.Error())