Skip to content

Commit bce0860

Browse files
committed
Enable testSendAndWaitThrowsOnTimeout in CI
- Enhanced CapiProxy.isAlive() to include HTTP health check - When proxy crashes (e.g., due to no cached response), the HTTP check detects it and triggers automatic restart - Removed @DisabledIfEnvironmentVariable annotation from timeout test - All 80 tests now pass in CI mode The upstream Node.js harness has a bug where it crashes on 'no cached response' due to missing 'return' after exitWithNoMatchingRequestError. This fix works around it by detecting the crashed proxy and restarting.
1 parent 07b8b3f commit bce0860

2 files changed

Lines changed: 27 additions & 9 deletions

File tree

src/test/java/com/github/copilot/sdk/CapiProxy.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,34 @@ public String getProxyUrl() {
289289
}
290290

291291
/**
292-
* Checks if the proxy process is still alive.
292+
* Checks if the proxy process is still alive and responsive. This does both a
293+
* process alive check AND an HTTP health check.
293294
*
294-
* @return true if the proxy is running, false otherwise
295+
* @return true if the proxy is running and responsive, false otherwise
295296
*/
296297
public boolean isAlive() {
297-
return process != null && process.isAlive();
298+
if (process == null || !process.isAlive()) {
299+
return false;
300+
}
301+
302+
// Also verify the proxy is responsive via HTTP
303+
if (proxyUrl != null) {
304+
try {
305+
java.net.HttpURLConnection conn = (java.net.HttpURLConnection) new java.net.URL(proxyUrl + "/exchanges")
306+
.openConnection();
307+
conn.setRequestMethod("GET");
308+
conn.setConnectTimeout(1000);
309+
conn.setReadTimeout(1000);
310+
int responseCode = conn.getResponseCode();
311+
conn.disconnect();
312+
return responseCode == 200;
313+
} catch (Exception e) {
314+
// If HTTP check fails, the proxy is not responsive
315+
return false;
316+
}
317+
}
318+
319+
return true;
298320
}
299321

300322
/**

src/test/java/com/github/copilot/sdk/CopilotSessionTest.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import org.junit.jupiter.api.AfterAll;
2020
import org.junit.jupiter.api.BeforeAll;
2121
import org.junit.jupiter.api.Test;
22-
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
2322

2423
import com.github.copilot.sdk.events.AbstractSessionEvent;
2524
import com.github.copilot.sdk.events.AbortEvent;
@@ -487,12 +486,9 @@ void testCreateSessionWithCustomConfigDir() throws Exception {
487486
}
488487
}
489488

490-
// Skip in CI - this test validates client-side timeout behavior, not LLM
491-
// responses.
492-
// The test intentionally times out before receiving a response, so there's no
493-
// snapshot to replay.
489+
// This test validates client-side timeout behavior. The snapshot has no
490+
// assistant response because the test expects timeout BEFORE completion.
494491
@Test
495-
@DisabledIfEnvironmentVariable(named = "CI", matches = ".*")
496492
void testSendAndWaitThrowsOnTimeout() throws Exception {
497493
ctx.configureForTest("session", "sendandwait_throws_on_timeout");
498494

0 commit comments

Comments
 (0)