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
7575 private static final File appFile = new File (System .getProperty ("ai.smoke-test.test-app-file" ));
7676
7777 // TODO (trask) make private and expose methods on AiSmokeTest(?)
78- protected final MockedAppInsightsIngestionServer mockedIngestion =
79- new MockedAppInsightsIngestionServer ();
78+ protected final MockedAppInsightsIngestionServer mockedIngestion ;
8079
8180 protected final MockedOtlpIngestionServer mockedOtlpIngestion = new MockedOtlpIngestionServer ();
8281
@@ -167,6 +166,8 @@ public static SmokeTestExtensionBuilder builder() {
167166 this .jvmArgs = jvmArgs ;
168167 this .useDefaultHttpPort = useDefaultHttpPort ;
169168 this .useOtlpEndpoint = useOtlpEndpoint ;
169+
170+ mockedIngestion = new MockedAppInsightsIngestionServer (useOld3xAgent );
170171 }
171172
172173 private static String getProfilerEndpoint (ProfilerState profilerState ) {
@@ -285,12 +286,13 @@ private void clearOutAnyInitLogs() throws Exception {
285286 String contextRootUrl = getBaseUrl () + "/" ;
286287 HttpHelper .getResponseCodeEnsuringSampled (contextRootUrl );
287288 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+ }
294296 System .out .println ("Clearing any RequestData from health check." );
295297 mockedIngestion .resetData ();
296298 }
Original file line number Diff line number Diff line change @@ -27,14 +27,14 @@ public class MockedAppInsightsIngestionServer {
2727 private final MockedQuickPulseServlet quickPulseServlet ;
2828 private final Server server ;
2929
30- public MockedAppInsightsIngestionServer () {
30+ public MockedAppInsightsIngestionServer (boolean usingOld3xAgent ) {
3131 server = new Server (DEFAULT_PORT );
3232 ServletHandler handler = new ServletHandler ();
3333 server .setHandler (handler );
3434
3535 servlet = new MockedAppInsightsIngestionServlet ();
3636 profilerSettingsServlet = new MockedProfilerSettingsServlet ();
37- quickPulseServlet = new MockedQuickPulseServlet ();
37+ quickPulseServlet = new MockedQuickPulseServlet (usingOld3xAgent );
3838
3939 handler .addServletWithMapping (new ServletHolder (profilerSettingsServlet ), "/profiler/*" );
4040 handler .addServletWithMapping (new ServletHolder (quickPulseServlet ), "/QuickPulseService.svc/*" );
@@ -295,7 +295,7 @@ public LiveMetricsVerifier getLiveMetrics() {
295295
296296 @ SuppressWarnings ("SystemOut" )
297297 public static void main (String [] args ) throws Exception {
298- MockedAppInsightsIngestionServer i = new MockedAppInsightsIngestionServer ();
298+ MockedAppInsightsIngestionServer i = new MockedAppInsightsIngestionServer (false );
299299 System .out .println ("Starting mocked ingestion on port " + DEFAULT_PORT );
300300 Runtime .getRuntime ()
301301 .addShutdownHook (
Original file line number Diff line number Diff line change 1313
1414public class MockedQuickPulseServlet extends HttpServlet {
1515
16+ private final boolean usingOld3xAgent ;
1617 private final AtomicBoolean pingReceived = new AtomicBoolean ();
1718 private final AtomicBoolean postReceived = new AtomicBoolean ();
1819 private volatile LiveMetricsVerifier verifier = new LiveMetricsVerifier ();
@@ -23,7 +24,9 @@ public class MockedQuickPulseServlet extends HttpServlet {
2324
2425 private volatile boolean loggingEnabled ;
2526
26- public MockedQuickPulseServlet () {}
27+ public MockedQuickPulseServlet (boolean usingOld3xAgent ) {
28+ this .usingOld3xAgent = usingOld3xAgent ;
29+ }
2730
2831 @ SuppressWarnings ("SystemOut" )
2932 private void logit (String message ) {
@@ -34,6 +37,10 @@ private void logit(String message) {
3437
3538 @ Override
3639 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+ }
3744 Readable reader = req .getReader ();
3845 StringWriter sw = new StringWriter ();
3946 CharStreams .copy (reader , sw );
You can’t perform that action at this time.
0 commit comments