use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.
the class CruiseControlTest method testContainerTemplateEnvVarsWithKeyConflict.
@ParallelTest
public void testContainerTemplateEnvVarsWithKeyConflict() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = "TEST_ENV_1";
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
ContainerEnvVar envVar2 = new ContainerEnvVar();
String testEnvTwoKey = "TEST_ENV_2";
String testEnvTwoValue = "my-special-value";
envVar2.setName(testEnvTwoKey);
envVar2.setValue(testEnvTwoValue);
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withNewTemplate().withNewCruiseControlContainer().withEnv(envVar1, envVar2).endCruiseControlContainer().endTemplate().build();
Kafka resource = createKafka(cruiseControlSpec);
CruiseControl cc = createCruiseControl(resource);
List<EnvVar> envVarList = cc.getEnvVars();
assertThat(envVarList, hasItems(new EnvVar(testEnvOneKey, testEnvOneValue, null)));
assertThat(envVarList, hasItems(new EnvVar(testEnvTwoKey, testEnvTwoValue, null)));
}
use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.
the class CruiseControlTest method testBrokerCapacities.
@ParallelTest
public void testBrokerCapacities() {
// Test user defined capacities
BrokerCapacity userDefinedBrokerCapacity = new BrokerCapacity();
userDefinedBrokerCapacity.setInboundNetwork("50000KB/s");
userDefinedBrokerCapacity.setOutboundNetwork("50000KB/s");
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withBrokerCapacity(userDefinedBrokerCapacity).build();
Kafka resource = createKafka(cruiseControlSpec);
Capacity capacity = new Capacity(resource.getSpec(), kafkaStorage);
assertThat(getCapacityConfigurationFromEnvVar(resource, ENV_VAR_CRUISE_CONTROL_CAPACITY_CONFIGURATION), is(capacity.generateCapacityConfig()));
// Test generated disk capacity
JbodStorage jbodStorage = new JbodStorage();
List<SingleVolumeStorage> volumes = new ArrayList<>();
PersistentClaimStorage p1 = new PersistentClaimStorage();
p1.setId(0);
p1.setSize("50Gi");
volumes.add(p1);
PersistentClaimStorage p2 = new PersistentClaimStorage();
p2.setId(1);
volumes.add(p2);
jbodStorage.setVolumes(volumes);
resource = new KafkaBuilder(ResourceUtils.createKafka(namespace, cluster, replicas, image, healthDelay, healthTimeout)).editSpec().editKafka().withVersion(version).withStorage(jbodStorage).endKafka().withCruiseControl(cruiseControlSpec).endSpec().build();
capacity = new Capacity(resource.getSpec(), jbodStorage);
assertThat(getCapacityConfigurationFromEnvVar(resource, ENV_VAR_CRUISE_CONTROL_CAPACITY_CONFIGURATION), is(capacity.generateCapacityConfig()));
}
use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi by strimzi.
the class CruiseControlTest method testContainerTemplateEnvVars.
@ParallelTest
public void testContainerTemplateEnvVars() {
ContainerEnvVar envVar1 = new ContainerEnvVar();
String testEnvOneKey = "TEST_ENV_1";
String testEnvOneValue = "test.env.one";
envVar1.setName(testEnvOneKey);
envVar1.setValue(testEnvOneValue);
ContainerEnvVar envVar2 = new ContainerEnvVar();
String testEnvTwoKey = "TEST_ENV_2";
String testEnvTwoValue = "test.env.two";
envVar2.setName(testEnvTwoKey);
envVar2.setValue(testEnvTwoValue);
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withNewTemplate().withNewCruiseControlContainer().withEnv(envVar1, envVar2).endCruiseControlContainer().endTemplate().build();
Kafka resource = createKafka(cruiseControlSpec);
CruiseControl cc = createCruiseControl(resource);
List<EnvVar> envVarList = cc.getEnvVars();
assertThat(envVarList, hasItems(new EnvVar(testEnvOneKey, testEnvOneValue, null)));
assertThat(envVarList, hasItems(new EnvVar(testEnvTwoKey, testEnvTwoValue, null)));
}
use of io.strimzi.api.kafka.model.CruiseControlSpec in project strimzi 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 by strimzi.
the class CruiseControlTest method testSecurityContext.
@ParallelTest
public void testSecurityContext() {
CruiseControlSpec cruiseControlSpec = new CruiseControlSpecBuilder().withImage(ccImage).withConfig(ccConfig).withNewTemplate().withNewPod().withSecurityContext(new PodSecurityContextBuilder().withFsGroup(123L).withRunAsGroup(456L).withRunAsUser(789L).build()).endPod().endTemplate().build();
Kafka resource = createKafka(cruiseControlSpec);
CruiseControl cc = createCruiseControl(resource);
Deployment dep = cc.generateDeployment(true, null, null, null);
assertThat(dep.getSpec().getTemplate().getSpec().getSecurityContext(), is(notNullValue()));
assertThat(dep.getSpec().getTemplate().getSpec().getSecurityContext().getFsGroup(), is(Long.valueOf(123)));
assertThat(dep.getSpec().getTemplate().getSpec().getSecurityContext().getRunAsGroup(), is(Long.valueOf(456)));
assertThat(dep.getSpec().getTemplate().getSpec().getSecurityContext().getRunAsUser(), is(Long.valueOf(789)));
}
Aggregations