use of io.strimzi.api.kafka.model.KafkaBridge 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.KafkaBridge 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.KafkaBridge 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)));
}
use of io.strimzi.api.kafka.model.KafkaBridge in project strimzi by strimzi.
the class KafkaBridgeClusterTest method testGenerateDeploymentWithOAuthWithMissingClientSecret.
@ParallelTest
public void testGenerateDeploymentWithOAuthWithMissingClientSecret() {
assertThrows(InvalidResourceException.class, () -> {
KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withAuthentication(new KafkaClientAuthenticationOAuthBuilder().withClientId("my-client-id").withTokenEndpointUri("http://my-oauth-server").build()).endSpec().build();
KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
});
}
use of io.strimzi.api.kafka.model.KafkaBridge in project strimzi by strimzi.
the class KafkaBridgeClusterTest method testGenerateDeploymentWithOAuthWithClientSecret.
@ParallelTest
public void testGenerateDeploymentWithOAuthWithClientSecret() {
KafkaBridge resource = new KafkaBridgeBuilder(this.resource).editSpec().withAuthentication(new KafkaClientAuthenticationOAuthBuilder().withClientId("my-client-id").withTokenEndpointUri("http://my-oauth-server").withAudience("kafka").withScope("all").withNewClientSecret().withSecretName("my-secret-secret").withKey("my-secret-key").endClientSecret().build()).endSpec().build();
KafkaBridgeCluster kb = KafkaBridgeCluster.fromCrd(Reconciliation.DUMMY_RECONCILIATION, resource, VERSIONS);
Deployment dep = kb.generateDeployment(emptyMap(), true, null, null);
Container cont = dep.getSpec().getTemplate().getSpec().getContainers().get(0);
assertThat(cont.getEnv().stream().filter(var -> KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_SASL_MECHANISM.equals(var.getName())).findFirst().orElseThrow().getValue(), is("oauth"));
assertThat(cont.getEnv().stream().filter(var -> KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_OAUTH_CLIENT_SECRET.equals(var.getName())).findFirst().orElseThrow().getValueFrom().getSecretKeyRef().getName(), is("my-secret-secret"));
assertThat(cont.getEnv().stream().filter(var -> KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_OAUTH_CLIENT_SECRET.equals(var.getName())).findFirst().orElseThrow().getValueFrom().getSecretKeyRef().getKey(), is("my-secret-key"));
assertThat(cont.getEnv().stream().filter(var -> KafkaBridgeCluster.ENV_VAR_KAFKA_BRIDGE_OAUTH_CONFIG.equals(var.getName())).findFirst().orElseThrow().getValue().trim(), is(String.format("%s=\"%s\" %s=\"%s\" %s=\"%s\" %s=\"%s\"", ClientConfig.OAUTH_CLIENT_ID, "my-client-id", ClientConfig.OAUTH_TOKEN_ENDPOINT_URI, "http://my-oauth-server", ClientConfig.OAUTH_SCOPE, "all", ClientConfig.OAUTH_AUDIENCE, "kafka")));
}
Aggregations