diff --git a/.checkstyle/checkstyle.xml b/.checkstyle/checkstyle.xml index 3fda23dd..648ab007 100644 --- a/.checkstyle/checkstyle.xml +++ b/.checkstyle/checkstyle.xml @@ -97,7 +97,7 @@ - + diff --git a/src/main/java/io/odh/test/framework/manager/ResourceManager.java b/src/main/java/io/odh/test/framework/manager/ResourceManager.java index 76cefde8..a37fac82 100644 --- a/src/main/java/io/odh/test/framework/manager/ResourceManager.java +++ b/src/main/java/io/odh/test/framework/manager/ResourceManager.java @@ -14,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.DataScienceInitializationResource; import io.odh.test.framework.manager.resources.NamespaceResource; import io.odh.test.framework.manager.resources.NotebookResource; import io.odh.test.framework.manager.resources.OperatorGroupResource; @@ -23,6 +24,7 @@ import io.odh.test.platform.cmdClient.Oc; import io.odh.test.utils.DeploymentUtils; import io.opendatahub.datasciencecluster.v1.DataScienceCluster; +import io.opendatahub.dscinitialization.v1.DSCInitialization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -66,6 +68,7 @@ public static KubeCmdClient getKubeCmdClient() { new SubscriptionResource(), new OperatorGroupResource(), new DataScienceClusterResource(), + new DataScienceInitializationResource(), new NotebookResource(), }; @@ -199,7 +202,8 @@ public final boolean waitResourceCondition(T resource, R // 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 || resource instanceof Namespace)) { + || resource instanceof DataScienceCluster || resource instanceof Namespace + || resource instanceof DSCInitialization)) { assertNotNull(resource.getMetadata().getNamespace()); } diff --git a/src/main/java/io/odh/test/framework/manager/resources/DataScienceClusterResource.java b/src/main/java/io/odh/test/framework/manager/resources/DataScienceClusterResource.java index 7428a9e3..a0cc095f 100644 --- a/src/main/java/io/odh/test/framework/manager/resources/DataScienceClusterResource.java +++ b/src/main/java/io/odh/test/framework/manager/resources/DataScienceClusterResource.java @@ -68,8 +68,8 @@ public boolean waitForReadiness(DataScienceCluster resource) { String namespace = OdhConstants.CONTROLLERS_NAMESPACE; LOGGER.info("Waiting for pods readiness in {}", namespace); PodUtils.waitForPodsReady(namespace, true, () -> { - ResourceManager.getKubeCmdClient().namespace(namespace).exec(false, "oc", "get", "pods"); - ResourceManager.getKubeCmdClient().namespace(namespace).exec(false, "oc", "get", "events"); + ResourceManager.getKubeCmdClient().namespace(namespace).exec(false, "get", "pods"); + ResourceManager.getKubeCmdClient().namespace(namespace).exec(false, "get", "events"); }); return true; diff --git a/src/main/java/io/odh/test/framework/manager/resources/DataScienceInitializationResource.java b/src/main/java/io/odh/test/framework/manager/resources/DataScienceInitializationResource.java new file mode 100644 index 00000000..897730dc --- /dev/null +++ b/src/main/java/io/odh/test/framework/manager/resources/DataScienceInitializationResource.java @@ -0,0 +1,63 @@ +/* + * 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.KubernetesResourceList; +import io.fabric8.kubernetes.client.dsl.MixedOperation; +import io.fabric8.kubernetes.client.dsl.Resource; +import io.odh.test.TestConstants; +import io.odh.test.TestUtils; +import io.odh.test.framework.manager.ResourceManager; +import io.odh.test.framework.manager.ResourceType; +import io.opendatahub.dscinitialization.v1.DSCInitialization; + +public class DataScienceInitializationResource implements ResourceType { + + @Override + public String getKind() { + return "DSCInitialization"; + } + + @Override + public DSCInitialization get(String namespace, String name) { + return dsciClient().withName(name).get(); + } + + @Override + public void create(DSCInitialization resource) { + dsciClient().resource(resource).create(); + } + + @Override + public void delete(DSCInitialization resource) { + dsciClient().withName(resource.getMetadata().getName()).delete(); + } + + @Override + public void update(DSCInitialization resource) { + dsciClient().resource(resource).update(); + } + + @Override + public boolean waitForReadiness(DSCInitialization resource) { + String message = String.format("DataScienceCluster %s readiness", resource.getMetadata().getName()); + TestUtils.waitFor(message, TestConstants.GLOBAL_POLL_INTERVAL_SHORT, TestConstants.GLOBAL_TIMEOUT, () -> { + boolean dsciReady; + + DSCInitialization dsci = dsciClient().withName(resource.getMetadata().getName()).get(); + + dsciReady = dsci.getStatus().getPhase().equals("Ready"); + + return dsciReady; + }, () -> { + }); + return true; + } + + public static MixedOperation, Resource> dsciClient() { + return ResourceManager.getClient().getClient().resources(DSCInitialization.class); + } + +} diff --git a/src/test/java/io/odh/test/e2e/standard/DataScienceClusterST.java b/src/test/java/io/odh/test/e2e/standard/DataScienceClusterST.java index 218dcf3e..b343ca7c 100644 --- a/src/test/java/io/odh/test/e2e/standard/DataScienceClusterST.java +++ b/src/test/java/io/odh/test/e2e/standard/DataScienceClusterST.java @@ -4,6 +4,7 @@ */ package io.odh.test.e2e.standard; +import io.odh.test.OdhConstants; import io.odh.test.TestSuite; import io.odh.test.framework.manager.ResourceManager; import io.odh.test.framework.manager.resources.DataScienceClusterResource; @@ -20,6 +21,11 @@ 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 io.opendatahub.dscinitialization.v1.DSCInitialization; +import io.opendatahub.dscinitialization.v1.DSCInitializationBuilder; +import io.opendatahub.dscinitialization.v1.dscinitializationspec.Monitoring; +import io.opendatahub.dscinitialization.v1.dscinitializationspec.ServiceMesh; +import io.opendatahub.dscinitialization.v1.dscinitializationspec.servicemesh.ControlPlane; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -32,6 +38,27 @@ public class DataScienceClusterST extends StandardAbstract { @Test void createDataScienceCluster() { + DSCInitialization dsci = new DSCInitializationBuilder() + .withNewMetadata() + .withName("default-dsci") + .endMetadata() + .withNewSpec() + .withApplicationsNamespace(OdhConstants.CONTROLLERS_NAMESPACE) + .withNewMonitoring() + .withManagementState(Monitoring.ManagementState.MANAGED) + .withNamespace(OdhConstants.CONTROLLERS_NAMESPACE) + .endMonitoring() + .withNewServiceMesh() + .withManagementState(ServiceMesh.ManagementState.REMOVED) + .withNewControlPlane() + .withName("data-science-smcp") + .withNamespace("istio-system") + .withMetricsCollection(ControlPlane.MetricsCollection.ISTIO) + .endControlPlane() + .endServiceMesh() + .endSpec() + .build(); + DataScienceCluster c = new DataScienceClusterBuilder() .withNewMetadata() .withName(DS_PROJECT_NAME) @@ -58,6 +85,8 @@ void createDataScienceCluster() { .endSpec() .build(); + + ResourceManager.getInstance().createResourceWithWait(dsci); ResourceManager.getInstance().createResourceWithWait(c); DataScienceCluster cluster = DataScienceClusterResource.dataScienceCLusterClient().withName(DS_PROJECT_NAME).get(); diff --git a/src/test/java/io/odh/test/e2e/standard/NotebookST.java b/src/test/java/io/odh/test/e2e/standard/NotebookST.java index d755866a..50e3d49f 100644 --- a/src/test/java/io/odh/test/e2e/standard/NotebookST.java +++ b/src/test/java/io/odh/test/e2e/standard/NotebookST.java @@ -12,6 +12,7 @@ import io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder; import io.fabric8.kubernetes.api.model.Quantity; import io.odh.test.OdhAnnotationsLabels; +import io.odh.test.OdhConstants; import io.odh.test.framework.manager.ResourceManager; import io.odh.test.framework.manager.resources.NotebookResource; import io.odh.test.utils.PodUtils; @@ -28,6 +29,11 @@ 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 io.opendatahub.dscinitialization.v1.DSCInitialization; +import io.opendatahub.dscinitialization.v1.DSCInitializationBuilder; +import io.opendatahub.dscinitialization.v1.dscinitializationspec.Monitoring; +import io.opendatahub.dscinitialization.v1.dscinitializationspec.ServiceMesh; +import io.opendatahub.dscinitialization.v1.dscinitializationspec.servicemesh.ControlPlane; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.kubeflow.v1.Notebook; @@ -84,6 +90,28 @@ void testCreateSimpleNotebook() throws IOException { @BeforeAll void deployDataScienceCluster() { + // Create DSCI + DSCInitialization dsci = new DSCInitializationBuilder() + .withNewMetadata() + .withName("default-dsci") + .endMetadata() + .withNewSpec() + .withApplicationsNamespace(OdhConstants.CONTROLLERS_NAMESPACE) + .withNewMonitoring() + .withManagementState(Monitoring.ManagementState.MANAGED) + .withNamespace(OdhConstants.CONTROLLERS_NAMESPACE) + .endMonitoring() + .withNewServiceMesh() + .withManagementState(ServiceMesh.ManagementState.REMOVED) + .withNewControlPlane() + .withName("data-science-smcp") + .withNamespace("istio-system") + .withMetricsCollection(ControlPlane.MetricsCollection.ISTIO) + .endControlPlane() + .endServiceMesh() + .endSpec() + .build(); + // Create DSC DataScienceCluster dsc = new DataScienceClusterBuilder() .withNewMetadata() @@ -110,7 +138,8 @@ void deployDataScienceCluster() { .build()) .endSpec() .build(); - // Deploy DSC + // Deploy DSCI,DSC + ResourceManager.getInstance().createResourceWithWait(dsci); ResourceManager.getInstance().createResourceWithWait(dsc); } } diff --git a/src/test/java/io/odh/test/e2e/upgrade/UpgradeAbstract.java b/src/test/java/io/odh/test/e2e/upgrade/UpgradeAbstract.java index 7d107e08..9f1cb9a6 100644 --- a/src/test/java/io/odh/test/e2e/upgrade/UpgradeAbstract.java +++ b/src/test/java/io/odh/test/e2e/upgrade/UpgradeAbstract.java @@ -11,6 +11,7 @@ import io.fabric8.kubernetes.api.model.Quantity; import io.odh.test.Environment; import io.odh.test.OdhAnnotationsLabels; +import io.odh.test.OdhConstants; import io.odh.test.TestSuite; import io.odh.test.e2e.Abstract; import io.odh.test.framework.listeners.OdhResourceCleaner; @@ -32,6 +33,11 @@ import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.ModelmeshservingBuilder; import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Workbenches; import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.WorkbenchesBuilder; +import io.opendatahub.dscinitialization.v1.DSCInitialization; +import io.opendatahub.dscinitialization.v1.DSCInitializationBuilder; +import io.opendatahub.dscinitialization.v1.dscinitializationspec.Monitoring; +import io.opendatahub.dscinitialization.v1.dscinitializationspec.ServiceMesh; +import io.opendatahub.dscinitialization.v1.dscinitializationspec.servicemesh.ControlPlane; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.extension.ExtendWith; import org.kubeflow.v1.Notebook; @@ -46,6 +52,27 @@ public abstract class UpgradeAbstract extends Abstract { protected void deployDsc(String name) { + DSCInitialization dsci = new DSCInitializationBuilder() + .withNewMetadata() + .withName("default-dsci") + .endMetadata() + .withNewSpec() + .withApplicationsNamespace(OdhConstants.CONTROLLERS_NAMESPACE) + .withNewMonitoring() + .withManagementState(Monitoring.ManagementState.MANAGED) + .withNamespace(OdhConstants.CONTROLLERS_NAMESPACE) + .endMonitoring() + .withNewServiceMesh() + .withManagementState(ServiceMesh.ManagementState.REMOVED) + .withNewControlPlane() + .withName("data-science-smcp") + .withNamespace("istio-system") + .withMetricsCollection(ControlPlane.MetricsCollection.ISTIO) + .endControlPlane() + .endServiceMesh() + .endSpec() + .build(); + // Deploy DSC DataScienceCluster dsc = new DataScienceClusterBuilder() .withNewMetadata() @@ -76,6 +103,7 @@ protected void deployDsc(String name) { .endSpec() .build(); // Deploy DSC + ResourceManager.getInstance().createResourceWithWait(dsci); ResourceManager.getInstance().createResourceWithWait(dsc); } public void deployNotebook(String namespace, String name) throws IOException {