use of io.strimzi.api.kafka.model.SystemPropertyBuilder in project strimzi by strimzi.
the class KafkaST method testJvmAndResources.
@ParallelNamespaceTest
void testJvmAndResources(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));
final LabelSelector zkSelector = KafkaResource.getLabelSelector(clusterName, KafkaResources.zookeeperStatefulSetName(clusterName));
ArrayList<SystemProperty> javaSystemProps = new ArrayList<>();
javaSystemProps.add(new SystemPropertyBuilder().withName("javax.net.debug").withValue("verbose").build());
Map<String, String> jvmOptionsXX = new HashMap<>();
jvmOptionsXX.put("UseG1GC", "true");
resourceManager.createResource(extensionContext, KafkaTemplates.kafkaEphemeral(clusterName, 1, 1).editSpec().editKafka().withResources(new ResourceRequirementsBuilder().addToLimits("memory", new Quantity("1.5Gi")).addToLimits("cpu", new Quantity("1")).addToRequests("memory", new Quantity("1Gi")).addToRequests("cpu", new Quantity("50m")).build()).withNewJvmOptions().withXmx("1g").withXms("512m").withXx(jvmOptionsXX).endJvmOptions().endKafka().editZookeeper().withResources(new ResourceRequirementsBuilder().addToLimits("memory", new Quantity("1G")).addToLimits("cpu", new Quantity("0.5")).addToRequests("memory", new Quantity("0.5G")).addToRequests("cpu", new Quantity("25m")).build()).withNewJvmOptions().withXmx("1G").withXms("512M").withXx(jvmOptionsXX).endJvmOptions().endZookeeper().withNewEntityOperator().withNewTopicOperator().withResources(new ResourceRequirementsBuilder().addToLimits("memory", new Quantity("1024Mi")).addToLimits("cpu", new Quantity("500m")).addToRequests("memory", new Quantity("384Mi")).addToRequests("cpu", new Quantity("0.025")).build()).withNewJvmOptions().withXmx("2G").withXms("1024M").withJavaSystemProperties(javaSystemProps).endJvmOptions().endTopicOperator().withNewUserOperator().withResources(new ResourceRequirementsBuilder().addToLimits("memory", new Quantity("512M")).addToLimits("cpu", new Quantity("300m")).addToRequests("memory", new Quantity("256M")).addToRequests("cpu", new Quantity("30m")).build()).withNewJvmOptions().withXmx("1G").withXms("512M").withJavaSystemProperties(javaSystemProps).endJvmOptions().endUserOperator().endEntityOperator().endSpec().build());
// Make snapshots for Kafka cluster to meke sure that there is no rolling update after CO reconciliation
final String zkStsName = KafkaResources.zookeeperStatefulSetName(clusterName);
final String kafkaStsName = kafkaStatefulSetName(clusterName);
final String eoDepName = KafkaResources.entityOperatorDeploymentName(clusterName);
final Map<String, String> zkPods = PodUtils.podSnapshot(namespaceName, zkSelector);
final Map<String, String> kafkaPods = PodUtils.podSnapshot(namespaceName, kafkaSelector);
final Map<String, String> eoPods = DeploymentUtils.depSnapshot(namespaceName, eoDepName);
assertResources(namespaceName, KafkaResources.kafkaPodName(clusterName, 0), "kafka", "1536Mi", "1", "1Gi", "50m");
assertExpectedJavaOpts(namespaceName, KafkaResources.kafkaPodName(clusterName, 0), "kafka", "-Xmx1g", "-Xms512m", "-XX:+UseG1GC");
assertResources(namespaceName, KafkaResources.zookeeperPodName(clusterName, 0), "zookeeper", "1G", "500m", "500M", "25m");
assertExpectedJavaOpts(namespaceName, KafkaResources.zookeeperPodName(clusterName, 0), "zookeeper", "-Xmx1G", "-Xms512M", "-XX:+UseG1GC");
Optional<Pod> pod = kubeClient(namespaceName).listPods(namespaceName).stream().filter(p -> p.getMetadata().getName().startsWith(KafkaResources.entityOperatorDeploymentName(clusterName))).findFirst();
assertThat("EO pod does not exist", pod.isPresent(), is(true));
assertResources(namespaceName, pod.get().getMetadata().getName(), "topic-operator", "1Gi", "500m", "384Mi", "25m");
assertResources(namespaceName, pod.get().getMetadata().getName(), "user-operator", "512M", "300m", "256M", "30m");
assertExpectedJavaOpts(namespaceName, pod.get().getMetadata().getName(), "topic-operator", "-Xmx2G", "-Xms1024M", null);
assertExpectedJavaOpts(namespaceName, pod.get().getMetadata().getName(), "user-operator", "-Xmx1G", "-Xms512M", null);
String eoPod = eoPods.keySet().toArray()[0].toString();
kubeClient(namespaceName).getPod(namespaceName, eoPod).getSpec().getContainers().forEach(container -> {
if (!container.getName().equals("tls-sidecar")) {
LOGGER.info("Check if -D java options are present in {}", container.getName());
String javaSystemProp = container.getEnv().stream().filter(envVar -> envVar.getName().equals("STRIMZI_JAVA_SYSTEM_PROPERTIES")).findFirst().orElseThrow().getValue();
String javaOpts = container.getEnv().stream().filter(envVar -> envVar.getName().equals("STRIMZI_JAVA_OPTS")).findFirst().orElseThrow().getValue();
assertThat(javaSystemProp, is("-Djavax.net.debug=verbose"));
if (container.getName().equals("topic-operator")) {
assertThat(javaOpts, is("-Xms1024M -Xmx2G"));
}
if (container.getName().equals("user-operator")) {
assertThat(javaOpts, is("-Xms512M -Xmx1G"));
}
}
});
LOGGER.info("Checking no rolling update for Kafka cluster");
RollingUpdateUtils.waitForNoRollingUpdate(namespaceName, zkSelector, zkPods);
RollingUpdateUtils.waitForNoRollingUpdate(namespaceName, kafkaSelector, kafkaPods);
DeploymentUtils.waitForNoRollingUpdate(namespaceName, eoDepName, eoPods);
}
use of io.strimzi.api.kafka.model.SystemPropertyBuilder in project strimzi by strimzi.
the class KafkaBridgeClusterTest method testJvmOptions.
@ParallelTest
public void testJvmOptions() {
KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withJvmOptions(new JvmOptionsBuilder().withXms("128m").withXmx("256m").withXx(Collections.singletonMap("InitiatingHeapOccupancyPercent", "36")).withJavaSystemProperties(new SystemPropertyBuilder().withName("myProperty1").withValue("myValue1").build(), new SystemPropertyBuilder().withName("myProperty2").withValue("myValue2").build()).build()).endSpec().build();
KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
EnvVar systemProps = kb.getEnvVars().stream().filter(envVar -> AbstractModel.ENV_VAR_STRIMZI_JAVA_SYSTEM_PROPERTIES.equals(envVar.getName())).findFirst().orElse(null);
assertThat(systemProps, is(notNullValue()));
assertThat(systemProps.getValue(), containsString("-DmyProperty1=myValue1"));
assertThat(systemProps.getValue(), containsString("-DmyProperty2=myValue2"));
EnvVar javaOpts = kb.getEnvVars().stream().filter(envVar -> AbstractModel.ENV_VAR_STRIMZI_JAVA_OPTS.equals(envVar.getName())).findFirst().orElse(null);
assertThat(javaOpts, is(notNullValue()));
assertThat(javaOpts.getValue(), containsString("-Xms128m"));
assertThat(javaOpts.getValue(), containsString("-Xmx256m"));
assertThat(javaOpts.getValue(), containsString("-XX:InitiatingHeapOccupancyPercent=36"));
}
use of io.strimzi.api.kafka.model.SystemPropertyBuilder in project strimzi 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"));
}
use of io.strimzi.api.kafka.model.SystemPropertyBuilder 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"));
}
use of io.strimzi.api.kafka.model.SystemPropertyBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaBridgeClusterTest method testJvmOptions.
@ParallelTest
public void testJvmOptions() {
KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withJvmOptions(new JvmOptionsBuilder().withXms("128m").withXmx("256m").withXx(Collections.singletonMap("InitiatingHeapOccupancyPercent", "36")).withJavaSystemProperties(new SystemPropertyBuilder().withName("myProperty1").withValue("myValue1").build(), new SystemPropertyBuilder().withName("myProperty2").withValue("myValue2").build()).build()).endSpec().build();
KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
EnvVar systemProps = kb.getEnvVars().stream().filter(envVar -> AbstractModel.ENV_VAR_STRIMZI_JAVA_SYSTEM_PROPERTIES.equals(envVar.getName())).findFirst().orElse(null);
assertThat(systemProps, is(notNullValue()));
assertThat(systemProps.getValue(), containsString("-DmyProperty1=myValue1"));
assertThat(systemProps.getValue(), containsString("-DmyProperty2=myValue2"));
EnvVar javaOpts = kb.getEnvVars().stream().filter(envVar -> AbstractModel.ENV_VAR_STRIMZI_JAVA_OPTS.equals(envVar.getName())).findFirst().orElse(null);
assertThat(javaOpts, is(notNullValue()));
assertThat(javaOpts.getValue(), containsString("-Xms128m"));
assertThat(javaOpts.getValue(), containsString("-Xmx256m"));
assertThat(javaOpts.getValue(), containsString("-XX:InitiatingHeapOccupancyPercent=36"));
}
Aggregations