aboutsummaryrefslogtreecommitdiff
path: root/gae-interop-testing
diff options
context:
space:
mode:
authorzpencer <spencerfang@google.com>2017-11-09 16:07:58 -0800
committerGitHub <noreply@github.com>2017-11-09 16:07:58 -0800
commit970785d82b7441fae6d8baa0216cbf4856c9e67e (patch)
tree1c3dc4d097e83428b9fc0986728df4445973c620 /gae-interop-testing
parent1a42a4c9215d896f7c5183a6d4d2d83b25a5850e (diff)
downloadgrpc-grpc-java-970785d82b7441fae6d8baa0216cbf4856c9e67e.tar.gz
gae-interop-testing: create new instance per test for okhttp (#3698)
Without this, the test is flakey for some test methods. The flakiness is probably caused by AbstractInteropTest and not due to gRPC itself.
Diffstat (limited to 'gae-interop-testing')
-rw-r--r--gae-interop-testing/gae-jdk7/src/main/java/io/grpc/testing/integration/OkHttpClientInteropServlet.java5
1 files changed, 3 insertions, 2 deletions
diff --git a/gae-interop-testing/gae-jdk7/src/main/java/io/grpc/testing/integration/OkHttpClientInteropServlet.java b/gae-interop-testing/gae-jdk7/src/main/java/io/grpc/testing/integration/OkHttpClientInteropServlet.java
index 42255bb9e..d7d7632a1 100644
--- a/gae-interop-testing/gae-jdk7/src/main/java/io/grpc/testing/integration/OkHttpClientInteropServlet.java
+++ b/gae-interop-testing/gae-jdk7/src/main/java/io/grpc/testing/integration/OkHttpClientInteropServlet.java
@@ -60,12 +60,11 @@ public final class OkHttpClientInteropServlet extends HttpServlet {
// We can not use JUnit because it tries to spawn backgrounds threads.
// GAE+JDK7 does not allow arbitrary background threads.
// Let's use reflection to run test methods.
- Tester tester = new Tester();
List<Method> befores = new ArrayList<>();
List<Method> afters = new ArrayList<>();
List<Method> testMethods = new ArrayList<>();
int ignored = 0;
- for (Method method : tester.getClass().getMethods()) {
+ for (Method method : Tester.class.getMethods()) {
if (method.getAnnotation(Test.class) != null) {
if (method.getAnnotation(Ignore.class) != null) {
ignored++;
@@ -82,6 +81,8 @@ public final class OkHttpClientInteropServlet extends HttpServlet {
StringBuilder sb = new StringBuilder();
int failures = 0;
for (Method method : testMethods) {
+ // JUnit creates a new instance per test method, we will emulate that behavior.
+ Tester tester = new Tester();
try {
for (Method before : befores) {
before.invoke(tester);