-
Notifications
You must be signed in to change notification settings - Fork 3
Update result analyzer and remaining changes #23
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
Open
eerxuan
wants to merge
8
commits into
documentdb:main
Choose a base branch
from
eerxuan:result-analyzer-updates-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d927723
Update result analyzer and remaining changes
a85dd94
Fix lint: line too long in report_generator.py, formatting in analyze…
8c15c6b
Move Counter import to top-level per PEP 8
62989be
Fix pytest.ini discovery: resolve relative to package instead of CWD
1e4935a
Merge generate_text_report and print_summary into single function
c70ae17
Add unit tests for failure extraction and categorization
5ce3b42
Add unit tests job to PR checks
71110c8
Fix mypy failures and run mypy on PR lint check.
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
Some comments aren't visible on the classic Files Changed page.
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
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
104 changes: 104 additions & 0 deletions
104
documentdb_tests/compatibility/result_analyzer/test_analyzer.py
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,104 @@ | ||
| """Tests for failure extraction and categorization in the analyzer.""" | ||
|
|
||
| from documentdb_tests.compatibility.result_analyzer.analyzer import ( | ||
| extract_exception_type, | ||
| extract_failure_tag, | ||
| is_infrastructure_error, | ||
| ) | ||
|
|
||
|
|
||
| def _make_test_result(crash_message: str) -> dict: | ||
| """Helper to build a minimal test result dict with a crash message.""" | ||
| return {"call": {"crash": {"message": crash_message}}} | ||
|
|
||
|
|
||
| # --- extract_failure_tag --- | ||
|
|
||
|
|
||
| class TestExtractFailureTag: | ||
| def test_result_mismatch(self): | ||
| result = _make_test_result("[RESULT_MISMATCH] Expected [1,2,3] but got [1,2]") | ||
| assert extract_failure_tag(result) == "RESULT_MISMATCH" | ||
|
|
||
| def test_unexpected_error(self): | ||
| result = _make_test_result("[UNEXPECTED_ERROR] Expected success but got exception") | ||
| assert extract_failure_tag(result) == "UNEXPECTED_ERROR" | ||
|
|
||
| def test_error_mismatch(self): | ||
| result = _make_test_result("[ERROR_MISMATCH] Expected code 11000 but got 26") | ||
| assert extract_failure_tag(result) == "ERROR_MISMATCH" | ||
|
|
||
| def test_unexpected_success(self): | ||
| result = _make_test_result("[UNEXPECTED_SUCCESS] Expected error but got result") | ||
| assert extract_failure_tag(result) == "UNEXPECTED_SUCCESS" | ||
|
|
||
| def test_test_exception(self): | ||
| result = _make_test_result("[TEST_EXCEPTION] Bad test setup") | ||
| assert extract_failure_tag(result) == "TEST_EXCEPTION" | ||
|
|
||
| def test_no_tag(self): | ||
| result = _make_test_result("AssertionError: values differ") | ||
| assert extract_failure_tag(result) == "" | ||
|
|
||
| def test_empty_message(self): | ||
| result = _make_test_result("") | ||
| assert extract_failure_tag(result) == "" | ||
|
|
||
| def test_missing_call(self): | ||
| assert extract_failure_tag({}) == "" | ||
|
|
||
|
|
||
| # --- extract_exception_type --- | ||
|
|
||
|
|
||
| class TestExtractExceptionType: | ||
| def test_simple_exception(self): | ||
| assert extract_exception_type("ConnectionError: refused") == "ConnectionError" | ||
|
|
||
| def test_dotted_exception(self): | ||
| assert ( | ||
| extract_exception_type("pymongo.errors.OperationFailure: code 11000") | ||
| == "pymongo.errors.OperationFailure" | ||
| ) | ||
|
|
||
| def test_no_colon(self): | ||
| assert extract_exception_type("just a message") == "" | ||
|
|
||
| def test_empty(self): | ||
| assert extract_exception_type("") == "" | ||
|
|
||
|
|
||
| # --- is_infrastructure_error --- | ||
|
|
||
|
|
||
| class TestIsInfrastructureError: | ||
| def test_connection_error(self): | ||
| result = _make_test_result("ConnectionError: Cannot connect") | ||
| assert is_infrastructure_error(result) is True | ||
|
|
||
| def test_timeout_error(self): | ||
| result = _make_test_result("TimeoutError: timed out") | ||
| assert is_infrastructure_error(result) is True | ||
|
|
||
| def test_pymongo_connection_failure(self): | ||
| result = _make_test_result("pymongo.errors.ConnectionFailure: connection lost") | ||
| assert is_infrastructure_error(result) is True | ||
|
|
||
| def test_pymongo_server_selection(self): | ||
| result = _make_test_result("pymongo.errors.ServerSelectionTimeoutError: no servers") | ||
| assert is_infrastructure_error(result) is True | ||
|
|
||
| def test_assertion_error_not_infra(self): | ||
| result = _make_test_result("AssertionError: [RESULT_MISMATCH] wrong value") | ||
| assert is_infrastructure_error(result) is False | ||
|
|
||
| def test_operation_failure_not_infra(self): | ||
| result = _make_test_result("pymongo.errors.OperationFailure: code 11000") | ||
| assert is_infrastructure_error(result) is False | ||
|
|
||
| def test_empty_message(self): | ||
| result = _make_test_result("") | ||
| assert is_infrastructure_error(result) is False | ||
|
|
||
| def test_missing_call(self): | ||
| assert is_infrastructure_error({}) is False |
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 @@ | ||
| """Collection management tests.""" |
Oops, something went wrong.
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.