diff --git a/sdks/python/apache_beam/io/external/xlang_kinesisio_it_test.py b/sdks/python/apache_beam/io/external/xlang_kinesisio_it_test.py index 6a86248571e3..2d625b9337fc 100644 --- a/sdks/python/apache_beam/io/external/xlang_kinesisio_it_test.py +++ b/sdks/python/apache_beam/io/external/xlang_kinesisio_it_test.py @@ -286,6 +286,10 @@ def create_stream(self, stream_name): if i == retries - 1: logging.error('Could not create kinesis stream') raise e + # LocalStack's HTTP endpoint may not be ready to accept connections + # immediately after container startup; sleep before retrying so all + # attempts are not exhausted immediately on ConnectionClosedError. + time.sleep(3) # Wait for the stream to be active self.get_first_shard_id(stream_name) diff --git a/sdks/python/apache_beam/yaml/integration_tests.py b/sdks/python/apache_beam/yaml/integration_tests.py index a05a7b3ed317..5b204b6ef29d 100644 --- a/sdks/python/apache_beam/yaml/integration_tests.py +++ b/sdks/python/apache_beam/yaml/integration_tests.py @@ -1016,6 +1016,10 @@ def _create_kinesis_stream(kinesis_client, stream_name): if attempt == retries - 1: _LOGGER.error('Could not create kinesis stream') raise exn + # LocalStack's HTTP endpoint may not be ready to accept connections + # immediately after container startup; sleep before retrying so all + # attempts are not exhausted immediately on ConnectionClosedError. + time.sleep(3) for attempt in range(retries): stream = kinesis_client.describe_stream(StreamName=stream_name)