Skip to content

Commit 30dc617

Browse files
authored
Fix(test): Make template path unique in DataflowJobServiceTest (#35776)
* Fix(test): Make template path unique in DataflowJobServiceTest The `DirectPipelineTemplateTest` used a hardcoded GCS path for the `template_location`. This can cause test flakiness due to collisions between concurrent test runs or leftover artifacts from previous runs. This change uses `time.time()` to generate a unique template path for each test execution, ensuring test isolation and improving reliability. * format
1 parent 1386408 commit 30dc617

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sdks/python/apache_beam/runners/dataflow/dataflow_job_service_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# limitations under the License.
1616
#
1717

18+
import time
1819
import unittest
1920

2021
import apache_beam as beam
@@ -63,14 +64,16 @@ def test_template(self):
6364
None, beam_job_type=dataflow_job_service.DataflowBeamJob)
6465
port = job_servicer.start_grpc_server(0)
6566
try:
67+
template_path = (
68+
'gs://apache-beam-testing-temp/test/template-{}'.format(time.time()))
6669
options = PipelineOptions(
6770
runner='PortableRunner',
6871
job_endpoint=f'localhost:{port}',
6972
project='apache-beam-testing',
7073
region='us-central1',
7174
staging_location='gs://apache-beam-testing-stg/stg/',
7275
temp_location='gs://apache-beam-testing-temp/tmp',
73-
template_location='gs://apache-beam-testing-temp/test/template',
76+
template_location=template_path,
7477
)
7578
with beam.Pipeline(options=options) as p:
7679
_ = p | beam.Create([1, 2, 3]) | beam.Map(lambda x: x * x)

0 commit comments

Comments
 (0)