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

Refactor tests + wait for namespace deletion in RM + prepare for upgrade #31

Merged
merged 1 commit 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
21 changes: 17 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@
<id>continuous</id>
<properties>
<it.skip>false</it.skip>
<it.test>
io.odh.test.e2e.continuous.*IT
</it.test>
<groups>
continuous
</groups>
</properties>
</profile>

Expand All @@ -315,8 +315,21 @@
<properties>
<it.skip>false</it.skip>
<it.test>
io.odh.test.e2e.standard.*IT
io.odh.test.e2e.standard.*ST
</it.test>
<groups>
!upgrade
</groups>
</properties>
</profile>

<profile>
<id>upgrade</id>
<properties>
<it.skip>false</it.skip>
<groups>
upgrade
</groups>
</properties>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package io.odh.test.framework.manager;

import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.Namespace;
import io.fabric8.kubernetes.api.model.admissionregistration.v1.ValidatingWebhookConfiguration;
import io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition;
import io.fabric8.kubernetes.api.model.apps.Deployment;
Expand All @@ -13,6 +14,7 @@
import io.odh.test.TestConstants;
import io.odh.test.TestUtils;
import io.odh.test.framework.manager.resources.DataScienceClusterResource;
import io.odh.test.framework.manager.resources.NamespaceResource;
import io.odh.test.framework.manager.resources.NotebookResource;
import io.odh.test.framework.manager.resources.OperatorGroupResource;
import io.odh.test.framework.manager.resources.SubscriptionResource;
Expand Down Expand Up @@ -60,6 +62,7 @@ public static KubeCmdClient getKubeCmdClient() {
}

private final ResourceType<?>[] resourceTypes = new ResourceType[]{
new NamespaceResource(),
new SubscriptionResource(),
new OperatorGroupResource(),
new DataScienceClusterResource(),
Expand Down Expand Up @@ -194,7 +197,9 @@ public final <T extends HasMetadata> boolean waitResourceCondition(T resource, R
assertNotNull(resource.getMetadata().getName());

// cluster role binding and custom resource definition does not need namespace...
if (!(resource instanceof ClusterRoleBinding || resource instanceof CustomResourceDefinition || resource instanceof ClusterRole || resource instanceof ValidatingWebhookConfiguration || resource instanceof DataScienceCluster)) {
if (!(resource instanceof ClusterRoleBinding || resource instanceof CustomResourceDefinition
|| resource instanceof ClusterRole || resource instanceof ValidatingWebhookConfiguration
|| resource instanceof DataScienceCluster || resource instanceof Namespace)) {
assertNotNull(resource.getMetadata().getNamespace());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.framework.manager.resources;

import io.fabric8.kubernetes.api.model.Namespace;
import io.odh.test.framework.manager.ResourceManager;
import io.odh.test.framework.manager.ResourceType;


public class NamespaceResource implements ResourceType<Namespace> {

@Override
public String getKind() {
return "Namespace";
}

@Override
public Namespace get(String namespace, String name) {
return ResourceManager.getClient().getClient().namespaces().withName(name).get();
}

@Override
public void create(Namespace resource) {
ResourceManager.getClient().getClient().resource(resource).create();
}

@Override
public void delete(Namespace resource) {
ResourceManager.getClient().getClient().namespaces().withName(resource.getMetadata().getName()).delete();
}

@Override
public void update(Namespace resource) {
ResourceManager.getClient().getClient().resource(resource).update();
}

@Override
public boolean waitForReadiness(Namespace resource) {
return resource != null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

@Tag("continuous")
public class DataScienceClusterIT extends Abstract {
public class DataScienceClusterST extends Abstract {

private static final String DS_CLUSTER_NAME = "default";
private static final String DS_DASHBOARD_CONFIG_NAME = "odh-dashboard-config";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

@Tag("continuous")
public class DataScienceProjectIT extends Abstract {
static final Logger LOGGER = LoggerFactory.getLogger(DataScienceProjectIT.class);
public class DataScienceProjectST extends Abstract {
static final Logger LOGGER = LoggerFactory.getLogger(DataScienceProjectST.class);

MixedOperation<Notebook, KubernetesResourceList<Notebook>, Resource<Notebook>> notebookCli;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
*/
package io.odh.test.e2e.standard;

import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.odh.test.framework.manager.ResourceManager;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import io.opendatahub.datasciencecluster.v1.DataScienceClusterBuilder;
Expand All @@ -22,44 +18,21 @@
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.KserveBuilder;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Workbenches;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.WorkbenchesBuilder;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

@Tag("standard")
public class DataScienceClusterIT extends StandardAbstract {
@Tag("smoke")
public class DataScienceClusterST extends StandardAbstract {

private static final String DS_PROJECT_NAME = "test-dsp";
private static final String DS_PROJECT_NAMESPACE = "test-ns-ds";
MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceCluster>, Resource<DataScienceCluster>> cli;

@BeforeAll
void init() {
cli = ResourceManager.getClient().dataScienceClusterClient();
}

@AfterAll
void clean() {
cli.inNamespace(DS_PROJECT_NAMESPACE).withName(DS_PROJECT_NAME).delete();
ResourceManager.getClient().getClient().namespaces().withName(DS_PROJECT_NAMESPACE).delete();
}

@Test
void createDataScienceCluster() {
if (!ResourceManager.getClient().namespaceExists(DS_PROJECT_NAMESPACE)) {
ResourceManager.getClient().getClient()
.namespaces()
.resource(new NamespaceBuilder().withNewMetadata().withName(DS_PROJECT_NAMESPACE).endMetadata().build())
.create();
}

DataScienceCluster c = new DataScienceClusterBuilder()
.withNewMetadata()
.withName(DS_PROJECT_NAME)
.withNamespace(DS_PROJECT_NAMESPACE)
.endMetadata()
.withNewSpec()
.withComponents(
Expand All @@ -83,9 +56,9 @@ void createDataScienceCluster() {
.endSpec()
.build();

cli.resource(c).create();
ResourceManager.getInstance().createResourceWithWait(c);

DataScienceCluster cluster = cli.inNamespace(DS_PROJECT_NAMESPACE).withName(DS_PROJECT_NAME).get();
DataScienceCluster cluster = ResourceManager.getClient().dataScienceClusterClient().withName(DS_PROJECT_NAME).get();

assertEquals(Kserve.ManagementState.MANAGED, cluster.getSpec().getComponents().getKserve().getManagementState());
assertEquals(Codeflare.ManagementState.MANAGED, cluster.getSpec().getComponents().getCodeflare().getManagementState());
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/io/odh/test/e2e/standard/UpgradeST.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Skodjob authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.e2e.standard;

import org.junit.jupiter.api.Tag;

@Tag("upgrade")
public class UpgradeST extends StandardAbstract {
}
Loading