From 69880b08114c61d5258b06b095fbbbc990dea005 Mon Sep 17 00:00:00 2001 From: David Kornel Date: Tue, 5 Dec 2023 17:27:53 +0100 Subject: [PATCH 1/2] Add bundle install test + RM can handle all kind of resoruces --- .../odh/test/framework/manager/ResourceManager.java | 10 ++++------ src/main/java/io/odh/test/install/BundleInstall.java | 12 +++++++++++- .../java/io/odh/test/e2e/standard/OdhInstall.java | 5 ++++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/odh/test/framework/manager/ResourceManager.java b/src/main/java/io/odh/test/framework/manager/ResourceManager.java index 7f108396..2a736085 100644 --- a/src/main/java/io/odh/test/framework/manager/ResourceManager.java +++ b/src/main/java/io/odh/test/framework/manager/ResourceManager.java @@ -95,11 +95,8 @@ private void createResource(boolean waitReady, T... reso if (waitReady) { DeploymentUtils.waitForDeploymentReady(resource.getMetadata().getNamespace(), resource.getMetadata().getName()); } - continue; } else { - LOGGER.error("Invalid resource {} {}/{}. Please implement it in ResourceManager", - resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()); - continue; + client.getClient().resource(resource).create(); } } else { type.create(resource); @@ -124,13 +121,14 @@ public final void deleteResource(T... resources) { for (T resource : resources) { ResourceType type = findResourceType(resource); if (type == null) { + LOGGER.info("Deleting of {} {}", + resource.getKind(), resource.getMetadata().getName()); if (resource instanceof Deployment) { Deployment deployment = (Deployment) resource; client.getClient().apps().deployments().resource(deployment).delete(); DeploymentUtils.waitForDeploymentDeletion(resource.getMetadata().getNamespace(), resource.getMetadata().getName()); } else { - LOGGER.error("Invalid resource {} {}/{}. Please implement it in ResourceManager", - resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()); + client.getClient().resource(resource).delete(); } } else { if (resource.getMetadata().getNamespace() == null) { diff --git a/src/main/java/io/odh/test/install/BundleInstall.java b/src/main/java/io/odh/test/install/BundleInstall.java index b2ce43e7..52b0e521 100644 --- a/src/main/java/io/odh/test/install/BundleInstall.java +++ b/src/main/java/io/odh/test/install/BundleInstall.java @@ -5,6 +5,8 @@ package io.odh.test.install; import io.fabric8.kubernetes.api.model.HasMetadata; +import io.fabric8.kubernetes.api.model.Namespace; +import io.fabric8.kubernetes.api.model.apps.Deployment; import io.odh.test.Environment; import io.odh.test.TestConstants; import io.odh.test.TestUtils; @@ -39,6 +41,14 @@ public BundleInstall() throws IOException { this(Environment.INSTALL_FILE_PATH); } + public String getNamespace() { + return resources.stream().filter(r -> r instanceof Namespace).findFirst().get().getMetadata().getName(); + } + + public String getDeploymentName() { + return resources.stream().filter(r -> r instanceof Deployment).findFirst().get().getMetadata().getName(); + } + public void printResources() { resources.forEach(r -> { LOGGER.info("Kind: {}, Name: {}", r.getKind(), r.getMetadata().getName()); @@ -46,6 +56,6 @@ public void printResources() { } public void installBundle() { - //TODO implement using RM + ResourceManager.getInstance().createResourceWithWait(resources.toArray(new HasMetadata[0])); } } diff --git a/src/test/java/io/odh/test/e2e/standard/OdhInstall.java b/src/test/java/io/odh/test/e2e/standard/OdhInstall.java index 9113ea4c..0e406177 100644 --- a/src/test/java/io/odh/test/e2e/standard/OdhInstall.java +++ b/src/test/java/io/odh/test/e2e/standard/OdhInstall.java @@ -30,6 +30,9 @@ void testInstallOdhOlm() { void testInstallOdhBundle() throws IOException { BundleInstall bundle = new BundleInstall(); bundle.printResources(); - //TODO complete + bundle.installBundle(); + + Deployment dep = ResourceManager.getClient().getDeployment(bundle.getNamespace(), bundle.getDeploymentName()); + assertNotNull(dep); } } From 55d86927f4fab1cc1d88d74b6c8caf18e158c20a Mon Sep 17 00:00:00 2001 From: David Kornel Date: Tue, 5 Dec 2023 17:31:59 +0100 Subject: [PATCH 2/2] Handle update for non modificated resoryces --- .../java/io/odh/test/framework/manager/ResourceManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/odh/test/framework/manager/ResourceManager.java b/src/main/java/io/odh/test/framework/manager/ResourceManager.java index 2a736085..205bed82 100644 --- a/src/main/java/io/odh/test/framework/manager/ResourceManager.java +++ b/src/main/java/io/odh/test/framework/manager/ResourceManager.java @@ -158,7 +158,11 @@ public final void deleteResource(T... resources) { public final void updateResource(T... resources) { for (T resource : resources) { ResourceType type = findResourceType(resource); - type.update(resource); + if (type != null) { + type.update(resource); + } else { + client.getClient().resource(resource).update(); + } } }