Skip to content

Commit

Permalink
Use logtest if possible to clean up logs
Browse files Browse the repository at this point in the history
Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
  • Loading branch information
kzys committed Oct 14, 2022
1 parent 62d866e commit 3edebb7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion integration/build_local_containerd_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"

"github.com/containerd/containerd"
"github.com/containerd/containerd/log/logtest"
"github.com/containerd/containerd/pkg/cri/constants"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin"
Expand Down Expand Up @@ -61,7 +62,7 @@ var (
// buildLocalContainerdClient is to return containerd client with initialized
// core plugins in local.
func buildLocalContainerdClient(t *testing.T, tmpDir string) *containerd.Client {
ctx := context.Background()
ctx := logtest.WithT(context.Background(), t)

// load plugins
loadPluginOnce.Do(func() {
Expand Down
5 changes: 3 additions & 2 deletions integration/image_pull_timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/leases"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/log/logtest"
"github.com/containerd/containerd/namespaces"
criconfig "github.com/containerd/containerd/pkg/cri/config"
criserver "github.com/containerd/containerd/pkg/cri/server"
Expand Down Expand Up @@ -79,7 +80,7 @@ func testCRIImagePullTimeoutByHoldingContentOpenWriter(t *testing.T) {
criService, err := initLocalCRIPlugin(cli, tmpDir, criconfig.Registry{})
assert.NoError(t, err)

ctx := namespaces.WithNamespace(context.Background(), k8sNamespace)
ctx := namespaces.WithNamespace(logtest.WithT(context.Background(), t), k8sNamespace)
contentStore := cli.ContentStore()

// imageIndexJSON is the manifest of ghcr.io/containerd/volume-ownership:2.1.
Expand Down Expand Up @@ -241,7 +242,7 @@ func testCRIImagePullTimeoutByNoDataTransferred(t *testing.T) {
err = os.WriteFile(filepath.Join(hostCfgDir, "hosts.toml"), []byte(hostTomlContent), 0600)
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{
{
ConfigPath: filepath.Dir(hostCfgDir),
Expand Down

0 comments on commit 3edebb7

Please sign in to comment.