- Notifications
You must be signed in to change notification settings - Fork1k
feat: include read/write byte stats in scaletests JSON report#17777
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -17,13 +17,24 @@ type testFns struct { | ||
RunFn func(ctx context.Context, id string, logs io.Writer) error | ||
// CleanupFn is optional if no cleanup is required. | ||
CleanupFn func(ctx context.Context, id string, logs io.Writer) error | ||
// getBytesTransferred is optional if byte transfer tracking is required. | ||
getBytesTransferred func() (int64, int64) | ||
} | ||
// Run implements Runnable. | ||
func (fns testFns) Run(ctx context.Context, id string, logs io.Writer) error { | ||
return fns.RunFn(ctx, id, logs) | ||
} | ||
// GetBytesTransferred implements Collectable. | ||
func (fns testFns) GetBytesTransferred() (bytesRead int64, bytesWritten int64) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I'm curious what's going on with this pattern, but your addition seems totally in line with what's already here :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. yeah I don't particularly like it, feels odd/reads strangely, but it's already in use for the cleanable interface as well so 🤷 | ||
if fns.getBytesTransferred == nil { | ||
return 0, 0 | ||
} | ||
return fns.getBytesTransferred() | ||
} | ||
// Cleanup implements Cleanable. | ||
func (fns testFns) Cleanup(ctx context.Context, id string, logs io.Writer) error { | ||
if fns.CleanupFn == nil { | ||
@@ -40,9 +51,10 @@ func Test_TestRun(t *testing.T) { | ||
t.Parallel() | ||
var ( | ||
name, id = "test", "1" | ||
runCalled int64 | ||
cleanupCalled int64 | ||
collectableCalled int64 | ||
testFns = testFns{ | ||
RunFn: func(ctx context.Context, id string, logs io.Writer) error { | ||
@@ -53,6 +65,10 @@ func Test_TestRun(t *testing.T) { | ||
atomic.AddInt64(&cleanupCalled, 1) | ||
return nil | ||
}, | ||
getBytesTransferred: func() (int64, int64) { | ||
atomic.AddInt64(&collectableCalled, 1) | ||
return 0, 0 | ||
}, | ||
} | ||
) | ||
@@ -62,6 +78,7 @@ func Test_TestRun(t *testing.T) { | ||
err := run.Run(context.Background()) | ||
require.NoError(t, err) | ||
require.EqualValues(t, 1, atomic.LoadInt64(&runCalled)) | ||
require.EqualValues(t, 1, atomic.LoadInt64(&collectableCalled)) | ||
err = run.Cleanup(context.Background()) | ||
require.NoError(t, err) | ||
@@ -105,6 +122,24 @@ func Test_TestRun(t *testing.T) { | ||
}) | ||
}) | ||
t.Run("Collectable", func(t *testing.T) { | ||
t.Parallel() | ||
t.Run("NoFn", func(t *testing.T) { | ||
t.Parallel() | ||
run := harness.NewTestRun("test", "1", testFns{ | ||
RunFn: func(ctx context.Context, id string, logs io.Writer) error { | ||
return nil | ||
}, | ||
getBytesTransferred: nil, | ||
}) | ||
err := run.Run(context.Background()) | ||
require.NoError(t, err) | ||
}) | ||
}) | ||
t.Run("CatchesRunPanic", func(t *testing.T) { | ||
t.Parallel() | ||
Uh oh!
There was an error while loading.Please reload this page.