From a72bed5b34b0eaf3e307d9a1f63bec58fa2681da Mon Sep 17 00:00:00 2001 From: Eric Ernst Date: Fri, 22 Oct 2021 14:58:37 -0700 Subject: [PATCH] hypervisor: update tests based on createSandbox->CreateVM change Fixup a couple of broken tests. Signed-off-by: Eric Ernst --- src/runtime/virtcontainers/acrn_test.go | 4 ++-- src/runtime/virtcontainers/clh_test.go | 4 ++-- .../virtcontainers/mock_hypervisor_test.go | 6 +++--- src/runtime/virtcontainers/qemu_test.go | 20 +++++++++---------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/runtime/virtcontainers/acrn_test.go b/src/runtime/virtcontainers/acrn_test.go index 9d23669966..f3d46b7b8b 100644 --- a/src/runtime/virtcontainers/acrn_test.go +++ b/src/runtime/virtcontainers/acrn_test.go @@ -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) } diff --git a/src/runtime/virtcontainers/clh_test.go b/src/runtime/virtcontainers/clh_test.go index 0ce6dea9cf..54718dd57c 100644 --- a/src/runtime/virtcontainers/clh_test.go +++ b/src/runtime/virtcontainers/clh_test.go @@ -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) } diff --git a/src/runtime/virtcontainers/mock_hypervisor_test.go b/src/runtime/virtcontainers/mock_hypervisor_test.go index 6ea73083c9..e7da0e18a2 100644 --- a/src/runtime/virtcontainers/mock_hypervisor_test.go +++ b/src/runtime/virtcontainers/mock_hypervisor_test.go @@ -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) } diff --git a/src/runtime/virtcontainers/qemu_test.go b/src/runtime/virtcontainers/qemu_test.go index c83705c52d..eb10857dd2 100644 --- a/src/runtime/virtcontainers/qemu_test.go +++ b/src/runtime/virtcontainers/qemu_test.go @@ -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())