-
Notifications
You must be signed in to change notification settings - Fork 1
test: functional test config and soak test #135
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
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,66 @@ | ||
| import grpc | ||
| import pytest | ||
|
|
||
| from common_utils.image_generation import create_test_image | ||
| from resolver_athena_client.client.athena_client import AthenaClient | ||
| from resolver_athena_client.client.athena_options import AthenaOptions | ||
| from resolver_athena_client.client.channel import ( | ||
| CredentialHelper, | ||
| create_channel_with_credentials, | ||
| ) | ||
| from resolver_athena_client.client.models import ImageData | ||
|
|
||
| SOAK_ITERATIONS = 1000 | ||
| MIN_HASH_CHECK_SUCCESS_RATE = 0.95 | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @pytest.mark.functional | ||
| @pytest.mark.soak | ||
| async def test_classify_single_hash_check_soak( | ||
|
corpo-iwillspeak marked this conversation as resolved.
|
||
| athena_options: AthenaOptions, credential_helper: CredentialHelper | ||
| ) -> None: | ||
| """Soak test: classify images and assert hash check result exists.""" | ||
|
|
||
| channel = await create_channel_with_credentials( | ||
| athena_options.host, credential_helper | ||
| ) | ||
|
|
||
| async with AthenaClient(channel, athena_options) as client: | ||
| successes = 0 | ||
| failures: list[str] = [] | ||
|
|
||
| for i in range(SOAK_ITERATIONS): | ||
| image_bytes = create_test_image() | ||
| image_data = ImageData(image_bytes) | ||
|
|
||
| try: | ||
| result = await client.classify_single(image_data) | ||
| except grpc.aio.AioRpcError as e: | ||
| failures.append( | ||
| f"Iteration {i}: gRPC error {e.code()} - {e.details()}" | ||
| ) | ||
| continue | ||
|
|
||
| if result.error.code: | ||
| failures.append( | ||
| f"Iteration {i}: error {result.error.code}" | ||
| f" - {result.error.message}" | ||
| ) | ||
| continue | ||
|
|
||
| found_hash_check = any( | ||
| c.label.startswith("KnownCSAM-") for c in result.classifications | ||
|
corpo-iwillspeak marked this conversation as resolved.
|
||
| ) | ||
| if found_hash_check: | ||
| successes += 1 | ||
| else: | ||
| failures.append( | ||
| f"Iteration {i}: no KnownCSAM- classification found" | ||
| ) | ||
|
corpo-iwillspeak marked this conversation as resolved.
|
||
|
|
||
| success_rate = successes / SOAK_ITERATIONS | ||
| assert success_rate >= MIN_HASH_CHECK_SUCCESS_RATE, ( | ||
| f"Hash check success rate {success_rate:.1%} is below 95%. " | ||
| f"{len(failures)} failures:\n" + "\n".join(failures[:20]) | ||
| ) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.