Skip to content

Commit a1194b6

Browse files
committed
fix
Signed-off-by: csviri <[email protected]>
1 parent 5325982 commit a1194b6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/main/java/io/csviri/operator/resourceglue/Utils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import io.javaoperatorsdk.operator.processing.event.ResourceID;
1111
import io.javaoperatorsdk.operator.processing.event.source.informer.InformerEventSource;
1212

13+
import static io.csviri.operator.resourceglue.reconciler.glue.GlueReconciler.DEPENDENT_NAME_ANNOTATION_KEY;
14+
1315
public class Utils {
1416

1517
public static final String RESOURCE_NAME_DELIMITER = "#";
@@ -24,7 +26,10 @@ public static Map<String, GenericKubernetesResource> getActualResourcesByNameInW
2426
var dependentSpec = glue.getSpec().getResources().stream()
2527
.filter(r -> Utils.getApiVersion(r).equals(sr.getApiVersion())
2628
&& Utils.getKind(r).equals(sr.getKind())
27-
&& Utils.getName(r).equals(sr.getMetadata().getName())
29+
// checking the name from annotation since it might be templated name
30+
// therefore "Utils.getName(r).equals(sr.getMetadata().getName())" would not work
31+
&& r.getName()
32+
.equals(sr.getMetadata().getAnnotations().get(DEPENDENT_NAME_ANNOTATION_KEY))
2833
// namespace not compared here, it should be done it is just not trivial, now it is limited to
2934
// have one kind of resource in the workflow with the same resource name
3035
).findFirst();

src/test/java/io/csviri/operator/resourceglue/GlueTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ void stringTemplate() {
121121

122122
@Test
123123
void simpleConcurrencyTest() {
124-
// todo set 10
125-
int num = 1;
124+
int num = 10;
126125
List<Glue> glueList = testWorkflowList(num);
127126

128127
glueList.forEach(this::create);
@@ -136,13 +135,16 @@ void simpleConcurrencyTest() {
136135

137136
assertThat(cm1).isNotNull();
138137
assertThat(cm2).isNotNull();
138+
assertThat(cm2.getData().get("valueFromCM1"))
139+
.isEqualTo("value1");
139140
}));
140141

141142
glueList.forEach(this::delete);
142-
await().timeout(Duration.ofMinutes(5)).untilAsserted(() -> IntStream.range(0, num).forEach(index -> {
143-
var w = get(Glue.class, "testglue" + index);
144-
assertThat(w).isNull();
145-
}));
143+
await().timeout(Duration.ofMinutes(5))
144+
.untilAsserted(() -> IntStream.range(0, num).forEach(index -> {
145+
var w = get(Glue.class, "testglue" + index);
146+
assertThat(w).isNull();
147+
}));
146148
}
147149

148150
@Test

0 commit comments

Comments
 (0)