mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-26 17:54:24 +01:00
Fixes: #2023 CompatOCISpec is used to gurantee backward compatbility for old runtime specs, after we convert CompatOCISpec to standard specs.Spec, we should use specs.Spec instead of CompatOCISpec, and CompatOCISpec should be useless from then. Spread usage of CompatOCISpec can make code structure confusing and making the runtime spec usage non-standard. Besides, this can be the very first step of removing CompatOCISpec from config's Annotations field. Signed-off-by: Wei Zhang <weizhang555.zw@gmail.com>
62 lines
1.3 KiB
Go
62 lines
1.3 KiB
Go
// Copyright (c) 2017 Intel Corporation
|
|
// Copyright (c) 2018 HyperHQ Inc.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package containerdshim
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/kata-containers/runtime/virtcontainers/pkg/oci"
|
|
"github.com/kata-containers/runtime/virtcontainers/pkg/vcmock"
|
|
)
|
|
|
|
func TestDeleteContainerSuccessAndFail(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
sandbox := &vcmock.Sandbox{
|
|
MockID: testSandboxID,
|
|
}
|
|
|
|
rootPath, bundlePath := testConfigSetup(t)
|
|
defer os.RemoveAll(rootPath)
|
|
_, err := oci.ParseConfigJSON(bundlePath)
|
|
assert.NoError(err)
|
|
|
|
s := &service{
|
|
id: testSandboxID,
|
|
sandbox: sandbox,
|
|
containers: make(map[string]*container),
|
|
}
|
|
|
|
reqCreate := &taskAPI.CreateTaskRequest{
|
|
ID: testContainerID,
|
|
}
|
|
s.containers[testContainerID], err = newContainer(s, reqCreate, "", nil)
|
|
assert.NoError(err)
|
|
}
|
|
|
|
func testConfigSetup(t *testing.T) (rootPath string, bundlePath string) {
|
|
assert := assert.New(t)
|
|
|
|
tmpdir, err := ioutil.TempDir("", "")
|
|
assert.NoError(err)
|
|
|
|
bundlePath = filepath.Join(tmpdir, "bundle")
|
|
err = os.MkdirAll(bundlePath, testDirMode)
|
|
assert.NoError(err)
|
|
|
|
err = createOCIConfig(bundlePath)
|
|
assert.NoError(err)
|
|
|
|
return tmpdir, bundlePath
|
|
}
|