Python: update test_logical.py to use seed in random #17652
Closed
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.
Pull Request checklist
All query authors
.qhelp
. See the documentation in this repository.Internal query authors only
.ql
,.qll
, or.qhelp
files. See the documentation (internal access required).Description
This PR introduces a global random seed, set immediately after the imports in the test file. By doing so, the tests will exhibit consistent random behavior across runs, making them more deterministic and significantly easier to debug.
Current Issues (Before this PR):
a. Flaky Tests: Test outcomes can vary, sometimes passing and other times failing due to unpredictable random values;
b. Difficult to Reproduce: When a test fails, it becomes challenging to recreate the exact conditions for debugging;
c. Inconsistent CI/CD Results: Different CI pipeline runs may yield inconsistent outcomes;
d. Wasted Debugging Time: Developers spend unnecessary time chasing down issues that are difficult to replicate.
Solution
To address these issues, this PR sets a global random seed at the top of the test file, right after the imports.
Benefits
a. Reproducibility: Each test run will generate the same random values, ensuring consistency;
b. Improved Debugging: Failures can be easily reproduced, aiding in quicker diagnosis and resolution;
c. Stable CI/CD Pipelines: CI runs will produce consistent results, reducing pipeline variability;
d. Explicit Control: The use of controlled randomness is immediately clear in the test structure;
e. Time Efficiency: Developers will spend less time debugging random-related failures, improving overall productivity.