Skip to content

Commit a84f28e

Browse files
committed
Minor ST improvements
Signed-off-by: Federico Valeri <[email protected]>
1 parent 1191d58 commit a84f28e

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

development-docs/systemtests/io.strimzi.systemtest.metrics.StrimziMetricsReporterST.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
| Step | Action | Result |
88
| - | - | - |
9-
| 1. | Create namespaces {@namespaceFirst} and {@namespaceSecond}. | Namespaces {@namespaceFirst} and {@namespaceSecond} are created. |
9+
| 1. | Create namespace {@namespace}. | Namespace {@namespace} is created. |
1010
| 2. | Deploy Cluster Operator. | Cluster Operator is deployed. |
11-
| 3. | Deploy Kafka {@kafkaClusterName} with metrics. | Kafka @{kafkaClusterName} is deployed. |
12-
| 4. | Deploy scraper Pod in namespace {@namespace} for collecting metrics from Strimzi pods. | Scraper Pods are deployed. |
11+
| 3. | Deploy Kafka {@clusterName} with metrics. | Kafka @{clusterName} is deployed. |
12+
| 4. | Deploy scraper Pod in namespace {@namespace} for collecting metrics from Strimzi pods. | Scraper Pods is deployed. |
1313
| 5. | Create KafkaTopic resource. | KafkaTopic resource is Ready. |
1414
| 6. | Create collector for Kafka. | Metrics collected in collectors structs. |
1515

systemtest/src/main/java/io/strimzi/systemtest/templates/crd/KafkaTemplates.java

-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ public static KafkaBuilder kafkaWithMetrics(String namespaceName, String kafkaCl
5757
public static KafkaBuilder kafkaWithStrimziMetricsReporter(String namespaceName, String kafkaClusterName, int kafkaReplicas) {
5858
KafkaBuilder kafkaBuilder = kafka(namespaceName, kafkaClusterName, kafkaReplicas)
5959
.editSpec()
60-
.withNewKafkaExporter()
61-
.endKafkaExporter()
6260
.editKafka()
6361
.withNewStrimziMetricsReporterConfig()
6462
.withNewValues()

systemtest/src/test/java/io/strimzi/systemtest/metrics/StrimziMetricsReporterST.java

+15-14
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@
4747
@SuiteDoc(
4848
description = @Desc("This test suite is designed for testing metrics exposed by the Strimzi Metrics Reporter."),
4949
beforeTestSteps = {
50-
@Step(value = "Create namespaces {@namespaceFirst} and {@namespaceSecond}.", expected = "Namespaces {@namespaceFirst} and {@namespaceSecond} are created."),
50+
@Step(value = "Create namespace {@namespace}.", expected = "Namespace {@namespace} is created."),
5151
@Step(value = "Deploy Cluster Operator.", expected = "Cluster Operator is deployed."),
52-
@Step(value = "Deploy Kafka {@kafkaClusterName} with metrics.", expected = "Kafka @{kafkaClusterName} is deployed."),
53-
@Step(value = "Deploy scraper Pod in namespace {@namespace} for collecting metrics from Strimzi pods.", expected = "Scraper Pods are deployed."),
52+
@Step(value = "Deploy Kafka {@clusterName} with metrics.", expected = "Kafka @{clusterName} is deployed."),
53+
@Step(value = "Deploy scraper Pod in namespace {@namespace} for collecting metrics from Strimzi pods.", expected = "Scraper Pods is deployed."),
5454
@Step(value = "Create KafkaTopic resource.", expected = "KafkaTopic resource is Ready."),
5555
@Step(value = "Create collector for Kafka.", expected = "Metrics collected in collectors structs.")
5656
},
@@ -64,6 +64,9 @@
6464
public class StrimziMetricsReporterST extends AbstractST {
6565
private static final Logger LOGGER = LogManager.getLogger(StrimziMetricsReporterST.class);
6666

67+
private final String namespace = Environment.TEST_SUITE_NAMESPACE;
68+
private final String clusterName = "my-cluster";
69+
6770
private BaseMetricsCollector kafkaCollector;
6871

6972
@ParallelTest
@@ -93,28 +96,26 @@ void setupEnvironment() {
9396
.createInstallation()
9497
.runInstallation();
9598

96-
cluster.setNamespace(Environment.TEST_SUITE_NAMESPACE);
99+
cluster.setNamespace(namespace);
97100

98-
String clusterName = "my-cluster";
99-
String topicName = KafkaTopicUtils.generateRandomNameOfTopic();
100-
String scraperName = Environment.TEST_SUITE_NAMESPACE + "-" + TestConstants.SCRAPER_NAME;
101+
String scraperName = namespace + "-" + TestConstants.SCRAPER_NAME;
101102

102103
// create resources without wait to deploy them simultaneously
103104
resourceManager.createResourceWithWait(
104-
KafkaNodePoolTemplates.brokerPool(Environment.TEST_SUITE_NAMESPACE, KafkaNodePoolResource.getBrokerPoolName(clusterName), clusterName, 3).build(),
105-
KafkaNodePoolTemplates.controllerPool(Environment.TEST_SUITE_NAMESPACE, KafkaNodePoolResource.getControllerPoolName(clusterName), clusterName, 3).build()
105+
KafkaNodePoolTemplates.brokerPool(namespace, KafkaNodePoolResource.getBrokerPoolName(clusterName), clusterName, 3).build(),
106+
KafkaNodePoolTemplates.controllerPool(namespace, KafkaNodePoolResource.getControllerPoolName(clusterName), clusterName, 3).build()
106107
);
107108
resourceManager.createResourceWithoutWait(
108-
KafkaTemplates.kafkaWithStrimziMetricsReporter(Environment.TEST_SUITE_NAMESPACE, clusterName, 3).build(),
109-
ScraperTemplates.scraperPod(Environment.TEST_SUITE_NAMESPACE, scraperName).build()
109+
KafkaTemplates.kafkaWithStrimziMetricsReporter(namespace, clusterName, 3).build(),
110+
ScraperTemplates.scraperPod(namespace, scraperName).build()
110111
);
111112

112113
// sync resources
113114
resourceManager.synchronizeResources();
114115

115-
resourceManager.createResourceWithWait(KafkaTopicTemplates.topic(Environment.TEST_SUITE_NAMESPACE, topicName, clusterName, 5, 2).build());
116+
resourceManager.createResourceWithWait(KafkaTopicTemplates.topic(namespace, KafkaTopicUtils.generateRandomNameOfTopic(), clusterName, 5, 2).build());
116117

117-
String scraperPodName = ResourceManager.kubeClient().listPodsByPrefixInName(Environment.TEST_SUITE_NAMESPACE, scraperName).get(0).getMetadata().getName();
118+
String scraperPodName = ResourceManager.kubeClient().listPodsByPrefixInName(namespace, scraperName).get(0).getMetadata().getName();
118119

119120
// wait some time for metrics to be stable, at least reconciliation interval + 10s
120121
LOGGER.info("Sleeping for {} to give operators and operands some time to stable the metrics values before collecting",
@@ -123,7 +124,7 @@ void setupEnvironment() {
123124

124125
kafkaCollector = new BaseMetricsCollector.Builder()
125126
.withScraperPodName(scraperPodName)
126-
.withNamespaceName(Environment.TEST_SUITE_NAMESPACE)
127+
.withNamespaceName(namespace)
127128
.withComponent(KafkaMetricsComponent.create(clusterName))
128129
.build();
129130

0 commit comments

Comments
 (0)