Skip to content
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

[ST] Remove storageMap from the suite #10440

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import io.strimzi.systemtest.resources.NamespaceManager;
import io.strimzi.systemtest.resources.ResourceManager;
import io.strimzi.systemtest.resources.operator.SetupClusterOperator;
import io.strimzi.systemtest.storage.TestStorage;
import io.strimzi.systemtest.utils.StUtils;
import io.strimzi.test.interfaces.TestSeparator;
import io.strimzi.test.k8s.KubeClusterResource;
Expand All @@ -29,7 +28,6 @@

import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import static io.strimzi.systemtest.matchers.Matchers.logHasNoUnexpectedErrors;
import static io.strimzi.test.k8s.KubeClusterResource.cmdKubeClient;
Expand All @@ -54,9 +52,6 @@ public abstract class AbstractST implements TestSeparator {
// {thread-safe} this needs to be static because when more threads spawns diff. TestSuites it might produce race conditions
private static final Object LOCK = new Object();

protected static ConcurrentHashMap<ExtensionContext, TestStorage> storageMap = new ConcurrentHashMap<>();


protected void assertNoCoErrorsLogged(String namespaceName, long sinceSeconds) {
LOGGER.info("Search in strimzi-cluster-operator log for errors in last {} second(s)", sinceSeconds);
String clusterOperatorLog = cmdKubeClient(namespaceName).searchInLog(TestConstants.DEPLOYMENT, ResourceManager.getCoDeploymentName(), sinceSeconds, "Exception", "Error", "Throwable", "OOM");
Expand Down Expand Up @@ -109,7 +104,6 @@ protected void beforeEachMayOverride() {
synchronized (LOCK) {
LOGGER.info("Not first test we are gonna generate cluster name");
testSuiteNamespaceManager.createParallelNamespace();
storageMap.put(ResourceManager.getTestContext(), new TestStorage(ResourceManager.getTestContext()));
}
}

Expand Down Expand Up @@ -172,7 +166,7 @@ void tearDownTestCase(ExtensionContext extensionContext) throws Exception {
try {
// This method needs to be disabled for the moment, as it brings flakiness and is unstable due to regexes and current matcher checks.
// Needs to be reworked on what errors to ignore. Better error logging should be added.
//assertNoCoErrorsLogged(clusterOperator.getDeploymentNamespace(), storageMap.get(extensionContext).getTestExecutionTimeInSeconds());
// assertNoCoErrorsLogged(clusterOperator.getDeploymentNamespace(), (long) extensionContext.getStore(ExtensionContext.Namespace.GLOBAL).get(TestConstants.TEST_EXECUTION_START_TIME_KEY));
} finally {
afterEachMayOverride();
afterEachMustExecute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
package io.strimzi.systemtest.security.oauth;

import io.fabric8.kubernetes.api.model.batch.v1.Job;
import io.strimzi.api.kafka.model.common.CertSecretSourceBuilder;
import io.strimzi.api.kafka.model.kafka.listener.GenericKafkaListener;
import io.strimzi.api.kafka.model.kafka.listener.GenericKafkaListenerBuilder;
Expand All @@ -15,19 +14,15 @@
import io.strimzi.systemtest.annotations.IPv6NotSupported;
import io.strimzi.systemtest.keycloak.KeycloakInstance;
import io.strimzi.systemtest.resources.NamespaceManager;
import io.strimzi.systemtest.resources.ResourceManager;
import io.strimzi.systemtest.resources.keycloak.SetupKeycloak;
import io.strimzi.systemtest.templates.specific.ScraperTemplates;
import io.strimzi.systemtest.utils.kubeUtils.controllers.JobUtils;
import io.strimzi.systemtest.utils.kubeUtils.objects.SecretUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.hamcrest.CoreMatchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Tag;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

Expand Down Expand Up @@ -142,20 +137,6 @@ protected void setupCoAndKeycloak(String keycloakNamespace) {
createSecretsForDeployments(keycloakNamespace);
}

@AfterEach
void tearDownEach() {
List<Job> clusterJobList = kubeClient().getJobList().getItems()
.stream()
.filter(
job -> job.getMetadata().getName().contains(storageMap.get(ResourceManager.getTestContext()).getClusterName()))
.toList();

for (Job job : clusterJobList) {
LOGGER.info("Deleting Job: {}/{} ", job.getMetadata().getNamespace(), job.getMetadata().getName());
JobUtils.deleteJobWithWait(job.getMetadata().getNamespace(), job.getMetadata().getName());
}
}

/**
* Auxiliary method, which creating kubernetes secrets
* f.e name kafka-broker-secret -> will be encoded to base64 format and use as a key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;

import java.util.HashMap;
Expand Down Expand Up @@ -332,11 +331,6 @@ private void consumeDataWithNewSinkConnector(String newConnectorName, String con
KafkaConnectUtils.waitForMessagesInKafkaConnectFileSink(namespace, kafkaConnectPodName, TestConstants.DEFAULT_SINK_FILE_PATH, msgCount);
}

@BeforeEach
void createTestResources() {
storageMap.put(ResourceManager.getTestContext(), new TestStorage(ResourceManager.getTestContext()));
}

@BeforeAll
void setup() {
this.clusterOperator = this.clusterOperator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.extension.ExtensionContext;

Expand Down Expand Up @@ -75,14 +74,10 @@ public class OpenTelemetryST extends AbstractST {

private final Tracing otelTracing = new OpenTelemetryTracing();

@ParallelNamespaceTest
@Tag(ACCEPTANCE)
@ParallelNamespaceTest
void testProducerConsumerStreamsService() {
// Current implementation of Jaeger deployment and test parallelism does not allow to run this test with STRIMZI_RBAC_SCOPE=NAMESPACE`
assumeFalse(Environment.isNamespaceRbacScope());

// This testStorage gets resources set by BeforeEach, so it must be retrieved from storageMap
final TestStorage testStorage = storageMap.get(ResourceManager.getTestContext());
TestStorage testStorage = deployInitialResourcesAndGetTestStorage();
im-konge marked this conversation as resolved.
Show resolved Hide resolved

resourceManager.createResourceWithWait(
NodePoolsConverter.convertNodePoolsIfNeeded(
Expand Down Expand Up @@ -121,11 +116,7 @@ void testProducerConsumerStreamsService() {
@ParallelNamespaceTest
@Tag(MIRROR_MAKER2)
void testProducerConsumerMirrorMaker2Service() {
// Current implementation of Jaeger deployment and test parallelism does not allow to run this test with STRIMZI_RBAC_SCOPE=NAMESPACE`
assumeFalse(Environment.isNamespaceRbacScope());

// This testStorage gets resources set by BeforeEach, so it must be retrieved from storageMap
final TestStorage testStorage = storageMap.get(ResourceManager.getTestContext());
TestStorage testStorage = deployInitialResourcesAndGetTestStorage();

resourceManager.createResourceWithWait(
NodePoolsConverter.convertNodePoolsIfNeeded(
Expand Down Expand Up @@ -204,11 +195,7 @@ void testProducerConsumerMirrorMaker2Service() {
@ParallelNamespaceTest
@Tag(MIRROR_MAKER)
void testProducerConsumerMirrorMakerService() {
// Current implementation of Jaeger deployment and test parallelism does not allow to run this test with STRIMZI_RBAC_SCOPE=NAMESPACE`
assumeFalse(Environment.isNamespaceRbacScope());

// This testStorage gets resources set by BeforeEach, so it must be retrieved from storageMap
final TestStorage testStorage = storageMap.get(ResourceManager.getTestContext());
TestStorage testStorage = deployInitialResourcesAndGetTestStorage();

resourceManager.createResourceWithWait(
NodePoolsConverter.convertNodePoolsIfNeeded(
Expand Down Expand Up @@ -277,11 +264,7 @@ void testProducerConsumerMirrorMakerService() {
@Tag(CONNECT_COMPONENTS)
@SuppressWarnings({"checkstyle:MethodLength"})
void testProducerConsumerStreamsConnectService() {
// Current implementation of Jaeger deployment and test parallelism does not allow to run this test with STRIMZI_RBAC_SCOPE=NAMESPACE`
assumeFalse(Environment.isNamespaceRbacScope());

// This testStorage gets resources set by BeforeEach, so it must be retrieved from storageMap
final TestStorage testStorage = storageMap.get(ResourceManager.getTestContext());
TestStorage testStorage = deployInitialResourcesAndGetTestStorage();

resourceManager.createResourceWithWait(
NodePoolsConverter.convertNodePoolsIfNeeded(
Expand Down Expand Up @@ -359,8 +342,7 @@ void testProducerConsumerStreamsConnectService() {
@Tag(BRIDGE)
@ParallelNamespaceTest
void testKafkaBridgeService() {
// This testStorage gets resources set by BeforeEach, so it must be retrieved from storageMap
final TestStorage testStorage = storageMap.get(ResourceManager.getTestContext());
TestStorage testStorage = deployInitialResourcesAndGetTestStorage();

resourceManager.createResourceWithWait(
NodePoolsConverter.convertNodePoolsIfNeeded(
Expand Down Expand Up @@ -425,8 +407,7 @@ void testKafkaBridgeService() {
@Tag(BRIDGE)
@ParallelNamespaceTest
void testKafkaBridgeServiceWithHttpTracing() {
// This testStorage gets resources set by BeforeEach, so it must be retrieved from storageMap
final TestStorage testStorage = storageMap.get(ResourceManager.getTestContext());
TestStorage testStorage = deployInitialResourcesAndGetTestStorage();

resourceManager.createResourceWithWait(
NodePoolsConverter.convertNodePoolsIfNeeded(
Expand Down Expand Up @@ -489,8 +470,7 @@ void testKafkaBridgeServiceWithHttpTracing() {
TracingUtils.verify(testStorage.getNamespaceName(), bridgeProducer, testStorage.getScraperPodName(), JAEGER_QUERY_SERVICE);
}

@BeforeEach
void createTestResources() {
private TestStorage deployInitialResourcesAndGetTestStorage() {
final TestStorage testStorage = new TestStorage(ResourceManager.getTestContext());

SetupJaeger.deployJaegerInstance(testStorage.getNamespaceName());
Expand All @@ -517,11 +497,13 @@ void createTestResources() {

testStorage.addToTestStorage(TestConstants.KAFKA_TRACING_CLIENT_KEY, kafkaTracingClients);

storageMap.put(ResourceManager.getTestContext(), testStorage);
return testStorage;
}

@BeforeAll
void setup() {
assumeFalse(Environment.isNamespaceRbacScope());

this.clusterOperator = this.clusterOperator
.defaultInstallation()
.createInstallation()
Expand Down
Loading