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

Deploy DSCI as it is not created automatically #66

Merged
merged 1 commit into from
Jan 17, 2024
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
2 changes: 1 addition & 1 deletion .checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</module>
<module name="BooleanExpressionComplexity">
<!-- default is 3 -->
<property name="max" value="5"/>
<property name="max" value="7"/>
</module>

<module name="ClassFanOutComplexity">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -66,6 +68,7 @@ public static KubeCmdClient getKubeCmdClient() {
new SubscriptionResource(),
new OperatorGroupResource(),
new DataScienceClusterResource(),
new DataScienceInitializationResource(),
new NotebookResource(),
};

Expand Down Expand Up @@ -199,7 +202,8 @@ public final <T extends HasMetadata> 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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<DSCInitialization> {

@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<DSCInitialization, KubernetesResourceList<DSCInitialization>, Resource<DSCInitialization>> dsciClient() {
return ResourceManager.getClient().getClient().resources(DSCInitialization.class);
}

}
29 changes: 29 additions & 0 deletions src/test/java/io/odh/test/e2e/standard/DataScienceClusterST.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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)
Expand All @@ -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();
Expand Down
31 changes: 30 additions & 1 deletion src/test/java/io/odh/test/e2e/standard/NotebookST.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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()
Expand All @@ -110,7 +138,8 @@ void deployDataScienceCluster() {
.build())
.endSpec()
.build();
// Deploy DSC
// Deploy DSCI,DSC
ResourceManager.getInstance().createResourceWithWait(dsci);
ResourceManager.getInstance().createResourceWithWait(dsc);
}
}
28 changes: 28 additions & 0 deletions src/test/java/io/odh/test/e2e/upgrade/UpgradeAbstract.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
Loading