Skip to content

Commit

Permalink
Add bundle install test + RM can handle all kind of resoruces (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
kornys authored Dec 6, 2023
1 parent 7fb74eb commit 73e56c3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
16 changes: 9 additions & 7 deletions src/main/java/io/odh/test/framework/manager/ResourceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,8 @@ private <T extends HasMetadata> 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);
Expand All @@ -124,13 +121,14 @@ public final <T extends HasMetadata> void deleteResource(T... resources) {
for (T resource : resources) {
ResourceType<T> 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) {
Expand Down Expand Up @@ -160,7 +158,11 @@ public final <T extends HasMetadata> void deleteResource(T... resources) {
public final <T extends HasMetadata> void updateResource(T... resources) {
for (T resource : resources) {
ResourceType<T> type = findResourceType(resource);
type.update(resource);
if (type != null) {
type.update(resource);
} else {
client.getClient().resource(resource).update();
}
}
}

Expand Down
12 changes: 11 additions & 1 deletion src/main/java/io/odh/test/install/BundleInstall.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,13 +41,21 @@ 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());
});
}

public void installBundle() {
//TODO implement using RM
ResourceManager.getInstance().createResourceWithWait(resources.toArray(new HasMetadata[0]));
}
}
5 changes: 4 additions & 1 deletion src/test/java/io/odh/test/e2e/standard/OdhInstall.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 73e56c3

Please sign in to comment.