diff --git a/src/main/java/io/odh/test/framework/TestSeparator.java b/src/main/java/io/odh/test/framework/TestSeparator.java index 005e14be..6dc65ff1 100644 --- a/src/main/java/io/odh/test/framework/TestSeparator.java +++ b/src/main/java/io/odh/test/framework/TestSeparator.java @@ -21,12 +21,14 @@ public interface TestSeparator { @BeforeEach default void beforeEachTest(ExtensionContext testContext) { LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR))); - LOGGER.info(String.format("%s.%s-STARTED", testContext.getRequiredTestClass().getName(), testContext.getRequiredTestMethod().getName())); + LOGGER.info(String.format("%s.%s-STARTED", testContext.getRequiredTestClass().getName(), + testContext.getDisplayName().replace("()", ""))); } @AfterEach default void afterEachTest(ExtensionContext testContext) { - LOGGER.info(String.format("%s.%s-FINISHED", testContext.getRequiredTestClass().getName(), testContext.getRequiredTestMethod().getName())); + LOGGER.info(String.format("%s.%s-FINISHED", testContext.getRequiredTestClass().getName(), + testContext.getDisplayName().replace("()", ""))); LOGGER.info(String.join("", Collections.nCopies(76, SEPARATOR_CHAR))); } } diff --git a/src/main/java/io/odh/test/platform/KubeUtils.java b/src/main/java/io/odh/test/platform/KubeUtils.java index 63a38eca..91e39e8a 100644 --- a/src/main/java/io/odh/test/platform/KubeUtils.java +++ b/src/main/java/io/odh/test/platform/KubeUtils.java @@ -4,13 +4,15 @@ */ 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) { + public static io.opendatahub.datasciencecluster.v1.datascienceclusterstatus.Conditions getDscConditionByType(List conditions, String type) { + return conditions.stream().filter(c -> c.getType().equals(type)).findFirst().orElseGet(null); + } + + public static org.kubeflow.v1.notebookstatus.Conditions getNotebookConditionByType(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/continuous/DataScienceProjectIT.java b/src/test/java/io/odh/test/e2e/continuous/DataScienceProjectIT.java index 66a3b0ba..c052d3ee 100644 --- a/src/test/java/io/odh/test/e2e/continuous/DataScienceProjectIT.java +++ b/src/test/java/io/odh/test/e2e/continuous/DataScienceProjectIT.java @@ -8,38 +8,58 @@ import io.fabric8.kubernetes.client.dsl.MixedOperation; import io.fabric8.kubernetes.client.dsl.Resource; import io.odh.test.e2e.Abstract; +import io.odh.test.framework.TestSeparator; +import io.odh.test.platform.KubeUtils; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; import org.kubeflow.v1.Notebook; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.stream.Stream; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @Tag("continuous") public class DataScienceProjectIT extends Abstract { + static final Logger LOGGER = LoggerFactory.getLogger(TestSeparator.class); - private static final String DS_PROJECT_NAME = "test"; - private static final String DS_WORKBENCH_NAME = "test-workbench"; MixedOperation, Resource> notebookCli; + private static Stream getDsProjects() { + return Stream.of( + Arguments.of("project-sammons"), + Arguments.of("project-hughie"), + Arguments.of("project-homelander") + ); + } + @BeforeAll void init() { notebookCli = kubeClient.notebookClient(); } - @Test - void checkDataScienceProject() { - assertTrue(kubeClient.namespaceExists(DS_PROJECT_NAME)); + @ParameterizedTest(name = "checkDataScienceProjects-{0}") + @MethodSource("getDsProjects") + void checkDataScienceProjects(String dsProjectName) { + assertTrue(kubeClient.namespaceExists(dsProjectName)); assertEquals("true", - kubeClient.getNamespace(DS_PROJECT_NAME).getMetadata().getLabels().getOrDefault("opendatahub.io/dashboard", "false")); + kubeClient.getNamespace(dsProjectName).getMetadata().getLabels().getOrDefault("opendatahub.io/dashboard", "false")); - Notebook testWorkbench = notebookCli.inNamespace(DS_PROJECT_NAME).withName(DS_WORKBENCH_NAME).get(); + notebookCli.inNamespace(dsProjectName).list().getItems().forEach(notebook -> { + LOGGER.info("Found notebook {} in datascience project {}", notebook.getMetadata().getName(), dsProjectName); + assertEquals("true", + notebook.getMetadata().getLabels().getOrDefault("opendatahub.io/dashboard", "false")); + assertEquals("true", + notebook.getMetadata().getLabels().getOrDefault("opendatahub.io/odh-managed", "false")); - assertEquals("true", - testWorkbench.getMetadata().getLabels().getOrDefault("opendatahub.io/dashboard", "false")); - assertEquals("true", - testWorkbench.getMetadata().getLabels().getOrDefault("opendatahub.io/odh-managed", "false")); + assertEquals("True", KubeUtils.getNotebookConditionByType(notebook.getStatus().getConditions(), "ContainersReady").getStatus()); + assertEquals("True", KubeUtils.getNotebookConditionByType(notebook.getStatus().getConditions(), "Ready").getStatus()); + }); } }