use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi-kafka-operator by strimzi.
the class CruiseControlTest method testTlsSidecarContainerSecurityContext.
@ParallelTest
public void testTlsSidecarContainerSecurityContext() {
SecurityContext securityContext = new SecurityContextBuilder().withPrivileged(false).withReadOnlyRootFilesystem(false).withAllowPrivilegeEscalation(false).withRunAsNonRoot(true).withNewCapabilities().addNewDrop("ALL").endCapabilities().build();
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withConfig(ccConfig).withNewTemplate().withNewTlsSidecarContainer().withSecurityContext(securityContext).endTlsSidecarContainer().endTemplate().build();
Kafka resource = createKafka(cruiseControlSpec);
CruiseControl cc = createCruiseControl(resource);
Deployment dep = cc.generateDeployment(true, null, null, null);
assertThat(dep.getSpec().getTemplate().getSpec().getContainers(), hasItem(allOf(hasProperty("name", equalTo(CruiseControl.TLS_SIDECAR_NAME)), hasProperty("securityContext", equalTo(securityContext)))));
}
use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi-kafka-operator 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-kafka-operator by strimzi.
the class CruiseControlTest method testJvmOptions.
@ParallelTest
public void testJvmOptions() {
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withNewJvmOptions().withXms("128m").withXmx("256m").withXx(Map.of("InitiatingHeapOccupancyPercent", "36")).withJavaSystemProperties(new SystemPropertyBuilder().withName("myProperty").withValue("myValue").build(), new SystemPropertyBuilder().withName("myProperty2").withValue("myValue2").build()).endJvmOptions().build();
Kafka resource = createKafka(cruiseControlSpec);
CruiseControl cc = CruiseControl.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS, kafkaStorage);
EnvVar systemProps = cc.getEnvVars().stream().filter(var -> AbstractModel.ENV_VAR_STRIMZI_JAVA_SYSTEM_PROPERTIES.equals(var.getName())).findFirst().orElse(null);
assertThat(systemProps, is(notNullValue()));
assertThat(systemProps.getValue(), containsString("-DmyProperty=myValue"));
assertThat(systemProps.getValue(), containsString("-DmyProperty2=myValue2"));
EnvVar heapOpts = cc.getEnvVars().stream().filter(var -> AbstractModel.ENV_VAR_KAFKA_HEAP_OPTS.equals(var.getName())).findFirst().orElse(null);
assertThat(heapOpts, is(notNullValue()));
assertThat(heapOpts.getValue(), containsString("-Xms128m"));
assertThat(heapOpts.getValue(), containsString("-Xmx256m"));
EnvVar perfOptions = cc.getEnvVars().stream().filter(var -> AbstractModel.ENV_VAR_KAFKA_JVM_PERFORMANCE_OPTS.equals(var.getName())).findFirst().orElse(null);
assertThat(perfOptions, is(notNullValue()));
assertThat(perfOptions.getValue(), containsString("-XX:InitiatingHeapOccupancyPercent=36"));
}
Aggregations