Skip to content

Commit b2959f3

Browse files
committed
WiP
1 parent d049973 commit b2959f3

File tree

11 files changed

+222
-361
lines changed

11 files changed

+222
-361
lines changed

e2e_batch/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
APIGEE_ACCESS_TOKEN ?= $(shell export SSO_LOGIN_URL=https://login.apigee.com && eval get_token -u $(APIGEE_USERNAME))
44
AWS_DOMAIN_NAME=https://$(shell make -C ../terraform -s output name=service_domain_name || true)
5-
PARALLEL_WORKERS=1
5+
PARALLEL_WORKERS=2
66

77
print-token:
88
@echo "APIGEE_ACCESS_TOKEN=$(APIGEE_ACCESS_TOKEN)"
99

1010

1111
run-immunization-batch:
12-
ENVIRONMENT=$(environment) poetry run python -m unittest -v -c
12+
ENVIRONMENT=$(ENVIRONMENT) poetry run python -m unittest -v -c
1313

1414
test:
15-
ENVIRONMENT=$(environment) poetry run python -m unittest -v -c
15+
ENVIRONMENT=$(ENVIRONMENT) time poetry run python -m unittest -v -c
1616

1717
testp1:
1818
ENVIRONMENT=$(ENVIRONMENT) time poetry run unittest-parallel -v -j $(PARALLEL_WORKERS)

e2e_batch/e2e_batch_base.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

e2e_batch/per_test.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,33 @@
55
logger = logging.getLogger("PERFORMANCE")
66
logger.setLevel("INFO")
77

8-
marker = {}
8+
test_marker = {}
9+
std_marker = {}
910

1011

11-
def monitor(nameMarker):
12+
def dump_stats(marker):
13+
total = 0
14+
15+
for name, start_time in marker.items():
16+
duration = time.perf_counter_ns() - start_time
17+
elapsed_s = duration / 1_000_000_000
18+
total += elapsed_s
19+
logger.info(f"end [{name}]: {elapsed_s:.3f} s")
20+
logger.info(f"total: {total:.3f} s | average: {total / len(marker):.3f} s")
21+
22+
23+
def monitor(nameMarker, is_test=True):
1224
t = time.perf_counter_ns()
25+
marker = test_marker if is_test else std_marker
26+
1327
if nameMarker in marker:
1428
duration = t - marker[nameMarker]
1529
elapsed_ms = duration / 1_000_000
16-
logger.info(f"end [{nameMarker}]: {elapsed_ms} ms")
17-
30+
elapsed_s = elapsed_ms / 1000
31+
logger.info(f"end [{nameMarker}]: {elapsed_s:.3f} s")
32+
if is_test:
33+
dump_stats(marker)
1834
del marker[nameMarker] # <-- remove the marker after logging
1935
else:
2036
logger.info(f"start [{nameMarker}]")
21-
marker[nameMarker] = t
37+
marker[nameMarker] = t

e2e_batch/poetry.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e_batch/test_e2e_batch.py

Lines changed: 6 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import time
21
import unittest
32
from utils import (
43
generate_csv,
@@ -7,9 +6,6 @@
76
wait_for_ack_file,
87
check_ack_file_content,
98
validate_row_count,
10-
upload_config_file,
11-
generate_csv_with_ordered_100000_rows,
12-
verify_final_ack_file,
139
delete_file_from_s3
1410
)
1511
from per_test import monitor
@@ -18,10 +14,7 @@
1814
SOURCE_BUCKET,
1915
INPUT_PREFIX,
2016
ACK_BUCKET,
21-
PRE_VALIDATION_ERROR,
22-
POST_VALIDATION_ERROR,
2317
DUPLICATE,
24-
FILE_NAME_VAL_ERROR,
2518
environment
2619
)
2720

@@ -32,10 +25,16 @@ def setUp(self):
3225
self.ack_files = [] # Tracks ack keys
3326

3427
def tearDown(self):
28+
# get name of unit test
29+
unit_test_name = self._testMethodName
30+
marker = f"tearDown-{unit_test_name}"
31+
32+
monitor(marker, is_test=False)
3533
for file_key in self.uploaded_files:
3634
delete_file_from_s3(SOURCE_BUCKET, file_key)
3735
for ack_key in self.ack_files:
3836
delete_file_from_s3(ACK_BUCKET, ack_key)
37+
monitor(marker, is_test=False)
3938

