Skip to content

Commit

Permalink
working integration test
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Mészáros <csviri@gmail.com>
  • Loading branch information
csviri committed May 13, 2024
1 parent 037c1f8 commit 6392b75
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ private ObjectMeta glueMetadata(GlueOperator glueOperator,

var glueMeta = glueOperator.getSpec().getGlueMetadata();
if (glueMeta != null) {
// todo optimize
// optimize
var data = Map.of(PARENT_RELATED_RESOURCE_NAME, parent);
var glueName = genericTemplateHandler.processInputAndTemplate(data, glueMeta.getName());
var glueNamespace =
genericTemplateHandler.processInputAndTemplate(data, glueMeta.getNamespace());
objectMetaBuilder.withName(glueName);
objectMetaBuilder.withName(glueNamespace);
objectMetaBuilder.withNamespace(glueNamespace);
} else {
objectMetaBuilder.withName(
glueName(parent.getMetadata().getName(), parent.getKind()))
Expand Down
20 changes: 14 additions & 6 deletions src/test/java/io/csviri/operator/glue/GlueOperatorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.csviri.operator.glue.customresource.TestCustomResource;
import io.csviri.operator.glue.customresource.TestCustomResource2;
import io.csviri.operator.glue.customresource.glue.DependentResourceSpec;
import io.csviri.operator.glue.customresource.glue.Glue;
import io.csviri.operator.glue.customresource.operator.GlueOperator;
import io.csviri.operator.glue.customresource.operator.GlueOperatorSpec;
import io.csviri.operator.glue.customresource.operator.Parent;
Expand All @@ -29,6 +30,8 @@
@QuarkusTest
class GlueOperatorTest extends TestBase {

public static final String COPIED_SECRET_NAME = "copied-secret";

@BeforeEach
void applyCRD() {
TestUtils.applyTestCrd(client, TestCustomResource.class, TestCustomResource2.class);
Expand Down Expand Up @@ -202,7 +205,7 @@ void secretCopySample() {
var namespaces = client.namespaces().list().getItems();
namespaces.forEach(ns -> {
var copiedSecret =
client.secrets().inNamespace(ns.getMetadata().getName()).withName("copied-secret")
client.secrets().inNamespace(ns.getMetadata().getName()).withName(COPIED_SECRET_NAME)
.get();
assertThat(copiedSecret).isNotNull();
assertThat(copiedSecret.getData().get("shared-password"))
Expand All @@ -211,12 +214,17 @@ void secretCopySample() {
});

delete(go);
client.namespaces().list().getItems().forEach(ns -> {
client.resources(Glue.class)
.inNamespace(ns.getMetadata().getName()).withName("copied-secret-glue").delete();
client.secrets()
.inNamespace(ns.getMetadata().getName()).withName(COPIED_SECRET_NAME).delete();
});
await().untilAsserted(() -> {
var namespaces = client.namespaces().list().getItems();
namespaces.forEach(ns -> {
var copiedSecret =
client.secrets().inNamespace(ns.getMetadata().getName()).withName("copied-secret");
assertThat(copiedSecret).isNull();
client.namespaces().list().getItems().forEach(ns -> {
var g = client.resources(Glue.class)
.inNamespace(ns.getMetadata().getName()).withName("copied-glue-secret").get();
assertThat(g).isNull();
});
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
apiVersion: io.csviri.operator.glue/v1beta1
kind: GlueOperator
metadata:
name: webpage-operator
name: secret-copy-operator
spec:
parent:
apiVersion: v1
kind: Namespace
clusterScoped: true
glueMetadata:
name: copied-secret-glue
namespace: "{parent.metadata.name}"
Expand All @@ -18,7 +19,7 @@ spec:
name: copied-secret
type: Opaque
data:
shared-password: {sharedsecret.data.password}
shared-password: "{sharedsecret.data.password}"
relatedResources:
- name: sharedsecret
apiVersion: v1
Expand Down

0 comments on commit 6392b75

Please sign in to comment.