-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for continuous AI testing + Init tests for CRUD AI (#11)
- Loading branch information
Showing
5 changed files
with
181 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.odh.test.platform; | ||
|
||
|
||
import io.opendatahub.datasciencecluster.v1.datascienceclusterstatus.Conditions; | ||
|
||
import java.util.List; | ||
|
||
public class KubeUtils { | ||
|
||
public static Conditions getDscConditionByType(List<Conditions> conditions, String type) { | ||
return conditions.stream().filter(c -> c.getType().equals(type)).findFirst().orElseGet(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/test/java/io/odh/test/e2e/continuous/DataScienceClusterIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* 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.TestConstants; | ||
import io.odh.test.e2e.Abstract; | ||
import io.odh.test.platform.KubeUtils; | ||
import io.opendatahub.datasciencecluster.v1.DataScienceCluster; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Codeflare; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Dashboard; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Datasciencepipelines; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Kserve; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Modelmeshserving; | ||
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 org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
public class DataScienceClusterIT extends Abstract { | ||
|
||
private final String DS_PROJECT_NAME = "default"; | ||
MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceCluster>, Resource<DataScienceCluster>> cli; | ||
|
||
@BeforeAll | ||
void init() { | ||
cli = kubeClient.dataScienceClusterClient(); | ||
} | ||
|
||
@Test | ||
void checkDataScienceClusterExists() { | ||
DataScienceCluster cluster = cli.inNamespace(TestConstants.ODH_NAMESPACE).withName(DS_PROJECT_NAME).get(); | ||
|
||
assertEquals(Kserve.ManagementState.MANAGED, cluster.getSpec().getComponents().getKserve().getManagementState()); | ||
assertEquals(Codeflare.ManagementState.MANAGED, cluster.getSpec().getComponents().getCodeflare().getManagementState()); | ||
assertEquals(Dashboard.ManagementState.MANAGED, cluster.getSpec().getComponents().getDashboard().getManagementState()); | ||
assertEquals(Ray.ManagementState.MANAGED, cluster.getSpec().getComponents().getRay().getManagementState()); | ||
assertEquals(Modelmeshserving.ManagementState.MANAGED, cluster.getSpec().getComponents().getModelmeshserving().getManagementState()); | ||
assertEquals(Datasciencepipelines.ManagementState.MANAGED, cluster.getSpec().getComponents().getDatasciencepipelines().getManagementState()); | ||
assertEquals(Trustyai.ManagementState.MANAGED, cluster.getSpec().getComponents().getTrustyai().getManagementState()); | ||
assertEquals(Workbenches.ManagementState.MANAGED, cluster.getSpec().getComponents().getWorkbenches().getManagementState()); | ||
} | ||
|
||
@Test | ||
void checkDataScienceClusterStatus() { | ||
DataScienceCluster cluster = cli.inNamespace(TestConstants.ODH_NAMESPACE).withName(DS_PROJECT_NAME).get(); | ||
|
||
assertEquals("Ready", cluster.getStatus().getPhase()); | ||
assertNull(cluster.getStatus().getErrorMessage()); | ||
|
||
assertEquals("True", KubeUtils.getDscConditionByType(cluster.getStatus().getConditions(), "dashboardReady").getStatus()); | ||
//assertEquals("True", KubeUtils.getDscConditionByType(cluster.getStatus().getConditions(), "workbenchesReady").getStatus()); | ||
//assertEquals("True", KubeUtils.getDscConditionByType(cluster.getStatus().getConditions(), "data-science-pipelines-operatorReady").getStatus()); | ||
//assertEquals("True", KubeUtils.getDscConditionByType(cluster.getStatus().getConditions(), "kserveReady").getStatus()); | ||
//assertEquals("True", KubeUtils.getDscConditionByType(cluster.getStatus().getConditions(), "codeflareReady").getStatus()); | ||
//assertEquals("True", KubeUtils.getDscConditionByType(cluster.getStatus().getConditions(), "model-meshReady").getStatus()); | ||
//assertEquals("True", KubeUtils.getDscConditionByType(cluster.getStatus().getConditions(), "trustyaiReady").getStatus()); | ||
} | ||
} |
43 changes: 0 additions & 43 deletions
43
src/test/java/io/odh/test/e2e/deployed/DataScienceClusterIT.java
This file was deleted.
Oops, something went wrong.
100 changes: 100 additions & 0 deletions
100
src/test/java/io/odh/test/e2e/standard/DataScienceClusterIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* 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.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.TestConstants; | ||
import io.odh.test.e2e.Abstract; | ||
import io.odh.test.platform.KubeUtils; | ||
import io.opendatahub.datasciencecluster.v1.DataScienceCluster; | ||
import io.opendatahub.datasciencecluster.v1.DataScienceClusterBuilder; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.ComponentsBuilder; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Codeflare; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.CodeflareBuilder; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Dashboard; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.DashboardBuilder; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Datasciencepipelines; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.DatasciencepipelinesBuilder; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Kserve; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.KserveBuilder; | ||
import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Modelmeshserving; | ||
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.datasciencecluster.v1.datascienceclusterspec.components.WorkbenchesBuilder; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
public class DataScienceClusterIT extends Abstract { | ||
|
||
private final String DS_PROJECT_NAME = "test-dsp"; | ||
private final String DS_PROJECT_NAMESPACE = "test-ns-ds"; | ||
MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceCluster>, Resource<DataScienceCluster>> cli; | ||
|
||
@BeforeAll | ||
void init() { | ||
cli = kubeClient.dataScienceClusterClient(); | ||
} | ||
|
||
@AfterAll | ||
void clean() { | ||
cli.inNamespace(DS_PROJECT_NAMESPACE).withName(DS_PROJECT_NAME).delete(); | ||
kubeClient.getClient().namespaces().withName(DS_PROJECT_NAMESPACE).delete(); | ||
} | ||
|
||
@Test | ||
void checkDataScienceClusterExists() { | ||
if (!kubeClient.namespaceExists(DS_PROJECT_NAMESPACE)) { | ||
kubeClient.getClient() | ||
.namespaces() | ||
.resource(new NamespaceBuilder().withNewMetadata().withName(DS_PROJECT_NAMESPACE).endMetadata().build()) | ||
.create(); | ||
} | ||
|
||
DataScienceCluster c = new DataScienceClusterBuilder() | ||
.withNewMetadata() | ||
.withName("test-dsp") | ||
.withNamespace("test-ns") | ||
.endMetadata() | ||
.withNewSpec() | ||
.withComponents( | ||
new ComponentsBuilder() | ||
.withWorkbenches( | ||
new WorkbenchesBuilder().withManagementState(Workbenches.ManagementState.MANAGED).build() | ||
) | ||
.withDashboard( | ||
new DashboardBuilder().withManagementState(Dashboard.ManagementState.MANAGED).build() | ||
) | ||
.withKserve( | ||
new KserveBuilder().withManagementState(Kserve.ManagementState.MANAGED).build() | ||
) | ||
.withCodeflare( | ||
new CodeflareBuilder().withManagementState(Codeflare.ManagementState.MANAGED).build() | ||
) | ||
.withDatasciencepipelines( | ||
new DatasciencepipelinesBuilder().withManagementState(Datasciencepipelines.ManagementState.MANAGED).build() | ||
) | ||
.build()) | ||
.endSpec() | ||
.build(); | ||
|
||
cli.resource(c).create(); | ||
|
||
DataScienceCluster cluster = cli.inNamespace(DS_PROJECT_NAMESPACE).withName(DS_PROJECT_NAME).get(); | ||
|
||
assertEquals(Kserve.ManagementState.MANAGED, cluster.getSpec().getComponents().getKserve().getManagementState()); | ||
assertEquals(Codeflare.ManagementState.MANAGED, cluster.getSpec().getComponents().getCodeflare().getManagementState()); | ||
assertEquals(Dashboard.ManagementState.MANAGED, cluster.getSpec().getComponents().getDashboard().getManagementState()); | ||
assertEquals(Datasciencepipelines.ManagementState.MANAGED, cluster.getSpec().getComponents().getDatasciencepipelines().getManagementState()); | ||
assertEquals(Workbenches.ManagementState.MANAGED, cluster.getSpec().getComponents().getWorkbenches().getManagementState()); | ||
} | ||
} |