-
Notifications
You must be signed in to change notification settings - Fork 605
Improve the coverage of the e2e test suite #2069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
1086033
Add autoscaling test
RobertLucian 79be2aa
Fix bugs in autoscaling test
RobertLucian da48c62
Remove replica curve checker for autoscaling test
RobertLucian fd82a82
Fix bug
RobertLucian 3fac4d1
Add load test for realtime API
RobertLucian b2bf859
Add load test for async API
RobertLucian 0679ebc
Reorganize async
RobertLucian ae35a59
Add batch load test
RobertLucian b1109a6
Make task test faster
RobertLucian 31ac8cb
Add long-running test
RobertLucian 6721cb2
Update Circle CI config
RobertLucian 7db36b2
Merge branch 'master' into internal/tests
RobertLucian 36941aa
Add descriptive comments
RobertLucian 953f21e
Fix Circle CI config and cortex.yaml
RobertLucian 79a6a46
Add printer logs to load/autoscaling tests
RobertLucian 78d691c
Fix Circle CI again
RobertLucian 4ba3fb1
Print API spec / stream logs when test fails
RobertLucian 7d57412
Merge branch 'master' into internal/tests
RobertLucian 2c96628
Add missing flags to the README
RobertLucian 758beae
Misc
RobertLucian fe52eaa
Remove un-required copyright
RobertLucian 3d51714
Address self-review comments
RobertLucian 20a3407
Address PR comments
RobertLucian 7e2d885
Simplify test function
RobertLucian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,8 @@ | ||
| - name: summing-api | ||
| kind: BatchAPI | ||
| predictor: | ||
| type: python | ||
| path: predictor.py | ||
| compute: | ||
| cpu: 100m | ||
| mem: 200Mi |
This file contains hidden or 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,24 @@ | ||
| import os | ||
| import boto3 | ||
| import json | ||
| import re | ||
|
|
||
|
|
||
| class PythonPredictor: | ||
| def __init__(self, config, job_spec): | ||
| if len(config.get("dest_s3_dir", "")) == 0: | ||
| raise Exception("'dest_s3_dir' field was not provided in job submission") | ||
|
|
||
| self.s3 = boto3.client("s3") | ||
|
|
||
| self.bucket, self.key = re.match("s3://(.+?)/(.+)", config["dest_s3_dir"]).groups() | ||
| self.key = os.path.join(self.key, job_spec["job_id"]) | ||
| self.list = [] | ||
|
|
||
| def predict(self, payload, batch_id): | ||
| for numbers_list in payload: | ||
| self.list.append(sum(numbers_list)) | ||
|
|
||
| def on_job_complete(self): | ||
| json_output = json.dumps(self.list) | ||
| self.s3.put_object(Bucket=self.bucket, Key=f"{self.key}.json", Body=json_output) |
This file contains hidden or 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,3 @@ | ||
| [ | ||
| [1, 2, 67, -2, 43] | ||
| ] |
This file contains hidden or 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,9 @@ | ||
| from typing import List | ||
| from random import sample | ||
|
|
||
| RANGE = 10 ** 12 | ||
| LENGTH = 5 | ||
|
|
||
|
|
||
| def generate_sample() -> List[int]: | ||
| return sample(range(RANGE), LENGTH) |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -3,3 +3,5 @@ | |
| predictor: | ||
| type: python | ||
| path: predictor.py | ||
| compute: | ||
| cpu: 100m | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,3 +5,5 @@ | |
| path: predictor.py | ||
| models: | ||
| path: s3://cortex-examples/tensorflow/iris-classifier/nn/ | ||
| compute: | ||
| mem: 250Mi | ||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,48 @@ | ||
| # Copyright 2021 Cortex Labs, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| import importlib | ||
| import pathlib | ||
| from typing import Any, Callable, List | ||
| import sys | ||
| import inspect | ||
|
|
||
| from e2e.exceptions import GeneratorValidationException | ||
|
|
||
|
|
||
| def load_generator(sample_generator: pathlib.Path) -> Callable[[], List[int]]: | ||
| api_dir = str(sample_generator.parent) | ||
|
|
||
| sys.path.append(api_dir) | ||
| sample_generator_module = importlib.import_module(str(pathlib.Path(sample_generator).stem)) | ||
| sys.path.pop() | ||
|
|
||
| validate_module(sample_generator_module) | ||
|
|
||
| return sample_generator_module.generate_sample | ||
|
|
||
|
|
||
| def validate_module(sample_generator_module: Any): | ||
| if not hasattr(sample_generator_module, "generate_sample"): | ||
| raise GeneratorValidationException( | ||
| "sample generator module doesn't have a function called 'generate_sample'" | ||
| ) | ||
|
|
||
| if not inspect.isfunction(getattr(sample_generator_module, "generate_sample")): | ||
| raise GeneratorValidationException("'generate_sample' is not a function") | ||
|
|
||
| if inspect.getfullargspec(getattr(sample_generator_module, "generate_sample")).args != []: | ||
| raise GeneratorValidationException( | ||
| "'generate_sample' function must not have any parameters" | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be summed up to a single command
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be ideal - and it is possible, but we'd have to create dependencies (within pytest) between the single-request tests and the load/autoscaling tests. There's no point in letting a load test run if the single-request test failed. I saw this plugin https://pytest-dependency.readthedocs.io/en/stable/usage.html that we could use, but from what I read, this only works for tests that sit in the same module.
The simplest next thing is to just create these "dependencies" by separating the pytest command into multiple ones.