Skip to content

Commit 63dc1bd

Browse files
authored
[ST] Fixes to LogCollector and UserST (#11876)
Signed-off-by: Lukas Kral <lukywill16@gmail.com>
1 parent 79cc890 commit 63dc1bd

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

systemtest/src/main/java/io/strimzi/systemtest/TestTags.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ public interface TestTags {
156156
*/
157157
String PERFORMANCE = "performance";
158158

159+
/**
160+
* Tag for tests focusing on users - this one is especially for UserST in order to create `test-suite-namespace`.
161+
*/
162+
String USER = "user";
163+
159164
/**
160165
* Tag for tests that covers Tiered Storage integration
161166
*/

systemtest/src/main/java/io/strimzi/systemtest/listeners/ExecutionListener.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public static boolean requiresSharedNamespace(final ExtensionContext extensionCo
6868
TestTags.DYNAMIC_CONFIGURATION, // Dynamic configuration also because in DynamicConfSharedST we use @TestFactory
6969
TestTags.TRACING, // Tracing, because we deploy Jaeger operator inside additional namespace
7070
TestTags.KAFKA_SMOKE, // KafkaVersionsST, MigrationST because here we use @ParameterizedTest
71-
TestTags.KRAFT_UPGRADE
71+
TestTags.KRAFT_UPGRADE,
72+
TestTags.USER // Needed for UserST mainly, where we are deploying Kafka into the `test-suite-namespace` before running all other tests
7273
);
7374

7475
for (TestIdentifier testIdentifier : testCases) {

systemtest/src/main/java/io/strimzi/systemtest/logs/TestLogCollector.java

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ private LogCollector defaultLogCollector() {
142142
TestConstants.CONFIG_MAP.toLowerCase(Locale.ROOT),
143143
TestConstants.SERVICE.toLowerCase(Locale.ROOT),
144144
TestConstants.CERTIFICATE.toLowerCase(Locale.ROOT),
145+
TestConstants.JOB.toLowerCase(Locale.ROOT),
145146
Kafka.RESOURCE_SINGULAR,
146147
KafkaNodePool.RESOURCE_SINGULAR,
147148
KafkaConnect.RESOURCE_SINGULAR,
@@ -190,21 +191,24 @@ private Path checkPathAndReturnFullRootPathWithIndexFolder(Path rootPathToLogsFo
190191
String[] filesInLogsDir = logsForTestCase.list();
191192

192193
if (filesInLogsDir != null && filesInLogsDir.length > 0) {
193-
index = Integer.parseInt(
194-
Arrays
195-
.stream(filesInLogsDir)
196-
.filter(file -> {
197-
try {
198-
Integer.parseInt(file);
199-
return true;
200-
} catch (NumberFormatException e) {
201-
return false;
202-
}
203-
})
204-
.sorted()
205-
.toList()
206-
.get(filesInLogsDir.length - 1)
207-
) + 1;
194+
List<String> indexes = Arrays
195+
.stream(filesInLogsDir)
196+
.filter(file -> {
197+
try {
198+
Integer.parseInt(file);
199+
return true;
200+
} catch (NumberFormatException e) {
201+
return false;
202+
}
203+
})
204+
.sorted()
205+
.toList();
206+
207+
// check if there is actually something in the list of folders
208+
if (!indexes.isEmpty()) {
209+
// take the highest index and increase it by one for a new directory
210+
index = Integer.parseInt(indexes.get(indexes.size() - 1)) + 1;
211+
}
208212
}
209213
}
210214

systemtest/src/test/java/io/strimzi/systemtest/operators/user/UserST.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656
import static io.strimzi.systemtest.TestTags.ACCEPTANCE;
5757
import static io.strimzi.systemtest.TestTags.REGRESSION;
58+
import static io.strimzi.systemtest.TestTags.USER;
5859
import static org.hamcrest.CoreMatchers.containsString;
5960
import static org.hamcrest.MatcherAssert.assertThat;
6061
import static org.hamcrest.Matchers.equalTo;
@@ -66,6 +67,7 @@
6667
import static org.valid4j.matchers.jsonpath.JsonPathMatchers.hasJsonPath;
6768

6869
@Tag(REGRESSION)
70+
@Tag(USER)
6971
@SuiteDoc(
7072
description = @Desc("Test suite for various Kafka User operations and configurations."),
7173
beforeTestSteps = {
@@ -506,12 +508,18 @@ void testTlsExternalUser() {
506508
}
507509
);
508510

511+
// Change the producer name in order to sure that we will not pick old Pod (race condition)
512+
String newProducerName = testStorage.getProducerName() + "-authz";
513+
kafkaClients = new KafkaClientsBuilder(kafkaClients)
514+
.withProducerName(newProducerName)
515+
.build();
516+
509517
KubeResourceManager.get().createResourceWithWait(kafkaClients.producerTlsStrimzi(testStorage.getClusterName()));
510518

511519
PodUtils.waitUntilMessageIsInPodLogs(testStorage.getNamespaceName(),
512-
PodUtils.getPodNameByPrefix(testStorage.getNamespaceName(), testStorage.getProducerName()), "authorization failed");
520+
PodUtils.getPodNameByPrefix(testStorage.getNamespaceName(), newProducerName), "authorization failed");
513521

514-
ClientUtils.waitForInstantProducerClientTimeout(testStorage);
522+
ClientUtils.waitForClientTimeout(testStorage.getNamespaceName(), newProducerName, testStorage.getMessageCount());
515523
}
516524

517525
@BeforeAll

0 commit comments

Comments
 (0)