From c0b7dd62bbbc004b00ff9d92fb523467f1236560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Hern=C3=A1ndez?= <23639005+israel-hdez@users.noreply.github.com> Date: Wed, 13 Dec 2023 17:01:28 -0600 Subject: [PATCH] Revert and re-adapt test/e2e/common/utils.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts changes done in commit ecff079 to test/e2e/common/utils.py. It is possible to revert since opendatahub-io/odh-model-controller#59 is solved. After the revert, another adaptation was needed. CI in upstream assumes that the URL in the InferenceService cannot be resolved, so it uses the IP of the istio-ingressgateway together with the HTTP Host header to workaround this limitation. However, in ODH testing environment the URL of InferenceServices can be resolved. The adaptation adds a flag to use the URL of the isvc, rather than using the IP of the istio-ingressgateway. This adaptation can be contributed to upstream, because the community can benefit from it. The CI setup is updated, so that the revert works correctly: * odh-model-controller is now being installed * TLS is removed from the istio-ingressgateway Additionally, the following other changes were done to the CI setup: * Turn off Mesh-related components that are not needed for CI * Prefer usage of the ServiceMeshMember CRD to enroll namespaces to the Mesh Fixes opendatahub-io/kserve#50 Signed-off-by: Edgar Hernández <23639005+israel-hdez@users.noreply.github.com> --- test/e2e/common/utils.py | 30 +++++++++-------- test/e2e/predictor/test_tensorflow.py | 2 +- test/scripts/openshift-ci/deploy.ossm.sh | 22 ------------- .../scripts/openshift-ci/deploy.serverless.sh | 32 +++++++------------ test/scripts/openshift-ci/kustomization.yaml | 7 ++++ test/scripts/openshift-ci/run-e2e-tests.sh | 16 ++++++++-- 6 files changed, 50 insertions(+), 59 deletions(-) create mode 100644 test/scripts/openshift-ci/kustomization.yaml diff --git a/test/e2e/common/utils.py b/test/e2e/common/utils.py index 4a2bbca8a0b..dc6b2be8cdc 100644 --- a/test/e2e/common/utils.py +++ b/test/e2e/common/utils.py @@ -80,23 +80,20 @@ def predict_str(service_name, input_json, protocol_version="v1", ) # temporary sleep until this is fixed https://github.com/kserve/kserve/issues/604 time.sleep(10) - # cluster_ip = get_cluster_ip() - host = urlparse(isvc["status"]["components"]["predictor"]["url"]).netloc - path = urlparse(isvc["status"]["components"]["predictor"]["url"]).path - cluster_ip = host + cluster_ip, host, path = get_isvc_endpoint(isvc) headers = {"Host": host, "Content-Type": "application/json"} if model_name is None: model_name = service_name - url = f"https://{cluster_ip}{path}/v1/models/{model_name}:predict" + url = f"http://{cluster_ip}{path}/v1/models/{model_name}:predict" if protocol_version == "v2": - url = f"https://{cluster_ip}{path}/v2/models/{model_name}/infer" + url = f"http://{cluster_ip}{path}/v2/models/{model_name}/infer" logging.info("Sending Header = %s", headers) logging.info("Sending url = %s", url) logging.info("Sending request data: %s", input_json) - response = requests.post(url, input_json, headers=headers, verify=False) + response = requests.post(url, input_json, headers=headers) logging.info("Got response code %s, content %s", response.status_code, response.content) if response.status_code == 200: preds = json.loads(response.content.decode("utf-8")) @@ -118,8 +115,7 @@ def predict_ig(ig_name, input_json, protocol_version="v1", version=version, ) - cluster_ip = get_cluster_ip() - host = urlparse(ig["status"]["components"]["predictor"]["url"]).netloc + cluster_ip, host = get_isvc_endpoint(ig) headers = {"Host": host} url = f"http://{cluster_ip}" @@ -154,8 +150,7 @@ def explain_response(service_name, input_json): ) # temporary sleep until this is fixed https://github.com/kserve/kserve/issues/604 time.sleep(10) - cluster_ip = get_cluster_ip() - host = urlparse(isvc["status"]["components"]["predictor"]["url"]).netloc + cluster_ip, host = get_isvc_endpoint(isvc) url = "http://{}/v1/models/{}:explain".format(cluster_ip, service_name) headers = {"Host": host} with open(input_json) as json_file: @@ -210,7 +205,6 @@ def get_cluster_ip(name="istio-ingressgateway", namespace="istio-system"): def predict_grpc(service_name, payload, parameters=None, version=constants.KSERVE_V1BETA1_VERSION, model_name=None): - cluster_ip = get_cluster_ip() kfs_client = KServeClient( config_file=os.environ.get("KUBECONFIG", "~/.kube/config")) isvc = kfs_client.get( @@ -218,7 +212,7 @@ def predict_grpc(service_name, payload, parameters=None, version=constants.KSERV namespace=KSERVE_TEST_NAMESPACE, version=version, ) - host = urlparse(isvc["status"]["components"]["predictor"]["url"]).netloc + cluster_ip, host = get_isvc_endpoint(isvc) if ":" not in cluster_ip: cluster_ip = cluster_ip + ":80" @@ -244,3 +238,13 @@ def predict_modelmesh(service_name, input_json, pod_name, model_name=None): url = f"http://localhost:8008/v2/models/{model_name}/infer" response = requests.post(url, json.dumps(data)) return json.loads(response.content.decode("utf-8")) + + +def get_isvc_endpoint(isvc): + host = urlparse(isvc["status"]["url"]).netloc + path = urlparse(isvc["status"]["url"]).path + if os.environ.get("CI_USE_ISVC_HOST") == "1": + cluster_ip = host + else: + cluster_ip = get_cluster_ip() + return cluster_ip, host, path diff --git a/test/e2e/predictor/test_tensorflow.py b/test/e2e/predictor/test_tensorflow.py index e1c060dbdbf..6654ef053e4 100644 --- a/test/e2e/predictor/test_tensorflow.py +++ b/test/e2e/predictor/test_tensorflow.py @@ -38,7 +38,7 @@ def test_tensorflow_kserve(): storage_uri='gs://kfserving-examples/models/tensorflow/flowers', resources=V1ResourceRequirements( requests={'cpu': '10m', 'memory': '128Mi'}, - limits={'cpu': '100m', 'memory': '256Mi'} + limits={'cpu': '100m', 'memory': '512Mi'} ) ) ) diff --git a/test/scripts/openshift-ci/deploy.ossm.sh b/test/scripts/openshift-ci/deploy.ossm.sh index c30bd673017..d91c07e9d11 100755 --- a/test/scripts/openshift-ci/deploy.ossm.sh +++ b/test/scripts/openshift-ci/deploy.ossm.sh @@ -134,26 +134,4 @@ EOF # Waiting for OSSM minimum start waitpodready "istio-system" "app=istiod" -# Create SMMR to enroll namespaces via a label. Also, set mTLS policy to strict by default. -cat </dev/null export GITHUB_SHA=$(git rev-parse HEAD) + export CI_USE_ISVC_HOST="1" ./test/scripts/gh-actions/run-e2e-tests.sh "$1" popd