Skip to content

Commit fbeb6e1

Browse files
committed
1. Allow the newly deployed App Engine instance up to 2 minutes to complete its JVM initialization and handle the cold start, to avoid the SocketTimeoutException seen in GAE interop testing action http://shortn/_WEppvnsGXs.
2. Wait and Retry Loop: Added a loop that attempts the check up to 5 times with a 2-second sleep between attempts. This will gracefully absorb any transient warmup or App Engine routing latency (http://shortn/_ONTi0mqEdB) 3. Detailed Failure Logs: If all attempts fail, we now retrieve the response bodies (result.body().string()) and include them along with the status codes in the final error message, allowing for straightforward debugging of any persistent downstream issues.
1 parent 49a7e89 commit fbeb6e1

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

gae-interop-testing/gae-jdk8/build.gradle

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,35 @@ tasks.register("runInteropTestRemote") {
124124
logger.log(LogLevel.INFO, "the appURL=" + appUrl)
125125
def client = new com.squareup.okhttp.OkHttpClient()
126126
// The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry
127-
client.setReadTimeout(30, java.util.concurrent.TimeUnit.SECONDS)
127+
client.setReadTimeout(120, java.util.concurrent.TimeUnit.SECONDS)
128128
def request = new com.squareup.okhttp.Request.Builder()
129129
.url("${appUrl}/long_lived_channel?jdk8").build()
130-
def result1 = client.newCall(request).execute()
131-
def result2 = client.newCall(request).execute()
132-
if (result1.code() != 200 || result2.code() != 200) {
133-
throw new GradleException("Unable to reuse same channel across requests")
130+
int maxRetries = 5
131+
def result1 = null
132+
def result2 = null
133+
String result1Body = ""
134+
String result2Body = ""
135+
for (int attempt = 0; attempt < maxRetries; attempt++) {
136+
try {
137+
result1 = client.newCall(request).execute()
138+
result2 = client.newCall(request).execute()
139+
if (result1.code() == 200 && result2.code() == 200) {
140+
break
141+
}
142+
logger.log(LogLevel.WARN, "Channel reuse attempt ${attempt + 1} failed: result1 code = ${result1?.code()}, result2 code = ${result2?.code()}. Retrying...")
143+
} catch (Throwable t) {
144+
logger.log(LogLevel.WARN, "Channel reuse attempt ${attempt + 1} caught exception: ${t.message}. Retrying...", t)
145+
}
146+
Thread.sleep(2000)
147+
}
148+
if (result1 == null || result2 == null || result1.code() != 200 || result2.code() != 200) {
149+
if (result1 != null) {
150+
result1Body = result1.body().string()
151+
}
152+
if (result2 != null) {
153+
result2Body = result2.body().string()
154+
}
155+
throw new GradleException("Unable to reuse same channel across requests. result1: ${result1?.code()} (body: ${result1Body}), result2: ${result2?.code()} (body: ${result2Body})")
134156
}
135157

136158
// The test suite can take a while to run

0 commit comments

Comments
 (0)