use of io.strimzi.api.kafka.model.KafkaBridgeBuilder in project strimzi by strimzi.
the class KafkaBridgeTemplates method kafkaBridgeWithCors.
public static KafkaBridgeBuilder kafkaBridgeWithCors(String name, String clusterName, String bootstrap, int kafkaBridgeReplicas, String allowedCorsOrigin, String allowedCorsMethods) {
KafkaBridge kafkaBridge = getKafkaBridgeFromYaml(Constants.PATH_TO_KAFKA_BRIDGE_CONFIG);
KafkaBridgeBuilder kafkaBridgeBuilder = defaultKafkaBridge(kafkaBridge, name, clusterName, bootstrap, kafkaBridgeReplicas);
kafkaBridgeBuilder.editSpec().editHttp().withNewCors().withAllowedOrigins(allowedCorsOrigin).withAllowedMethods(allowedCorsMethods != null ? allowedCorsMethods : "GET,POST,PUT,DELETE,OPTIONS,PATCH").endCors().endHttp().endSpec();
return kafkaBridgeBuilder;
}
use of io.strimzi.api.kafka.model.KafkaBridgeBuilder in project strimzi by strimzi.
the class KafkaBridgeClusterTest method testCorsConfiguration.
@ParallelTest
public void testCorsConfiguration() {
KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().editHttp().withNewCors().withAllowedOrigins("https://strimzi.io", "https://cncf.io").withAllowedMethods("GET", "POST", "PUT", "DELETE", "PATCH").endCors().endHttp().endSpec().build();
KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
Deployment deployment = kb.generateDeployment(new HashMap<>(), true, null, null);
Container container = deployment.getSpec().getTemplate().getSpec().getContainers().get(0);
assertThat(AbstractModel.containerEnvVars(container).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_CORS_ENABLED), is("true"));
assertThat(AbstractModel.containerEnvVars(container).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_CORS_ALLOWED_ORIGINS), is("https://strimzi.io,https://cncf.io"));
assertThat(AbstractModel.containerEnvVars(container).get(KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_CORS_ALLOWED_METHODS), is("GET,POST,PUT,DELETE,PATCH"));
}
use of io.strimzi.api.kafka.model.KafkaBridgeBuilder 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.KafkaBridgeBuilder in project strimzi by strimzi.
the class KafkaBridgeClusterTest method testGracePeriod.
@ParallelTest
public void testGracePeriod() {
KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewTemplate().withNewPod().withTerminationGracePeriodSeconds(123).endPod().endTemplate().endSpec().build();
KafkaBridgeCluster kbc = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
Deployment dep = kbc.generateDeployment(emptyMap(), true, null, null);
assertThat(dep.getSpec().getTemplate().getSpec().getTerminationGracePeriodSeconds(), is(Long.valueOf(123)));
}
use of io.strimzi.api.kafka.model.KafkaBridgeBuilder in project strimzi by strimzi.
the class KafkaBridgeClusterTest method testProbeConfiguration.
@ParallelTest
public void testProbeConfiguration() {
KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withNewLivenessProbe().withInitialDelaySeconds(20).withPeriodSeconds(21).withTimeoutSeconds(22).endLivenessProbe().withNewReadinessProbe().withInitialDelaySeconds(30).withPeriodSeconds(31).withTimeoutSeconds(32).endReadinessProbe().endSpec().build();
KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
Deployment dep = kb.generateDeployment(new HashMap<String, String>(), true, null, null);
Container cont = dep.getSpec().getTemplate().getSpec().getContainers().get(0);
assertThat(cont.getLivenessProbe().getInitialDelaySeconds(), is(Integer.valueOf(20)));
assertThat(cont.getLivenessProbe().getPeriodSeconds(), is(Integer.valueOf(21)));
assertThat(cont.getLivenessProbe().getTimeoutSeconds(), is(Integer.valueOf(22)));
assertThat(cont.getReadinessProbe().getInitialDelaySeconds(), is(Integer.valueOf(30)));
assertThat(cont.getReadinessProbe().getPeriodSeconds(), is(Integer.valueOf(31)));
assertThat(cont.getReadinessProbe().getTimeoutSeconds(), is(Integer.valueOf(32)));
}
Aggregations