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 continuous test for check odh project stats + refactor tests #16

Merged
merged 1 commit into from
Nov 21, 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
9 changes: 9 additions & 0 deletions src/main/java/io/odh/test/platform/KubeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import io.fabric8.openshift.client.OpenShiftClient;
import io.odh.test.Environment;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import io.opendatahub.v1alpha.OdhDashboardConfig;
import org.kubeflow.v1.Notebook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -301,5 +303,12 @@ public MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceClus
return client.resources(DataScienceCluster.class);
}

public MixedOperation<OdhDashboardConfig, KubernetesResourceList<OdhDashboardConfig>, Resource<OdhDashboardConfig>> dashboardConfigClient() {
return client.resources(OdhDashboardConfig.class);
}

public MixedOperation<Notebook, KubernetesResourceList<Notebook>, Resource<Notebook>> notebookClient() {
return client.resources(Notebook.class);
}
}

31 changes: 26 additions & 5 deletions src/test/java/io/odh/test/e2e/continuous/DataScienceClusterIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,33 @@
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Ray;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Trustyai;
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Workbenches;
import io.opendatahub.v1alpha.OdhDashboardConfig;
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;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

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

private final String DS_PROJECT_NAME = "default";
MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceCluster>, Resource<DataScienceCluster>> cli;
private final String DS_CLUSTER_NAME = "default";
private final String DS_DASHBOARD_CONFIG_NAME = "odh-dashboard-config";
MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceCluster>, Resource<DataScienceCluster>> dataScienceProjectCli;
MixedOperation<OdhDashboardConfig, KubernetesResourceList<OdhDashboardConfig>, Resource<OdhDashboardConfig>> dashboardConfigCli;

@BeforeAll
void init() {
cli = kubeClient.dataScienceClusterClient();
dataScienceProjectCli = kubeClient.dataScienceClusterClient();
dashboardConfigCli = kubeClient.dashboardConfigClient();
}

@Test
void checkDataScienceClusterExists() {
DataScienceCluster cluster = cli.inNamespace(TestConstants.ODH_NAMESPACE).withName(DS_PROJECT_NAME).get();
DataScienceCluster cluster = dataScienceProjectCli.inNamespace(TestConstants.ODH_NAMESPACE).withName(DS_CLUSTER_NAME).get();

assertEquals(Kserve.ManagementState.MANAGED, cluster.getSpec().getComponents().getKserve().getManagementState());
assertEquals(Codeflare.ManagementState.MANAGED, cluster.getSpec().getComponents().getCodeflare().getManagementState());
Expand All @@ -53,7 +59,7 @@ void checkDataScienceClusterExists() {

@Test
void checkDataScienceClusterStatus() {
DataScienceCluster cluster = cli.inNamespace(TestConstants.ODH_NAMESPACE).withName(DS_PROJECT_NAME).get();
DataScienceCluster cluster = dataScienceProjectCli.inNamespace(TestConstants.ODH_NAMESPACE).withName(DS_CLUSTER_NAME).get();

assertEquals("Ready", cluster.getStatus().getPhase());
assertNull(cluster.getStatus().getErrorMessage());
Expand All @@ -67,4 +73,19 @@ void checkDataScienceClusterStatus() {
//assertEquals("True", KubeUtils.getDscConditionByType(cluster.getStatus().getConditions(), "model-meshReady").getStatus());
//assertEquals("True", KubeUtils.getDscConditionByType(cluster.getStatus().getConditions(), "trustyaiReady").getStatus());
}

@Test
void checkDataScienceDashboard() {
OdhDashboardConfig dashboard = dashboardConfigCli.inNamespace(TestConstants.ODH_NAMESPACE).withName(DS_DASHBOARD_CONFIG_NAME).get();

assertTrue(dashboard.getSpec().getNotebookController().getEnabled());

assertFalse(dashboard.getSpec().getDashboardConfig().getDisableInfo());
assertFalse(dashboard.getSpec().getDashboardConfig().getDisableBiasMetrics());
assertFalse(dashboard.getSpec().getDashboardConfig().getDisableClusterManager());
assertFalse(dashboard.getSpec().getDashboardConfig().getDisableCustomServingRuntimes());
assertFalse(dashboard.getSpec().getDashboardConfig().getDisableKServe());
assertFalse(dashboard.getSpec().getDashboardConfig().getDisablePipelines());
assertFalse(dashboard.getSpec().getDashboardConfig().getDisableProjects());
}
}
45 changes: 45 additions & 0 deletions src/test/java/io/odh/test/e2e/continuous/DataScienceProjectIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright Tealc authors.
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
package io.odh.test.e2e.continuous;

import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.odh.test.e2e.Abstract;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.kubeflow.v1.Notebook;

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

@Tag("continuous")
public class DataScienceProjectIT extends Abstract {

private final String DS_PROJECT_NAME = "test";
private final String DS_WORKBENCH_NAME = "test-workbench";
MixedOperation<Notebook, KubernetesResourceList<Notebook>, Resource<Notebook>> notebookCli;

@BeforeAll
void init() {
notebookCli = kubeClient.notebookClient();
}

@Test
void checkDataScienceProject() {
assertTrue(kubeClient.namespaceExists(DS_PROJECT_NAME));

assertEquals("true",
kubeClient.getNamespace(DS_PROJECT_NAME).getMetadata().getLabels().getOrDefault("opendatahub.io/dashboard", "false"));

Notebook testWorkbench = notebookCli.inNamespace(DS_PROJECT_NAME).withName(DS_WORKBENCH_NAME).get();

assertEquals("true",
testWorkbench.getMetadata().getLabels().getOrDefault("opendatahub.io/dashboard", "false"));
assertEquals("true",
testWorkbench.getMetadata().getLabels().getOrDefault("opendatahub.io/odh-managed", "false"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void clean() {
}

@Test
void checkDataScienceClusterExists() {
void createDataScienceCluster() {
if (!kubeClient.namespaceExists(DS_PROJECT_NAMESPACE)) {
kubeClient.getClient()
.namespaces()
Expand Down