4039
if environment != "ref":
4140
def test_create_success(self):
@@ -143,110 +142,3 @@ def test_delete_success(self):
143142
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
144143
check_ack_file_content(ack_content, "OK", None, "DELETE")
145144
monitor("test_delete_success")
146-
147-
def test_pre_validation_error(self):
148-
"""Test PRE-VALIDATION error scenario."""
149-
monitor("test_pre_validation_error")
150-
input_file = generate_csv("PHYLIS", "TRUE", action_flag="CREATE")
151-
152-
key = upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX)
153-
self.uploaded_files.append(key)
154-
155-
ack_key = wait_for_ack_file(None, input_file)
156-
self.ack_files.append(ack_key)
157-
158-
validate_row_count(input_file, ack_key)
159-
160-
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
161-
check_ack_file_content(ack_content, "Fatal Error", PRE_VALIDATION_ERROR, None)
162-
monitor("test_pre_validation_error")
163-
164-
def test_post_validation_error(self):
165-
"""Test POST-VALIDATION error scenario."""
166-
monitor("test_post_validation_error")
167-
input_file = generate_csv("", "0.3", action_flag="CREATE")
168-
169-
key = upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX)
170-
self.uploaded_files.append(key)
171-
172-
ack_key = wait_for_ack_file(None, input_file)
173-
self.ack_files.append(ack_key)
174-
175-
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
176-
check_ack_file_content(ack_content, "Fatal Error", POST_VALIDATION_ERROR, None)
177-
monitor("test_post_validation_error")
178-
179-
def test_file_name_validation_error(self):
180-
"""Test FILE-NAME-VALIDATION error scenario."""
181-
monitor("test_file_name_validation_error")
182-
input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE", file_key=True)
183-
184-
key = upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX)
185-
self.uploaded_files.append(key)
186-
187-
ack_key = wait_for_ack_file(True, input_file)
188-
self.ack_files.append(ack_key)
189-
190-
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
191-
check_ack_file_content(ack_content, "Failure", FILE_NAME_VAL_ERROR, None)
192-
monitor("test_file_name_validation_error")
193-
194-
def test_header_name_validation_error(self):
195-
"""Test HEADER-NAME-VALIDATION error scenario."""
196-
monitor("test_header_name_validation_error")
197-
input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE", headers="NH_NUMBER")
198-
199-
key = upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX)
200-
self.uploaded_files.append(key)
201-
202-
ack_key = wait_for_ack_file(True, input_file)
203-
self.ack_files.append(ack_key)
204-
205-
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
206-
check_ack_file_content(ack_content, "Failure", FILE_NAME_VAL_ERROR, None)
207-
monitor("test_header_name_validation_error")
208-
209-
# This test updates the permissions_config.json file from the imms-internal-dev-supplier-config
210-
# S3 bucket shared across multiple environments (PR environments, internal-dev, int, and ref).
211-
# Running this may modify permissions in these environments, causing unintended side effects.
212-
@unittest.skip("Modifies shared S3 permissions configuration")
213-
def test_invalid_permission(self):
214-
"""Test INVALID-PERMISSION error scenario."""
215-
monitor("test_invalid_permission")
216-
upload_config_file("MMR_FULL") # permissions_config.json is updated here
217-
time.sleep(20)
218-
219-
input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE")
220-
221-
key = upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX)
222-
self.uploaded_files.append(key)
223-
224-
ack_key = wait_for_ack_file(True, input_file)
225-
self.ack_files.append(ack_key)
226-
227-
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
228-
check_ack_file_content(ack_content, "Failure", FILE_NAME_VAL_ERROR, None)
229-
230-
upload_config_file("COVID19_FULL")
231-
time.sleep(20)
232-
monitor("test_invalid_permission")
233-
234-
else:
235-
def test_end_to_end_speed_test_with_100000_rows(self):
236-
monitor("test_end_to_end_speed_test_with_100000_rows")
237-
"""Test end_to_end_speed_test_with_100000_rows scenario with full integration"""
238-
input_file = generate_csv_with_ordered_100000_rows(None)
239-
240-
key = upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX)
241-
self.uploaded_files.append(key)
242-
243-
final_ack_key = wait_for_ack_file(None, input_file, timeout=1800)
244-
self.ack_files.append(final_ack_key)
245-
246-
response = verify_final_ack_file(final_ack_key)
247-
assert response is True
248-
monitor("test_end_to_end_speed_test_with_100000_rows")
249-
250-
251-
if __name__ == "__main__":
252-
unittest.main()

0 commit comments

Comments
 (0)