Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky unit test: TestCopyGraph_WithOptions/MountFrom_error #908

Open
Wwwsylvia opened this issue Mar 4, 2025 · 0 comments
Open

Flaky unit test: TestCopyGraph_WithOptions/MountFrom_error #908

Wwwsylvia opened this issue Mar 4, 2025 · 0 comments
Labels
testing General testing related issues or pull requests
Milestone

Comments

@Wwwsylvia
Copy link
Member

Wwwsylvia commented Mar 4, 2025

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)

oras-go/copy_test.go

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)
}
})

@Wwwsylvia Wwwsylvia added the testing General testing related issues or pull requests label Mar 4, 2025
@Wwwsylvia Wwwsylvia added this to the v2.6.0 milestone Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing General testing related issues or pull requests
Projects
None yet
Development

No branches or pull requests

1 participant