Skip to content

Commit 1e2860d

Browse files
authored
Improve the coverage of the e2e test suite (#2069)
1 parent f6e890b commit 1e2860d

File tree

22 files changed

+1258
-25
lines changed

22 files changed

+1258
-25
lines changed

.circleci/config.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ commands:
5858
command: cortex cluster up << parameters.config >> --configure-env aws -y
5959
- run:
6060
name: Run E2E Tests
61-
command: pytest -v test/e2e/tests --env aws
61+
command: |
62+
pytest -v test/e2e/tests --env aws --skip-autoscaling --skip-load --skip-long-running
63+
pytest -v test/e2e/tests --env aws -k test_autoscaling
64+
pytest -v test/e2e/tests --env aws -k test_load
6265
- run:
6366
name: Delete Cluster
6467
command: cortex cluster down --config << parameters.config >> -y
@@ -137,8 +140,8 @@ jobs:
137140
node_groups:
138141
- name: spot
139142
instance_type: t3.medium
140-
min_instances: 0
141-
max_instances: 1
143+
min_instances: 10
144+
max_instances: 10
142145
spot: true
143146
- name: cpu
144147
instance_type: c5.xlarge

pkg/cortex/serve/cortex_internal/lib/api/async_api.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from cortex_internal.lib.client.tensorflow import TensorFlowClient
2828
from cortex_internal.lib.exceptions import CortexException, UserException, UserRuntimeException
2929
from cortex_internal.lib.metrics import MetricsClient
30-
from cortex_internal.lib.model import ModelsHolder
3130
from cortex_internal.lib.storage import S3
3231
from cortex_internal.lib.type import (
3332
predictor_type_from_api_spec,

test/apis/batch/sum/cortex.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- name: summing-api
2+
kind: BatchAPI
3+
predictor:
4+
type: python
5+
path: predictor.py
6+
compute:
7+
cpu: 100m
8+
mem: 200Mi

test/apis/batch/sum/predictor.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import os
2+
import boto3
3+
import json
4+
import re
5+
6+
7+
class PythonPredictor:
8+
def __init__(self, config, job_spec):
9+
if len(config.get("dest_s3_dir", "")) == 0:
10+
raise Exception("'dest_s3_dir' field was not provided in job submission")
11+
12+
self.s3 = boto3.client("s3")
13+
14+
self.bucket, self.key = re.match("s3://(.+?)/(.+)", config["dest_s3_dir"]).groups()
15+
self.key = os.path.join(self.key, job_spec["job_id"])
16+
self.list = []
17+
18+
def predict(self, payload, batch_id):
19+
for numbers_list in payload:
20+
self.list.append(sum(numbers_list))
21+
22+
def on_job_complete(self):
23+
json_output = json.dumps(self.list)
24+
self.s3.put_object(Bucket=self.bucket, Key=f"{self.key}.json", Body=json_output)

test/apis/batch/sum/sample.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
[1, 2, 67, -2, 43]
3+
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from typing import List
2+
from random import sample
3+
4+
RANGE = 10 ** 12
5+
LENGTH = 5
6+
7+
8+
def generate_sample() -> List[int]:
9+
return sample(range(RANGE), LENGTH)

test/apis/sleep/cortex.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
predictor:
44
type: python
55
path: predictor.py
6+
compute:
7+
cpu: 100m

test/apis/tensorflow/iris-classifier/cortex.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
path: predictor.py
66
models:
77
path: s3://cortex-examples/tensorflow/iris-classifier/nn/
8+
compute:
9+
mem: 250Mi

test/e2e/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ It is possible to skip GPU tests by passing the `--skip-gpus` flag to the pytest
4444

4545
It is possible to skip Inferentia tests by passing the `--skip-infs` flag to the pytest command.
4646

47+
### Skip Autoscaling Test
48+
49+
It is possible to skip the autoscaling test by passing the `--skip-autoscaling` flag to the pytest command.
50+
51+
### Skip Load Test
52+
53+
It is possible to skip the load tests by passing the `--skip-load` flag to the pytest command.
54+
55+
### Skip Long Running Test
56+
57+
It is possible to skip the long running test by passing the `--skip-long-running` flag to the pytest command.
58+
4759
## Configuration
4860

4961
It is possible to configure the behaviour of the tests by defining environment variables or a `.env` file at the project

test/e2e/e2e/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@ class ClusterDeletionException(Exception):
88

99
class ExpectationsValidationException(Exception):
1010
pass
11+
12+
13+
class GeneratorValidationException(Exception):
14+
pass

0 commit comments

Comments
 (0)