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

kvserver: minor test cleanup #93363

Merged
Merged
Changes from all commits
Commits
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
21 changes: 11 additions & 10 deletions pkg/kv/kvserver/consistency_queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -542,25 +542,26 @@ func testConsistencyQueueRecomputeStatsImpl(t *testing.T, hadEstimates bool) {
// RecomputeStats does not see any skew in its MVCC stats when they are
// modified concurrently. Note that these writes don't interfere with the
// field we modified (SysCount).
//
// We want to run this task under the cluster's stopper, as opposed to the
// first node's stopper, so that the quiesce signal is delivered below before
// individual nodes start shutting down.
_ = tc.Stopper().RunAsyncTaskEx(ctx,
stop.TaskOpts{
TaskName: "recompute-loop",
// We want to run this task under the cluster's stopper, so that the
// quiesce signal is delivered below before individual nodes start
// shutting down. Since we're going to operate on a specific node, we
// can't mix the cluster stopper's tracer with the node's tracer, hence
// the Sterile option.
SpanOpt: stop.SterileRootSpan,
}, func(ctx context.Context) {
}, func(_ context.Context) {
// This channel terminates the loop early if the test takes more than five
// seconds. This is useful for stress race runs in CI where the tight loop
// can starve the actual work to be done.
done := time.After(5 * time.Second)
for {
require.NoError(t, db0.Put(ctx, fmt.Sprintf("%s%d", key, rand.Int63()), "ballast"))
// We're using context.Background for the KV call. As explained above,
// this task runs on the cluster's stopper, and so the ctx that was
// passed to this function has a span created with a Tracer that's
// different from the first node's Tracer. If we used the ctx, we'd be
// combining Tracers in the trace, which is illegal.
require.NoError(t, db0.Put(context.Background(), fmt.Sprintf("%s%d", key, rand.Int63()), "ballast"))
select {
case <-ctx.Done():
return
case <-tc.Stopper().ShouldQuiesce():
return
case <-done:
Expand Down