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

Fix robustness test logs by identifing failpoint availability on temporary cluster before creating subtest #18685

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
33 changes: 25 additions & 8 deletions tests/robustness/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,39 @@ func TestMain(m *testing.M) {
func TestRobustnessExploratory(t *testing.T) {
testRunner.BeforeTest(t)
for _, s := range scenarios.Exploratory(t) {
t.Run(s.Name, func(t *testing.T) {
ctx := context.Background()
s.Failpoint = randomFailpointForConfig(ctx, t, s.Profile, s.Cluster)
t.Run(s.Name+"/"+s.Failpoint.Name(), func(t *testing.T) {
lg := zaptest.NewLogger(t)
s.Cluster.Logger = lg
ctx := context.Background()
c, err := e2e.NewEtcdProcessCluster(ctx, t, e2e.WithConfig(&s.Cluster))
require.NoError(t, err)
if err != nil {
t.Fatal(err)
}
defer forcestopCluster(c)
s.Failpoint, err = failpoint.PickRandom(c, s.Profile)
require.NoError(t, err)
t.Run(s.Failpoint.Name(), func(t *testing.T) {
testRobustness(ctx, t, lg, s, c)
})
testRobustness(ctx, t, lg, s, c)
})
}
}

// TODO: Implement lightweight a way to generate list of failpoints without needing to start a cluster
func randomFailpointForConfig(ctx context.Context, t *testing.T, profile traffic.Profile, config e2e.EtcdProcessClusterConfig) failpoint.Failpoint {
config.Logger = zap.NewNop()
c, err := e2e.NewEtcdProcessCluster(ctx, t, e2e.WithConfig(&config))
if err != nil {
t.Fatal(err)
}
f, err := failpoint.PickRandom(c, profile)
if err != nil {
t.Fatal(err)
}
err = forcestopCluster(c)
Copy link
Contributor

Choose a reason for hiding this comment

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

why not return the cluster and reuse it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because logs will be directed to the different log name. During cluster creation we provide the logger, to correlate logs to tests, we use zaptest.New which takes the *testing.T as argument. If we reuse the cluster they will not be correlated to logs and clusters from all tests scenarios will be mixed.

if err != nil {
t.Fatal(err)
}
return f
}

func TestRobustnessRegression(t *testing.T) {
testRunner.BeforeTest(t)
for _, s := range scenarios.Regression(t) {
Expand Down
Loading