diff --git a/src/main/java/io/odh/test/platform/KubeUtils.java b/src/main/java/io/odh/test/platform/KubeUtils.java new file mode 100644 index 00000000..499fd3c9 --- /dev/null +++ b/src/main/java/io/odh/test/platform/KubeUtils.java @@ -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, String type) { + return conditions.stream().filter(c -> c.getType().equals(type)).findFirst().orElseGet(null); + } +} diff --git a/src/test/java/io/odh/test/e2e/Abstract.java b/src/test/java/io/odh/test/e2e/Abstract.java index 71b2d45a..b049b0cf 100644 --- a/src/test/java/io/odh/test/e2e/Abstract.java +++ b/src/test/java/io/odh/test/e2e/Abstract.java @@ -12,10 +12,6 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class Abstract implements TestSeparator { - protected KubeClient kubeClient; + protected KubeClient kubeClient = new KubeClient(TestConstants.ODH_NAMESPACE); - @BeforeAll - void init() { - kubeClient = new KubeClient(TestConstants.ODH_NAMESPACE); - } } diff --git a/src/test/java/io/odh/test/e2e/continuous/DataScienceClusterIT.java b/src/test/java/io/odh/test/e2e/continuous/DataScienceClusterIT.java new file mode 100644 index 00000000..4b9e2474 --- /dev/null +++ b/src/test/java/io/odh/test/e2e/continuous/DataScienceClusterIT.java @@ -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, Resource> 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()); + } +} diff --git a/src/test/java/io/odh/test/e2e/deployed/DataScienceClusterIT.java b/src/test/java/io/odh/test/e2e/deployed/DataScienceClusterIT.java deleted file mode 100644 index 74e736de..00000000 --- a/src/test/java/io/odh/test/e2e/deployed/DataScienceClusterIT.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.deployed; - -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.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.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class DataScienceClusterIT extends Abstract { - - @Test - void checkDataScienceClusterExists() { - MixedOperation, Resource> cli = - kubeClient.dataScienceClusterClient(); - - DataScienceCluster cluster = cli.inNamespace(TestConstants.ODH_NAMESPACE).withName("default").get(); - - assertEquals(cluster.getSpec().getComponents().getKserve().getManagementState(), Kserve.ManagementState.MANAGED); - assertEquals(cluster.getSpec().getComponents().getCodeflare().getManagementState(), Codeflare.ManagementState.MANAGED); - assertEquals(cluster.getSpec().getComponents().getDashboard().getManagementState(), Dashboard.ManagementState.MANAGED); - assertEquals(cluster.getSpec().getComponents().getRay().getManagementState(), Ray.ManagementState.MANAGED); - assertEquals(cluster.getSpec().getComponents().getModelmeshserving().getManagementState(), Modelmeshserving.ManagementState.MANAGED); - assertEquals(cluster.getSpec().getComponents().getDatasciencepipelines().getManagementState(), Datasciencepipelines.ManagementState.MANAGED); - assertEquals(cluster.getSpec().getComponents().getTrustyai().getManagementState(), Trustyai.ManagementState.MANAGED); - assertEquals(cluster.getSpec().getComponents().getWorkbenches().getManagementState(), Workbenches.ManagementState.MANAGED); - } -} diff --git a/src/test/java/io/odh/test/e2e/standard/DataScienceClusterIT.java b/src/test/java/io/odh/test/e2e/standard/DataScienceClusterIT.java new file mode 100644 index 00000000..992724ba --- /dev/null +++ b/src/test/java/io/odh/test/e2e/standard/DataScienceClusterIT.java @@ -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, Resource> 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()); + } +}