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

Add ModelServingST test #114

Merged
merged 5 commits into from
Mar 18, 2024
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
1 change: 1 addition & 0 deletions src/main/java/io/odh/test/OdhAnnotationsLabels.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class OdhAnnotationsLabels {
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_MODEL_MESH = "modelmesh-enabled";
public static final String ANNO_NTB_INJECT_OAUTH = "notebooks." + ODH_DOMAIN + "inject-oauth";
public static final String APP_LABEL_KEY = "app";
public static final String APP_LABEL_VALUE = "odh-e2e";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.odh.test.TestUtils;
import io.odh.test.framework.manager.resources.DataScienceClusterResource;
import io.odh.test.framework.manager.resources.DataScienceInitializationResource;
import io.odh.test.framework.manager.resources.InferenceServiceResource;
import io.odh.test.framework.manager.resources.NamespaceResource;
import io.odh.test.framework.manager.resources.NotebookResource;
import io.odh.test.framework.manager.resources.OperatorGroupResource;
Expand Down Expand Up @@ -80,6 +81,7 @@ public static KubeCmdClient getKubeCmdClient() {
new DataScienceClusterResource(),
new DataScienceInitializationResource(),
new NotebookResource(),
new InferenceServiceResource(),
};

public final void switchToTestResourceStack() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* 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.kserve.serving.v1beta1.InferenceService;
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.odh.test.utils.PodUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class InferenceServiceResource implements ResourceType<InferenceService> {

private static final Logger LOGGER = LoggerFactory.getLogger(InferenceServiceResource.class);
@Override
public String getKind() {
return "InferenceService";
}

@Override
public InferenceService get(String namespace, String name) {
return inferenceServiceClient().inNamespace(namespace).withName(name).get();
}

@Override
public void create(InferenceService resource) {
inferenceServiceClient().resource(resource).create();
}

@Override
public void delete(InferenceService resource) {
inferenceServiceClient().inNamespace(resource.getMetadata().getNamespace()).withName(resource.getMetadata().getName()).delete();
}

@Override
public void update(InferenceService resource) {
inferenceServiceClient().resource(resource).update();
}

@Override
public boolean waitForReadiness(InferenceService resource) {
String message = String.format("InferenceService %s readiness", resource.getMetadata().getName());
TestUtils.waitFor(message, TestConstants.GLOBAL_POLL_INTERVAL_SHORT, TestConstants.GLOBAL_TIMEOUT, () -> {
boolean isReady;

InferenceService inferenceService = get(resource.getMetadata().getNamespace(), resource.getMetadata().getName());

String predictorReadyStatus = KubeUtils.getInferenceServiceConditionByType(inferenceService.getStatus().getConditions(), "PredictorReady").getStatus();
LOGGER.debug("InferenceService {} PredictorReady status: {}", resource.getMetadata().getName(), predictorReadyStatus);
isReady = predictorReadyStatus.equals("True");

String readyStatus = KubeUtils.getInferenceServiceConditionByType(inferenceService.getStatus().getConditions(), "Ready").getStatus();
LOGGER.debug("InferenceService {} Ready status: {}", resource.getMetadata().getName(), readyStatus);
isReady = isReady && readyStatus.equals("True");

return isReady;
}, () -> { });

String namespace = resource.getMetadata().getNamespace();
LOGGER.info("Waiting for pods readiness in {}", namespace);
PodUtils.waitForPodsReady(namespace, true, () -> {
ResourceManager.getKubeCmdClient().namespace(namespace).exec(false, "get", "pods");
ResourceManager.getKubeCmdClient().namespace(namespace).exec(false, "get", "events");
});

return true;
}

public static MixedOperation<InferenceService, KubernetesResourceList<InferenceService>, Resource<InferenceService>> inferenceServiceClient() {
return ResourceManager.getKubeClient().getClient().resources(InferenceService.class);
}

}
4 changes: 4 additions & 0 deletions src/main/java/io/odh/test/platform/KubeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public static org.kubeflow.v1.notebookstatus.Conditions getNotebookConditionByTy
return conditions.stream().filter(c -> c.getType().equals(type)).findFirst().orElseGet(null);
}

public static io.kserve.serving.v1beta1.inferenceservicestatus.Conditions getInferenceServiceConditionByType(List<io.kserve.serving.v1beta1.inferenceservicestatus.Conditions> conditions, String type) {
return conditions.stream().filter(c -> c.getType().equals(type)).findFirst().orElseGet(null);
}

public static void clearOdhRemainingResources() {
ResourceManager.getKubeClient().getClient().apiextensions().v1().customResourceDefinitions().list().getItems()
.stream().filter(crd -> crd.getMetadata().getName().contains("opendatahub.io")).toList()
Expand Down
Loading
Loading