Skip to content

Commit

Permalink
Testing KServe CI
Browse files Browse the repository at this point in the history
  • Loading branch information
agunapal committed Oct 25, 2023
1 parent 1e28b62 commit d8eee7c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 73 deletions.
9 changes: 0 additions & 9 deletions kubernetes/kserve/tests/data/mnist_v1.json

This file was deleted.

40 changes: 0 additions & 40 deletions kubernetes/kserve/tests/data/mnist_v2.json

This file was deleted.

33 changes: 9 additions & 24 deletions kubernetes/kserve/tests/scripts/test_mnist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ function start_minikube_cluster() {

function install_kserve() {
echo "Install Kserve"
#cd $GITHUB_WORKSPACE/kserve
cd /home/ubuntu/kserve
cd $GITHUB_WORKSPACE/kserve
./hack/quick_install.sh
echo "Waiting for Kserve pod to come up ..."
wait_for_kserve_pod 300 5
}

function deploy_cluster() {
echo "Deploying the cluster"
#cd $GITHUB_WORKSPACE
cd /home/ubuntu/serve
cd $GITHUB_WORKSPACE
kubectl apply -f "$1"
echo "Waiting for pod to come up..."
wait_for_pod_running "$2" 120
Expand All @@ -35,7 +33,7 @@ function make_cluster_accessible() {
URL="$2"
wait_for_inference_service 300 5 "$1"
SERVICE_HOSTNAME=$(kubectl get inferenceservice ${SERVICE_NAME} -o jsonpath='{.status.url}' | cut -d "/" -f 3)
wait_for_port_forwarding 300 10
wait_for_port_forwarding 5
echo "Make inference request"
PREDICTION=$(curl -H "Content-Type: application/json" -H "Host: ${SERVICE_HOSTNAME}" ${URL} -d @"$3")
EXPECTED="$4"
Expand Down Expand Up @@ -116,41 +114,28 @@ function wait_for_pod_running() {

function wait_for_port_forwarding() {
echo "Wait for ports to be in forwarding"
max_wait_time="$1"
interval="$2"
interval="$1"
start_time=$(date +%s)
INGRESS_GATEWAY_SERVICE=$(kubectl get svc --namespace istio-system --selector="app=istio-ingressgateway" --output jsonpath='{.items[0].metadata.name}')
kubectl port-forward --namespace istio-system svc/${INGRESS_GATEWAY_SERVICE} 8080:80 &
sleep "$interval"
#while true; do
# if kubectl port-forward --namespace istio-system svc/${INGRESS_GATEWAY_SERVICE} 8080:80 >/dev/null 2>&1; then
# break
# fi
# current_time=$(date +%s)
# if (( current_time - start_time >= max_wait_time )); then
# echo "Timeout waiting for port forwarding to be established."
# exit 1
# fi
# sleep "$interval"
#done
}

export INGRESS_HOST=localhost
export INGRESS_PORT=8080
export MODEL_NAME=mnist

echo "MNIST KServe V2 test begin"
start_minikube_cluster
install_kserve

echo "MNIST KServe V2 test begin"
deploy_cluster "kubernetes/kserve/tests/configs/mnist_v2_cpu.yaml" "torchserve-mnist-v2-predictor"
URL="http://${INGRESS_HOST}:${INGRESS_PORT}/v2/models/${MODEL_NAME}/infer"
make_cluster_accessible "torchserve-mnist-v2" ${URL} "./kubernetes/kserve/tests/data/mnist_v2.json" '{"model_name":"mnist","model_version":null,"id":"d3b15cad-50a2-4eaf-80ce-8b0a428bd298","parameters":null,"outputs":[{"name":"input-0","shape":[1],"datatype":"INT64","parameters":null,"data":[1]}]}'
delete_minikube_cluster
make_cluster_accessible "torchserve-mnist-v2" ${URL} "./kubernetes/kserve/kf_request_json/v2/mnist/mnist_v2_tensor.json" '{"model_name":"mnist","model_version":null,"id":"d3b15cad-50a2-4eaf-80ce-8b0a428bd298","parameters":null,"outputs":[{"name":"input-0","shape":[1],"datatype":"INT64","parameters":null,"data":[1]}]}'

echo "MNIST KServe V1 test begin"
start_minikube_cluster
install_kserve
deploy_cluster "kubernetes/kserve/tests/configs/mnist_v1_cpu.yaml" "torchserve-predictor"
URL="http://${INGRESS_HOST}:${INGRESS_PORT}/v1/models/${MODEL_NAME}:predict"
make_cluster_accessible "torchserve" ${URL} "./kubernetes/kserve/tests/data/mnist_v1.json" '{"predictions":[2]}'
make_cluster_accessible "torchserve" ${URL} "./kubernetes/kserve/kf_request_json/v1/mnist.json" '{"predictions":[2]}'

delete_minikube_cluster

0 comments on commit d8eee7c

Please sign in to comment.