-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Notebooks to create them in tests (#28)
Signed-off-by: Jakub Stejskal <[email protected]>
- Loading branch information
Showing
21 changed files
with
666 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* 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; | ||
|
||
public class OdhAnnotationsLabels { | ||
public static final String OPENSHIFT_DOMAIN = "openshift.io/"; | ||
public static final String ODH_DOMAIN = "opendatahub.io/"; | ||
|
||
public static final String LABEL_DASHBOARD = ODH_DOMAIN + "dashboard"; | ||
public static final String LABEL_ODH_MANAGED = ODH_DOMAIN + "odh-managed"; | ||
public static final String LABEL_SIDECAR_ISTIO_INJECT = "sidecar.istio.io/inject"; | ||
|
||
public static final String ANNO_SERVICE_MESH = ODH_DOMAIN + "service-mesh"; | ||
public static final String ANNO_NTB_INJECT_OAUTH = "notebooks." + ODH_DOMAIN + "inject-oauth"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/io/odh/test/framework/manager/resources/DataScienceClusterResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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.odh.test.platform.KubeUtils; | ||
import io.opendatahub.datasciencecluster.v1.DataScienceCluster; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class DataScienceClusterResource implements ResourceType<DataScienceCluster> { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(DataScienceClusterResource.class); | ||
@Override | ||
public String getKind() { | ||
return "DataScienceCluster"; | ||
} | ||
|
||
@Override | ||
public DataScienceCluster get(String namespace, String name) { | ||
return dataScienceCLusterClient().withName(name).get(); | ||
} | ||
|
||
@Override | ||
public void create(DataScienceCluster resource) { | ||
dataScienceCLusterClient().resource(resource).create(); | ||
} | ||
|
||
@Override | ||
public void delete(DataScienceCluster resource) { | ||
dataScienceCLusterClient().withName(resource.getMetadata().getName()).delete(); | ||
} | ||
|
||
@Override | ||
public void update(DataScienceCluster resource) { | ||
dataScienceCLusterClient().resource(resource).update(); | ||
} | ||
|
||
@Override | ||
public boolean waitForReadiness(DataScienceCluster resource) { | ||
String message = String.format("DataScienceCluster %s readiness", resource.getMetadata().getName()); | ||
TestUtils.waitFor(message, TestConstants.GLOBAL_POLL_INTERVAL_SHORT, TestConstants.GLOBAL_TIMEOUT, () -> { | ||
boolean dscReady; | ||
|
||
DataScienceCluster dsc = dataScienceCLusterClient().withName(resource.getMetadata().getName()).get(); | ||
|
||
String dashboardStatus = KubeUtils.getDscConditionByType(dsc.getStatus().getConditions(), "dashboardReady").getStatus(); | ||
LOGGER.debug("DataScienceCluster {} dashboard status: {}", resource.getMetadata().getName(), dashboardStatus); | ||
dscReady = dashboardStatus.equals("True"); | ||
|
||
String workbenchesStatus = KubeUtils.getDscConditionByType(dsc.getStatus().getConditions(), "workbenchesReady").getStatus(); | ||
LOGGER.debug("DataScienceCluster {} workbenches status: {}", resource.getMetadata().getName(), workbenchesStatus); | ||
dscReady = dscReady && workbenchesStatus.equals("True"); | ||
|
||
return dscReady; | ||
}, () -> { }); | ||
return true; | ||
} | ||
|
||
public static MixedOperation<DataScienceCluster, KubernetesResourceList<DataScienceCluster>, Resource<DataScienceCluster>> dataScienceCLusterClient() { | ||
return ResourceManager.getClient().getClient().resources(DataScienceCluster.class); | ||
} | ||
|
||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/io/odh/test/framework/manager/resources/NotebookResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.TestUtils; | ||
import io.odh.test.framework.manager.ResourceManager; | ||
import io.odh.test.framework.manager.ResourceType; | ||
import org.kubeflow.v1.Notebook; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import org.apache.commons.io.IOUtils; | ||
|
||
|
||
public class NotebookResource implements ResourceType<Notebook> { | ||
|
||
private static final String NOTEBOOK_TEMPLATE_PATH = "notebook.yaml"; | ||
@Override | ||
public String getKind() { | ||
return "Notebook"; | ||
} | ||
|
||
@Override | ||
public Notebook get(String namespace, String name) { | ||
return notebookClient().inNamespace(namespace).withName(name).get(); | ||
} | ||
|
||
@Override | ||
public void create(Notebook resource) { | ||
notebookClient().inNamespace(resource.getMetadata().getNamespace()).resource(resource).create(); | ||
} | ||
|
||
@Override | ||
public void delete(Notebook resource) { | ||
notebookClient().inNamespace(resource.getMetadata().getNamespace()).withName(resource.getMetadata().getName()).delete(); | ||
} | ||
|
||
@Override | ||
public void update(Notebook resource) { | ||
notebookClient().inNamespace(resource.getMetadata().getNamespace()).resource(resource).update(); | ||
} | ||
|
||
@Override | ||
public boolean waitForReadiness(Notebook resource) { | ||
return resource != null; | ||
} | ||
|
||
public static MixedOperation<Notebook, KubernetesResourceList<Notebook>, Resource<Notebook>> notebookClient() { | ||
return ResourceManager.getClient().getClient().resources(Notebook.class); | ||
} | ||
|
||
public static Notebook loadDefaultNotebook(String namespace, String name) throws IOException { | ||
InputStream is = TestUtils.getFileFromResourceAsStream(NOTEBOOK_TEMPLATE_PATH); | ||
String notebookString = IOUtils.toString(is, "UTF-8"); | ||
notebookString = notebookString.replace("my-project", namespace).replace("my-workbench", name); | ||
return TestUtils.configFromYaml(notebookString, Notebook.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* 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.install; | ||
|
||
public enum InstallTypes { | ||
OLM, | ||
BUNDLE | ||
} |
Oops, something went wrong.