-
Notifications
You must be signed in to change notification settings - Fork 208
Smoke Test For Live Metrics #4066
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9f13f0f
starting to write test, debug test server
harsimar 0b4861a
changes before merge from main
harsimar 99994ac
Merge branch 'main' into harskaur/tests
harsimar eef5b9f
stuff
harsimar 4c24f73
minor
harsimar a78c06a
initial test changes
harsimar e0f1274
spotless apply
harsimar 7a6ab01
fix failing tests
harsimar 226d4c3
slight change to wait
harsimar 39a5be4
Revert "slight change to wait"
harsimar e400d19
trying a different wait strategy
harsimar 30619bf
spotless
harsimar 714623f
pr comments round 1
harsimar ea3da39
make more modular
harsimar a3e29d8
try to reduce flakiness
harsimar 8b7cd8c
pr comments
harsimar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
...va/com/microsoft/applicationinsights/smoketest/fakeingestion/MockedQuickPulseServlet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.microsoft.applicationinsights.smoketest.fakeingestion; | ||
|
|
||
| import com.google.common.io.CharStreams; | ||
| import java.io.IOException; | ||
| import java.io.StringWriter; | ||
| import java.rmi.ServerError; | ||
harsimar marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.concurrent.atomic.AtomicBoolean; | ||
| import javax.servlet.http.HttpServlet; | ||
| import javax.servlet.http.HttpServletRequest; | ||
| import javax.servlet.http.HttpServletResponse; | ||
|
|
||
| public class MockedQuickPulseServlet extends HttpServlet { | ||
|
|
||
| private final AtomicBoolean pingReceived = new AtomicBoolean(false); | ||
| private final List<String> postBodies = new ArrayList<>(); | ||
| private final Object lock = new Object(); | ||
|
|
||
| private static final String BODY = | ||
| "{\"ETag\":\"fake::etag\",\"Metrics\":[],\"QuotaInfo\":null,\"DocumentStreams\":[{\"Id\":\"all-types-default\",\"DocumentFilterGroups\":[{\"TelemetryType\":\"Request\",\"Filters\":{\"Filters\":[{\"FieldName\":\"Success\",\"Predicate\":\"Equal\",\"Comparand\":\"false\"}]}},{\"TelemetryType\":\"Dependency\",\"Filters\":{\"Filters\":[{\"FieldName\":\"Success\",\"Predicate\":\"Equal\",\"Comparand\":\"false\"}]}},{\"TelemetryType\":\"Exception\",\"Filters\":{\"Filters\":[]}},{\"TelemetryType\":\"Event\",\"Filters\":{\"Filters\":[]}},{\"TelemetryType\":\"Trace\",\"Filters\":{\"Filters\":[]}}]}]}"; | ||
|
|
||
| private volatile boolean loggingEnabled; | ||
|
|
||
| public MockedQuickPulseServlet() {} | ||
|
|
||
| @SuppressWarnings("SystemOut") | ||
| private void logit(String message) { | ||
| if (loggingEnabled) { | ||
| System.out.println("FAKE INGESTION: INFO - " + message); | ||
harsimar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { | ||
| Readable reader = req.getReader(); | ||
| StringWriter sw = new StringWriter(); | ||
| CharStreams.copy(reader, sw); | ||
| String body = sw.toString(); | ||
|
|
||
| String path = req.getPathInfo(); | ||
| logit("QuickPulse received: " + path); | ||
| if (path.equals("/ping")) { | ||
| pingReceived.set(true); | ||
| logit("ping body: " + body); | ||
| // want the following request to be a post | ||
| resp.setHeader("x-ms-qps-configuration-etag", "fake::etag"); | ||
| resp.setHeader("x-ms-qps-subscribed", "true"); | ||
| resp.setContentType("application/json"); | ||
| resp.getWriter().write(BODY); | ||
|
|
||
| } else if (path.equals("/post")) { | ||
| synchronized (lock) { | ||
| postBodies.add(body); | ||
| } | ||
| logit("post body: " + body); | ||
| // continue to post | ||
| resp.setHeader("x-ms-qps-subscribed", "true"); | ||
| resp.setHeader("x-ms-qps-configuration-etag", "fake::etag"); | ||
| } else { | ||
| throw new ServerError( | ||
| "Unexpected path: " + path + " please fix the test/mock server setup", new Error()); | ||
| } | ||
| } | ||
|
|
||
| public boolean isPingReceived() { | ||
| return pingReceived.get(); | ||
| } | ||
|
|
||
| public List<String> getPostBodies() { | ||
| synchronized (lock) { | ||
| return new ArrayList<>(postBodies); | ||
| } | ||
| } | ||
|
|
||
| public void setRequestLoggingEnabled(boolean enabled) { | ||
| loggingEnabled = enabled; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.