File tree Expand file tree Collapse file tree 3 files changed +21
-12
lines changed
smoke-tests/framework/src/main/java/com/microsoft/applicationinsights/smoketest Expand file tree Collapse file tree 3 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,7 @@ public class SmokeTestExtension
75
75
private static final File appFile = new File (System .getProperty ("ai.smoke-test.test-app-file" ));
76
76
77
77
// TODO (trask) make private and expose methods on AiSmokeTest(?)
78
- protected final MockedAppInsightsIngestionServer mockedIngestion =
79
- new MockedAppInsightsIngestionServer ();
78
+ protected final MockedAppInsightsIngestionServer mockedIngestion ;
80
79
81
80
protected final MockedOtlpIngestionServer mockedOtlpIngestion = new MockedOtlpIngestionServer ();
82
81
@@ -167,6 +166,8 @@ public static SmokeTestExtensionBuilder builder() {
167
166
this .jvmArgs = jvmArgs ;
168
167
this .useDefaultHttpPort = useDefaultHttpPort ;
169
168
this .useOtlpEndpoint = useOtlpEndpoint ;
169
+
170
+ mockedIngestion = new MockedAppInsightsIngestionServer (useOld3xAgent );
170
171
}
171
172
172
173
private static String getProfilerEndpoint (ProfilerState profilerState ) {
@@ -285,12 +286,13 @@ private void clearOutAnyInitLogs() throws Exception {
285
286
String contextRootUrl = getBaseUrl () + "/" ;
286
287
HttpHelper .getResponseCodeEnsuringSampled (contextRootUrl );
287
288
waitForHealthCheckTelemetry (contextRootUrl );
288
- await ()
289
- .untilAsserted (
290
- () ->
291
- assertThat (mockedIngestion .getLiveMetrics ().getRequestCount (contextRootUrl ))
292
- .isEqualTo (1 ));
293
-
289
+ if (!useOld3xAgent ) {
290
+ await ()
291
+ .untilAsserted (
292
+ () ->
293
+ assertThat (mockedIngestion .getLiveMetrics ().getRequestCount (contextRootUrl ))
294
+ .isEqualTo (1 ));
295
+ }
294
296
System .out .println ("Clearing any RequestData from health check." );
295
297
mockedIngestion .resetData ();
296
298
}
Original file line number Diff line number Diff line change @@ -27,14 +27,14 @@ public class MockedAppInsightsIngestionServer {
27
27
private final MockedQuickPulseServlet quickPulseServlet ;
28
28
private final Server server ;
29
29
30
- public MockedAppInsightsIngestionServer () {
30
+ public MockedAppInsightsIngestionServer (boolean usingOld3xAgent ) {
31
31
server = new Server (DEFAULT_PORT );
32
32
ServletHandler handler = new ServletHandler ();
33
33
server .setHandler (handler );
34
34
35
35
servlet = new MockedAppInsightsIngestionServlet ();
36
36
profilerSettingsServlet = new MockedProfilerSettingsServlet ();
37
- quickPulseServlet = new MockedQuickPulseServlet ();
37
+ quickPulseServlet = new MockedQuickPulseServlet (usingOld3xAgent );
38
38
39
39
handler .addServletWithMapping (new ServletHolder (profilerSettingsServlet ), "/profiler/*" );
40
40
handler .addServletWithMapping (new ServletHolder (quickPulseServlet ), "/QuickPulseService.svc/*" );
@@ -295,7 +295,7 @@ public LiveMetricsVerifier getLiveMetrics() {
295
295
296
296
@ SuppressWarnings ("SystemOut" )
297
297
public static void main (String [] args ) throws Exception {
298
- MockedAppInsightsIngestionServer i = new MockedAppInsightsIngestionServer ();
298
+ MockedAppInsightsIngestionServer i = new MockedAppInsightsIngestionServer (false );
299
299
System .out .println ("Starting mocked ingestion on port " + DEFAULT_PORT );
300
300
Runtime .getRuntime ()
301
301
.addShutdownHook (
Original file line number Diff line number Diff line change 13
13
14
14
public class MockedQuickPulseServlet extends HttpServlet {
15
15
16
+ private final boolean usingOld3xAgent ;
16
17
private final AtomicBoolean pingReceived = new AtomicBoolean ();
17
18
private final AtomicBoolean postReceived = new AtomicBoolean ();
18
19
private volatile LiveMetricsVerifier verifier = new LiveMetricsVerifier ();
@@ -23,7 +24,9 @@ public class MockedQuickPulseServlet extends HttpServlet {
23
24
24
25
private volatile boolean loggingEnabled ;
25
26
26
- public MockedQuickPulseServlet () {}
27
+ public MockedQuickPulseServlet (boolean usingOld3xAgent ) {
28
+ this .usingOld3xAgent = usingOld3xAgent ;
29
+ }
27
30
28
31
@ SuppressWarnings ("SystemOut" )
29
32
private void logit (String message ) {
@@ -34,6 +37,10 @@ private void logit(String message) {
34
37
35
38
@ Override
36
39
protected void doPost (HttpServletRequest req , HttpServletResponse resp ) throws IOException {
40
+ if (usingOld3xAgent ) {
41
+ // the old 3.x agent doesn't conform to the expectations of this mock server
42
+ return ;
43
+ }
37
44
Readable reader = req .getReader ();
38
45
StringWriter sw = new StringWriter ();
39
46
CharStreams .copy (reader , sw );
You can’t perform that action at this time.
0 commit comments