Skip to content

Commit 9eeb8b4

Browse files
committed
WIP - park
1 parent e19b3e0 commit 9eeb8b4

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

e2e_batch/test_e2e_batch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def process_acks_as_received(test_datas, ack_bucket, poll_interval=2, timeout=12
7373

7474
while pending and (time.time() - start_time) < timeout:
7575
for file_name in list(pending.keys()):
76-
ack_key = wait_for_ack_file(None, file_name, ack_bucket, timeout=0)
76+
ack_key = wait_for_ack_file(None, file_name, ack_bucket, timeout=1)
7777
if ack_key:
7878
# Process the ACK immediately
7979
validate_row_count(file_name, ack_key)

e2e_batch/utils.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,31 @@ def wait_for_ack_file(ack_prefix, input_file_name, timeout=1200):
181181
)
182182

183183

184+
def poll_ack_file(ack_prefix, input_file_name):
185+
"""Poll the ACK_BUCKET for an ack file that contains the input_file_name as a substring."""
186+
187+
filename_without_ext = input_file_name[:-4] if input_file_name.endswith(".csv") else input_file_name
188+
if ack_prefix:
189+
search_pattern = f"{ACK_PREFIX}{filename_without_ext}"
190+
ack_prefix = ACK_PREFIX
191+
else:
192+
search_pattern = f"{FORWARDEDFILE_PREFIX}{filename_without_ext}"
193+
ack_prefix = FORWARDEDFILE_PREFIX
194+
return poll_s3_file_pattern(ack_prefix, search_pattern)
195+
196+
197+
def poll_s3_file_pattern(prefix, search_pattern):
198+
"""Poll the ACK_BUCKET for an ack file that contains the input_file_name as a substring."""
199+
200+
response = s3_client.list_objects_v2(Bucket=ACK_BUCKET, Prefix=prefix)
201+
if "Contents" in response:
202+
for obj in response["Contents"]:
203+
key = obj["Key"]
204+
if search_pattern in key:
205+
return key
206+
return None
207+
208+
184209
def get_file_content_from_s3(bucket, key):
185210
"""Download and return the file content from S3."""
186211

0 commit comments

Comments
 (0)