Skip to content

Commit 2c74682

Browse files
authored
[ST] Change testChangingInternalToExternalLoggingTriggerRollingUpdate after removal of Kafka 3.9.x (#11850)
Signed-off-by: Lukas Kral <lukywill16@gmail.com>
1 parent ecf2f9a commit 2c74682

4 files changed

Lines changed: 71 additions & 43 deletions

File tree

development-docs/systemtests/io.strimzi.systemtest.log.LoggingChangeST.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515

1616
<hr style="border:1px solid">
1717

18-
## testChangingInternalToExternalLoggingTriggerRollingUpdate
18+
## testChangingInternalToExternalLoggingDoesNotTriggerRollingUpdate
1919

20-
**Description:** This test case checks that changing Logging configuration from internal to external triggers Rolling Update.
20+
**Description:** This test case checks that changing Logging configuration from internal to external will not trigger Rolling Update.
2121

2222
**Steps:**
2323

2424
| Step | Action | Result |
2525
| - | - | - |
2626
| 1. | Deploy Kafka cluster, without any logging related configuration. | Cluster is deployed. |
27-
| 2. | Modify Kafka by changing specification of logging to new external value. | Change in logging specification triggers Rolling Update. |
28-
| 3. | Modify ConfigMap to new logging format. | Change in logging specification triggers Rolling Update. |
27+
| 2. | Modify Kafka by changing specification of logging to new external value. | Change in logging specification doesn't trigger Rolling Update. |
28+
| 3. | Modify ConfigMap to new logging format. | Change in logging specification doesn't trigger Rolling Update. |
2929

3030
**Labels:**
3131

development-docs/systemtests/labels/kafka.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ These tests are crucial to ensure that Kafka clusters can handle production work
1212
- [testAdvertisedHostNamesAppearsInBrokerCerts](../io.strimzi.systemtest.kafka.listeners.ListenersST.md)
1313
- [testCertificateWithNonExistingDataCrt](../io.strimzi.systemtest.kafka.listeners.ListenersST.md)
1414
- [testCertificateWithNonExistingDataKey](../io.strimzi.systemtest.kafka.listeners.ListenersST.md)
15-
- [testChangingInternalToExternalLoggingTriggerRollingUpdate](../io.strimzi.systemtest.log.LoggingChangeST.md)
15+
- [testChangingInternalToExternalLoggingDoesNotTriggerRollingUpdate](../io.strimzi.systemtest.log.LoggingChangeST.md)
1616
- [testClusterIp](../io.strimzi.systemtest.kafka.listeners.ListenersST.md)
1717
- [testClusterIpTls](../io.strimzi.systemtest.kafka.listeners.ListenersST.md)
1818
- [testClusterOperatorMetrics](../io.strimzi.systemtest.metrics.MetricsST.md)

development-docs/systemtests/labels/logging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ and stability of Kafka deployments in production environments.
1313
<!-- generated part -->
1414
**Tests:**
1515
- [testBridgeLogSetting](../io.strimzi.systemtest.log.LogSettingST.md)
16-
- [testChangingInternalToExternalLoggingTriggerRollingUpdate](../io.strimzi.systemtest.log.LoggingChangeST.md)
16+
- [testChangingInternalToExternalLoggingDoesNotTriggerRollingUpdate](../io.strimzi.systemtest.log.LoggingChangeST.md)
1717
- [testConnectLogSetting](../io.strimzi.systemtest.log.LogSettingST.md)
1818
- [testCruiseControlLogChange](../io.strimzi.systemtest.log.LogSettingST.md)
1919
- [testDynamicallyAndNonDynamicSetConnectLoggingLevels](../io.strimzi.systemtest.log.LoggingChangeST.md)

systemtest/src/test/java/io/strimzi/systemtest/log/LoggingChangeST.java

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
import io.strimzi.test.TestUtils;
6262
import org.apache.logging.log4j.LogManager;
6363
import org.apache.logging.log4j.Logger;
64-
import org.junit.jupiter.api.Assumptions;
6564
import org.junit.jupiter.api.BeforeAll;
6665
import org.junit.jupiter.api.Tag;
6766

@@ -2132,88 +2131,117 @@ void testLoggingHierarchy() {
21322131
@ParallelNamespaceTest
21332132
@Tag(ROLLING_UPDATE)
21342133
@TestDoc(
2135-
description = @Desc("This test case checks that changing Logging configuration from internal to external triggers Rolling Update."),
2134+
description = @Desc("This test case checks that changing Logging configuration from internal to external will not trigger Rolling Update."),
21362135
steps = {
21372136
@Step(value = "Deploy Kafka cluster, without any logging related configuration.", expected = "Cluster is deployed."),
2138-
@Step(value = "Modify Kafka by changing specification of logging to new external value.", expected = "Change in logging specification triggers Rolling Update."),
2139-
@Step(value = "Modify ConfigMap to new logging format.", expected = "Change in logging specification triggers Rolling Update.")
2137+
@Step(value = "Modify Kafka by changing specification of logging to new external value.", expected = "Change in logging specification doesn't trigger Rolling Update."),
2138+
@Step(value = "Modify ConfigMap to new logging format.", expected = "Change in logging specification doesn't trigger Rolling Update.")
21402139
},
21412140
labels = {
21422141
@Label(value = TestDocsLabels.KAFKA),
21432142
@Label(value = TestDocsLabels.LOGGING)
21442143
}
21452144
)
2146-
void testChangingInternalToExternalLoggingTriggerRollingUpdate() {
2147-
// This test would need some changes since Kafka 4.0.0 uses Log4j2 which provides dynamic logging changes for the brokers and is therefore disabled.
2148-
// This test can be enabled again once we fix the issue: https://github.com/strimzi/strimzi-kafka-operator/issues/11312
2149-
Assumptions.assumeTrue(TestKafkaVersion.compareDottedVersions(Environment.ST_KAFKA_VERSION, "4.0.0") < 0);
2150-
2145+
void testChangingInternalToExternalLoggingDoesNotTriggerRollingUpdate() {
21512146
final TestStorage testStorage = new TestStorage(KubeResourceManager.get().getTestContext());
21522147

21532148
// EO dynamic logging is tested in io.strimzi.systemtest.log.LoggingChangeST.testDynamicallySetEOloggingLevels
21542149
KubeResourceManager.get().createResourceWithWait(
21552150
KafkaNodePoolTemplates.brokerPool(testStorage.getNamespaceName(), testStorage.getBrokerPoolName(), testStorage.getClusterName(), 3).build(),
21562151
KafkaNodePoolTemplates.controllerPool(testStorage.getNamespaceName(), testStorage.getControllerPoolName(), testStorage.getClusterName(), 3).build()
21572152
);
2158-
KubeResourceManager.get().createResourceWithWait(KafkaTemplates.kafka(testStorage.getNamespaceName(), testStorage.getClusterName(), 3).build());
2153+
KubeResourceManager.get().createResourceWithWait(
2154+
KafkaTemplates.kafka(testStorage.getNamespaceName(), testStorage.getClusterName(), 3).build(),
2155+
ScraperTemplates.scraperPod(testStorage.getNamespaceName(), testStorage.getScraperName()).build()
2156+
);
21592157

21602158
Map<String, String> brokerPods = PodUtils.podSnapshot(testStorage.getNamespaceName(), testStorage.getBrokerSelector());
21612159
Map<String, String> controllerPods = PodUtils.podSnapshot(testStorage.getNamespaceName(), testStorage.getControllerSelector());
2160+
String scraperPodName = KubeResourceManager.get().kubeClient().listPodsByPrefixInName(testStorage.getNamespaceName(), testStorage.getScraperName()).get(0).getMetadata().getName();
21622161

2163-
final String loggersConfig = "log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender\n" +
2164-
"log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout\n" +
2165-
"log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %p %m (%c) [%t]\n" +
2166-
"kafka.root.logger.level=INFO\n" +
2167-
"log4j.rootLogger=${kafka.root.logger.level}, CONSOLE\n" +
2168-
"log4j.logger.kafka=INFO\n" +
2169-
"log4j.logger.org.apache.kafka=INFO\n" +
2170-
"log4j.logger.kafka.request.logger=WARN, CONSOLE\n" +
2171-
"log4j.logger.kafka.network.Processor=INFO\n" +
2172-
"log4j.logger.kafka.server.KafkaApis=INFO\n" +
2173-
"log4j.logger.kafka.network.RequestChannel$=INFO\n" +
2174-
"log4j.logger.kafka.controller=INFO\n" +
2175-
"log4j.logger.kafka.log.LogCleaner=INFO\n" +
2176-
"log4j.logger.state.change.logger=TRACE\n" +
2177-
"log4j.logger.kafka.authorizer.logger=INFO";
2162+
assertThat(KafkaCmdClient.describeKafkaBrokerLoggersUsingPodCli(testStorage.getNamespaceName(), scraperPodName, KafkaResources.plainBootstrapAddress(testStorage.getClusterName()), 0).contains("root=DEBUG"), is(true));
2163+
2164+
final String loggersConfig = """
2165+
status = WARN
2166+
# Periodic interval for Log4j2 to check the properties and change it accordingly
2167+
monitorInterval = 10
2168+
# Dynamic property
2169+
property.kafka.root.logger.level = INFO
2170+
appender.console.type = Console
2171+
appender.console.name = CONSOLE
2172+
appender.console.target = SYSTEM_OUT
2173+
appender.console.layout.type = PatternLayout
2174+
appender.console.layout.pattern = %d{ISO8601} %p %m (%c) [%t]
2175+
rootLogger.level = ${kafka.root.logger.level}
2176+
rootLogger.appenderRef.console.ref = CONSOLE
2177+
logger.kafka.name = kafka
2178+
logger.kafka.level = INFO
2179+
logger.orgapachekafka.name = org.apache.kafka
2180+
logger.orgapachekafka.level = INFO
2181+
logger.kafkarequest.name = kafka.request.logger
2182+
logger.kafkarequest.level = WARN
2183+
logger.kafkarequest.additivity = false
2184+
logger.kafkarequest.appenderRef.console.ref = CONSOLE
2185+
logger.kafkanetproc.name = kafka.network.Processor
2186+
logger.kafkanetproc.level = INFO
2187+
logger.kafkaserverapis.name = kafka.server.KafkaApis
2188+
logger.kafkaserverapis.level = INFO
2189+
logger.kafkarequestchannel.name = kafka.network.RequestChannel$
2190+
logger.kafkarequestchannel.level = INFO
2191+
logger.kafkacontroller.name = kafka.controller
2192+
logger.kafkacontroller.level = INFO
2193+
logger.kafkalogcleaner.name = kafka.log.LogCleaner
2194+
logger.kafkalogcleaner.level = INFO
2195+
logger.statechange.name = state.change.logger
2196+
logger.statechange.level = TRACE
2197+
logger.kafkabrokerauth.name = kafka.authorizer.logger
2198+
logger.kafkabrokerauth.level = INFO
2199+
""";
21782200

21792201
final String configMapLoggersName = "loggers-config-map";
21802202
ConfigMap configMapLoggers = new ConfigMapBuilder()
21812203
.withNewMetadata()
21822204
.withNamespace(testStorage.getNamespaceName())
21832205
.withName(configMapLoggersName)
21842206
.endMetadata()
2185-
.addToData("log4j-custom.properties", loggersConfig)
2207+
.addToData("log4j2-custom.properties", loggersConfig)
21862208
.build();
21872209

21882210
ConfigMapKeySelector log4jLoggimgCMselector = new ConfigMapKeySelectorBuilder()
21892211
.withName(configMapLoggersName)
2190-
.withKey("log4j-custom.properties")
2212+
.withKey("log4j2-custom.properties")
21912213
.build();
21922214

21932215
KubeResourceManager.get().createResourceWithWait(configMapLoggers);
21942216

21952217
KafkaUtils.replace(testStorage.getNamespaceName(), testStorage.getClusterName(), kafka -> {
21962218
kafka.getSpec().getKafka().setLogging(new ExternalLoggingBuilder()
21972219
.withNewValueFrom()
2198-
.withConfigMapKeyRef(log4jLoggimgCMselector)
2220+
.withConfigMapKeyRef(log4jLoggimgCMselector)
21992221
.endValueFrom()
22002222
.build());
22012223
});
22022224

2203-
LOGGER.info("Waiting for controller pods to roll after change in logging");
2204-
controllerPods = RollingUpdateUtils.waitTillComponentHasRolledAndPodsReady(testStorage.getNamespaceName(), testStorage.getControllerSelector(), 3, controllerPods);
2225+
LOGGER.info("Waiting for controller pods to not roll after change in logging");
2226+
RollingUpdateUtils.waitForNoRollingUpdate(testStorage.getNamespaceName(), testStorage.getControllerSelector(), controllerPods);
2227+
2228+
LOGGER.info("Waiting for broker pods to not roll after change in logging");
2229+
RollingUpdateUtils.waitForNoRollingUpdate(testStorage.getNamespaceName(), testStorage.getBrokerSelector(), brokerPods);
22052230

2206-
LOGGER.info("Waiting for broker pods to roll after change in logging");
2207-
brokerPods = RollingUpdateUtils.waitTillComponentHasRolledAndPodsReady(testStorage.getNamespaceName(), testStorage.getBrokerSelector(), 3, brokerPods);
2231+
TestUtils.waitFor("Logger change", TestConstants.GLOBAL_POLL_INTERVAL, TestConstants.GLOBAL_TIMEOUT,
2232+
() -> KafkaCmdClient.describeKafkaBrokerLoggersUsingPodCli(testStorage.getNamespaceName(), scraperPodName, KafkaResources.plainBootstrapAddress(testStorage.getClusterName()), 0).contains("root=INFO"));
22082233

2209-
configMapLoggers.getData().put("log4j-custom.properties", loggersConfig.replace("%p %m (%c) [%t]", "%p %m (%c) [%t]%n"));
2234+
configMapLoggers.getData().put("log4j2-custom.properties", loggersConfig.replace("property.kafka.root.logger.level = INFO", "property.kafka.root.logger.level = WARN"));
22102235
KubeResourceManager.get().updateResource(configMapLoggers);
22112236

2212-
LOGGER.info("Waiting for controller pods to roll after change in logging properties config map");
2213-
RollingUpdateUtils.waitTillComponentHasRolledAndPodsReady(testStorage.getNamespaceName(), testStorage.getControllerSelector(), 3, controllerPods);
2237+
LOGGER.info("Waiting for controller pods to not roll after change in logging");
2238+
RollingUpdateUtils.waitForNoRollingUpdate(testStorage.getNamespaceName(), testStorage.getControllerSelector(), controllerPods);
22142239

2215-
LOGGER.info("Waiting for broker pods to roll after change in logging properties config map");
2216-
RollingUpdateUtils.waitTillComponentHasRolledAndPodsReady(testStorage.getNamespaceName(), testStorage.getBrokerSelector(), 3, brokerPods);
2240+
LOGGER.info("Waiting for broker pods to not roll after change in logging");
2241+
RollingUpdateUtils.waitForNoRollingUpdate(testStorage.getNamespaceName(), testStorage.getBrokerSelector(), brokerPods);
2242+
2243+
TestUtils.waitFor("Logger change", TestConstants.GLOBAL_POLL_INTERVAL, TestConstants.GLOBAL_TIMEOUT,
2244+
() -> KafkaCmdClient.describeKafkaBrokerLoggersUsingPodCli(testStorage.getNamespaceName(), scraperPodName, KafkaResources.plainBootstrapAddress(testStorage.getClusterName()), 0).contains("root=WARN"));
22172245
}
22182246

22192247
@BeforeAll

0 commit comments

Comments
 (0)