From f122de85f28eddb29e06a86267bd82c0a9d23921 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Wed, 8 Jan 2025 19:26:35 +0100 Subject: [PATCH] wip: add more logging Signed-off-by: Chris Laprun --- .../junit/LocallyRunOperatorExtension.java | 9 +++++---- .../junit/LocallyRunOperatorExtensionTest.java | 3 +++ .../src/test/resources/log4j2.xml | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 operator-framework-junit5/src/test/resources/log4j2.xml diff --git a/operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/LocallyRunOperatorExtension.java b/operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/LocallyRunOperatorExtension.java index 0765e84cab..6ba8c55eb5 100644 --- a/operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/LocallyRunOperatorExtension.java +++ b/operator-framework-junit5/src/main/java/io/javaoperatorsdk/operator/junit/LocallyRunOperatorExtension.java @@ -178,12 +178,13 @@ public void applyCrd(Class crClass) { */ public void applyCrd(String resourceTypeName) { // first attempt to use a manually defined CRD - final var path = crdMappings.get(resourceTypeName); - if (path != null) { + final var pathAsString = crdMappings.get(resourceTypeName); + if (pathAsString != null) { + final var path = Path.of(pathAsString); try { - applyCrd(Files.readString(Path.of(path)), path, getKubernetesClient()); + applyCrd(Files.readString(path), pathAsString, getKubernetesClient()); } catch (IOException e) { - throw new IllegalStateException("Cannot open CRD file at " + path, e); + throw new IllegalStateException("Cannot open CRD file at " + path.toAbsolutePath(), e); } } else { // if no manually defined CRD matches the resource type, apply the generated one diff --git a/operator-framework-junit5/src/test/java/io/javaoperatorsdk/operator/junit/LocallyRunOperatorExtensionTest.java b/operator-framework-junit5/src/test/java/io/javaoperatorsdk/operator/junit/LocallyRunOperatorExtensionTest.java index f6d8ff6254..e5b57fa173 100644 --- a/operator-framework-junit5/src/test/java/io/javaoperatorsdk/operator/junit/LocallyRunOperatorExtensionTest.java +++ b/operator-framework-junit5/src/test/java/io/javaoperatorsdk/operator/junit/LocallyRunOperatorExtensionTest.java @@ -1,5 +1,6 @@ package io.javaoperatorsdk.operator.junit; +import java.nio.file.Path; import java.util.List; import org.junit.jupiter.api.Test; @@ -12,6 +13,8 @@ class LocallyRunOperatorExtensionTest { @Test void getAdditionalCRDsFromFiles() { + System.out.println(Path.of("").toAbsolutePath()); + System.out.println(Path.of("src/test/crd/test.crd").toAbsolutePath()); final var crds = LocallyRunOperatorExtension.getAdditionalCRDsFromFiles( List.of("src/test/resources/crd/test.crd", "src/test/crd/test.crd"), new KubernetesClientBuilder().build()); diff --git a/operator-framework-junit5/src/test/resources/log4j2.xml b/operator-framework-junit5/src/test/resources/log4j2.xml new file mode 100644 index 0000000000..82d8fa2cb1 --- /dev/null +++ b/operator-framework-junit5/src/test/resources/log4j2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + +