Skip to content

Commit 0fd120a

Browse files
authored
Merge pull request #1056 from microsoft/trask/more-test-improvements
More test improvements
2 parents 9a4fef2 + 417f603 commit 0fd120a

File tree

22 files changed

+202
-94
lines changed

22 files changed

+202
-94
lines changed

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

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ protected static void stopContainer(ContainerInfo info) throws Exception {
155155
protected String targetUri;
156156
protected String httpMethod;
157157
protected long targetUriDelayMs;
158+
protected long targetUriCallCount;
158159
protected long targetUriTimeoutMs;
159160
//endregion
160161

@@ -187,6 +188,7 @@ protected void starting(Description description) {
187188
thiz.targetUri = null;
188189
thiz.httpMethod = null;
189190
thiz.targetUriDelayMs = 0L;
191+
thiz.targetUriCallCount = 1;
190192
thiz.targetUriTimeoutMs = TELEMETRY_RECEIVE_TIMEOUT_SECONDS * 1000;
191193
} else {
192194
thiz.targetUri = targetUri.value();
@@ -195,6 +197,7 @@ protected void starting(Description description) {
195197
}
196198
thiz.httpMethod = targetUri.method().toUpperCase();
197199
thiz.targetUriDelayMs = targetUri.delay();
200+
thiz.targetUriCallCount = targetUri.callCount();
198201
thiz.targetUriTimeoutMs = targetUri.timeout() > 0 ? targetUri.timeout() : TELEMETRY_RECEIVE_TIMEOUT_SECONDS * 1000;
199202
}
200203

@@ -395,20 +398,26 @@ protected void callTargetUriAndWaitForTelemetry() throws Exception {
395398
}
396399
System.out.println("Calling "+targetUri+" ...");
397400
String url = getBaseUrl()+targetUri;
398-
System.out.println("calling " + url);
399-
final String content;
400-
switch(httpMethod) {
401-
case "GET":
402-
content = HttpHelper.get(url);
403-
break;
404-
default:
405-
throw new NotSupportedException(String.format("http method '%s' is not currently supported", httpMethod));
401+
if (targetUriCallCount == 1) {
402+
System.out.println("calling " + url);
403+
} else {
404+
System.out.println("calling " + url + " " + targetUriCallCount + " times");
405+
}
406+
for (int i = 0; i < targetUriCallCount; i++) {
407+
final String content;
408+
switch (httpMethod) {
409+
case "GET":
410+
content = HttpHelper.get(url);
411+
break;
412+
default:
413+
throw new NotSupportedException(
414+
String.format("http method '%s' is not currently supported", httpMethod));
415+
}
416+
String expectationMessage = "The base context in testApps should return a nonempty response.";
417+
assertNotNull(String.format("Null response from targetUri: '%s'. %s", targetUri, expectationMessage), content);
418+
assertTrue(String.format("Empty response from targetUri: '%s'. %s", targetUri, expectationMessage),
419+
content.length() > 0);
406420
}
407-
408-
String expectationMessage = "The base context in testApps should return a nonempty response.";
409-
assertNotNull(String.format("Null response from targetUri: '%s'. %s", targetUri, expectationMessage), content);
410-
assertTrue(String.format("Empty response from targetUri: '%s'. %s", targetUri, expectationMessage), content.length() > 0);
411-
412421
if (this.targetUriTimeoutMs > 0) {
413422
Stopwatch sw = Stopwatch.createStarted();
414423
mockedIngestion.awaitAnyItems(this.targetUriTimeoutMs, TimeUnit.MILLISECONDS);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
*/
1717
long delay() default 0L;
1818

19+
/**
20+
* The number of times to call the target uri.
21+
*/
22+
int callCount() default 1;
23+
1924
/**
2025
* The number of milliseconds to wait for a response.
2126
*/

test/smoke/testApps/AutoPerfCounters/src/main/resources/ApplicationInsights.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
</TelemetryInitializers>
3333

3434
<Channel>
35-
<!-- <EndpointAddress>http://localhost:60606/v2/track</EndpointAddress> -->
3635
<EndpointAddress>http://fakeingestion:60606/v2/track</EndpointAddress>
3736
<DeveloperMode>true</DeveloperMode>
3837
<FlushIntervalInSeconds>1</FlushIntervalInSeconds>

test/smoke/testApps/CachingCalculator/src/main/resources/ApplicationInsights.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
</TelemetryInitializers>
3434

3535
<Channel>
36-
<!-- <EndpointAddress>http://localhost:60606/v2/track</EndpointAddress> -->
3736
<EndpointAddress>http://fakeingestion:60606/v2/track</EndpointAddress>
3837
<DeveloperMode>true</DeveloperMode>
3938
<FlushIntervalInSeconds>1</FlushIntervalInSeconds>

test/smoke/testApps/CachingCalculator/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/SampleTestWithDependencyContainer.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.microsoft.applicationinsights.internal.schemav2.Data;
66
import com.microsoft.applicationinsights.internal.schemav2.Envelope;
77
import com.microsoft.applicationinsights.internal.schemav2.RemoteDependencyData;
8-
import com.microsoft.applicationinsights.internal.schemav2.RequestData;
98
import org.junit.*;
109

1110
import static org.hamcrest.Matchers.hasSize;

test/smoke/testApps/CoreAndFilter/src/main/java/com/microsoft/ajl/simplecalc/SimpleTrackPageViewServlet.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.microsoft.ajl.simplecalc;
22

33
import java.io.IOException;
4-
import java.util.HashMap;
5-
import java.util.Map;
64

75
import javax.servlet.ServletException;
86
import javax.servlet.annotation.WebServlet;

test/smoke/testApps/CoreAndFilter/src/main/java/com/microsoft/ajl/simplecalc/SlowRequestCpuBoundServlet.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.microsoft.ajl.simplecalc;
22

3-
import com.google.common.base.Predicate;
4-
import com.google.common.base.Predicates;
53
import org.apache.commons.lang3.StringUtils;
6-
import org.checkerframework.checker.nullness.compatqual.NullableDecl;
74

85
import javax.servlet.ServletException;
96
import javax.servlet.annotation.WebServlet;

test/smoke/testApps/CoreAndFilter/src/main/resources/ApplicationInsights.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
</TelemetryInitializers>
3434

3535
<Channel>
36-
<!-- <EndpointAddress>http://localhost:60606/v2/track</EndpointAddress> -->
3736
<EndpointAddress>http://fakeingestion:60606/v2/track</EndpointAddress>
3837
<DeveloperMode>true</DeveloperMode>
3938
<FlushIntervalInSeconds>1</FlushIntervalInSeconds>

test/smoke/testApps/CoreAndFilter/src/smokeTest/java/com/microsoft/applicationinsights/smoketest/CoreAndFilterTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import com.microsoft.applicationinsights.smoketest.matchers.PageViewDataMatchers;
2222
import com.microsoft.applicationinsights.smoketest.matchers.TraceDataMatchers;
2323
import com.microsoft.applicationinsights.telemetry.Duration;
24-
import org.junit.Ignore;
2524
import org.junit.Test;
2625

2726
import static com.microsoft.applicationinsights.smoketest.matchers.ExceptionDataMatchers.ExceptionDetailsMatchers.withMessage;

test/smoke/testApps/CustomInstrumentation/src/smokeTest/java/com/microsoft/applicationinsights/smoketestapp/CustomInstrumentationTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
import com.microsoft.applicationinsights.smoketest.UseAgent;
1414
import org.junit.Test;
1515

16-
import static org.hamcrest.Matchers.hasSize;
1716
import static org.junit.Assert.assertEquals;
1817
import static org.junit.Assert.assertNotNull;
19-
import static org.junit.Assert.assertThat;
2018
import static org.junit.Assert.assertTrue;
2119

2220
@UseAgent("CustomInstrumentation")

0 commit comments

Comments
 (0)