Search in sources :

Example 21 with CruiseControlSpec

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)));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) Kafka(io.strimzi.api.kafka.model.Kafka) ContainerEnvVar(io.strimzi.api.kafka.model.ContainerEnvVar) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) ContainerEnvVar(io.strimzi.api.kafka.model.ContainerEnvVar) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 22 with CruiseControlSpec

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()));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) BrokerCapacity(io.strimzi.api.kafka.model.balancing.BrokerCapacity) Capacity(io.strimzi.operator.cluster.model.cruisecontrol.Capacity) BrokerCapacity(io.strimzi.api.kafka.model.balancing.BrokerCapacity) SingleVolumeStorage(io.strimzi.api.kafka.model.storage.SingleVolumeStorage) PersistentClaimStorage(io.strimzi.api.kafka.model.storage.PersistentClaimStorage) Kafka(io.strimzi.api.kafka.model.Kafka) ArrayList(java.util.ArrayList) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) KafkaBuilder(io.strimzi.api.kafka.model.KafkaBuilder) JbodStorage(io.strimzi.api.kafka.model.storage.JbodStorage) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 23 with CruiseControlSpec

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)));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) Kafka(io.strimzi.api.kafka.model.Kafka) ContainerEnvVar(io.strimzi.api.kafka.model.ContainerEnvVar) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) ContainerEnvVar(io.strimzi.api.kafka.model.ContainerEnvVar) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) IntOrString(io.fabric8.kubernetes.api.model.IntOrString) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 24 with CruiseControlSpec

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)))));
}
Also used : SecurityContextBuilder(io.fabric8.kubernetes.api.model.SecurityContextBuilder) PodSecurityContextBuilder(io.fabric8.kubernetes.api.model.PodSecurityContextBuilder) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) SecurityContext(io.fabric8.kubernetes.api.model.SecurityContext) Kafka(io.strimzi.api.kafka.model.Kafka) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Example 25 with CruiseControlSpec

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)));
}
Also used : PodSecurityContextBuilder(io.fabric8.kubernetes.api.model.PodSecurityContextBuilder) CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) Kafka(io.strimzi.api.kafka.model.Kafka) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

CruiseControlSpec (io.strimzi.api.kafka.model.CruiseControlSpec)38 CruiseControlSpecBuilder (io.strimzi.api.kafka.model.CruiseControlSpecBuilder)34 Kafka (io.strimzi.api.kafka.model.Kafka)30 ParallelTest (io.strimzi.test.annotations.ParallelTest)30 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)16 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)16 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)14 Container (io.fabric8.kubernetes.api.model.Container)8 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)8 ContainerEnvVar (io.strimzi.api.kafka.model.ContainerEnvVar)8 PodSecurityContextBuilder (io.fabric8.kubernetes.api.model.PodSecurityContextBuilder)6 LabelSelector (io.fabric8.kubernetes.api.model.LabelSelector)4 SecurityContext (io.fabric8.kubernetes.api.model.SecurityContext)4 SecurityContextBuilder (io.fabric8.kubernetes.api.model.SecurityContextBuilder)4 Capacity (io.strimzi.operator.cluster.model.cruisecontrol.Capacity)4 ParallelNamespaceTest (io.strimzi.systemtest.annotations.ParallelNamespaceTest)4 Affinity (io.fabric8.kubernetes.api.model.Affinity)2 AffinityBuilder (io.fabric8.kubernetes.api.model.AffinityBuilder)2 ConfigMapKeySelectorBuilder (io.fabric8.kubernetes.api.model.ConfigMapKeySelectorBuilder)2 HostAlias (io.fabric8.kubernetes.api.model.HostAlias)2