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

Parametrized test check All notebook status for all DS project #21

Merged
merged 1 commit into from
Dec 4, 2023
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
6 changes: 4 additions & 2 deletions src/main/java/io/odh/test/framework/TestSeparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
}
8 changes: 5 additions & 3 deletions src/main/java/io/odh/test/platform/KubeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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> conditions, String type) {
public static io.opendatahub.datasciencecluster.v1.datascienceclusterstatus.Conditions getDscConditionByType(List<io.opendatahub.datasciencecluster.v1.datascienceclusterstatus.Conditions> conditions, String type) {
return conditions.stream().filter(c -> c.getType().equals(type)).findFirst().orElseGet(null);
}

public static org.kubeflow.v1.notebookstatus.Conditions getNotebookConditionByType(List<org.kubeflow.v1.notebookstatus.Conditions> conditions, String type) {
return conditions.stream().filter(c -> c.getType().equals(type)).findFirst().orElseGet(null);
}

Expand Down
44 changes: 32 additions & 12 deletions src/test/java/io/odh/test/e2e/continuous/DataScienceProjectIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Notebook, KubernetesResourceList<Notebook>, Resource<Notebook>> notebookCli;

private static Stream<Arguments> 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());
});
}
}
Loading