mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-14 16:48:10 +00:00
We are creating Store directories but never removing them. Calling into a VM factory created vm Stop() will now clean the VM Store artifacts up. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
52 lines
968 B
Go
52 lines
968 B
Go
// Copyright (c) 2018 HyperHQ Inc.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package cache
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
vc "github.com/kata-containers/runtime/virtcontainers"
|
|
"github.com/kata-containers/runtime/virtcontainers/factory/direct"
|
|
)
|
|
|
|
func TestTemplateFactory(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
testDir, _ := ioutil.TempDir("", "vmfactory-tmp-")
|
|
hyperConfig := vc.HypervisorConfig{
|
|
KernelPath: testDir,
|
|
ImagePath: testDir,
|
|
}
|
|
vmConfig := vc.VMConfig{
|
|
HypervisorType: vc.MockHypervisor,
|
|
AgentType: vc.NoopAgentType,
|
|
ProxyType: vc.NoopProxyType,
|
|
HypervisorConfig: hyperConfig,
|
|
}
|
|
|
|
ctx := context.Background()
|
|
|
|
// 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)
|
|
}
|