Skip to content

Commit

Permalink
Adding debug in Jenkins to spot the issue
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Bescos Gascon <[email protected]>
  • Loading branch information
jbescos committed Jul 9, 2021
1 parent b977231 commit 85288ba
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
Expand All @@ -40,6 +41,9 @@
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.TestProperties;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;

public class StressTest extends JerseyTest {
Expand All @@ -50,6 +54,16 @@ public class StressTest extends JerseyTest {
private static CountDownLatch requests;
private static CountDownLatch latch;

@BeforeClass
public static void beforeClass() {
System.out.println("Starting test StressTest");
}

@AfterClass
public static void afterClass() {
System.out.println("Finish test StressTest");
}

@Path("/test")
public static class TestResource {
@GET
Expand Down Expand Up @@ -85,6 +99,7 @@ protected void configureClient(ClientConfig config) {
}

@Test
@Ignore
public void hangAllRequestsStatus200() throws InterruptedException, ExecutionException {
ExecutorService executor = Executors.newFixedThreadPool(PARALLELISM,
new ThreadFactoryBuilder().setNameFormat("client-%d").build());
Expand All @@ -99,14 +114,15 @@ public void hangAllRequestsStatus200() throws InterruptedException, ExecutionExc
assertTrue(requests.await(20, TimeUnit.SECONDS));
latch.countDown();
for (Future<Response> response : responses) {
assertEquals(200, response.get().getStatus());
assertEquals(threadDump(), 200, response.get().getStatus());
}
}
executor.shutdown();
assertTrue(executor.awaitTermination(10, TimeUnit.SECONDS));
}

@Test
@Ignore
public void randomnessStatus200() throws InterruptedException, ExecutionException {
ExecutorService executor = Executors.newFixedThreadPool(PARALLELISM,
new ThreadFactoryBuilder().setNameFormat("client-%d").build());
Expand All @@ -118,7 +134,7 @@ public void randomnessStatus200() throws InterruptedException, ExecutionExceptio
responses.add(future);
}
for (Future<Response> response : responses) {
assertEquals(200, response.get().getStatus());
assertEquals(threadDump(), 200, response.get().getStatus());
}
}
executor.shutdown();
Expand All @@ -136,4 +152,15 @@ public void asyncTest() throws InterruptedException, ExecutionException {
Future<Response> response = target("/test/2").request().async().get();
assertEquals(200, response.get().getStatus());
}

private String threadDump() {
StringBuilder builder = new StringBuilder();
for (Entry<Thread, StackTraceElement[]> entry : Thread.getAllStackTraces().entrySet()) {
builder.append(entry.getKey().getName()).append("\r\n");
for (StackTraceElement element : entry.getValue()) {
builder.append("\t").append(element).append("\r\n");
}
}
return builder.toString();
}
}
2 changes: 1 addition & 1 deletion etc/jenkins/jenkins_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

export DEBUG=true

mvn -V -U -B -e clean install glassfish-copyright:check -Dcopyright.quiet=false -Dsurefire.systemPropertiesFile=${WORKSPACE}/etc/jenkins/systemPropertiesFile
mvn -X -V -U -B -e clean install glassfish-copyright:check -Dcopyright.quiet=false -Dsurefire.systemPropertiesFile=${WORKSPACE}/etc/jenkins/systemPropertiesFile

0 comments on commit 85288ba

Please sign in to comment.