Skip to content

Commit 481e34c

Browse files
authored
Merge pull request #1059 from microsoft/arlittle/connection_strings/smoketests
smoketest updates for connection strings
2 parents e53f772 + fd59a30 commit 481e34c

File tree

21 files changed

+70
-69
lines changed

21 files changed

+70
-69
lines changed

core/src/main/java/com/microsoft/applicationinsights/internal/channel/ConfiguredTransmissionOutput.java

Lines changed: 0 additions & 7 deletions
This file was deleted.

core/src/main/java/com/microsoft/applicationinsights/internal/channel/common/TransmissionNetworkOutput.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323

2424
import com.google.common.base.Preconditions;
2525
import com.microsoft.applicationinsights.TelemetryConfiguration;
26-
import com.microsoft.applicationinsights.internal.channel.ConfiguredTransmissionOutput;
2726
import com.microsoft.applicationinsights.internal.channel.TransmissionDispatcher;
2827
import com.microsoft.applicationinsights.internal.channel.TransmissionHandlerArgs;
28+
import com.microsoft.applicationinsights.internal.channel.TransmissionOutput;
2929
import com.microsoft.applicationinsights.internal.logger.InternalLogger;
3030
import org.apache.commons.lang3.StringUtils;
3131
import org.apache.http.Header;
@@ -52,7 +52,7 @@
5252
*
5353
* Created by gupele on 12/18/2014.
5454
*/
55-
public final class TransmissionNetworkOutput implements ConfiguredTransmissionOutput {
55+
public final class TransmissionNetworkOutput implements TransmissionOutput {
5656
private static final String CONTENT_TYPE_HEADER = "Content-Type";
5757
private static final String CONTENT_ENCODING_HEADER = "Content-Encoding";
5858
private static final String RESPONSE_THROTTLING_HEADER = "Retry-After";
@@ -263,11 +263,6 @@ private HttpPost createTransmissionPostRequest(Transmission transmission) {
263263
return request;
264264
}
265265

266-
@Override
267-
public void setConfiguration(TelemetryConfiguration configuration) {
268-
this.configuration = configuration;
269-
}
270-
271266
private String getIngestionEndpoint() {
272267
if (serverUri != null) {
273268
return serverUri;

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

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import java.util.Map.Entry;
5454
import java.util.Properties;
5555
import java.util.Random;
56+
import java.util.concurrent.ExecutionException;
5657
import java.util.concurrent.TimeUnit;
5758
import java.util.concurrent.atomic.AtomicReference;
5859

@@ -363,27 +364,38 @@ protected static void waitForApplicationToStart() throws Exception {
363364
String.format("%s on %s", getAppContext(), containerInfo.getImageName()),
364365
HEALTH_CHECK_RETRIES);
365366
System.out.println("Test app health check complete.");
366-
if (requestCaptureEnabled) {
367-
Stopwatch sw = Stopwatch.createStarted();
368-
mockedIngestion.waitForItem(new Predicate<Envelope>() {
369-
@Override
370-
public boolean apply(Envelope input) {
371-
if (!"RequestData".equals(input.getData().getBaseType())) {
372-
return false;
373-
}
374-
RequestData data = (RequestData) ((Data) input.getData()).getBaseData();
375-
return contextRootUrl.equals(data.getUrl()) && "200".equals(data.getResponseCode());
376-
}
377-
}, TELEMETRY_RECEIVE_TIMEOUT_SECONDS, TimeUnit.SECONDS);
378-
System.out.printf("Received request telemetry after %.3f seconds...%n",
379-
sw.elapsed(TimeUnit.MILLISECONDS) / 1000.0);
380-
System.out.println("Clearing any RequestData from health check.");
381-
}
367+
waitForHealthCheckTelemetryIfNeeded(contextRootUrl);
382368
} catch (Exception e) {
383369
docker.printContainerLogs(containerInfo.getContainerId());
384370
throw e;
371+
} finally {
372+
mockedIngestion.resetData();
373+
}
374+
}
375+
376+
private static void waitForHealthCheckTelemetryIfNeeded(final String contextRootUrl) throws InterruptedException, ExecutionException {
377+
if (!requestCaptureEnabled) {
378+
return;
379+
}
380+
381+
Stopwatch receivedTelemetryTimer = Stopwatch.createStarted();
382+
final int requestTelemetryFromHealthCheckTimeout = TELEMETRY_RECEIVE_TIMEOUT_SECONDS;
383+
try {
384+
mockedIngestion.waitForItem(new Predicate<Envelope>() {
385+
@Override
386+
public boolean apply(Envelope input) {
387+
if (!"RequestData".equals(input.getData().getBaseType())) {
388+
return false;
389+
}
390+
RequestData data = (RequestData) ((Data) input.getData()).getBaseData();
391+
return contextRootUrl.equals(data.getUrl()) && "200".equals(data.getResponseCode());
392+
}
393+
}, requestTelemetryFromHealthCheckTimeout, TimeUnit.SECONDS);
394+
System.out.printf("Received request telemetry after %.3f seconds...%n", receivedTelemetryTimer.elapsed(TimeUnit.MILLISECONDS) / 1000.0);
395+
System.out.println("Clearing any RequestData from health check.");
396+
} catch (java.util.concurrent.TimeoutException e) {
397+
throw new TimeoutException("request telemetry from application health check", requestTelemetryFromHealthCheckTimeout, TimeUnit.SECONDS, e);
385398
}
386-
mockedIngestion.resetData();
387399
}
388400

389401
protected void callTargetUriAndWaitForTelemetry() throws Exception {
@@ -710,8 +722,7 @@ protected static void waitForUrl(String url, long timeout, TimeUnit timeoutUnit,
710722
assertFalse(String.format("Empty response from '%s'. Health check urls should return something non-empty", url), rval.isEmpty());
711723
}
712724

713-
protected static void waitForUrlWithRetries(String url, long timeout, TimeUnit timeoutUnit, String appName, int numberOfRetries)
714-
throws IOException {
725+
protected static void waitForUrlWithRetries(String url, long timeout, TimeUnit timeoutUnit, String appName, int numberOfRetries) throws IOException {
715726
Preconditions.checkArgument(numberOfRetries >= 0, "numberOfRetries must be non-negative");
716727
int triedCount = 0;
717728
boolean success = false;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<!-- The key from the portal: -->
66

7-
<InstrumentationKey>00000000-0000-0000-0000-0FEEDDADBEEF</InstrumentationKey>
7+
<ConnectionString>InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://fakeingestion:60606</ConnectionString>
88

99
<SDKLogger type="CONSOLE">
1010
<enabled>true</enabled>
@@ -32,7 +32,6 @@
3232
</TelemetryInitializers>
3333

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<!-- The key from the portal: -->
66

7-
<InstrumentationKey>00000000-0000-0000-0000-0FEEDDADBEEF</InstrumentationKey>
7+
<ConnectionString>InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://fakeingestion:60606</ConnectionString>
88

99
<SDKLogger type="CONSOLE">
1010
<enabled>true</enabled>
@@ -33,7 +33,7 @@
3333
</TelemetryInitializers>
3434

3535
<Channel>
36-
<EndpointAddress>http://fakeingestion:60606/v2/track</EndpointAddress>
36+
3737
<DeveloperMode>true</DeveloperMode>
3838
<FlushIntervalInSeconds>1</FlushIntervalInSeconds>
3939
</Channel>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<!-- The key from the portal: -->
66

7-
<InstrumentationKey>00000000-0000-0000-0000-0FEEDDADBEEF</InstrumentationKey>
7+
<ConnectionString>InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://fakeingestion:60606</ConnectionString>
88

99
<SDKLogger type="CONSOLE">
1010
<enabled>true</enabled>
@@ -33,7 +33,6 @@
3333
</TelemetryInitializers>
3434

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

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<!-- The key from the portal: -->
55

6-
<InstrumentationKey>00000000-0000-0000-0000-0FEEDDADBEEF</InstrumentationKey>
6+
<ConnectionString>InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://fakeingestion:60606</ConnectionString>
77

88
<SDKLogger type="CONSOLE">
99
<enabled>true</enabled>
@@ -33,7 +33,6 @@
3333
</TelemetryInitializers>
3434

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<!-- The key from the portal: -->
66

7-
<InstrumentationKey>00000000-0000-0000-0000-0FEEDDADBEEF</InstrumentationKey>
7+
<ConnectionString>InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://fakeingestion:60606</ConnectionString>
88

99
<SDKLogger type="CONSOLE">
1010
<enabled>true</enabled>
@@ -32,7 +32,7 @@
3232
</TelemetryInitializers>
3333

3434
<Channel>
35-
<EndpointAddress>http://fakeingestion:60606/v2/track</EndpointAddress>
35+
3636
<DeveloperMode>true</DeveloperMode>
3737
<FlushIntervalInSeconds>1</FlushIntervalInSeconds>
3838
</Channel>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<!-- The key from the portal: -->
66

7-
<InstrumentationKey>00000000-0000-0000-0000-0FEEDDADBEEF</InstrumentationKey>
7+
<ConnectionString>InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://fakeingestion:60606</ConnectionString>
88

99
<QuickPulse enabled="false" />
1010
<!-- HTTP request component (not required for bare API) -->
@@ -31,7 +31,7 @@
3131
</TelemetryInitializers>
3232

3333
<Channel>
34-
<EndpointAddress>http://fakeingestion:60606/v2/track</EndpointAddress>
34+
3535
<DeveloperMode>true</DeveloperMode>
3636
<FlushIntervalInSeconds>1</FlushIntervalInSeconds>
3737
</Channel>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<!-- The key from the portal: -->
55

6-
<InstrumentationKey>00000000-0000-0000-0000-0FEEDDADBEEF</InstrumentationKey>
6+
<ConnectionString>InstrumentationKey=00000000-0000-0000-0000-0FEEDDADBEEF;IngestionEndpoint=http://fakeingestion:60606</ConnectionString>
77

88
<SDKLogger type="CONSOLE">
99
<enabled>true</enabled>
@@ -33,7 +33,7 @@
3333
</TelemetryInitializers>
3434

3535
<Channel>
36-
<EndpointAddress>http://fakeingestion:60606/v2/track</EndpointAddress>
36+
3737
<DeveloperMode>true</DeveloperMode>
3838
<FlushIntervalInSeconds>1</FlushIntervalInSeconds>
3939
</Channel>

0 commit comments

Comments
 (0)