Skip to content

Commit c40ae21

Browse files
authored
Merge pull request #4818 from haytok/issue_4789
test: resolve a flaky test of TestLoadStdinFromPipe
2 parents 7e75010 + b5755a0 commit c40ae21

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

cmd/nerdctl/image/image_load_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestLoadStdinFromPipe(t *testing.T) {
3838

3939
testCase := &test.Case{
4040
Description: "TestLoadStdinFromPipe",
41-
Require: require.All(require.Linux, nerdtest.IsFlaky("https://github.com/containerd/nerdctl/issues/4789")),
41+
Require: require.Linux,
4242
Setup: func(data test.Data, helpers test.Helpers) {
4343
identifier := data.Identifier()
4444
helpers.Ensure("pull", "--quiet", testutil.CommonImage)

pkg/imgutil/load/load.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func FromArchive(ctx context.Context, client *containerd.Client, options types.I
8686

8787
var loadedImages []images.Image
8888
pf, done := transferutil.ProgressHandler(ctx, options.Stdout)
89-
defer done()
9089

9190
err = client.Transfer(ctx,
9291
tarchive.NewImageImportStream(options.Stdin, ""),
@@ -96,16 +95,21 @@ func FromArchive(ctx context.Context, client *containerd.Client, options types.I
9695
if img, err := imageService.Get(ctx, p.Name); err == nil {
9796
if !beforeSet[img.Name] {
9897
loadedImages = append(loadedImages, img)
99-
if !options.Quiet {
100-
fmt.Fprintf(options.Stdout, "Loaded image: %s\n", img.Name)
101-
}
10298
}
10399
}
104100
}
105101
pf(p)
106102
}),
107103
)
108104

105+
done()
106+
107+
if !options.Quiet {
108+
for _, img := range loadedImages {
109+
fmt.Fprintf(options.Stdout, "Loaded image: %s\n", img.Name)
110+
}
111+
}
112+
109113
return loadedImages, err
110114
}
111115

0 commit comments

Comments
 (0)