Skip to content

Commit

Permalink
fix: naming and cleanup (#74)
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 authored Apr 9, 2024
1 parent 5ad0e89 commit 2f162b7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.fabric8.kubernetes.api.model.ObjectMetaBuilder;
import io.quarkus.test.junit.QuarkusTest;

import static io.csviri.operator.resourceglue.TestUtils.GC_WAIT_TIMEOUT_SECOND;
import static io.csviri.operator.resourceglue.customresource.TestCustomResource.CR_GROUP;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
Expand Down Expand Up @@ -139,12 +140,13 @@ void simpleConcurrencyForMultipleOperatorTest() {
crs.forEach(this::delete);
cr2s.forEach(this::delete);

await().untilAsserted(() -> IntStream.range(0, num).forEach(n -> {
var cm = get(ConfigMap.class, TEST_RESOURCE_PREFIX + n);
assertThat(cm).isNull();
var cm2 = get(ConfigMap.class, TEST_RESOURCE2_PREFIX + n);
assertThat(cm2).isNull();
}));
await().timeout(GC_WAIT_TIMEOUT_SECOND)
.untilAsserted(() -> IntStream.range(0, num).forEach(n -> {
var cm = get(ConfigMap.class, TEST_RESOURCE_PREFIX + n);
assertThat(cm).isNull();
var cm2 = get(ConfigMap.class, TEST_RESOURCE2_PREFIX + n);
assertThat(cm2).isNull();
}));
}

TestCustomResource testCustomResource() {
Expand Down
3 changes: 3 additions & 0 deletions src/test/java/io/csviri/operator/resourceglue/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;
Expand All @@ -25,6 +26,8 @@

public class TestUtils {

public static final Duration GC_WAIT_TIMEOUT_SECOND = Duration.ofSeconds(30);

public static final int CRD_READY_WAIT = 1000;

private static final Logger log = LoggerFactory.getLogger(TestUtils.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.NonDeletingOperation;

import static io.csviri.operator.resourceglue.TestUtils.GC_WAIT_TIMEOUT_SECOND;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

Expand All @@ -37,7 +38,7 @@ void applyCRDs() throws MalformedURLException, URISyntaxException {

@Test
void testMutationHookDeployment() {
client.resource(TestUtils.load("/sample/mutation/mutation.glue.yaml"))
var glue = client.resource(TestUtils.load("/sample/mutation/mutation.glue.yaml"))
.createOr(NonDeletingOperation::update);

await().atMost(Duration.ofMinutes(5)).untilAsserted(() -> {
Expand All @@ -51,6 +52,13 @@ void testMutationHookDeployment() {
var pod = client.resource(testPod()).create();
assertThat(pod.getMetadata().getAnnotations()).containsEntry("sample.annotation.present",
"true");

client.resource(glue).delete();

await().timeout(GC_WAIT_TIMEOUT_SECOND).untilAsserted(() -> {
var deployment = client.apps().deployments().withName("pod-mutating-hook").get();
assertThat(deployment).isNull();
});
}

Pod testPod() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.csviri.operator.resourceglue;
package io.csviri.operator.resourceglue.sample.webpage;


import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import io.csviri.operator.resourceglue.TestUtils;
import io.csviri.operator.resourceglue.customresource.glue.Glue;
import io.csviri.operator.resourceglue.customresource.operator.GlueOperator;
import io.csviri.operator.resourceglue.sample.webpage.WebPage;
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.apps.Deployment;
Expand All @@ -15,6 +15,7 @@
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.NonDeletingOperation;

import static io.csviri.operator.resourceglue.TestUtils.GC_WAIT_TIMEOUT_SECOND;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

Expand Down Expand Up @@ -61,7 +62,7 @@ void testWebPageCRUDOperations() {

client.resource(createdWebPage).delete();

await().untilAsserted(() -> {
await().timeout(GC_WAIT_TIMEOUT_SECOND).untilAsserted(() -> {
var deployment =
client.resources(Deployment.class).withName(webPage.getMetadata().getName()).get();
var configMap =
Expand Down
18 changes: 0 additions & 18 deletions src/test/resources/resourceglueoperator/Simple.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion src/test/resources/resourceglueoperator/Templating.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: io.csviri.operator.resourceglue/v1beta1
kind: GlueOperator
metadata:
name: rfo-templating-sample
name: templating-sample
spec:
parent:
apiVersion: io.csviri.operator.resourceglue/v1
Expand Down

0 comments on commit 2f162b7

Please sign in to comment.