Skip to content

Commit 6be0443

Browse files
authored
Merge pull request #172 from edburns/edburns/resolve-fake-test-time-token-failures
Edburns/resolve fake test time token failures
2 parents 6c9fdba + 42283ca commit 6be0443

5 files changed

Lines changed: 19 additions & 24 deletions

File tree

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@
319319
<artifactId>maven-surefire-plugin</artifactId>
320320
<version>3.5.5</version>
321321
<configuration>
322+
<runOrder>alphabetical</runOrder>
322323
<!-- Inject JaCoCo agent + any JDK-version-specific flags -->
323324
<argLine>${testExecutionAgentArgs} ${surefire.jvm.args}</argLine>
324325
<!--

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ public String start() throws IOException, InterruptedException {
9898
: new ProcessBuilder("npx", "tsx", "server.ts");
9999
pb.directory(harnessDir.toFile());
100100
pb.redirectErrorStream(false);
101+
// Tell the replaying proxy to fail fast on unmatched requests rather than
102+
// forwarding them to the real API. Without this, unmatched requests hit the
103+
// live API with a fake token and crash the proxy's JSON parser.
104+
pb.environment().put("GITHUB_ACTIONS", "true");
101105

102106
process = pb.start();
103107

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import org.junit.jupiter.api.AfterAll;
1414
import org.junit.jupiter.api.BeforeAll;
15+
import org.junit.jupiter.api.Disabled;
1516
import org.junit.jupiter.api.Test;
1617
import org.junit.jupiter.api.Timeout;
1718

@@ -52,10 +53,17 @@ static void teardown() throws Exception {
5253
/**
5354
* Verifies that compaction is triggered with low threshold and emits events.
5455
*
56+
* <p>
57+
* Disabled due to flakiness — compaction timing is non-deterministic and the
58+
* snapshot cannot reliably match across platforms. The reference implementation
59+
* (nodejs) also skips this test. See <a href=
60+
* "https://github.com/github/copilot-sdk/issues/1227">copilot-sdk#1227</a>.
61+
*
5562
* @see Snapshot:
5663
* compaction/should_trigger_compaction_with_low_threshold_and_emit_events
5764
*/
5865
@Test
66+
@Disabled("Flaky: compaction timing varies by platform — see https://github.com/github/copilot-sdk/issues/1227")
5967
@Timeout(value = 300, unit = TimeUnit.SECONDS)
6068
void testShouldTriggerCompactionWithLowThresholdAndEmitEvents() throws Exception {
6169
ctx.configureForTest("compaction", "should_trigger_compaction_with_low_threshold_and_emit_events");

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

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,15 +270,10 @@ public Map<String, String> getEnvironment() {
270270
env.put("REQUESTS_CA_BUNDLE", caFile);
271271
env.put("CURL_CA_BUNDLE", caFile);
272272
env.put("GIT_SSL_CAINFO", caFile);
273-
env.put("GH_TOKEN", "");
274-
env.put("GITHUB_TOKEN", "");
275-
env.put("GH_ENTERPRISE_TOKEN", "");
276-
env.put("GITHUB_ENTERPRISE_TOKEN", "");
277-
}
278-
279-
if ("true".equals(System.getenv("GITHUB_ACTIONS"))) {
280273
env.put("GH_TOKEN", "fake-token-for-e2e-tests");
281274
env.put("GITHUB_TOKEN", "fake-token-for-e2e-tests");
275+
env.put("GH_ENTERPRISE_TOKEN", "");
276+
env.put("GITHUB_ENTERPRISE_TOKEN", "");
282277
}
283278

284279
return env;
@@ -291,13 +286,7 @@ public Map<String, String> getEnvironment() {
291286
*/
292287
public CopilotClient createClient() {
293288
CopilotClientOptions options = new CopilotClientOptions().setCliPath(cliPath).setCwd(workDir.toString())
294-
.setEnvironment(getEnvironment());
295-
296-
// In CI (GitHub Actions), use a fake token to avoid auth issues
297-
String ci = System.getenv("GITHUB_ACTIONS");
298-
if (ci != null && !ci.isEmpty()) {
299-
options.setGitHubToken("fake-token-for-e2e-tests");
300-
}
289+
.setEnvironment(getEnvironment()).setGitHubToken("fake-token-for-e2e-tests");
301290

302291
return new CopilotClient(options);
303292
}
@@ -321,10 +310,7 @@ public CopilotClient createClient(CopilotClientOptions options) {
321310
if (options.getEnvironment() == null || options.getEnvironment().isEmpty()) {
322311
options.setEnvironment(getEnvironment());
323312
}
324-
325-
// In CI (GitHub Actions), use a fake token to avoid auth issues
326-
String ci = System.getenv("GITHUB_ACTIONS");
327-
if (ci != null && !ci.isEmpty() && options.getGitHubToken() == null) {
313+
if (options.getGitHubToken() == null) {
328314
options.setGitHubToken("fake-token-for-e2e-tests");
329315
}
330316

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,8 @@ int getTaskCount() {
8787

8888
private CopilotClientOptions createOptionsWithExecutor(TrackingExecutor executor) {
8989
CopilotClientOptions options = new CopilotClientOptions().setCliPath(ctx.getCliPath())
90-
.setCwd(ctx.getWorkDir().toString()).setEnvironment(ctx.getEnvironment()).setExecutor(executor);
91-
92-
String ci = System.getenv("GITHUB_ACTIONS");
93-
if (ci != null && !ci.isEmpty()) {
94-
options.setGitHubToken("fake-token-for-e2e-tests");
95-
}
90+
.setCwd(ctx.getWorkDir().toString()).setEnvironment(ctx.getEnvironment()).setExecutor(executor)
91+
.setGitHubToken("fake-token-for-e2e-tests");
9692
return options;
9793
}
9894

0 commit comments

Comments
 (0)