-
Notifications
You must be signed in to change notification settings - Fork 600
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
Seperate out checkpoint tests for audit tests #30556
base: integration
Are you sure you want to change the base?
Changes from all commits
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,97 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package io.openliberty.microprofile.telemetry.logging.internal_fat; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import com.ibm.websphere.simplicity.RemoteFile; | ||
import com.ibm.websphere.simplicity.log.Log; | ||
|
||
import componenttest.annotation.CheckpointTest; | ||
import componenttest.custom.junit.runner.FATRunner; | ||
import componenttest.rules.repeater.CheckpointRule; | ||
import componenttest.rules.repeater.CheckpointRule.ServerMode; | ||
import componenttest.rules.repeater.RepeatTests; | ||
import componenttest.topology.impl.LibertyServer; | ||
import componenttest.topology.impl.LibertyServerFactory; | ||
import componenttest.topology.utils.FATServletClient; | ||
import io.openliberty.microprofile.telemetry.internal_fat.shared.TelemetryActions; | ||
|
||
@RunWith(FATRunner.class) | ||
@CheckpointTest(alwaysRun = true) | ||
public class TelemetryAuditCheckpointTest extends FATServletClient { | ||
|
||
public static final String SERVER_NAME = "TelemetryAuditCheckpoint"; | ||
|
||
@ClassRule | ||
public static CheckpointRule checkpointRule = new CheckpointRule() | ||
.setConsoleLogName(TelemetryAuditCheckpointTest.class.getSimpleName() + ".log") | ||
.setRunNormalTests(false) | ||
.setServerSetup(TelemetryAuditCheckpointTest::initialSetup) | ||
.setServerStart(TelemetryAuditCheckpointTest::testSetup) | ||
.setServerTearDown(TelemetryAuditCheckpointTest::testTearDown); | ||
|
||
//This test will run on all mp 2.0 repeats to ensure we have some test coverage on all versions. | ||
//I chose this one because TelemetryMessages is core to this bucket | ||
// Will re-enable in follow-on issue. | ||
@ClassRule | ||
public static RepeatTests rt = TelemetryActions.telemetry20Repeats(); | ||
|
||
private static LibertyServer server; | ||
|
||
public static LibertyServer initialSetup(ServerMode mode) throws Exception { | ||
server = LibertyServerFactory.getLibertyServer(SERVER_NAME, null, true); | ||
server.saveServerConfiguration(); | ||
return server; | ||
} | ||
|
||
public static void testSetup(ServerMode mode, LibertyServer server) throws Exception { | ||
server.startServer(); | ||
} | ||
|
||
public static void testTearDown(ServerMode mode, LibertyServer server) throws Exception { | ||
server.stopServer(); | ||
|
||
// Restore the server configuration, after each test case. | ||
server.restoreServerConfiguration(); | ||
} | ||
|
||
/** | ||
* Ensures Audit messages are correctly bridged and all attributes are present. | ||
*/ | ||
@Test | ||
public void testTelemetryAuditLogs() throws Exception { | ||
// on restore we expect no audit messages that happened on the checkpoint side | ||
RemoteFile consoleLog = server.getConsoleLogFile(); | ||
List<String> linesConsoleLog = server.findStringsInLogsUsingMark(".*scopeInfo.*", consoleLog); | ||
|
||
Log.info(getClass(), "testRestoreTelemetryAuditLogs", "Number of logs: " + linesConsoleLog.size()); | ||
for (String line : linesConsoleLog) { | ||
Log.info(getClass(), "testRestoreTelemetryAuditLogs", line); | ||
} | ||
|
||
linesConsoleLog = linesConsoleLog.stream().filter((l) -> !l.contains("WebSphere:type=ThreadPoolStats")).collect(Collectors.toList()); | ||
|
||
assertEquals("Expected no audit messages on restore", 0, linesConsoleLog.size()); | ||
// generate JMX_MBEAN_REGISTER audit message by hitting the root of the server | ||
TestUtils.runGetMethod("http://" + server.getHostname() + ":" + server.getHttpDefaultPort()); | ||
String line = server.waitForStringInLog("JMXService", server.getConsoleLogFile()); | ||
assertNotNull("The JMXService audit event was not not found.", line); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bootstrap.include=../testports.properties | ||
com.ibm.ws.logging.console.log.level=OFF | ||
com.ibm.ws.logging.trace.specification=io.openliberty.microprofile.telemetry.internal.common=all:io.openliberty.microprofile.telemetry.logging.internal.fat.MpTelemetryLogApp.*=all | ||
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. This line can be removed, since we aren't checking for trace or even using the test app in the checkpoint test. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-Dcom.ibm.ws.beta.edition=true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
OTEL_LOGS_EXPORTER=console | ||
OTEL_METRICS_EXPORTER=none | ||
OTEL_TRACE_EXPORTER=none | ||
OTEL_SDK_DISABLED=false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<!-- | ||
Copyright (c) 2024 IBM Corporation and others. | ||
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. Not sure if this needs to be updated to 2025, or if config files even need a copyright header? |
||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License 2.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-2.0/ | ||
|
||
SPDX-License-Identifier: EPL-2.0 | ||
|
||
Contributors: | ||
IBM Corporation - initial API and implementation | ||
--> | ||
<server description="Telemetry Server to test Message logs"> | ||
<featureManager> | ||
<feature>servlet-6.1</feature> | ||
<feature>mpTelemetry-2.0</feature> | ||
<feature>audit-2.0</feature> | ||
<feature>componentTest-2.0</feature> | ||
<feature>appsecurity-6.0</feature> | ||
</featureManager> | ||
<include location="../fatTestPorts.xml"/> | ||
<mpTelemetry source="audit"/> | ||
</server> |
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.
Copyright year -> 2025