Skip to content

Commit

Permalink
Merge pull request opendatahub-io#147 from israel-hdez/50-revert-e2e-…
Browse files Browse the repository at this point in the history
…utils-temp-fix

Revert and re-adapt test/e2e/common/utils.py
  • Loading branch information
openshift-merge-bot[bot] authored Dec 26, 2023
2 parents 7146558 + f5fdcf4 commit 4825c74
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 59 deletions.
30 changes: 17 additions & 13 deletions test/e2e/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand All @@ -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}"

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -210,15 +205,14 @@ 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(
service_name,
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"

Expand All @@ -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
2 changes: 1 addition & 1 deletion test/e2e/predictor/test_tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
)
)
)
Expand Down
22 changes: 0 additions & 22 deletions test/scripts/openshift-ci/deploy.ossm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF | oc apply -f -
apiVersion: maistra.io/v1
kind: ServiceMeshMemberRoll
metadata:
name: default
namespace: istio-system
spec:
memberSelectors:
- matchLabels:
testing.kserve.io/add-to-mesh: "true"
---
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
name: default
namespace: istio-system
spec:
mtls:
mode: STRICT
EOF

echo -e "\n OSSM has partially started and should be fully ready soon."
32 changes: 11 additions & 21 deletions test/scripts/openshift-ci/deploy.serverless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ waitpodready "openshift-serverless" "name=knative-operator"

# Install KNative
cat <<EOF | oc apply -f -
apiVersion: v1
kind: Namespace
apiVersion: maistra.io/v1
kind: ServiceMeshMember
metadata:
name: knative-serving
labels:
testing.kserve.io/add-to-mesh: "true"
name: default
namespace: knative-serving
spec:
controlPlaneRef:
namespace: istio-system
name: basic
---
apiVersion: operator.knative.dev/v1beta1
kind: KnativeServing
Expand Down Expand Up @@ -144,12 +147,9 @@ spec:
- hosts:
- '*'
port:
name: https
number: 443
protocol: HTTPS
tls:
credentialName: wildcard-certs
mode: SIMPLE
name: http
number: 80
protocol: HTTP
---
apiVersion: networking.istio.io/v1beta1
kind: Gateway
Expand All @@ -167,14 +167,4 @@ spec:
number: 8081
protocol: HTTP
---
apiVersion: v1
data:
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMzekNDQWNjQ0FRQXdEUVlKS29aSWh2Y05BUUVMQlFBd0tURVRNQkVHQTFVRUNnd0tRMnhoYzJnZ1NXNWoKTGpFU01CQUdBMVVFQXd3SlkyeGhjMmd1WTI5dE1CNFhEVEl6TURNeE1ERXdNakExT1ZvWERUSTBNRE13T1RFdwpNakExT1Zvd1FqRXJNQ2tHQTFVRUF3d2lLaTVqYkdGemFDNWhjSEJ6TG05d1pXNXphR2xtZEM1bGVHRnRjR3hsCkx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ZFandoM1ZoN0JaQ0hJc0FmY3ZoUUZ2OE1UZXVGQzBvNUZGU3gwCjN0MHpKQWdrWFBXYnhXQU9mU3FZc1NGR0tyVHFuNngzcTRWQXVyZ09Qa2pFd3VIUkFMajJyMFZVWUg4OWRab0QKWDBGcUM4SUNRWjRlbDFVd0c5bXAvaEE9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
kind: Secret
metadata:
name: wildcard-certs
namespace: istio-system
type: kubernetes.io/tls
---
EOF
7 changes: 7 additions & 0 deletions test/scripts/openshift-ci/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- github.com/opendatahub-io/odh-model-controller/config/base?ref=main

namespace: kserve
16 changes: 14 additions & 2 deletions test/scripts/openshift-ci/run-e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ kustomize build $PROJECT_ROOT/config/overlays/test | \
oc apply -f -
oc wait --for=condition=ready pod -l control-plane=kserve-controller-manager -n kserve --timeout=300s

echo "Installing odh-model-controller"
oc apply -k $PROJECT_ROOT/test/scripts/openshift-ci

echo "Add testing models to minio storage ..." # Reference: config/overlays/test/minio/minio-init-job.yaml
curl -L https://storage.googleapis.com/kfserving-examples/models/sklearn/1.0/model/model.joblib -o /tmp/sklearn-model.joblib
oc expose service minio-service -n kserve && sleep 5
Expand All @@ -93,8 +96,16 @@ apiVersion: v1
kind: Namespace
metadata:
name: kserve-ci-e2e-test
labels:
testing.kserve.io/add-to-mesh: "true"
---
apiVersion: maistra.io/v1
kind: ServiceMeshMember
metadata:
name: default
namespace: kserve-ci-e2e-test
spec:
controlPlaneRef:
namespace: istio-system
name: basic
EOF

oc apply -f $PROJECT_ROOT/config/overlays/test/minio/minio-user-secret.yaml -n kserve-ci-e2e-test
Expand All @@ -108,5 +119,6 @@ kustomize build $PROJECT_ROOT/config/overlays/test/clusterresources | \
echo "Run E2E tests: $1"
pushd $PROJECT_ROOT >/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

0 comments on commit 4825c74

Please sign in to comment.