-
Notifications
You must be signed in to change notification settings - Fork 8
Split e2e tests out #528
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
Split e2e tests out #528
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,183 +0,0 @@ | ||
| import os | ||
| import time | ||
| import pytest | ||
| import requests as requests_library | ||
| import itertools | ||
|
|
||
| from entityservice.tests.util import create_project_upload_fake_data, delete_project, create_project_no_data | ||
|
|
||
| THROTTLE_SLEEP = 0.2 | ||
|
|
||
|
|
||
| @pytest.fixture(scope='session') | ||
| def requests(): | ||
| """ | ||
| We inject the requests session. | ||
| For now we just add a small sleep after every request to ensure we don't get throttled when | ||
| tests run back to back. Note the rate limit in nginx is 10 requests per ip per second. | ||
| """ | ||
| def delay_next(r, *args, **kwargs): | ||
| time.sleep(THROTTLE_SLEEP) | ||
|
|
||
| testing_session = requests_library.Session() | ||
| testing_session.hooks['response'].append(delay_next) | ||
| yield testing_session | ||
|
|
||
|
|
||
| # Parameterising on: | ||
| # | ||
| # - pairs of dataset sizes | ||
| # - overlap of the sizes | ||
| # - result_type for 2 parties in ['similarity_scores', 'permutations'] and for more parties in ['groups'] | ||
| # - threshold | ||
|
|
||
| ENVVAR_NAME = 'ENTITY_SERVICE_RUN_SLOW_TESTS' | ||
| THRESHOLDS = [0.9, 1.0] | ||
| OVERLAPS = [0.0, 0.9] | ||
| ENCODING_SIZES = [8] | ||
| NUMBERS_PARTIES = [2, 3, 5] | ||
|
|
||
| if os.getenv(ENVVAR_NAME): | ||
| ENCODING_SIZES.extend([64, 128, 512, 2048]) | ||
| OVERLAPS.extend([0.2, 0.5, 1.0]) | ||
| THRESHOLDS.extend([0.6, 0.8, 0.95]) | ||
|
|
||
| FAST_SIZES_2P = tuple(itertools.product([1, 1000], repeat=2)) | ||
| FAST_SIZES_NP = tuple(itertools.chain( | ||
| FAST_SIZES_2P, | ||
| [(1, 1000, 1000), | ||
| (1000, 1, 1000), | ||
| (1000, 1000, 1), | ||
| (1000, 1000, 1000), | ||
| (1000, 1000, 1000, 1000, 1000)])) | ||
|
|
||
| SLOW_SIZES_2P = tuple(itertools.combinations([1, 10000, 100000, 1000000], 2)) | ||
| SLOW_SIZES_NP = tuple(itertools.chain( | ||
| SLOW_SIZES_2P, | ||
| itertools.product( | ||
| [10000, 100000], [10000, 100000], [100000, 1000000]), | ||
| ((10000, 10000, 100000, 100000, 1000000),))) | ||
|
|
||
| SIZES_2P = (tuple(itertools.chain(FAST_SIZES_2P, SLOW_SIZES_2P)) | ||
| if os.getenv(ENVVAR_NAME) | ||
| else FAST_SIZES_2P) | ||
| SIZES_NP = (tuple(itertools.chain(FAST_SIZES_NP, SLOW_SIZES_NP)) | ||
| if os.getenv(ENVVAR_NAME) | ||
| else FAST_SIZES_NP) | ||
|
|
||
| PROJECT_PARAMS_2P = tuple( | ||
| itertools.product(SIZES_2P, OVERLAPS, ENCODING_SIZES)) | ||
| PROJECT_PARAMS_NP = tuple( | ||
| itertools.product(SIZES_NP, OVERLAPS, ENCODING_SIZES)) | ||
| PROJECT_RESULT_TYPES_2P = ['similarity_scores', 'permutations'] | ||
| PROJECT_RESULT_TYPES_NP = ['groups'] | ||
|
|
||
|
|
||
| def create_project_response(requests, size, overlap, result_type, encoding_size=128): | ||
| """ | ||
| Create a project with the given size, overlap and result_type. | ||
|
|
||
| Tests that use one of these projects will get a dict like the following: | ||
|
|
||
| { | ||
| "project_id": "ID", | ||
| "upload-mode": "BINARY" | "JSON", | ||
| "size": [size 1, size 2], | ||
| "encoding-size": int number of bytes in each encoding e.g. 128, | ||
| "overlap": float between 0 and 1, | ||
| "result_token": "TOKEN", | ||
| "upload_tokens": [TOKENS, ...], | ||
| "dp_1": <JSON RESPONSE TO DATA UPLOAD> | ||
| "dp_2": <JSON RESPONSE TO DATA UPLOAD> | ||
| } | ||
| """ | ||
| project, dp_responses = create_project_upload_fake_data( | ||
| requests, size, overlap=overlap, result_type=result_type, encoding_size=encoding_size) | ||
| project.update({ | ||
| 'size': size, | ||
| 'encoding-size': encoding_size, | ||
| 'upload-mode': 'JSON', | ||
| 'overlap': overlap, | ||
| 'dp_responses': dp_responses | ||
| }) | ||
| return project | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function', params=PROJECT_PARAMS_2P) | ||
| def similarity_scores_project(request, requests): | ||
| size, overlap, encoding_size = request.param | ||
| prj = create_project_response(requests, size, overlap, 'similarity_scores', encoding_size) | ||
| yield prj | ||
| delete_project(requests, prj) | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function', params=tuple(itertools.chain( | ||
| [(t, 2) for t in PROJECT_RESULT_TYPES_2P], | ||
| [(t, n) for t in PROJECT_RESULT_TYPES_NP for n in NUMBERS_PARTIES]))) | ||
| def result_type_number_parties(request): | ||
| yield request.param | ||
|
|
||
|
|
||
| @pytest.fixture(params=( | ||
| *[(t, n) for t in PROJECT_RESULT_TYPES_2P | ||
| for n in (None, 2)], | ||
| *[(t, n) for t in PROJECT_RESULT_TYPES_NP | ||
| for n in (None, *NUMBERS_PARTIES)])) | ||
| def result_type_number_parties_or_none(request): | ||
| yield request.param | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def valid_project_params(request, result_type_number_parties_or_none): | ||
| result_type, number_parties_or_none = result_type_number_parties_or_none | ||
| # None is what we use to test handling of default values | ||
| params_dict = {'result_type': result_type} | ||
| if number_parties_or_none is not None: | ||
| params_dict['number_parties'] = number_parties_or_none | ||
| return params_dict | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function') | ||
| def project(request, requests, result_type_number_parties): | ||
| result_type, number_parties = result_type_number_parties | ||
| project = create_project_no_data( | ||
| requests, | ||
| result_type=result_type, | ||
| number_parties=number_parties) | ||
| yield project | ||
| # Release project resource | ||
| delete_project(requests, project) | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function', params=ENCODING_SIZES) | ||
| def encoding_size(request): | ||
| yield request.param | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function', params=THRESHOLDS) | ||
| def threshold(request): | ||
| yield request.param | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function', params=PROJECT_PARAMS_2P) | ||
| def permutations_project(request, requests): | ||
| size, overlap, encoding_size = request.param | ||
| prj = create_project_response(requests, size, overlap, 'permutations', encoding_size) | ||
| yield prj | ||
| delete_project(requests, prj) | ||
|
|
||
|
|
||
| @pytest.fixture(scope='function', params=PROJECT_PARAMS_NP) | ||
| def groups_project(request, requests): | ||
| size, overlap, encoding_size = request.param | ||
| prj = create_project_response(requests, size, overlap, 'groups', encoding_size) | ||
| yield prj | ||
| delete_project(requests, prj) | ||
|
|
||
|
|
||
| @pytest.fixture( | ||
| params=itertools.chain( | ||
| itertools.product(PROJECT_RESULT_TYPES_2P, [1, 3, 4, 5]), | ||
| [(t, 1) for t in PROJECT_RESULT_TYPES_NP])) | ||
| def invalid_result_type_number_parties(request): | ||
| yield request.param | ||
This file was deleted.
Oops, something went wrong.
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
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.
What does E2E stand for? end to end? from which end to which end?
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.
Yup end to end, here it means tests that only use the public REST api. We could expand further, or add another level to test the integration between client apps and the server.