-
Notifications
You must be signed in to change notification settings - Fork 102
Description
The unit test TestCopyGraph_WithOptions/MountFrom_error
in copy_test.go
has been flaky in recent builds.
Here is an instance: https://github.com/oras-project/oras-go/actions/runs/13639868900/job/38127074239?pr=906
=== RUN TestCopyGraph_WithOptions/MountFrom_error
copy_test.go:1810: count(Exists()) = 3, want 2
copy_test.go:1819: count(MountFrom()) = 2, want 1
=== RUN TestCopyGraph_WithOptions/MountFrom_OnMounted_error
--- FAIL: TestCopyGraph_WithOptions (0.01s)
--- PASS: TestCopyGraph_WithOptions/SkipNode (0.00s)
--- PASS: TestCopyGraph_WithOptions/MountFrom_mounted (0.00s)
--- PASS: TestCopyGraph_WithOptions/MountFrom_copied (0.00s)
--- PASS: TestCopyGraph_WithOptions/MountFrom_mounted_second_try (0.00s)
--- PASS: TestCopyGraph_WithOptions/MountFrom_copied_dst_not_a_Mounter (0.00s)
--- PASS: TestCopyGraph_WithOptions/MountFrom_empty_sourceRepositories (0.00s)
--- FAIL: TestCopyGraph_WithOptions/MountFrom_error (0.00s)
--- PASS: TestCopyGraph_WithOptions/MountFrom_OnMounted_error (0.00s)
Lines 1792 to 1821 in f3f718b
t.Run("MountFrom error", func(t *testing.T) { | |
root = descs[3] | |
dst := &countingStorage{storage: cas.NewMemory()} | |
opts = oras.CopyGraphOptions{ | |
// to make the run result deterministic, we limit concurrency to 1 | |
Concurrency: 1, | |
} | |
var numMountFrom atomic.Int64 | |
e := errors.New("mountFrom error") | |
opts.MountFrom = func(ctx context.Context, desc ocispec.Descriptor) ([]string, error) { | |
numMountFrom.Add(1) | |
return nil, e | |
} | |
if err := oras.CopyGraph(ctx, src, dst, root, opts); !errors.Is(err, e) { | |
t.Fatalf("CopyGraph() error = %v, wantErr %v", err, e) | |
} | |
if got, expected := dst.numExists.Load(), int64(2); got != expected { | |
t.Errorf("count(Exists()) = %d, want %d", got, expected) | |
} | |
if got, expected := dst.numFetch.Load(), int64(0); got != expected { | |
t.Errorf("count(Fetch()) = %d, want %d", got, expected) | |
} | |
if got, expected := dst.numPush.Load(), int64(0); got != expected { | |
t.Errorf("count(Push()) = %d, want %d", got, expected) | |
} | |
if got, expected := numMountFrom.Load(), int64(1); got != expected { | |
t.Errorf("count(MountFrom()) = %d, want %d", got, expected) | |
} | |
}) |