diff --git a/src/main/java/io/csviri/operator/resourceglue/Utils.java b/src/main/java/io/csviri/operator/resourceglue/Utils.java index 224c5d8..e316a38 100644 --- a/src/main/java/io/csviri/operator/resourceglue/Utils.java +++ b/src/main/java/io/csviri/operator/resourceglue/Utils.java @@ -10,6 +10,8 @@ import io.javaoperatorsdk.operator.processing.event.ResourceID; import io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource; +import static io.csviri.operator.resourceglue.reconciler.glue.GlueReconciler.DEPENDENT_NAME_ANNOTATION_KEY; + public class Utils { public static final String RESOURCE_NAME_DELIMITER = "#"; @@ -24,7 +26,10 @@ public static Map getActualResourcesByNameInW var dependentSpec = glue.getSpec().getResources().stream() .filter(r -> Utils.getApiVersion(r).equals(sr.getApiVersion()) && Utils.getKind(r).equals(sr.getKind()) - && Utils.getName(r).equals(sr.getMetadata().getName()) + // checking the name from annotation since it might be templated name + // therefore "Utils.getName(r).equals(sr.getMetadata().getName())" would not work + && r.getName() + .equals(sr.getMetadata().getAnnotations().get(DEPENDENT_NAME_ANNOTATION_KEY)) // namespace not compared here, it should be done it is just not trivial, now it is limited to // have one kind of resource in the workflow with the same resource name ).findFirst(); diff --git a/src/test/java/io/csviri/operator/resourceglue/GlueTest.java b/src/test/java/io/csviri/operator/resourceglue/GlueTest.java index 7e922f8..4c28abf 100644 --- a/src/test/java/io/csviri/operator/resourceglue/GlueTest.java +++ b/src/test/java/io/csviri/operator/resourceglue/GlueTest.java @@ -121,8 +121,7 @@ void stringTemplate() { @Test void simpleConcurrencyTest() { - // todo set 10 - int num = 1; + int num = 10; List glueList = testWorkflowList(num); glueList.forEach(this::create); @@ -136,13 +135,16 @@ void simpleConcurrencyTest() { assertThat(cm1).isNotNull(); assertThat(cm2).isNotNull(); + assertThat(cm2.getData().get("valueFromCM1")) + .isEqualTo("value1"); })); glueList.forEach(this::delete); - await().timeout(Duration.ofMinutes(5)).untilAsserted(() -> IntStream.range(0, num).forEach(index -> { - var w = get(Glue.class, "testglue" + index); - assertThat(w).isNull(); - })); + await().timeout(Duration.ofMinutes(5)) + .untilAsserted(() -> IntStream.range(0, num).forEach(index -> { + var w = get(Glue.class, "testglue" + index); + assertThat(w).isNull(); + })); } @Test