Repository navigation
Conversation
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR fixes a retry timing bug in Kinesis integration tests (xlang_kinesisio_it_test.py and yaml/integration_tests.py) where time.sleep(2) was placed inside the try block rather than the except block during create_stream retries. Moving the sleep into the exception handler and increasing the retry count from 10 to 15 properly spaces out retry attempts while waiting for the LocalStack Kinesis service to initialize.
🔍 General Feedback
- The changes in both test files are clean, minimal, and directly resolve the premature timeout when LocalStack startup takes several seconds.
- Stream readiness polling via
describe_streamalready waits for theACTIVEstatus in subsequent loops, so removing the sleep after a successfulcreate_streamcall is safe.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #41204 +/- ##
============================================
- Coverage 59.26% 59.15% -0.11%
+ Complexity 4925 4892 -33
============================================
Files 1462 1461 -1
Lines 186313 186183 -130
Branches 3669 3645 -24
============================================
- Hits 110417 110143 -274
- Misses 72540 72685 +145
+ Partials 3356 3355 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| def create_stream(self, stream_name): | ||
| # localstack could not have initialized in the container yet so repeat | ||
| retries = 10 | ||
| retries = 15 |
There was a problem hiding this comment.
Why do we need to increase the number of retries?
| StreamName=stream_name, | ||
| ShardCount=1, | ||
| ) | ||
| time.sleep(2) |
There was a problem hiding this comment.
Removing this seems unnecessary. I think this is supposed to help us wait for the stream to be active.
There was a problem hiding this comment.
Done in 8cc143c — restored retries = 10 and the post-create_stream time.sleep(1), and added a comment explaining the time.sleep(2) in the except block.
| if i == retries - 1: | ||
| logging.error('Could not create kinesis stream') | ||
| raise e | ||
| time.sleep(2) |
There was a problem hiding this comment.
How does sleeping here help us? Add a comment explaining. Also, if we need to sleep longer to support fewer retries, that is ok.
| _LOCALSTACK_KINESIS_REGION = 'us-east-1' | ||
|
|
||
|
|
||
| def _create_kinesis_stream(kinesis_client, stream_name): |
There was a problem hiding this comment.
Same comments apply here as in the other file
There was a problem hiding this comment.
Done in 8cc143c — restored retries = 10 and the post-create_stream time.sleep(1), and added the explanatory comment here as well.
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR resolves flaky ConnectionClosedError failures in the LocalStack-based Kinesis integration tests (CrossLanguageKinesisIOTest and YAML KinesisTest) by adding a time.sleep(3) delay inside the except block of the create_stream retry loops. Previously, retries executed back-to-back without waiting when create_stream threw an exception during container startup.
🔍 General Feedback
- The root cause analysis and fix are clean, minimal, and consistently applied across both
xlang_kinesisio_it_test.pyandyaml/integration_tests.py. - No issues found; the changes look good to merge.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
…calstack-create-stream-retry
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR fixes flaky ConnectionClosedError failures in the Kinesis LocalStack integration tests (xlang_kinesisio_it_test.py and yaml/integration_tests.py) by adding a time.sleep(3) delay between create_stream retry attempts when an exception occurs. Previously, time.sleep(2) only ran after a successful create_stream call, causing all 10 retries to execute immediately in a tight loop before the LocalStack HTTP server finished initializing.
🔍 General Feedback
- The fix is minimal, targeted, and directly addresses the tight-loop retry exhaustion during LocalStack container startup across both test suites.
- Explanatory comments clearly document why the sleep in the
exceptblock is necessary.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:
Full details of the methodology of generation and review can be found here - https://docs.google.com/document/d/14lj7ECVov4T4EdwmIzNlWrRGE3lLDMOwX5xUMGzaLoc/edit?usp=sharing
If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)
Summary
Fixes flaky
botocore.exceptions.ConnectionClosedError: Connection was closed before we received a valid response from endpoint URL: "http://localhost:.../"failures inKinesisTest::test_only(PostCommit YAML Xlang Direct, run 43012453285) andCrossLanguageKinesisIOTest::test_kinesis_write(PostCommit Python).Root Cause
Both
_create_kinesis_stream(sdks/python/apache_beam/yaml/integration_tests.py) andKinesisHelper.create_stream(sdks/python/apache_beam/io/external/xlang_kinesisio_it_test.py) retrykinesis_client.create_stream(...)10 times while thelocalstack/localstack:3.8.1container is starting up. However,time.sleep(2)was only placed inside thetryblock aftercreate_stream()succeeded, with no sleep in theexcept Exception:block—so whencreate_stream()raisedConnectionClosedErrorbefore LocalStack's HTTP server finished initializing, all 10 retry attempts executed back-to-back in a tight loop and exhausted in under 1 second.Fix
Add
time.sleep(3)in theexcept Exception:block of_create_kinesis_streamandKinesisHelper.create_stream(while keepingretries = 10and the post-createtime.sleep(2)) so retries wait up to 30 seconds for LocalStack's HTTP endpoint to accept connections.Verification
python3 -m py_compile sdks/python/apache_beam/yaml/integration_tests.py sdks/python/apache_beam/io/external/xlang_kinesisio_it_test.pybeam_PostCommit_Yaml_Xlang_Direct.ymlon branchfix/kinesis-it-localstack-create-stream-retry(previous run 43054337164:success)