Skip to content

Commit

Permalink
[ST] add skip mixed role annotation to ST. (#9743)
Browse files Browse the repository at this point in the history
Signed-off-by: hzrncik <[email protected]>
  • Loading branch information
henryZrncik authored Feb 27, 2024
1 parent d4d38bc commit 1575f35
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright Strimzi authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.strimzi.systemtest.annotations;

import org.junit.jupiter.api.extension.ExtendWith;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@ExtendWith(MixedRoleNotSupportedCondition.class)
public @interface MixedRoleNotSupported {
String value() default "Mixed role in Kafka Node Pools is not supported with configuration in this test case.";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright Strimzi authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.strimzi.systemtest.annotations;

import io.strimzi.systemtest.Environment;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
import org.junit.jupiter.api.extension.ExecutionCondition;
import org.junit.jupiter.api.extension.ExtensionContext;

public class MixedRoleNotSupportedCondition implements ExecutionCondition {
private static final Logger LOGGER = LogManager.getLogger(MixedRoleNotSupportedCondition.class);

@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) {
if (Environment.isSeparateRolesMode() || !Environment.isKafkaNodePoolsEnabled() || !Environment.isKRaftModeEnabled()) {
return ConditionEvaluationResult.enabled("Test is enabled");
} else {
LOGGER.warn("According to {} env variable with value: {}, the mixed role mode is used, skipping this test because is not mixed role mode compliant",
Environment.STRIMZI_NODE_POOLS_ROLE_MODE_ENV,
Environment.STRIMZI_NODE_POOLS_ROLE_MODE);
return ConditionEvaluationResult.disabled("Test is disabled");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.strimzi.systemtest.annotations.IsolatedTest;
import io.strimzi.systemtest.annotations.KRaftNotSupported;
import io.strimzi.systemtest.annotations.KRaftWithoutUTONotSupported;
import io.strimzi.systemtest.annotations.MixedRoleNotSupported;
import io.strimzi.systemtest.annotations.ParallelNamespaceTest;
import io.strimzi.systemtest.annotations.UTONotSupported;
import io.strimzi.systemtest.resources.NodePoolsConverter;
Expand Down Expand Up @@ -448,20 +449,23 @@ void testCruiseControlIntraBrokerBalancingWithoutSpecifyingJBODStorage() {
}

@IsolatedTest
@MixedRoleNotSupported("Scaling a Kafka Node Pool with mixed roles is not supported yet")
void testCruiseControlDuringBrokerScaleUpAndDown() {
TestStorage testStorage = new TestStorage(ResourceManager.getTestContext(), TestConstants.CO_NAMESPACE);
final int initialReplicas = 3;
final int scaleTo = 5;

resourceManager.createResourceWithWait(
// if we run test in kraft mode test makes sense only with separated roles
KafkaNodePoolTemplates.brokerPool(testStorage.getNamespaceName(), testStorage.getBrokerPoolName(), testStorage.getClusterName(), initialReplicas).build(),
KafkaNodePoolTemplates.controllerPool(testStorage.getNamespaceName(), testStorage.getControllerPoolName(), testStorage.getClusterName(), initialReplicas)
.editOrNewMetadata()
// controllers have Ids set in order to keep default ordering for brokers only (once we scale broker KNP)
.withAnnotations(Map.of(Annotations.ANNO_STRIMZI_IO_NEXT_NODE_IDS, "[100-103]"))
.endMetadata()
.build()
NodePoolsConverter.convertNodePoolsIfNeeded(
KafkaNodePoolTemplates.brokerPool(testStorage.getNamespaceName(), testStorage.getBrokerPoolName(), testStorage.getClusterName(), initialReplicas).build(),
KafkaNodePoolTemplates.controllerPool(testStorage.getNamespaceName(), testStorage.getControllerPoolName(), testStorage.getClusterName(), initialReplicas)
.editOrNewMetadata()
// controllers have Ids set in order to keep default ordering for brokers only (once we scale broker KNP)
.withAnnotations(Map.of(Annotations.ANNO_STRIMZI_IO_NEXT_NODE_IDS, "[100-103]"))
.endMetadata()
.build()
)

);
resourceManager.createResourceWithWait(
KafkaTemplates.kafkaWithCruiseControl(testStorage.getClusterName(), initialReplicas, initialReplicas).build(),
Expand Down

0 comments on commit 1575f35

Please sign in to comment.