use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectBuildTest method testDeploymentWithoutPushSecret.
@ParallelTest
public void testDeploymentWithoutPushSecret() {
KafkaConnect kc = new KafkaConnectBuilder().withNewMetadata().withName(cluster).withNamespace(namespace).endMetadata().withNewSpec().withBootstrapServers("my-kafka:9092").withNewBuild().withNewDockerOutput().withImage("my-image:latest").endDockerOutput().withPlugins(new PluginBuilder().withName("my-connector").withArtifacts(jarArtifactWithChecksum).build(), new PluginBuilder().withName("my-connector2").withArtifacts(jarArtifactNoChecksum).build()).endBuild().endSpec().build();
KafkaConnectBuild build = KafkaConnectBuild.fromCrd(new Reconciliation("test", kc.getKind(), kc.getMetadata().getNamespace(), kc.getMetadata().getName()), kc, VERSIONS);
Pod pod = build.generateBuilderPod(true, ImagePullPolicy.IFNOTPRESENT, null, null);
assertThat(pod.getSpec().getVolumes().size(), is(1));
assertThat(pod.getSpec().getContainers().get(0).getArgs(), is(defaultArgs));
assertThat(pod.getSpec().getVolumes().get(0).getName(), is("dockerfile"));
assertThat(pod.getSpec().getVolumes().get(0).getConfigMap().getName(), is(KafkaConnectResources.dockerFileConfigMapName(cluster)));
assertThat(pod.getSpec().getContainers().get(0).getVolumeMounts().size(), is(1));
assertThat(pod.getSpec().getContainers().get(0).getVolumeMounts().get(0).getName(), is("dockerfile"));
assertThat(pod.getSpec().getContainers().get(0).getVolumeMounts().get(0).getMountPath(), is("/dockerfile"));
}
use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectBuildTest method testFromCrd.
@ParallelTest
public void testFromCrd() {
KafkaConnect kc = new KafkaConnectBuilder().withNewMetadata().withName(cluster).withNamespace(namespace).endMetadata().withNewSpec().withBootstrapServers("my-kafka:9092").withNewBuild().withNewDockerOutput().withImage("my-image:latest").withPushSecret("my-docker-credentials").endDockerOutput().withPlugins(new PluginBuilder().withName("my-connector").withArtifacts(jarArtifactWithChecksum).build(), new PluginBuilder().withName("my-connector2").withArtifacts(jarArtifactNoChecksum).build()).endBuild().endSpec().build();
KafkaConnectBuild.fromCrd(new Reconciliation("test", kc.getKind(), kc.getMetadata().getNamespace(), kc.getMetadata().getName()), kc, VERSIONS);
}
use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectDockerfileTest method testMultipleTgzArtifact.
@ParallelTest
public void testMultipleTgzArtifact() {
Build connectBuild = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(tgzArtifactNoChecksum, tgzArtifactWithChecksum).build()).build();
KafkaConnectDockerfile df = new KafkaConnectDockerfile("myImage:latest", connectBuild);
assertThat(df.getDockerfile(), isEquivalent("FROM myImage:latest", "USER root:root", "RUN 'mkdir' '-p' '/opt/kafka/plugins/my-connector-plugin/6718766b' \\", " && 'curl' '-L' '--output' '/opt/kafka/plugins/my-connector-plugin/6718766b.tgz' 'https://mydomain.tld/my.tgz' \\", " && 'tar' 'xvfz' '/opt/kafka/plugins/my-connector-plugin/6718766b.tgz' '-C' '/opt/kafka/plugins/my-connector-plugin/6718766b' \\", " && 'rm' '-vf' '/opt/kafka/plugins/my-connector-plugin/6718766b.tgz'", "RUN 'mkdir' '-p' '/opt/kafka/plugins/my-connector-plugin/638bd501' \\", " && 'curl' '-L' '--output' '/opt/kafka/plugins/my-connector-plugin/638bd501.tgz' 'https://mydomain.tld/my2.tgz' \\", " && 'echo' 'sha-512-checksum /opt/kafka/plugins/my-connector-plugin/638bd501.tgz' > '/opt/kafka/plugins/my-connector-plugin/638bd501.tgz.sha512' \\", " && 'sha512sum' '--check' '/opt/kafka/plugins/my-connector-plugin/638bd501.tgz.sha512' \\", " && 'rm' '-f' '/opt/kafka/plugins/my-connector-plugin/638bd501.tgz.sha512' \\", " && 'tar' 'xvfz' '/opt/kafka/plugins/my-connector-plugin/638bd501.tgz' '-C' '/opt/kafka/plugins/my-connector-plugin/638bd501' \\", " && 'rm' '-vf' '/opt/kafka/plugins/my-connector-plugin/638bd501.tgz'", "USER 1001"));
}
use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectDockerfileTest method testNoUrlWhenRequired.
@ParallelTest
public void testNoUrlWhenRequired() {
Artifact tgzArtifact = new TgzArtifactBuilder().build();
Artifact jarArtifact = new JarArtifactBuilder().build();
Artifact zipArtifact = new ZipArtifactBuilder().build();
Artifact otherArtifact = new OtherArtifactBuilder().build();
Build connectBuildTgz = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(tgzArtifact)).build()).build();
Throwable e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildTgz));
assertThat(e.getMessage(), is("`tgz` artifact is missing a URL."));
Build connectBuildZip = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(zipArtifact)).build()).build();
e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildZip));
assertThat(e.getMessage(), is("`zip` artifact is missing a URL."));
Build connectBuildJar = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(jarArtifact)).build()).build();
e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildJar));
assertThat(e.getMessage(), is("`jar` artifact is missing a URL."));
Build connectBuildOther = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(singletonList(otherArtifact)).build()).build();
e = assertThrows(InvalidConfigurationException.class, () -> new KafkaConnectDockerfile("myImage:latest", connectBuildOther));
assertThat(e.getMessage(), is("`other` artifact is missing a URL."));
}
use of io.strimzi.api.kafka.model.connect.build.PluginBuilder in project strimzi-kafka-operator by strimzi.
the class KafkaConnectDockerfileTest method testNoChecksumOtherArtifact.
@ParallelTest
public void testNoChecksumOtherArtifact() {
Build connectBuild = new BuildBuilder().withPlugins(new PluginBuilder().withName("my-connector-plugin").withArtifacts(otherArtifactNoChecksum).build()).build();
KafkaConnectDockerfile df = new KafkaConnectDockerfile("myImage:latest", connectBuild);
assertThat(df.getDockerfile(), isEquivalent("FROM myImage:latest", "USER root:root", "RUN 'mkdir' '-p' '/opt/kafka/plugins/my-connector-plugin/2c3b64c7' \\", " && 'curl' '-L' '--output' '/opt/kafka/plugins/my-connector-plugin/2c3b64c7/my.so' 'https://mydomain.tld/download?artifact=my.so'", "USER 1001"));
}
Aggregations