Search in sources :

Example 36 with CruiseControlSpecBuilder

use of io.strimzi.api.kafka.model.CruiseControlSpecBuilder 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"));
}
Also used : CruiseControlSpec(io.strimzi.api.kafka.model.CruiseControlSpec) SystemPropertyBuilder(io.strimzi.api.kafka.model.SystemPropertyBuilder) Kafka(io.strimzi.api.kafka.model.Kafka) CruiseControlSpecBuilder(io.strimzi.api.kafka.model.CruiseControlSpecBuilder) ContainerEnvVar(io.strimzi.api.kafka.model.ContainerEnvVar) EnvVar(io.fabric8.kubernetes.api.model.EnvVar) ParallelTest(io.strimzi.test.annotations.ParallelTest)

Aggregations

CruiseControlSpec (io.strimzi.api.kafka.model.CruiseControlSpec)36 CruiseControlSpecBuilder (io.strimzi.api.kafka.model.CruiseControlSpecBuilder)36 Kafka (io.strimzi.api.kafka.model.Kafka)30 ParallelTest (io.strimzi.test.annotations.ParallelTest)30 Deployment (io.fabric8.kubernetes.api.model.apps.Deployment)16 IntOrString (io.fabric8.kubernetes.api.model.IntOrString)14 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)14 Container (io.fabric8.kubernetes.api.model.Container)10 EnvVar (io.fabric8.kubernetes.api.model.EnvVar)10 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 ParallelNamespaceTest (io.strimzi.systemtest.annotations.ParallelNamespaceTest)3 HashMap (java.util.HashMap)3 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