Skip to content

Commit 9f2bdef

Browse files
trasklittleaj
authored andcommitted
Print docker log when app fails to start
1 parent 2e34011 commit 9f2bdef

File tree

1 file changed

+23
-14
lines changed
  • test/smoke/framework/testCore/src/main/java/com/microsoft/applicationinsights/smoketest

1 file changed

+23
-14
lines changed

test/smoke/framework/testCore/src/main/java/com/microsoft/applicationinsights/smoketest/AiSmokeTest.java

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -340,19 +340,27 @@ protected static String getBaseUrl() {
340340
}
341341

342342
protected static void waitForApplicationToStart() throws Exception {
343-
System.out.printf("Test app health check: Waiting for %s to start...%n", warFileName);
344-
waitForUrlWithRetries(getBaseUrl(), APPLICATION_READY_TIMEOUT_SECONDS, TimeUnit.SECONDS, String.format("%s on %s", getAppContext(), currentContainerInfo.getImageName()), HEALTH_CHECK_RETRIES);
345-
System.out.println("Test app health check complete.");
346-
if (requestCaptureEnabled) {
347-
Stopwatch sw = Stopwatch.createStarted();
348-
mockedIngestion.waitForItem(new Predicate<Envelope>() {
349-
@Override
350-
public boolean apply(Envelope input) {
351-
return "RequestData".equals(input.getData().getBaseType());
352-
}
353-
}, TELEMETRY_RECEIVE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
354-
System.out.printf("Received request telemetry after %.3f seconds...%n", sw.elapsed(TimeUnit.MILLISECONDS)/1000.0);
355-
System.out.println("Clearing any RequestData from health check.");
343+
try {
344+
System.out.printf("Test app health check: Waiting for %s to start...%n", warFileName);
345+
waitForUrlWithRetries(getBaseUrl(), APPLICATION_READY_TIMEOUT_SECONDS, TimeUnit.SECONDS,
346+
String.format("%s on %s", getAppContext(), currentContainerInfo.getImageName()),
347+
HEALTH_CHECK_RETRIES);
348+
System.out.println("Test app health check complete.");
349+
if (requestCaptureEnabled) {
350+
Stopwatch sw = Stopwatch.createStarted();
351+
mockedIngestion.waitForItem(new Predicate<Envelope>() {
352+
@Override
353+
public boolean apply(Envelope input) {
354+
return "RequestData".equals(input.getData().getBaseType());
355+
}
356+
}, TELEMETRY_RECEIVE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
357+
System.out.printf("Received request telemetry after %.3f seconds...%n",
358+
sw.elapsed(TimeUnit.MILLISECONDS) / 1000.0);
359+
System.out.println("Clearing any RequestData from health check.");
360+
}
361+
} catch (Exception e) {
362+
docker.printContainerLogs(currentContainerInfo.getContainerId());
363+
throw e;
356364
}
357365
mockedIngestion.resetData();
358366
}
@@ -666,7 +674,8 @@ protected static void waitForUrl(String url, long timeout, TimeUnit timeoutUnit,
666674
assertFalse(String.format("Empty response from '%s'. Health check urls should return something non-empty", url), rval.isEmpty());
667675
}
668676

669-
protected static void waitForUrlWithRetries(String url, long timeout, TimeUnit timeoutUnit, String appName, int numberOfRetries) {
677+
protected static void waitForUrlWithRetries(String url, long timeout, TimeUnit timeoutUnit, String appName, int numberOfRetries)
678+
throws IOException {
670679
Preconditions.checkArgument(numberOfRetries >= 0, "numberOfRetries must be non-negative");
671680
int triedCount = 0;
672681
boolean success = false;

0 commit comments

Comments
 (0)