use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.
the class CruiseControlConfigurationST method testDeployAndUnDeployCruiseControl.
@ParallelNamespaceTest
void testDeployAndUnDeployCruiseControl(ExtensionContext extensionContext) throws IOException {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaWithCruiseControl(clusterName, 3, 3).build());
Map<String, String> kafkaPods = PodUtils.podSnapshot(namespaceName, kafkaSelector);
KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
LOGGER.info("Removing Cruise Control to the classic Kafka.");
kafka.getSpec().setCruiseControl(null);
}, namespaceName);
kafkaPods = RollingUpdateUtils.waitTillComponentHasRolled(namespaceName, kafkaSelector, 3, kafkaPods);
LOGGER.info("Verifying that in {} is not present in the Kafka cluster", Constants.CRUISE_CONTROL_NAME);
assertThat(KafkaResource.kafkaClient().inNamespace(namespaceName).withName(clusterName).get().getSpec().getCruiseControl(), nullValue());
LOGGER.info("Verifying that {} pod is not present", clusterName + "-cruise-control-");
PodUtils.waitUntilPodStabilityReplicasCount(namespaceName, clusterName + "-cruise-control-", 0);
LOGGER.info("Verifying that in Kafka config map there is no configuration to cruise control metric reporter");
assertThrows(WaitException.class, () -> CruiseControlUtils.verifyCruiseControlMetricReporterConfigurationInKafkaConfigMapIsPresent(CruiseControlUtils.getKafkaCruiseControlMetricsReporterConfiguration(namespaceName, clusterName)));
LOGGER.info("Cruise Control topics will not be deleted and will stay in the Kafka cluster");
CruiseControlUtils.verifyThatCruiseControlTopicsArePresent(namespaceName);
KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
LOGGER.info("Adding Cruise Control to the classic Kafka.");
kafka.getSpec().setCruiseControl(new CruiseControlSpec());
}, namespaceName);
RollingUpdateUtils.waitTillComponentHasRolled(namespaceName, kafkaSelector, 3, kafkaPods);
LOGGER.info("Verifying that in Kafka config map there is configuration to cruise control metric reporter");
CruiseControlUtils.verifyCruiseControlMetricReporterConfigurationInKafkaConfigMapIsPresent(CruiseControlUtils.getKafkaCruiseControlMetricsReporterConfiguration(namespaceName, clusterName));
LOGGER.info("Verifying that {} topics are created after CC is instantiated.", Constants.CRUISE_CONTROL_NAME);
CruiseControlUtils.verifyThatCruiseControlTopicsArePresent(namespaceName);
}
use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.
the class CruiseControlConfigurationST method testConfigurationDiskChangeDoNotTriggersRollingUpdateOfKafkaPods.
@ParallelNamespaceTest
void testConfigurationDiskChangeDoNotTriggersRollingUpdateOfKafkaPods(ExtensionContext extensionContext) {
final String namespaceName = StUtils.getNamespaceBasedOnRbac(namespace, extensionContext);
final String clusterName = mapWithClusterNames.get(extensionContext.getDisplayName());
final LabelSelector kafkaSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.kafkaStatefulSetName(clusterName));
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaWithCruiseControl(clusterName, 3, 3).build());
Map<String, String> kafkaSnapShot = PodUtils.podSnapshot(namespaceName, kafkaSelector);
Map<String, String> cruiseControlSnapShot = DeploymentUtils.depSnapshot(namespaceName, CruiseControlResources.deploymentName(clusterName));
KafkaResource.replaceKafkaResourceInSpecificNamespace(clusterName, kafka -> {
LOGGER.info("Changing the broker capacity of the cruise control");
CruiseControlSpec cruiseControl = new CruiseControlSpecBuilder().withNewBrokerCapacity().withOutboundNetwork("20KB/s").endBrokerCapacity().build();
kafka.getSpec().setCruiseControl(cruiseControl);
}, namespaceName);
LOGGER.info("Verifying that CC pod is rolling, because of change size of disk");
DeploymentUtils.waitTillDepHasRolled(namespaceName, CruiseControlResources.deploymentName(clusterName), 1, cruiseControlSnapShot);
LOGGER.info("Verifying that Kafka pods did not roll");
RollingUpdateUtils.waitForNoRollingUpdate(namespaceName, kafkaSelector, kafkaSnapShot);
LOGGER.info("Verifying new configuration in the Kafka CR");
assertThat(KafkaResource.kafkaClient().inNamespace(namespaceName).withName(clusterName).get().getSpec().getCruiseControl().getBrokerCapacity().getOutboundNetwork(), is("20KB/s"));
CruiseControlUtils.verifyThatCruiseControlTopicsArePresent(namespaceName);
}
use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.
the class CruiseControlTest method testProbeConfiguration.
@ParallelTest
public void testProbeConfiguration() {
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withNewLivenessProbe().withInitialDelaySeconds(healthDelay).withTimeoutSeconds(healthTimeout).endLivenessProbe().withNewReadinessProbe().withInitialDelaySeconds(healthDelay).withTimeoutSeconds(healthTimeout).endReadinessProbe().build();
Kafka resource = createKafka(cruiseControlSpec);
CruiseControl cc = createCruiseControl(resource);
Deployment dep = cc.generateDeployment(true, null, null, null);
List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
// checks on the main Cruise Control container
Container ccContainer = containers.stream().filter(container -> ccImage.equals(container.getImage())).findFirst().orElseThrow();
assertThat(ccContainer.getImage(), is(cc.image));
assertThat(ccContainer.getLivenessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay)));
assertThat(ccContainer.getLivenessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout)));
assertThat(ccContainer.getReadinessProbe().getInitialDelaySeconds(), is(Integer.valueOf(healthDelay)));
assertThat(ccContainer.getReadinessProbe().getTimeoutSeconds(), is(Integer.valueOf(healthTimeout)));
}
use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.
the class CruiseControlTest method testApiSecurity.
public void testApiSecurity(Boolean apiAuthEnabled, Boolean apiSslEnabled) {
String e1Key = CruiseControl.ENV_VAR_API_AUTH_ENABLED;
String e1Value = apiAuthEnabled.toString();
EnvVar e1 = new EnvVar(e1Key, e1Value, null);
String e2Key = CruiseControl.ENV_VAR_API_SSL_ENABLED;
String e2Value = apiSslEnabled.toString();
EnvVar e2 = new EnvVar(e2Key, e2Value, null);
Map<String, Object> config = ccConfig;
config.put(CruiseControlConfigurationParameters.CRUISE_CONTROL_WEBSERVER_SECURITY_ENABLE.getValue(), apiAuthEnabled);
config.put(CruiseControlConfigurationParameters.CRUISE_CONTROL_WEBSERVER_SSL_ENABLE.getValue(), apiSslEnabled);
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withConfig(config).build();
Kafka resource = createKafka(cruiseControlSpec);
CruiseControl cc = createCruiseControl(resource);
Deployment dep = cc.generateDeployment(true, null, null, null);
List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
// checks on the main Cruise Control container
Container ccContainer = containers.stream().filter(container -> ccImage.equals(container.getImage())).findFirst().get();
List<EnvVar> envVarList = ccContainer.getEnv();
assertThat(envVarList.contains(e1), is(true));
assertThat(envVarList.contains(e2), is(true));
}
use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.
the class CruiseControlTest method testResources.
@ParallelTest
public void testResources() {
Map<String, Quantity> requests = new HashMap<>(2);
requests.put("cpu", new Quantity("250m"));
requests.put("memory", new Quantity("512Mi"));
Map<String, Quantity> limits = new HashMap<>(2);
limits.put("cpu", new Quantity("500m"));
limits.put("memory", new Quantity("1024Mi"));
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withResources(new ResourceRequirementsBuilder().withLimits(limits).withRequests(requests).build()).build();
Kafka resource = createKafka(cruiseControlSpec);
CruiseControl cc = createCruiseControl(resource);
Deployment dep = cc.generateDeployment(true, null, null, null);
List<Container> containers = dep.getSpec().getTemplate().getSpec().getContainers();
Container ccContainer = containers.stream().filter(container -> ccImage.equals(container.getImage())).findFirst().orElseThrow();
assertThat(ccContainer.getResources().getLimits(), is(limits));
assertThat(ccContainer.getResources().getRequests(), is(requests));
}
Aggregations