use of io.strimzi.api.kafka.model.SystemProperty 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.SystemProperty in project strimzi-kafka-operator 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);
}
Aggregations