-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #764 from ryandawsonuk/747-prepackservertests
prepackage model server tests
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pytest | ||
retrying | ||
seldon_core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |