Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
509c602
Removed redundant code. Return no error.
prasad-shirodkar Apr 10, 2024
1cf07b6
Merge remote-tracking branch 'upstream/main' into remove_context_check
prasad-shirodkar Apr 17, 2024
326e7f6
handle cancellations
prasad-shirodkar Apr 17, 2024
3dae347
removed flaky deadline test case
prasad-shirodkar Apr 17, 2024
48d3eb8
added tests for ignoring context errors
prasad-shirodkar Apr 17, 2024
0d63602
Merge remote-tracking branch 'upstream/main' into remove_context_check
prasad-shirodkar Apr 17, 2024
7c88d49
updated changelog
prasad-shirodkar Apr 17, 2024
34908f3
renamed to TestExporterShutdownIgnoresContext
prasad-shirodkar Apr 17, 2024
7373862
updated changelog
prasad-shirodkar Apr 17, 2024
fa49342
removed DeadlineExceeded Ignored test case
prasad-shirodkar Apr 17, 2024
261659f
removed redundant test cases
prasad-shirodkar Apr 17, 2024
5edd3cb
removed flaky test case TestExporterShutdownHonorsTimeout
prasad-shirodkar Apr 17, 2024
a93250e
Merge remote-tracking branch 'upstream/main' into remove_context_check
prasad-shirodkar Apr 20, 2024
1909f88
simplified to background context
prasad-shirodkar Apr 20, 2024
c9f7c08
reverted
prasad-shirodkar Apr 20, 2024
477d2ed
Merge remote-tracking branch 'upstream/main' into remove_context_check
prasad-shirodkar Apr 22, 2024
0094a5a
Merge remote-tracking branch 'upstream/main' into remove_context_check
prasad-shirodkar Apr 23, 2024
638c349
Merge remote-tracking branch 'upstream/main' into remove_context_check
prasad-shirodkar Apr 24, 2024
53b3bba
Merge branch 'main' into remove_context_check
pellared Apr 25, 2024
e9b4df0
Update CHANGELOG.md
pellared Apr 25, 2024
450bc87
Merge branch 'main' into remove_context_check
pellared Apr 25, 2024
10b6e63
Update CHANGELOG.md
pellared Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added tests for ignoring context errors
  • Loading branch information
prasad-shirodkar committed Apr 17, 2024
commit 48d3eb873e9a5d930e788a010265531635331f3b
47 changes: 46 additions & 1 deletion exporters/stdout/stdoutmetric/exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,36 @@ func testCtxErrHonored(factory func(*testing.T) func(context.Context) error) fun
}
}

func TestExporterHonorsContextErrors(t *testing.T) {
func testCtxErrIgnored(factory func(*testing.T) func(context.Context) error) func(t *testing.T) {
return func(t *testing.T) {
t.Helper()
ctx, cancel := context.WithCancel(context.Background())
t.Cleanup(cancel)

t.Run("DeadlineExceeded Ignored", func(t *testing.T) {
innerCtx, innerCancel := context.WithTimeout(ctx, time.Nanosecond)
t.Cleanup(innerCancel)

f := factory(t)
assert.NoError(t, f(innerCtx))
})

t.Run("Canceled Ignored", func(t *testing.T) {
innerCtx, innerCancel := context.WithCancel(ctx)
innerCancel()

f := factory(t)
assert.NoError(t, f(innerCtx))
})

t.Run("NoError", func(t *testing.T) {
f := factory(t)
assert.NoError(t, f(ctx))
})
}
}

func TestExporterExportHonorsContextErrors(t *testing.T) {
t.Run("Export", testCtxErrHonored(func(t *testing.T) func(context.Context) error {
exp, err := stdoutmetric.New(testEncoderOption())
require.NoError(t, err)
Expand All @@ -65,6 +94,22 @@ func TestExporterHonorsContextErrors(t *testing.T) {
}))
}

func TestExporterForceFlushIgnoresContextErrors(t *testing.T) {
t.Run("ForceFlush", testCtxErrIgnored(func(t *testing.T) func(context.Context) error {
exp, err := stdoutmetric.New(testEncoderOption())
require.NoError(t, err)
return exp.ForceFlush
}))
}

func TestExporterShutdownIgnoresContextErrors(t *testing.T) {
t.Run("Shutdown", testCtxErrIgnored(func(t *testing.T) func(context.Context) error {
exp, err := stdoutmetric.New(testEncoderOption())
require.NoError(t, err)
return exp.Shutdown
}))
}

func TestExporterShutdown(t *testing.T) {
exporter, err := stdoutmetric.New(testEncoderOption())
assert.NoError(t, err)
Expand Down