3737 * that ships with OS X by default.
3838 */
3939public class CrashtrackingSmokeTest {
40- private static final long DATA_TIMEOUT_MS = 25 * 1000 ;
41- private static Path LOG_FILE_DIR ;
40+ private static final long DATA_TIMEOUT_MS = 10 * 1000 ;
41+ private static final OutputThreads OUTPUT = new OutputThreads ();
42+ private static final Path LOG_FILE_DIR =
43+ Paths .get (System .getProperty ("datadog.smoketest.builddir" ), "reports" );
44+
4245 private MockWebServer tracingServer ;
4346 private TestUDPServer udpServer ;
44- private BlockingQueue <CrashTelemetryData > crashEvents = new LinkedBlockingQueue <>();
47+ private final BlockingQueue <CrashTelemetryData > crashEvents = new LinkedBlockingQueue <>();
4548
4649 @ BeforeAll
4750 static void setupAll () {
4851 // Only Hotspot based implementation are supported
4952 assumeFalse (Platform .isJ9 ());
50-
51- LOG_FILE_DIR = Paths .get (System .getProperty ("datadog.smoketest.builddir" ), "reports" );
5253 }
5354
5455 private Path tempDir ;
55- private static OutputThreads outputThreads = new OutputThreads ();
5656
5757 @ BeforeEach
5858 void setup () throws Exception {
@@ -65,7 +65,9 @@ void setup() throws Exception {
6565 tracingServer .setDispatcher (
6666 new Dispatcher () {
6767 @ Override
68- public MockResponse dispatch (final RecordedRequest request ) throws InterruptedException {
68+ public MockResponse dispatch (final RecordedRequest request ) {
69+ System .out .println ("URL ====== " + request .getPath ());
70+
6971 String data = request .getBody ().readString (StandardCharsets .UTF_8 );
7072
7173 if ("/telemetry/proxy/api/v2/apmtelemetry" .equals (request .getPath ())) {
@@ -82,7 +84,7 @@ public MockResponse dispatch(final RecordedRequest request) throws InterruptedEx
8284 System .out .println ("Unable to parse " + e );
8385 }
8486 }
85- System . out . println ( "URL ====== " + request . getPath ());
87+
8688 System .out .println (data );
8789
8890 return new MockResponse ().setResponseCode (200 );
@@ -92,9 +94,7 @@ public MockResponse dispatch(final RecordedRequest request) throws InterruptedEx
9294 udpServer = new TestUDPServer ();
9395 udpServer .start ();
9496
95- synchronized (outputThreads .testLogMessages ) {
96- outputThreads .testLogMessages .clear ();
97- }
97+ OUTPUT .clearMessages ();
9898 }
9999
100100 @ AfterEach
@@ -110,7 +110,7 @@ void teardown() throws Exception {
110110
111111 @ AfterAll
112112 static void shutdown () {
113- outputThreads .close ();
113+ OUTPUT .close ();
114114 }
115115
116116 private static String javaPath () {
@@ -159,8 +159,7 @@ void testCrashTracking() throws Exception {
159159 pb .environment ().put ("DD_TRACE_AGENT_PORT" , String .valueOf (tracingServer .getPort ()));
160160
161161 Process p = pb .start ();
162- outputThreads .captureOutput (
163- p , LOG_FILE_DIR .resolve ("testProcess.testCrashTracking.log" ).toFile ());
162+ OUTPUT .captureOutput (p , LOG_FILE_DIR .resolve ("testProcess.testCrashTracking.log" ).toFile ());
164163
165164 assertNotEquals (0 , p .waitFor (), "Application should have crashed" );
166165 assertCrashData ();
@@ -195,7 +194,7 @@ void testCrashTrackingLegacy() throws Exception {
195194 pb .environment ().put ("DD_TRACE_AGENT_PORT" , String .valueOf (tracingServer .getPort ()));
196195
197196 Process p = pb .start ();
198- outputThreads .captureOutput (
197+ OUTPUT .captureOutput (
199198 p , LOG_FILE_DIR .resolve ("testProcess.testCrashTrackingLegacy.log" ).toFile ());
200199
201200 assertNotEquals (0 , p .waitFor (), "Application should have crashed" );
@@ -227,12 +226,10 @@ void testOomeTracking() throws Exception {
227226 "-jar" ,
228227 appShadowJar (),
229228 script .toString ()));
229+ pb .environment ().put ("DD_DOGSTATSD_PORT" , String .valueOf (udpServer .getPort ()));
230230
231231 Process p = pb .start ();
232- outputThreads .captureOutput (
233- p , LOG_FILE_DIR .resolve ("testProcess.testOomeTracking.log" ).toFile ());
234- pb .environment ().put ("DD_DOGSTATSD_PORT" , String .valueOf (udpServer .getPort ()));
235- System .out .println ("Set port to: " + pb .environment ().get ("DD_DOGSTATSD_PORT" ));
232+ OUTPUT .captureOutput (p , LOG_FILE_DIR .resolve ("testProcess.testOomeTracking.log" ).toFile ());
236233
237234 assertNotEquals (0 , p .waitFor (), "Application should have crashed" );
238235 assertOOMEvent ();
@@ -264,11 +261,8 @@ void testCombineTracking() throws Exception {
264261 pb .environment ().put ("DD_TRACE_AGENT_PORT" , String .valueOf (tracingServer .getPort ()));
265262 pb .environment ().put ("DD_DOGSTATSD_PORT" , String .valueOf (udpServer .getPort ()));
266263
267- System .out .println ("Set port to: " + pb .environment ().get ("DD_DOGSTATSD_PORT" ));
268-
269264 Process p = pb .start ();
270- outputThreads .captureOutput (
271- p , LOG_FILE_DIR .resolve ("testProcess.testCombineTracking.log" ).toFile ());
265+ OUTPUT .captureOutput (p , LOG_FILE_DIR .resolve ("testProcess.testCombineTracking.log" ).toFile ());
272266
273267 assertNotEquals (0 , p .waitFor (), "Application should have crashed" );
274268
0 commit comments