Skip to content

Commit

Permalink
Cleanup test and do not run trace logging on slow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Nov 21, 2023
1 parent 21aa01e commit f9d9621
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
16 changes: 0 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -732,22 +732,6 @@
<includesFile>src/test/resources/slow-or-flaky-tests.txt</includesFile>
</configuration>
</execution>
<execution>
<id>slow-or-flaky-test-tracing</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<classesDirectory>${project.basedir}/target/github-api-${project.version}.jar</classesDirectory>
<rerunFailingTestsCount>2</rerunFailingTestsCount>
<includesFile>src/test/resources/slow-or-flaky-tests.txt</includesFile>
<!-- Run some test passes with trace logging turned on -->
<systemPropertyVariables>
<java.util.logging.config.file>src/test/resources/test-trace-logging.properties</java.util.logging.config.file>
</systemPropertyVariables>
</configuration>
</execution>
<execution>
<!-- Verify that JWT suite 0.11.x still works -->
<id>jwt0.11.x-test</id>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/kohsuke/github/GitHubClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -689,8 +689,8 @@ private static void logRetryConnectionError(IOException e, URL url, int retries)
() -> String.format(
"(%s) %s while connecting to %s: '%s'. Sleeping %d milliseconds before retrying (%d retries remaining)",
sendRequestTraceId.get(),
url.toString(),
e.getClass().toString(),
url.toString(),
e.getMessage(),
sleepTime,
retries));
Expand Down
27 changes: 11 additions & 16 deletions src/test/java/org/kohsuke/github/RequesterRetryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ public void testSocketConnectionAndRetry() throws Exception {
}

String capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(true));
assertThat(capturedLog.contains("will try 1 more time"), is(true));
assertThat(capturedLog, containsString("(2 retries remaining)"));
assertThat(capturedLog, containsString("(1 retries remaining)"));

assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + 6));
}
Expand Down Expand Up @@ -216,8 +216,8 @@ public void testSocketConnectionAndRetry_StatusCode() throws Exception {
}

String capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(true));
assertThat(capturedLog.contains("will try 1 more time"), is(true));
assertThat(capturedLog, containsString("(2 retries remaining)"));
assertThat(capturedLog, containsString("(1 retries remaining)"));

assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + 6));
}
Expand Down Expand Up @@ -275,8 +275,8 @@ public void testSocketConnectionAndRetry_Success() throws Exception {
GHBranch branch = repo.getBranch("test/timeout");
assertThat(branch, notNullValue());
String capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(true));
assertThat(capturedLog.contains("will try 1 more time"), is(true));
assertThat(capturedLog, containsString("(2 retries remaining)"));
assertThat(capturedLog, containsString("(1 retries remaining)"));

assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + 6));
}
Expand Down Expand Up @@ -307,8 +307,7 @@ public void testResponseCodeFailureExceptions() throws Exception {
assertThat(e.getCause(), instanceOf(IOException.class));
assertThat(e.getCause().getMessage(), is("Custom"));
String capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(false));
assertThat(capturedLog.contains("will try 1 more time"), is(false));
assertThat(capturedLog, not(containsString("retries remaining")));
assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount));
}

Expand All @@ -328,8 +327,7 @@ public void testResponseCodeFailureExceptions() throws Exception {
assertThat(e, instanceOf(FileNotFoundException.class));
assertThat(e.getMessage(), is("Custom"));
String capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(false));
assertThat(capturedLog.contains("will try 1 more time"), is(false));
assertThat(capturedLog, not(containsString("retries remaining")));
assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount));
}
}
Expand Down Expand Up @@ -360,8 +358,7 @@ public void testInputStreamFailureExceptions() throws Exception {
assertThat(e.getCause(), instanceOf(IOException.class));
assertThat(e.getCause().getMessage(), is("Custom"));
String capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(false));
assertThat(capturedLog.contains("will try 1 more time"), is(false));
assertThat(capturedLog, not(containsString("retries remaining")));
assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + 1));
}

Expand All @@ -378,8 +375,7 @@ public void testInputStreamFailureExceptions() throws Exception {
assertThat(e.getCause(), instanceOf(FileNotFoundException.class));
assertThat(e.getCause().getMessage(), containsString("hub4j-test-org-missing"));
String capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(false));
assertThat(capturedLog.contains("will try 1 more time"), is(false));
assertThat(capturedLog, not(containsString("retries remaining")));
assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + 1));
}

Expand All @@ -394,8 +390,7 @@ public void testInputStreamFailureExceptions() throws Exception {
.fetchHttpStatusCode(),
equalTo(404));
String capturedLog = getTestCapturedLog();
assertThat(capturedLog.contains("will try 2 more time"), is(false));
assertThat(capturedLog.contains("will try 1 more time"), is(false));
assertThat(capturedLog, not(containsString("retries remaining")));
assertThat(this.mockGitHub.getRequestCount(), equalTo(baseRequestCount + 1));
}

Expand Down

0 comments on commit f9d9621

Please sign in to comment.