Skip to content

Commit

Permalink
Merge pull request #764 from ryandawsonuk/747-prepackservertests
Browse files Browse the repository at this point in the history
prepackage model server tests
  • Loading branch information
ryandawsonuk authored Aug 7, 2019
2 parents 520e988 + 93c3a72 commit fea275c
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions testing/scripts/dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pytest
retrying
seldon_core
67 changes: 67 additions & 0 deletions testing/scripts/test_prepackaged_servers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import pytest
import time
import subprocess
from subprocess import run
import json
from seldon_utils import *
from k8s_utils import *
from seldon_core.seldon_client import SeldonClient

def wait_for_status(name):
for attempts in range(7):
completedProcess = run("kubectl get sdep "+name+" -o json -n seldon", shell=True, check=True, stdout=subprocess.PIPE)
jStr = completedProcess.stdout
j = json.loads(jStr)
if "status" in j and j['status'] == "Available":
return j
else:
print("Failed to find status - sleeping")
time.sleep(5)

def wait_for_rollout(deploymentName):
ret = run("kubectl rollout status deploy/"+deploymentName, shell=True)
while ret.returncode > 0:
time.sleep(1)
ret = run("kubectl rollout status deploy/"+deploymentName, shell=True)

@pytest.mark.usefixtures("seldon_images")
@pytest.mark.usefixtures("clusterwide_seldon_helm")
class TestPrepackSkLearn(object):

# Test prepackaged server for sklearn
def test_sklearn(self):
run("kubectl delete sdep --all", shell=True)
run("kubectl apply -f ../../servers/sklearnserver/samples/iris.yaml", shell=True, check=True)
wait_for_rollout("iris-default")
wait_for_status("sklearn")
print("Initial request")
sc = SeldonClient(deployment_name="sklearn",namespace="seldon")
r = sc.predict(gateway="ambassador",transport="rest",shape=(1,4))
assert r.success
print("Success for test_prepack_sklearn")


# Test prepackaged server for tfserving
def test_tfserving(self):
run("kubectl delete sdep --all", shell=True)
run("kubectl apply -f ../../servers/tfserving/samples/mnist_rest.yaml", shell=True, check=True)
wait_for_rollout("mnist-default")
wait_for_status("tfserving")
print("Initial request")
sc = SeldonClient(deployment_name="tfserving",namespace="seldon")
r = sc.predict(gateway="ambassador",transport="rest",shape=(1,784))
assert r.success
print("Success for test_prepack_tfserving")


# Test prepackaged server for xgboost
def test_xgboost(self):
run("kubectl delete sdep --all", shell=True)
run("kubectl apply -f ../../servers/xgboostserver/samples/iris.yaml", shell=True, check=True)
wait_for_rollout("iris-default")
wait_for_status("xgboost")
print("Initial request")
sc = SeldonClient(deployment_name="xgboost",namespace="seldon")
r = sc.predict(gateway="ambassador",transport="rest",shape=(1,4))
assert r.success
print("Success for test_prepack_xgboost")

0 comments on commit fea275c

Please sign in to comment.