Use logtest if possible to clean up logs
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
parent
a76d68ee48
commit
8e7ef890a5
@ -23,6 +23,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/containerd/containerd"
|
"github.com/containerd/containerd"
|
||||||
|
"github.com/containerd/containerd/log/logtest"
|
||||||
"github.com/containerd/containerd/pkg/cri/constants"
|
"github.com/containerd/containerd/pkg/cri/constants"
|
||||||
"github.com/containerd/containerd/platforms"
|
"github.com/containerd/containerd/platforms"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
@ -61,7 +62,7 @@ var (
|
|||||||
// buildLocalContainerdClient is to return containerd client with initialized
|
// buildLocalContainerdClient is to return containerd client with initialized
|
||||||
// core plugins in local.
|
// core plugins in local.
|
||||||
func buildLocalContainerdClient(t *testing.T, tmpDir string) *containerd.Client {
|
func buildLocalContainerdClient(t *testing.T, tmpDir string) *containerd.Client {
|
||||||
ctx := context.Background()
|
ctx := logtest.WithT(context.Background(), t)
|
||||||
|
|
||||||
// load plugins
|
// load plugins
|
||||||
loadPluginOnce.Do(func() {
|
loadPluginOnce.Do(func() {
|
||||||
|
@ -37,6 +37,7 @@ import (
|
|||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
"github.com/containerd/containerd/leases"
|
"github.com/containerd/containerd/leases"
|
||||||
"github.com/containerd/containerd/log"
|
"github.com/containerd/containerd/log"
|
||||||
|
"github.com/containerd/containerd/log/logtest"
|
||||||
"github.com/containerd/containerd/namespaces"
|
"github.com/containerd/containerd/namespaces"
|
||||||
criconfig "github.com/containerd/containerd/pkg/cri/config"
|
criconfig "github.com/containerd/containerd/pkg/cri/config"
|
||||||
criserver "github.com/containerd/containerd/pkg/cri/server"
|
criserver "github.com/containerd/containerd/pkg/cri/server"
|
||||||
@ -79,7 +80,7 @@ func testCRIImagePullTimeoutByHoldingContentOpenWriter(t *testing.T) {
|
|||||||
criService, err := initLocalCRIPlugin(cli, tmpDir, criconfig.Registry{})
|
criService, err := initLocalCRIPlugin(cli, tmpDir, criconfig.Registry{})
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
ctx := namespaces.WithNamespace(context.Background(), k8sNamespace)
|
ctx := namespaces.WithNamespace(logtest.WithT(context.Background(), t), k8sNamespace)
|
||||||
contentStore := cli.ContentStore()
|
contentStore := cli.ContentStore()
|
||||||
|
|
||||||
// imageIndexJSON is the manifest of ghcr.io/containerd/volume-ownership:2.1.
|
// imageIndexJSON is the manifest of ghcr.io/containerd/volume-ownership:2.1.
|
||||||
@ -241,7 +242,7 @@ func testCRIImagePullTimeoutByNoDataTransferred(t *testing.T) {
|
|||||||
err = os.WriteFile(filepath.Join(hostCfgDir, "hosts.toml"), []byte(hostTomlContent), 0600)
|
err = os.WriteFile(filepath.Join(hostCfgDir, "hosts.toml"), []byte(hostTomlContent), 0600)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
ctx := namespaces.WithNamespace(context.Background(), k8sNamespace)
|
ctx := namespaces.WithNamespace(logtest.WithT(context.Background(), t), k8sNamespace)
|
||||||
for idx, registryCfg := range []criconfig.Registry{
|
for idx, registryCfg := range []criconfig.Registry{
|
||||||
{
|
{
|
||||||
ConfigPath: filepath.Dir(hostCfgDir),
|
ConfigPath: filepath.Dir(hostCfgDir),
|
||||||
|
Loading…
Reference in New Issue
Block a user