Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: csviri <[email protected]>
  • Loading branch information
csviri committed Mar 29, 2024
1 parent 5325982 commit a1194b6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/main/java/io/csviri/operator/resourceglue/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "#";
Expand All @@ -24,7 +26,10 @@ public static Map<String, GenericKubernetesResource> 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();
Expand Down
14 changes: 8 additions & 6 deletions src/test/java/io/csviri/operator/resourceglue/GlueTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ void stringTemplate() {

@Test
void simpleConcurrencyTest() {
// todo set 10
int num = 1;
int num = 10;
List<Glue> glueList = testWorkflowList(num);

glueList.forEach(this::create);
Expand All @@ -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
Expand Down

0 comments on commit a1194b6

Please sign in to comment.