Skip to content

Commit

Permalink
MInor improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Stejskal <[email protected]>
  • Loading branch information
Frawless committed Jan 30, 2024
1 parent 1d7a115 commit 2b0e99a
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 37 deletions.
10 changes: 10 additions & 0 deletions src/main/java/io/odh/test/TestConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class TestConstants {
public static final String SUBSCRIPTION = "Subscription";
public static final String OPERATOR_GROUP = "OperatorGroup";

public static final String APPROVAL_AUTOMATIC = "Automatic";
public static final String APPROVAL_MANUAL = "Manual";

public static final String LATEST_BUNDLE_DEPLOY_FILE = "install-files/latest.yaml";
public static final String RELEASED_BUNDLE_DEPLOY_FILE = "install-files/released.yaml";

Expand All @@ -23,6 +26,13 @@ public class TestConstants {
public static final long GLOBAL_STABILITY_TIME = Duration.ofMinutes(1).toSeconds();
public static final String LOG_COLLECT_LABEL = "io.odh-e2e.collect-logs";

// OLM Constants
public static final String OPENSHIFT_MARKETPLACE_NS = "openshift-marketplace";
public static final String OPENSHIFT_OPERATORS_NS = "openshift-operators";
public static final String REDHAT_CATALOG = "redhat-operators";
public static final String CHANNEL_STABLE = "stable";
public static final String CHANNEL_LATEST = "latest";

private TestConstants() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,14 @@ private <T extends HasMetadata> void createResource(boolean waitReady, T... reso
} else {
client.getClient().resource(resource).create();
}

}
} else {
type.create(resource);
if (client.getClient().resource(resource).get() != null) {
type.update(resource);
} else {
type.create(resource);
}

if (waitReady) {
assertTrue(waitResourceCondition(resource, ResourceCondition.readiness(type)),
String.format("Timed out waiting for %s %s/%s to be ready", resource.getKind(), resource.getMetadata().getNamespace(), resource.getMetadata().getName()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription;
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionBuilder;
import io.odh.test.OdhAnnotationsLabels;
import io.odh.test.TestConstants;
import io.odh.test.framework.manager.ResourceItem;
import io.odh.test.framework.manager.ResourceManager;
import org.slf4j.Logger;
Expand All @@ -18,19 +19,22 @@
public class PipelinesOperator {
private static final Logger LOGGER = LoggerFactory.getLogger(PipelinesOperator.class);

public static final String SUBSCRIPTION_NAME = "openshift-pipelines-operator";
public static final String OPERATOR_NAME = "openshift-pipelines-operator-rh";

public static void deployOperator() {
Subscription subscription = new SubscriptionBuilder()
.editOrNewMetadata()
.withName("openshift-pipelines-operator")
.withNamespace("openshift-operators")
.withName(SUBSCRIPTION_NAME)
.withNamespace(TestConstants.OPENSHIFT_OPERATORS_NS)
.withLabels(Collections.singletonMap(OdhAnnotationsLabels.APP_LABEL_KEY, OdhAnnotationsLabels.APP_LABEL_VALUE))
.endMetadata()
.editOrNewSpec()
.withName("openshift-pipelines-operator-rh")
.withChannel("latest")
.withSource("redhat-operators")
.withSourceNamespace("openshift-marketplace")
.withInstallPlanApproval("Automatic")
.withName(OPERATOR_NAME)
.withChannel(TestConstants.CHANNEL_LATEST)
.withSource(TestConstants.REDHAT_CATALOG)
.withSourceNamespace(TestConstants.OPENSHIFT_MARKETPLACE_NS)
.withInstallPlanApproval(TestConstants.APPROVAL_AUTOMATIC)
.editOrNewConfig()
.endConfig()
.endSpec()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription;
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionBuilder;
import io.odh.test.OdhAnnotationsLabels;
import io.odh.test.TestConstants;
import io.odh.test.framework.manager.ResourceItem;
import io.odh.test.framework.manager.ResourceManager;
import io.odh.test.framework.manager.resources.OperatorGroupResource;
Expand All @@ -21,22 +22,24 @@

public class ServerlessOperator {
private static final Logger LOGGER = LoggerFactory.getLogger(ServerlessOperator.class);
public static final String SUBSCRIPTION_NAME = "serverless-operator";
public static final String OPERATOR_NAME = "serverless-operator";
public static final String OPERATOR_NAMESPACE = "openshift-serverless";
public static void deployOperator() {
String operatorNs = "openshift-serverless";
// Create ns for the operator
Namespace ns = new NamespaceBuilder()
.withNewMetadata()
.withName(operatorNs)
.withName(OPERATOR_NAMESPACE)
.withLabels(Collections.singletonMap(OdhAnnotationsLabels.APP_LABEL_KEY, OdhAnnotationsLabels.APP_LABEL_VALUE))
.endMetadata()
.build();
ResourceManager.getInstance().createResourceWithoutWait(ns);
//Create operator group for the operator
if (OperatorGroupResource.operatorGroupClient().inNamespace(operatorNs).list().getItems().isEmpty()) {
if (OperatorGroupResource.operatorGroupClient().inNamespace(OPERATOR_NAMESPACE).list().getItems().isEmpty()) {
OperatorGroupBuilder operatorGroup = new OperatorGroupBuilder()
.editOrNewMetadata()
.withName("odh-group")
.withNamespace(operatorNs)
.withNamespace(OPERATOR_NAMESPACE)
.withLabels(Collections.singletonMap(OdhAnnotationsLabels.APP_LABEL_KEY, OdhAnnotationsLabels.APP_LABEL_VALUE))
.endMetadata();

Expand All @@ -47,16 +50,16 @@ public static void deployOperator() {
// Create subscription
Subscription subscription = new SubscriptionBuilder()
.editOrNewMetadata()
.withName("serverless-operator")
.withNamespace(operatorNs)
.withName(SUBSCRIPTION_NAME)
.withNamespace(OPERATOR_NAMESPACE)
.withLabels(Collections.singletonMap(OdhAnnotationsLabels.APP_LABEL_KEY, OdhAnnotationsLabels.APP_LABEL_VALUE))
.endMetadata()
.editOrNewSpec()
.withName("serverless-operator")
.withChannel("stable")
.withSource("redhat-operators")
.withSourceNamespace("openshift-marketplace")
.withInstallPlanApproval("Automatic")
.withName(OPERATOR_NAME)
.withChannel(TestConstants.CHANNEL_STABLE)
.withSource(TestConstants.REDHAT_CATALOG)
.withSourceNamespace(TestConstants.OPENSHIFT_MARKETPLACE_NS)
.withInstallPlanApproval(TestConstants.APPROVAL_AUTOMATIC)
.editOrNewConfig()
.endConfig()
.endSpec()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription;
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionBuilder;
import io.odh.test.OdhAnnotationsLabels;
import io.odh.test.TestConstants;
import io.odh.test.framework.manager.ResourceItem;
import io.odh.test.framework.manager.ResourceManager;
import org.slf4j.Logger;
Expand All @@ -17,20 +18,24 @@

public class ServiceMeshOperator {
private static final Logger LOGGER = LoggerFactory.getLogger(ServiceMeshOperator.class);
public static final String SUBSCRIPTION_NAME = "servicemeshoperator";
public static final String OPERATOR_NAME = "servicemeshoperator";
public static final String SERVICE_MESH_NAMESPACE = "istio-system";
public static final String SERVICE_MESH_NAME = "data-science-smcp";

public static void deployOperator() {
Subscription subscription = new SubscriptionBuilder()
.editOrNewMetadata()
.withName("servicemeshoperator")
.withNamespace("openshift-operators")
.withName(SUBSCRIPTION_NAME)
.withNamespace(TestConstants.OPENSHIFT_OPERATORS_NS)
.withLabels(Collections.singletonMap(OdhAnnotationsLabels.APP_LABEL_KEY, OdhAnnotationsLabels.APP_LABEL_VALUE))
.endMetadata()
.editOrNewSpec()
.withName("servicemeshoperator")
.withChannel("stable")
.withSource("redhat-operators")
.withSourceNamespace("openshift-marketplace")
.withInstallPlanApproval("Automatic")
.withName(OPERATOR_NAME)
.withChannel(TestConstants.CHANNEL_STABLE)
.withSource(TestConstants.REDHAT_CATALOG)
.withSourceNamespace(TestConstants.OPENSHIFT_MARKETPLACE_NS)
.withInstallPlanApproval(TestConstants.APPROVAL_AUTOMATIC)
.editOrNewConfig()
.endConfig()
.endSpec()
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/odh/test/install/OlmInstall.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import io.fabric8.openshift.client.OpenShiftClient;
import io.odh.test.Environment;
import io.odh.test.OdhConstants;
import io.odh.test.TestConstants;
import io.odh.test.framework.manager.ResourceItem;
import io.odh.test.framework.manager.ResourceManager;
import io.odh.test.framework.manager.resources.OperatorGroupResource;
Expand All @@ -37,7 +38,7 @@ public class OlmInstall {
private String operatorVersion = Environment.OLM_OPERATOR_VERSION;
private String csvName = operatorName + "." + operatorVersion;

private String approval = "Automatic";
private String approval = TestConstants.APPROVAL_AUTOMATIC;

public void create() {
createNamespace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.odh.test.OdhConstants;
import io.odh.test.TestSuite;
import io.odh.test.framework.manager.ResourceManager;
import io.odh.test.framework.manager.requirements.ServiceMeshOperator;
import io.odh.test.framework.manager.resources.DataScienceClusterResource;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import io.opendatahub.datasciencecluster.v1.DataScienceClusterBuilder;
Expand Down Expand Up @@ -57,8 +58,8 @@ void createDataScienceCluster() {
.withNewServiceMesh()
.withManagementState(ServiceMesh.ManagementState.MANAGED)
.withNewControlPlane()
.withName("data-science-smcp")
.withNamespace("istio-system")
.withName(ServiceMeshOperator.SERVICE_MESH_NAME)
.withNamespace(ServiceMeshOperator.SERVICE_MESH_NAMESPACE)
.withMetricsCollection(ControlPlane.MetricsCollection.ISTIO)
.endControlPlane()
.endServiceMesh()
Expand Down
11 changes: 6 additions & 5 deletions src/test/java/io/odh/test/e2e/standard/NotebookST.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.odh.test.OdhAnnotationsLabels;
import io.odh.test.OdhConstants;
import io.odh.test.framework.manager.ResourceManager;
import io.odh.test.framework.manager.requirements.ServiceMeshOperator;
import io.odh.test.framework.manager.resources.NotebookResource;
import io.odh.test.utils.PodUtils;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
Expand Down Expand Up @@ -109,8 +110,8 @@ void deployDataScienceCluster() {
.withNewServiceMesh()
.withManagementState(ServiceMesh.ManagementState.MANAGED)
.withNewControlPlane()
.withName("data-science-smcp")
.withNamespace("istio-system")
.withName(ServiceMeshOperator.SERVICE_MESH_NAME)
.withNamespace(ServiceMeshOperator.SERVICE_MESH_NAMESPACE)
.withMetricsCollection(ControlPlane.MetricsCollection.ISTIO)
.endControlPlane()
.endServiceMesh()
Expand Down Expand Up @@ -141,13 +142,13 @@ void deployDataScienceCluster() {
new DatasciencepipelinesBuilder().withManagementState(Datasciencepipelines.ManagementState.REMOVED).build()
)
.withModelmeshserving(
new ModelmeshservingBuilder().withManagementState(Modelmeshserving.ManagementState.MANAGED).build()
new ModelmeshservingBuilder().withManagementState(Modelmeshserving.ManagementState.REMOVED).build()
)
.withRay(
new RayBuilder().withManagementState(Ray.ManagementState.MANAGED).build()
new RayBuilder().withManagementState(Ray.ManagementState.REMOVED).build()
)
.withTrustyai(
new TrustyaiBuilder().withManagementState(Trustyai.ManagementState.MANAGED).build()
new TrustyaiBuilder().withManagementState(Trustyai.ManagementState.REMOVED).build()
)
.build())
.endSpec()
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/io/odh/test/e2e/upgrade/UpgradeAbstract.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.odh.test.framework.listeners.OdhResourceCleaner;
import io.odh.test.framework.listeners.ResourceManagerDeleteHandler;
import io.odh.test.framework.manager.ResourceManager;
import io.odh.test.framework.manager.requirements.ServiceMeshOperator;
import io.odh.test.framework.manager.resources.NotebookResource;
import io.opendatahub.datasciencecluster.v1.DataScienceCluster;
import io.opendatahub.datasciencecluster.v1.DataScienceClusterBuilder;
Expand Down Expand Up @@ -69,8 +70,8 @@ protected void deployDsc(String name) {
.withNewServiceMesh()
.withManagementState(ServiceMesh.ManagementState.MANAGED)
.withNewControlPlane()
.withName("data-science-smcp")
.withNamespace("istio-system")
.withName(ServiceMeshOperator.SERVICE_MESH_NAME)
.withNamespace(ServiceMeshOperator.SERVICE_MESH_NAMESPACE)
.withMetricsCollection(ControlPlane.MetricsCollection.ISTIO)
.endControlPlane()
.endServiceMesh()
Expand Down

0 comments on commit 2b0e99a

Please sign in to comment.