Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bundle install test + RM can handle all kind of resoruces #29

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}