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

tests/robustness: cleanup errgroup usage #17858

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MadhavJivrajani
Copy link
Contributor

We don't really need to use errgroups. In most places we return nil from the errgroup goroutines, those can be replaced by goroutines + waitgroups.

There was one place where we returned ctx.Err() from the errgroup routine but never caught that error from Wait(). It is okay to not return an error here as well since we catch the context cancellation error higher up in the call stack anyway.

cc @serathius

We don't really need to use errgroups. In most places
we return nil from the errgroup goroutines, those can be
replaced by goroutines + waitgroups.

There was one place where we returned ctx.Err() from the
errgroup routine but never caught that error from Wait().
It is okay to not return an error here as well since we
catch the context cancellation error higher up in the call
stack anyway.

Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
Comment on lines -72 to +73
return ctx.Err()
return
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not returning an error here since we check for it anyway higher up in the call stack:

case <-ctx.Done():

Also, this way it is more consistent with how the etcdTraffic implementation handles this.

@@ -108,15 +108,17 @@ func testRobustness(ctx context.Context, t *testing.T, lg *zap.Logger, s testSce
func (s testScenario) run(ctx context.Context, t *testing.T, lg *zap.Logger, clus *e2e.EtcdProcessCluster) (reports []report.ClientReport) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
g := errgroup.Group{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we don't use errors, but usage of errgroup is more concise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am okay with keeping it in as well! I usually just prefer not using things in exp if the language or stdlib can handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants