-
Notifications
You must be signed in to change notification settings - Fork 200
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
Add a config to disable all logging appenders #3208
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketestapp; | ||
|
||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
@WebServlet("/testDisabled") | ||
public class JavaUtilLoggingDisabledServlet extends HttpServlet { | ||
|
||
private static final Logger logger = Logger.getLogger("smoketestapp"); | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) { | ||
logger.log(Level.WARNING, "this message will get suppressed."); | ||
} | ||
} | ||
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,67 @@ | ||||||||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||||||||
// Licensed under the MIT License. | ||||||||
|
||||||||
package com.microsoft.applicationinsights.smoketest; | ||||||||
|
||||||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11; | ||||||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11_OPENJ9; | ||||||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_17; | ||||||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_19; | ||||||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_20; | ||||||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8; | ||||||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9; | ||||||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8; | ||||||||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9; | ||||||||
import static org.assertj.core.api.Assertions.assertThat; | ||||||||
|
||||||||
import com.microsoft.applicationinsights.smoketest.schemav2.Data; | ||||||||
import com.microsoft.applicationinsights.smoketest.schemav2.Envelope; | ||||||||
import com.microsoft.applicationinsights.smoketest.schemav2.RequestData; | ||||||||
import java.util.List; | ||||||||
import org.junit.jupiter.api.Test; | ||||||||
import org.junit.jupiter.api.extension.RegisterExtension; | ||||||||
|
||||||||
@UseAgent("disabled_applicationinsights.json") | ||||||||
abstract class JavaUtilLoggingDisabledTest { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and then can remove all the subclasses (similar to the other disabled tests, no need to run these tests against envs)
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the purpose of doing subclass is to test all java versions.. this will cover one case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check the other |
||||||||
|
||||||||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||||||||
|
||||||||
@Test | ||||||||
@TargetUri("/testDisabled") | ||||||||
void testDisabled() throws Exception { | ||||||||
List<Envelope> rdList = testing.mockedIngestion.waitForItems("RequestData", 1); | ||||||||
|
||||||||
Envelope rdEnvelope = rdList.get(0); | ||||||||
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData(); | ||||||||
assertThat(rd.getName()).isEqualTo("GET /JavaUtilLogging/testDisabled"); | ||||||||
|
||||||||
assertThat(testing.mockedIngestion.getCountForType("MessageData")).isZero(); | ||||||||
} | ||||||||
|
||||||||
@Environment(TOMCAT_8_JAVA_8) | ||||||||
static class Tomcat8Java8Test extends JavaUtilLoggingDisabledTest {} | ||||||||
|
||||||||
@Environment(TOMCAT_8_JAVA_8_OPENJ9) | ||||||||
static class Tomcat8Java8OpenJ9Test extends JavaUtilLoggingDisabledTest {} | ||||||||
|
||||||||
@Environment(TOMCAT_8_JAVA_11) | ||||||||
static class Tomcat8Java11Test extends JavaUtilLoggingDisabledTest {} | ||||||||
|
||||||||
@Environment(TOMCAT_8_JAVA_11_OPENJ9) | ||||||||
static class Tomcat8Java11OpenJ9Test extends JavaUtilLoggingDisabledTest {} | ||||||||
|
||||||||
@Environment(TOMCAT_8_JAVA_17) | ||||||||
static class Tomcat8Java17Test extends JavaUtilLoggingDisabledTest {} | ||||||||
|
||||||||
@Environment(TOMCAT_8_JAVA_19) | ||||||||
static class Tomcat8Java19Test extends JavaUtilLoggingDisabledTest {} | ||||||||
|
||||||||
@Environment(TOMCAT_8_JAVA_20) | ||||||||
static class Tomcat8Java20Test extends JavaUtilLoggingDisabledTest {} | ||||||||
|
||||||||
@Environment(WILDFLY_13_JAVA_8) | ||||||||
static class Wildfly13Java8Test extends JavaUtilLoggingDisabledTest {} | ||||||||
|
||||||||
@Environment(WILDFLY_13_JAVA_8_OPENJ9) | ||||||||
static class Wildfly13Java8OpenJ9Test extends JavaUtilLoggingDisabledTest {} | ||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"role": { | ||
"name": "testrolename", | ||
"instance": "testroleinstance" | ||
}, | ||
"sampling": { | ||
"percentage": 100 | ||
}, | ||
"instrumentation": { | ||
"logging": { | ||
"enabled": "false" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketestapp; | ||
|
||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
@WebServlet("/testDisabled") | ||
public class Log4j2DisabledServlet extends HttpServlet { | ||
|
||
private static final Logger logger = LogManager.getLogger("smoketestapp"); | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) { | ||
logger.warn("This message will get suppressed"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketest; | ||
|
||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_17; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_19; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_20; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.microsoft.applicationinsights.smoketest.schemav2.Data; | ||
import com.microsoft.applicationinsights.smoketest.schemav2.Envelope; | ||
import com.microsoft.applicationinsights.smoketest.schemav2.RequestData; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
@UseAgent("disabled_applicationinsights.json") | ||
abstract class Log4j2DisabledTest { | ||
|
||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||
|
||
@Test | ||
@TargetUri("/testDisabled") | ||
void testDisabled() throws Exception { | ||
List<Envelope> rdList = testing.mockedIngestion.waitForItems("RequestData", 1); | ||
|
||
Envelope rdEnvelope = rdList.get(0); | ||
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData(); | ||
assertThat(rd.getName()).isEqualTo("GET /Log4j2/testDisabled"); | ||
|
||
assertThat(testing.mockedIngestion.getCountForType("MessageData")).isZero(); | ||
} | ||
|
||
@Environment(TOMCAT_8_JAVA_8) | ||
static class Tomcat8Java8Test extends Log4j2DisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_8_OPENJ9) | ||
static class Tomcat8Java8OpenJ9Test extends Log4j2DisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11) | ||
static class Tomcat8Java11Test extends Log4j2DisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11_OPENJ9) | ||
static class Tomcat8Java11OpenJ9Test extends Log4j2DisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_17) | ||
static class Tomcat8Java17Test extends Log4j2DisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_19) | ||
static class Tomcat8Java19Test extends Log4j2DisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_20) | ||
static class Tomcat8Java20Test extends Log4j2DisabledTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8) | ||
static class Wildfly13Java8Test extends Log4j2DisabledTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8_OPENJ9) | ||
static class Wildfly13Java8OpenJ9Test extends Log4j2DisabledTest {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"role": { | ||
"name": "testrolename", | ||
"instance": "testroleinstance" | ||
}, | ||
"sampling": { | ||
"percentage": 100 | ||
}, | ||
"instrumentation": { | ||
"logging": { | ||
"enabled": "false" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketestapp; | ||
|
||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@WebServlet("/testWithException") | ||
public class LogbackDisabledServlet extends HttpServlet { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger("smoketestapp"); | ||
|
||
protected void doGet(HttpServletRequest request, HttpServletResponse response) { | ||
logger.warn("This message will get suppressed"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.microsoft.applicationinsights.smoketest; | ||
|
||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_11_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_17; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_19; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_20; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.TOMCAT_8_JAVA_8_OPENJ9; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8; | ||
import static com.microsoft.applicationinsights.smoketest.EnvironmentValue.WILDFLY_13_JAVA_8_OPENJ9; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import com.microsoft.applicationinsights.smoketest.schemav2.Data; | ||
import com.microsoft.applicationinsights.smoketest.schemav2.Envelope; | ||
import com.microsoft.applicationinsights.smoketest.schemav2.RequestData; | ||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
@UseAgent | ||
abstract class LogbackDisabledTest { | ||
|
||
@RegisterExtension static final SmokeTestExtension testing = SmokeTestExtension.create(); | ||
|
||
// Not really sure that Logback is enabled with Wildfly | ||
// https://anotheria.net/blog/devops/enable-logback-in-jboss/ | ||
// https://www.oreilly.com/library/view/wildfly-cookbook/9781784392413/ch04s08.html | ||
boolean isWildflyServer() { | ||
return false; | ||
} | ||
|
||
@Test | ||
@TargetUri("/testDisabled") | ||
void testDisabled() throws Exception { | ||
List<Envelope> rdList = testing.mockedIngestion.waitForItems("RequestData", 1); | ||
|
||
Envelope rdEnvelope = rdList.get(0); | ||
RequestData rd = (RequestData) ((Data<?>) rdEnvelope.getData()).getBaseData(); | ||
assertThat(rd.getName()).isEqualTo("GET /Logback/testDisabled"); | ||
|
||
assertThat(testing.mockedIngestion.getCountForType("MessageData")).isZero(); | ||
} | ||
|
||
@Environment(TOMCAT_8_JAVA_8) | ||
static class Tomcat8Java8Test extends LogbackDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_8_OPENJ9) | ||
static class Tomcat8Java8OpenJ9Test extends LogbackDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11) | ||
static class Tomcat8Java11Test extends LogbackDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_11_OPENJ9) | ||
static class Tomcat8Java11OpenJ9Test extends LogbackDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_17) | ||
static class Tomcat8Java17Test extends LogbackDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_19) | ||
static class Tomcat8Java19Test extends LogbackDisabledTest {} | ||
|
||
@Environment(TOMCAT_8_JAVA_20) | ||
static class Tomcat8Java20Test extends LogbackDisabledTest {} | ||
|
||
@Environment(WILDFLY_13_JAVA_8) | ||
static class Wildfly13Java8Test extends LogbackDisabledTest { | ||
@Override | ||
boolean isWildflyServer() { | ||
return true; | ||
} | ||
} | ||
|
||
@Environment(WILDFLY_13_JAVA_8_OPENJ9) | ||
static class Wildfly13Java8OpenJ9Test extends LogbackDisabledTest { | ||
@Override | ||
boolean isWildflyServer() { | ||
return true; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"role": { | ||
"name": "testrolename", | ||
"instance": "testroleinstance" | ||
}, | ||
"sampling": { | ||
"percentage": 100 | ||
}, | ||
"instrumentation": { | ||
"logging": { | ||
"enabled": "false" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a separate Servlet for these tests, can just hit the same servlet that the normal test does (this is how other
*DisabledTest
smoke tests work)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i followed the existing setup.. one test per servlet. i think we can clean up later for all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i noticed those are spring boot apps. not servlet. we can chat about it in tomorrow's standup