Skip to content

Commit

Permalink
Compute build revision in KafkaConnectAssemblyOperatorPodSetTest
Browse files Browse the repository at this point in the history
  • Loading branch information
urbandan committed May 15, 2024
1 parent a900d30 commit 3f7366b
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import io.strimzi.operator.cluster.PlatformFeaturesAvailability;
import io.strimzi.operator.cluster.ResourceUtils;
import io.strimzi.operator.cluster.model.KafkaConnectCluster;
import io.strimzi.operator.cluster.model.KafkaConnectDockerfile;
import io.strimzi.operator.cluster.model.KafkaVersion;
import io.strimzi.operator.cluster.model.MockSharedEnvironmentProvider;
import io.strimzi.operator.cluster.model.PodSetUtils;
Expand All @@ -53,6 +54,7 @@
import io.strimzi.operator.cluster.operator.resource.kubernetes.StrimziPodSetOperator;
import io.strimzi.operator.common.Annotations;
import io.strimzi.operator.common.Reconciliation;
import io.strimzi.operator.common.Util;
import io.strimzi.operator.common.model.Labels;
import io.strimzi.operator.common.model.OrderedProperties;
import io.strimzi.operator.common.operator.resource.ReconcileResult;
Expand Down Expand Up @@ -1377,6 +1379,11 @@ public void testBuildChangedCluster(VertxTestContext context) {
.endStatus()
.build();

String baseImage = VERSIONS.kafkaConnectVersion(connect.getSpec().getImage(), connect.getSpec().getVersion());
KafkaConnectDockerfile dockerfile = new KafkaConnectDockerfile(baseImage,
connect.getSpec().getBuild(), SHARED_ENV_PROVIDER);
String expectedRevision = dockerfile.hashStub()
+ Util.hashStub(connect.getSpec().getBuild().getOutput().getImage());

ResourceOperatorSupplier supplier = ResourceUtils.supplierWithMocks(false);

Expand Down Expand Up @@ -1456,12 +1463,12 @@ public void testBuildChangedCluster(VertxTestContext context) {
assertThat(capturesPodSets.size(), is(1));
StrimziPodSet podSet = capturesPodSets.get(0);
assertThat(podSet.getMetadata().getName(), is(COMPONENT_NAME));
assertThat(podSet.getMetadata().getAnnotations().get(Annotations.STRIMZI_IO_CONNECT_BUILD_REVISION), is("28987d00751944b0"));
assertThat(podSet.getMetadata().getAnnotations().get(Annotations.STRIMZI_IO_CONNECT_BUILD_REVISION), is(expectedRevision));
assertThat(podSet.getMetadata().getAnnotations().get(Annotations.STRIMZI_IO_CONNECT_BUILD_IMAGE), is("my-connect-build@sha256:blablabla"));
assertThat(podSet.getSpec().getPods().size(), is(3));

for (Pod pod : PodSetUtils.podSetToPods(podSet)) {
assertThat(pod.getMetadata().getAnnotations().get(Annotations.STRIMZI_IO_CONNECT_BUILD_REVISION), is("28987d00751944b0"));
assertThat(pod.getMetadata().getAnnotations().get(Annotations.STRIMZI_IO_CONNECT_BUILD_REVISION), is(expectedRevision));
assertThat(pod.getSpec().getContainers().get(0).getImage(), is("my-connect-build@sha256:blablabla"));
}

Expand Down

0 comments on commit 3f7366b

Please sign in to comment.