Skip to content

GrpcCleanupRule errors out when retrying tests #8917

@laurentgo

Description

@laurentgo

When GrpcCleanupRule is used as a class rule and surefire/failsafe maven plugins are configured to retry failing tests, the rule throws an exception on the second run of the test with the following stacktrace:

java.lang.IllegalStateException: This stopwatch is already running.
	at com.google.common.base.Preconditions.checkState(Preconditions.java:502)
	at com.google.common.base.Stopwatch.start(Stopwatch.java:159)
	at io.grpc.testing.GrpcCleanupRule.teardown(GrpcCleanupRule.java:150)
	at io.grpc.testing.GrpcCleanupRule.access$100(GrpcCleanupRule.java:48)
	at io.grpc.testing.GrpcCleanupRule$1.evaluate(GrpcCleanupRule.java:138)
	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:299)
	at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:293)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.lang.Thread.run(Thread.java:829)

What version of gRPC-Java are you using?

1.44.0

What is your environment?

Linux/Java 8

What did you expect to see?

Expectation is for the rule not to throw when applied multiple times

What did you see instead?

An exception unrelated to the test is being thrown

Steps to reproduce the bug

Create a small maven project with a flakey test class, and enable surefire retry feature (see the attached project)

grpc-test-case.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions