From 850296885b916aea1467a4b61157a9b79c0cbb38 Mon Sep 17 00:00:00 2001 From: David Kornel Date: Fri, 19 Jan 2024 19:32:27 +0100 Subject: [PATCH] Update suite unit test to try dsci and new builders in dsc (#72) --- src/test/java/io/odh/test/unit/UnitTests.java | 73 ++++++++++++++++--- 1 file changed, 64 insertions(+), 9 deletions(-) diff --git a/src/test/java/io/odh/test/unit/UnitTests.java b/src/test/java/io/odh/test/unit/UnitTests.java index edb7ba06..11e3eab4 100644 --- a/src/test/java/io/odh/test/unit/UnitTests.java +++ b/src/test/java/io/odh/test/unit/UnitTests.java @@ -15,9 +15,16 @@ import io.odh.test.framework.listeners.TestVisualSeparator; 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.Datasciencepipelines; +import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Kserve; +import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.Workbenches; +import io.opendatahub.datasciencecluster.v1.datascienceclusterspec.components.datasciencepipelines.devflags.ManifestsBuilder; +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.ControlPlane; import io.opendatahub.v1alpha.OdhDashboardConfig; import io.opendatahub.v1alpha.OdhDashboardConfigBuilder; import org.junit.jupiter.api.Tag; @@ -37,6 +44,41 @@ public class UnitTests implements TestVisualSeparator { private KubernetesMockServer server; + @Test + void testCreateDSCInitialization() { + MixedOperation, Resource> dsciClient = + kubernetesClient.resources(DSCInitialization.class); + + DSCInitialization dsci = new DSCInitializationBuilder() + .withNewMetadata() + .withName("default") + .endMetadata() + .withNewSpec() + .withApplicationsNamespace("opendatahub") + .withNewMonitoring() + .withNamespace("odh") + .withManagementState(Monitoring.ManagementState.MANAGED) + .endMonitoring() + .withNewServiceMesh() + .withNewControlPlane() + .withNamespace("istio") + .withName("istio") + .withMetricsCollection(ControlPlane.MetricsCollection.ISTIO) + .endControlPlane() + .endServiceMesh() + .endSpec() + .build(); + dsciClient.resource(dsci).create(); + + DSCInitialization returned = dsciClient.withName(dsci.getMetadata().getName()).get(); + + assertEquals("opendatahub", returned.getSpec().getApplicationsNamespace()); + + dsciClient.withName(dsci.getMetadata().getName()).delete(); + + assertNull(dsciClient.withName(dsci.getMetadata().getName()).get()); + } + @Test void testCreateDeleteDataScienceCluster() { MixedOperation, Resource> dsClient = @@ -47,13 +89,26 @@ void testCreateDeleteDataScienceCluster() { .withName("Test") .endMetadata() .withNewSpec() - .withComponents( - new ComponentsBuilder() - .withCodeflare( - new CodeflareBuilder() - .withManagementState(Codeflare.ManagementState.MANAGED) - .build()) - .build()) + .withNewComponents() + .withNewCodeflare() + .withManagementState(Codeflare.ManagementState.MANAGED) + .endCodeflare() + .withNewDashboard() + .withManagementState(Dashboard.ManagementState.MANAGED) + .endDashboard() + .withNewKserve() + .withManagementState(Kserve.ManagementState.REMOVED) + .endKserve() + .withNewWorkbenches() + .withManagementState(Workbenches.ManagementState.MANAGED) + .endWorkbenches() + .withNewDatasciencepipelines() + .withManagementState(Datasciencepipelines.ManagementState.MANAGED) + .withNewDevFlags() + .withManifests(new ManifestsBuilder().withUri("https://kornys.com").build()) + .endDatasciencepipelinesDevFlags() + .endDatasciencepipelines() + .endDatascienceclusterspecComponents() .endSpec() .build();