Skip to content

Commit

Permalink
[systemtest] Change timeouts in resource classes and delete unused co…
Browse files Browse the repository at this point in the history
…nstants (strimzi#3361)

* add timeouts for forgotten methods and remove unused constants

Signed-off-by: Lukas Kral <[email protected]>

* fix logCurrentResourceStatus

Signed-off-by: Lukas Kral <[email protected]>

* fixup! fix logCurrentResourceStatus

Signed-off-by: Lukas Kral <[email protected]>

* review comments

Signed-off-by: Lukas Kral <[email protected]>

* fixup! review comments

Signed-off-by: Lukas Kral <[email protected]>
  • Loading branch information
im-konge authored Jul 23, 2020
1 parent fa32657 commit 6ddb175
Show file tree
Hide file tree
Showing 20 changed files with 74 additions and 91 deletions.
18 changes: 0 additions & 18 deletions systemtest/src/main/java/io/strimzi/systemtest/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,30 @@
*/
public interface Constants {
long TIMEOUT_FOR_RESOURCE_RECOVERY = Duration.ofMinutes(6).toMillis();
long TIMEOUT_FOR_RESOURCE_CREATION = Duration.ofMinutes(5).toMillis();
long TIMEOUT_FOR_SECRET_CREATION = Duration.ofMinutes(2).toMillis();
long TIMEOUT_FOR_RESOURCE_READINESS = Duration.ofMinutes(14).toMillis();
long TIMEOUT_FOR_CR_CREATION = Duration.ofMinutes(3).toMillis();
long TIMEOUT_FOR_MIRROR_MAKER_COPY_MESSAGES_BETWEEN_BROKERS = Duration.ofMinutes(7).toMillis();
long TIMEOUT_FOR_MIRROR_JOIN_TO_GROUP = Duration.ofMinutes(2).toMillis();
long TIMEOUT_FOR_TOPIC_CREATION = Duration.ofMinutes(1).toMillis();
long TIMEOUT_FOR_LOG = Duration.ofMinutes(2).toMillis();
long POLL_INTERVAL_FOR_RESOURCE_CREATION = Duration.ofSeconds(3).toMillis();
long POLL_INTERVAL_FOR_RESOURCE_READINESS = Duration.ofSeconds(1).toMillis();
long POLL_INTERVAL_FOR_RESOURCE_DELETION = Duration.ofSeconds(5).toMillis();
long WAIT_FOR_ROLLING_UPDATE_INTERVAL = Duration.ofSeconds(5).toMillis();
long WAIT_FOR_ROLLING_UPDATE_TIMEOUT = Duration.ofMinutes(7).toMillis();

long TIMEOUT_FOR_SEND_RECEIVE_MSG = Duration.ofSeconds(60).toMillis();
long TIMEOUT_AVAILABILITY_TEST = Duration.ofMinutes(1).toMillis();
long DEFAULT_TIMEOUT_FOR_CONTINUOUS_CLIENTS_FINISH = Duration.ofMinutes(1).toMillis();

long TIMEOUT_FOR_CLUSTER_STABLE = Duration.ofMinutes(20).toMillis();
long TIMEOUT_FOR_ZK_CLUSTER_STABILIZATION = Duration.ofMinutes(7).toMillis();

long GET_BROKER_API_TIMEOUT = Duration.ofMinutes(1).toMillis();
long GET_BROKER_API_INTERVAL = Duration.ofSeconds(5).toMillis();
long TIMEOUT_FOR_GET_SECRETS = Duration.ofMinutes(1).toMillis();
long TIMEOUT_TEARDOWN = Duration.ofSeconds(10).toMillis();
long GLOBAL_TIMEOUT = Duration.ofMinutes(5).toMillis();
long GLOBAL_STATUS_TIMEOUT = Duration.ofMinutes(3).toMillis();
long CONNECT_STATUS_TIMEOUT = Duration.ofMinutes(5).toMillis();
long GLOBAL_POLL_INTERVAL = Duration.ofSeconds(1).toMillis();
long GLOBAL_POLL_INTERVAL_MEDIUM = Duration.ofSeconds(10).toMillis();
long PRODUCER_POLL_INTERVAL = Duration.ofSeconds(30).toMillis();
long PRODUCER_TIMEOUT = Duration.ofSeconds(25).toMillis();

long GLOBAL_TRACING_POLL = Duration.ofSeconds(30).toMillis();
long GLOBAL_TRACING_TIMEOUT = Duration.ofMinutes(7).toMillis();

long API_CRUISE_CONTROL_POLL = Duration.ofSeconds(5).toMillis();
long API_CRUISE_CONTROL_TIMEOUT = Duration.ofMinutes(10).toMillis();
long GLOBAL_CRUISE_CONTROL_TIMEOUT = Duration.ofMinutes(1).toMillis();
long GLOBAL_CRUISE_CONTROL_EXCEPT_FAIL_TIMEOUT = Duration.ofSeconds(10).toMillis();


long GLOBAL_CLIENTS_POLL = Duration.ofSeconds(15).toMillis();
Expand All @@ -61,8 +45,6 @@ public interface Constants {
long CO_OPERATION_TIMEOUT_DEFAULT = Duration.ofMinutes(5).toMillis();
long CO_OPERATION_TIMEOUT_SHORT = Duration.ofSeconds(30).toMillis();
long CO_OPERATION_TIMEOUT_MEDIUM = Duration.ofMinutes(2).toMillis();
long CO_OPERATION_TIMEOUT_WAIT = CO_OPERATION_TIMEOUT_SHORT + Duration.ofSeconds(80).toMillis();
long CO_OPERATION_TIMEOUT_POLL = Duration.ofSeconds(2).toMillis();
long RECONCILIATION_INTERVAL = Duration.ofSeconds(30).toMillis();
long LOGGING_RELOADING_INTERVAL = Duration.ofSeconds(30).toMillis();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@
import java.util.List;
import java.util.Map;

import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;
import static io.strimzi.test.k8s.KubeClusterResource.kubeClient;

public class KubernetesResource {
private static final Logger LOGGER = LogManager.getLogger(KubernetesResource.class);

public static DoneableDeployment deployNewDeployment(Deployment deployment) {
return new DoneableDeployment(deployment, co -> {
TestUtils.waitFor("Deployment creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("Deployment creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
ResourceManager.kubeClient().createOrReplaceDeployment(co);
Expand All @@ -66,7 +67,7 @@ public static DoneableDeployment deployNewDeployment(Deployment deployment) {

public static DoneableJob deployNewJob(Job job) {
return new DoneableJob(job, kubernetesJob -> {
TestUtils.waitFor("Job creation " + job.getMetadata().getName(), Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("Job creation " + job.getMetadata().getName(), Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
ResourceManager.kubeClient().getClient().batch().jobs().inNamespace(kubeClient().getNamespace()).createOrReplace(kubernetesJob);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class ResourceManager {
private static final Logger LOGGER = LogManager.getLogger(ResourceManager.class);

public static final String STRIMZI_PATH_TO_CO_CONFIG = "../install/cluster-operator/050-Deployment-strimzi-cluster-operator.yaml";
public static final long CR_CREATION_TIMEOUT = ResourceOperation.getTimeoutForResourceReadiness();

private static Stack<Runnable> classResources = new Stack<>();
private static Stack<Runnable> methodResources = new Stack<>();
Expand Down Expand Up @@ -382,34 +383,36 @@ public static String getImageValueFromCO(String name) {
* @param customResource - Kafka, KafkaConnect etc. - every resource that HasMetadata and HasStatus (Strimzi status)
*/
public static <T extends HasMetadata & HasStatus> void logCurrentResourceStatus(T customResource) {
List<String> printWholeCR = Arrays.asList(KafkaConnector.RESOURCE_KIND, KafkaTopic.RESOURCE_KIND, KafkaUser.RESOURCE_KIND);
if (customResource != null) {
List<String> printWholeCR = Arrays.asList(KafkaConnector.RESOURCE_KIND, KafkaTopic.RESOURCE_KIND, KafkaUser.RESOURCE_KIND);

String kind = customResource.getKind();
String name = customResource.getMetadata().getName();
String kind = customResource.getKind();
String name = customResource.getMetadata().getName();

if (printWholeCR.contains(kind)) {
LOGGER.info(customResource);
} else {
List<String> log = new ArrayList<>(asList("\n", kind, " status:\n", "\nConditions:\n"));
if (printWholeCR.contains(kind)) {
LOGGER.info(customResource);
} else {
List<String> log = new ArrayList<>(asList("\n", kind, " status:\n", "\nConditions:\n"));

for (Condition condition : customResource.getStatus().getConditions()) {
log.add("\tType: " + condition.getType() + "\n");
log.add("\tMessage: " + condition.getMessage() + "\n");
}
for (Condition condition : customResource.getStatus().getConditions()) {
log.add("\tType: " + condition.getType() + "\n");
log.add("\tMessage: " + condition.getMessage() + "\n");
}

log.add("\nPods with conditions and messages:\n\n");
log.add("\nPods with conditions and messages:\n\n");

for (Pod pod : kubeClient().listPodsByPrefixInName(name)) {
log.add(pod.getMetadata().getName() + ":");
for (PodCondition podCondition : pod.getStatus().getConditions()) {
if (podCondition.getMessage() != null) {
log.add("\n\tType: " + podCondition.getType() + "\n");
log.add("\tMessage: " + podCondition.getMessage() + "\n");
for (Pod pod : kubeClient().listPodsByPrefixInName(name)) {
log.add(pod.getMetadata().getName() + ":");
for (PodCondition podCondition : pod.getStatus().getConditions()) {
if (podCondition.getMessage() != null) {
log.add("\n\tType: " + podCondition.getType() + "\n");
log.add("\tMessage: " + podCondition.getMessage() + "\n");
}
}
log.add("\n\n");
}
log.add("\n\n");
LOGGER.info("{}", String.join("", log));
}
LOGGER.info("{}", String.join("", log));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
import java.time.Duration;

public class ResourceOperation {
public static long getTimeoutForResourceReadiness() {
return getTimeoutForResourceReadiness("default");
}

public static long getTimeoutForResourceReadiness(String kind) {
long timeout;

Expand All @@ -42,7 +46,7 @@ public static long getTimeoutForResourceReadiness(String kind) {
timeout = Duration.ofMinutes(4).toMillis();
break;
default:
timeout = Duration.ofMinutes(2).toMillis();
timeout = Duration.ofMinutes(3).toMillis();
}

return timeout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.util.function.Consumer;

import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;

public class KafkaBridgeResource {

public static final String PATH_TO_KAFKA_BRIDGE_CONFIG = "../examples/bridge/kafka-bridge.yaml";
Expand Down Expand Up @@ -92,7 +94,7 @@ private static KafkaBridgeBuilder defaultKafkaBridge(KafkaBridge kafkaBridge, St

private static DoneableKafkaBridge deployKafkaBridge(KafkaBridge kafkaBridge) {
return new DoneableKafkaBridge(kafkaBridge, kB -> {
TestUtils.waitFor("KafkaBridge creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("KafkaBridge creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
kafkaBridgeClient().inNamespace(ResourceManager.kubeClient().getNamespace()).createOrReplace(kB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import java.util.function.Consumer;

import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;

public class KafkaConnectResource {
public static final String PATH_TO_KAFKA_CONNECT_CONFIG = "../examples/connect/kafka-connect.yaml";
public static final String PATH_TO_KAFKA_CONNECT_METRICS_CONFIG = "../examples/metrics/kafka-connect-metrics.yaml";
Expand Down Expand Up @@ -84,7 +86,7 @@ private static DoneableKafkaConnect deployKafkaConnect(KafkaConnect kafkaConnect
KubernetesResource.allowNetworkPolicySettingsForResource(kafkaConnect, KafkaConnectResources.deploymentName(kafkaConnect.getMetadata().getName()));
}
return new DoneableKafkaConnect(kafkaConnect, kC -> {
TestUtils.waitFor("KafkaConnect creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("KafkaConnect creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
kafkaConnectClient().inNamespace(ResourceManager.kubeClient().getNamespace()).createOrReplace(kC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import java.util.function.Consumer;

import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;

public class KafkaConnectS2IResource {
public static final String PATH_TO_KAFKA_CONNECT_S2I_CONFIG = "../examples/connect/kafka-connect-s2i.yaml";

Expand Down Expand Up @@ -68,7 +70,7 @@ private static DoneableKafkaConnectS2I deployKafkaConnectS2I(KafkaConnectS2I kaf
KubernetesResource.allowNetworkPolicySettingsForResource(kafkaConnectS2I, KafkaConnectS2IResources.deploymentName(kafkaConnectS2I.getMetadata().getName()));
}
return new DoneableKafkaConnectS2I(kafkaConnectS2I, kC -> {
TestUtils.waitFor("KafkaConnect creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("KafkaConnect creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
kafkaConnectS2IClient().inNamespace(ResourceManager.kubeClient().getNamespace()).createOrReplace(kC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import java.util.function.Consumer;

import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;

public class KafkaConnectorResource {
public static final String PATH_TO_KAFKA_CONNECTOR_CONFIG = "../examples/connect/source-connector.yaml";

Expand Down Expand Up @@ -67,7 +69,7 @@ public static void deleteKafkaConnectorWithoutWait(String connectorName) {

private static DoneableKafkaConnector deployKafkaConnector(KafkaConnector kafkaConnector) {
return new DoneableKafkaConnector(kafkaConnector, kC -> {
TestUtils.waitFor("KafkaConnector creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("KafkaConnector creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
kafkaConnectorClient().inNamespace(ResourceManager.kubeClient().getNamespace()).createOrReplace(kC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import java.util.function.Consumer;

import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;

public class KafkaMirrorMaker2Resource {
public static final String PATH_TO_KAFKA_MIRROR_MAKER_2_CONFIG = "../examples/mirror-maker/kafka-mirror-maker-2.yaml";
public static final String PATH_TO_KAFKA_MIRROR_MAKER_2_METRICS_CONFIG = "../examples/metrics/kafka-mirror-maker-2-metrics.yaml";
Expand Down Expand Up @@ -100,7 +102,7 @@ private static KafkaMirrorMaker2Builder defaultKafkaMirrorMaker2(KafkaMirrorMake

private static DoneableKafkaMirrorMaker2 deployKafkaMirrorMaker2(KafkaMirrorMaker2 kafkaMirrorMaker2) {
return new DoneableKafkaMirrorMaker2(kafkaMirrorMaker2, kC -> {
TestUtils.waitFor("KafkaMirrorMaker2 creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("KafkaMirrorMaker2 creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
kafkaMirrorMaker2Client().inNamespace(ResourceManager.kubeClient().getNamespace()).createOrReplace(kC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

import java.util.function.Consumer;

import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;

public class KafkaMirrorMakerResource {
public static final String PATH_TO_KAFKA_MIRROR_MAKER_CONFIG = "../examples/mirror-maker/kafka-mirror-maker.yaml";

Expand Down Expand Up @@ -77,7 +79,7 @@ private static KafkaMirrorMakerBuilder defaultKafkaMirrorMaker(KafkaMirrorMaker

private static DoneableKafkaMirrorMaker deployKafkaMirrorMaker(KafkaMirrorMaker kafkaMirrorMaker) {
return new DoneableKafkaMirrorMaker(kafkaMirrorMaker, kB -> {
TestUtils.waitFor("KafkaMirrorMaker creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("KafkaMirrorMaker creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
kafkaMirrorMakerClient().inNamespace(ResourceManager.kubeClient().getNamespace()).createOrReplace(kB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import java.util.function.Consumer;

import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;

public class KafkaRebalanceResource {
public static final String PATH_TO_KAFKA_REBALANCE_CONFIG = "../examples/cruise-control/kafka-rebalance.yaml";

Expand All @@ -41,7 +43,7 @@ private static KafkaRebalance defaultKafkaRebalance(KafkaRebalance kafkaRebalanc

private static DoneableKafkaRebalance deployKafkaRebalance(KafkaRebalance kafkaRebalance) {
return new DoneableKafkaRebalance(kafkaRebalance, kB -> {
TestUtils.waitFor("KafkaRebalance creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("KafkaRebalance creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
kafkaRebalanceClient().inNamespace(ResourceManager.kubeClient().getNamespace()).createOrReplace(kB);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@
import io.strimzi.systemtest.utils.StUtils;
import io.strimzi.systemtest.utils.TestKafkaVersion;
import io.strimzi.test.TestUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.function.Consumer;

public class KafkaResource {
private static final Logger LOGGER = LogManager.getLogger(KafkaResource.class);
import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;

public class KafkaResource {
private static final String PATH_TO_KAFKA_METRICS_CONFIG = "../examples/metrics/kafka-metrics.yaml";
private static final String PATH_TO_KAFKA_CRUISE_CONTROL_CONFIG = "../examples/cruise-control/kafka-cruise-control.yaml";
private static final String PATH_TO_KAFKA_EPHEMERAL_CONFIG = "../examples/kafka/kafka-ephemeral.yaml";
Expand Down Expand Up @@ -166,7 +164,7 @@ private static KafkaBuilder defaultKafka(Kafka kafka, String name, int kafkaRepl

static DoneableKafka deployKafka(Kafka kafka) {
return new DoneableKafka(kafka, k -> {
TestUtils.waitFor("Kafka creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, Constants.TIMEOUT_FOR_CR_CREATION,
TestUtils.waitFor("Kafka creation", Constants.POLL_INTERVAL_FOR_RESOURCE_CREATION, CR_CREATION_TIMEOUT,
() -> {
try {
kafkaClient().inNamespace(ResourceManager.kubeClient().getNamespace()).createOrReplace(k);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.Map;
import java.util.stream.Collectors;

import static io.strimzi.systemtest.resources.ResourceManager.CR_CREATION_TIMEOUT;

public class OlmResource {
private static final Logger LOGGER = LogManager.getLogger(OlmResource.class);

Expand Down Expand Up @@ -58,7 +60,7 @@ public static void clusterOperator(String namespace, long operationTimeout, long

ResourceManager.cmdKubeClient().apply(subscriptionFile);
// Make sure that operator will be deleted
TestUtils.waitFor("Cluster Operator deployment creation", Constants.GLOBAL_POLL_INTERVAL, Constants.TIMEOUT_FOR_RESOURCE_CREATION,
TestUtils.waitFor("Cluster Operator deployment creation", Constants.GLOBAL_POLL_INTERVAL, CR_CREATION_TIMEOUT,
() -> ResourceManager.kubeClient().getDeploymentNameByPrefix(Environment.OLM_OPERATOR_NAME) != null);
String deploymentName = ResourceManager.kubeClient().getDeploymentNameByPrefix(Environment.OLM_OPERATOR_NAME);
ResourceManager.setCoDeploymentName(deploymentName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void waitForKafkaUserDeletion(String userName) {

public static void waitForKafkaUserIncreaseObserverGeneration(long observation, String userName) {
TestUtils.waitFor("increase observation generation from " + observation + " for user " + userName,
Constants.GLOBAL_POLL_INTERVAL, Constants.TIMEOUT_FOR_SECRET_CREATION,
Constants.GLOBAL_POLL_INTERVAL, Constants.GLOBAL_STATUS_TIMEOUT,
() -> observation < KafkaUserResource.kafkaUserClient()
.inNamespace(kubeClient().getNamespace()).withName(userName).get().getStatus().getObservedGeneration());
}
Expand Down
Loading

0 comments on commit 6ddb175

Please sign in to comment.