-
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
Signed-off-by: Jakub Stejskal <[email protected]>
- Loading branch information
Showing
15 changed files
with
573 additions
and
24 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
49 changes: 49 additions & 0 deletions
49
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,49 @@ | ||
/* | ||
* 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.framework.manager.ResourceManager; | ||
import io.odh.test.framework.manager.ResourceType; | ||
import io.opendatahub.datasciencecluster.v1.DataScienceCluster; | ||
|
||
public class DataScienceClusterResource implements ResourceType<DataScienceCluster> { | ||
@Override | ||
public String getKind() { | ||
return "DataScienceCluster"; | ||
} | ||
|
||
@Override | ||
public DataScienceCluster get(String namespace, String name) { | ||
return dataScienceCLusterClient().inNamespace(namespace).withName(name).get(); | ||
} | ||
|
||
@Override | ||
public void create(DataScienceCluster resource) { | ||
dataScienceCLusterClient().inNamespace(resource.getMetadata().getNamespace()).resource(resource).create(); | ||
} | ||
|
||
@Override | ||
public void delete(DataScienceCluster resource) { | ||
dataScienceCLusterClient().inNamespace(resource.getMetadata().getNamespace()).withName(resource.getMetadata().getName()).delete(); | ||
} | ||
|
||
@Override | ||
public void update(DataScienceCluster resource) { | ||
dataScienceCLusterClient().inNamespace(resource.getMetadata().getNamespace()).resource(resource).update(); | ||
} | ||
|
||
@Override | ||
public boolean waitForReadiness(DataScienceCluster resource) { | ||
return resource != null; | ||
} | ||
|
||
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
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 | ||
} |
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,37 @@ | ||
/* | ||
* 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.utils; | ||
|
||
import io.odh.test.TestConstants; | ||
import io.odh.test.TestUtils; | ||
import io.odh.test.framework.manager.ResourceManager; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.time.Duration; | ||
|
||
public class NamespaceUtils { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(NamespaceUtils.class); | ||
private static final long DELETION_TIMEOUT = Duration.ofMinutes(2).toMillis(); | ||
|
||
private NamespaceUtils() { } | ||
|
||
public static void waitForNamespaceReadiness(String name) { | ||
LOGGER.info("Waiting for Namespace: {} readiness", name); | ||
|
||
TestUtils.waitFor("Namespace: " + name, TestConstants.GLOBAL_POLL_INTERVAL_SHORT, DELETION_TIMEOUT, | ||
() -> ResourceManager.getClient().getNamespace(name) != null); | ||
LOGGER.info("Namespace: {} is ready", name); | ||
} | ||
|
||
public static void waitForNamespaceDeletion(String name) { | ||
LOGGER.info("Waiting for Namespace: {} deletion", name); | ||
|
||
TestUtils.waitFor("Namespace: " + name, TestConstants.GLOBAL_POLL_INTERVAL_SHORT, DELETION_TIMEOUT, | ||
() -> ResourceManager.getClient().getNamespace(name) == null); | ||
LOGGER.info("Namespace: {} was deleted", name); | ||
} | ||
} |
Oops, something went wrong.