From 62221d86dc34fa704cf19eeba18774ae2ace5085 Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Wed, 16 Mar 2022 15:43:36 -0700 Subject: [PATCH 1/3] Align concurrency test acceptance criteria with short-term product needs --- .../test_operation_simple_heavy_traffic_concurrent.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py b/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py index ddd414302..db74fcc7a 100644 --- a/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py +++ b/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py @@ -23,16 +23,9 @@ from monitoring.prober.scd import actions -# TODO: verify if following issues are fixed with this PR. -# This test is implemented to fire requests concurrently, given there are several concurrent related issues: -# - https://github.com/interuss/dss/issues/417 -# - https://github.com/interuss/dss/issues/418 -# - https://github.com/interuss/dss/issues/419 -# - https://github.com/interuss/dss/issues/420 -# - https://github.com/interuss/dss/issues/421 - BASE_URL = 'https://example.com/uss' -OP_TYPES = [register_resource_type(110 + i, 'Operational intent {}'.format(i)) for i in range(100)] +# TODO(#742): Increase number of concurrent operations from 20 to 100 +OP_TYPES = [register_resource_type(110 + i, 'Operational intent {}'.format(i)) for i in range(20)] GROUP_SIZE = len(OP_TYPES) // 3 # Semaphore is added to limit the number of simultaneous requests, # default is 100. From 8b8aa224f6f8cc69878091f924bbfd9b7790de70 Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Tue, 22 Mar 2022 13:06:13 -0700 Subject: [PATCH 2/3] Add diagnostic information --- ...eration_simple_heavy_traffic_concurrent.py | 42 +++++++++++++++++-- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py b/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py index db74fcc7a..e3240b260 100644 --- a/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py +++ b/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py @@ -13,13 +13,14 @@ import asyncio import datetime +import json import inspect from monitoring.monitorlib.infrastructure import default_scope from monitoring.monitorlib import scd from monitoring.monitorlib.scd import SCOPE_SC from monitoring.monitorlib.testing import assert_datetimes_are_equal -from monitoring.prober.infrastructure import depends_on, for_api_versions, register_resource_type +from monitoring.prober.infrastructure import depends_on, for_api_versions, register_resource_type, IDFactory, resource_type_code_descriptions from monitoring.prober.scd import actions @@ -95,12 +96,20 @@ def _make_op_request_differ_in_time(idx, time_gap): # requests, so these two types of requests do not overlap at any time. def _make_op_request(idx, additional_time_gap=0): if idx < GROUP_SIZE: - return _make_op_request_differ_in_2d(idx) + req = _make_op_request_differ_in_2d(idx) + deconflict = '2d' elif idx < GROUP_SIZE * 2: - return _make_op_request_differ_in_altitude(idx) + req = _make_op_request_differ_in_altitude(idx) + deconflict = 'altitude' else: time_gap = datetime.timedelta(minutes=20 + additional_time_gap) - return _make_op_request_differ_in_time(idx, time_gap) + req = _make_op_request_differ_in_time(idx, time_gap) + deconflict = 'time' + extent = req['extents'][0] + volume = extent['volume'] + center = volume['outline_circle']['center'] + print('{} ({}): ({}, {}) {}-{} {}-{}'.format(idx, deconflict, center['lat'], center['lng'], volume['altitude_lower']['value'], volume['altitude_upper']['value'], extent['time_start']['value'], extent['time_end']['value'])) + return req def _intersection(list1, list2): @@ -220,6 +229,31 @@ def test_create_ops_concurrent(ids, scd_api, scd_session_async): op_resp_map[op_id]['status_code'] = resp[0][0] op_resp_map[op_id]['content'] = resp[0][1] for op_id, resp in op_resp_map.items(): + if resp['status_code'] != 200: + try: + owner_name, id_code = IDFactory.decode(op_id) + except ValueError: + owner_name = '' + id_code = '' + print('Error with op_id {}: {}\'s {}'.format(op_id, owner_name, resource_type_code_descriptions.get(id_code, ''))) + print('=== Request ===') + print(json.dumps(op_req_map[op_id])) + print('=== Response ===') + print(json.dumps(resp['content'])) + print('=== Missing operational intents ===') + if 'missing_operational_intents' in resp['content']: + for missing_op in resp['content']['missing_operational_intents']: + missing_id = missing_op.get('id', '') + try: + owner_name, id_code = IDFactory.decode(missing_id) + except ValueError: + owner_name = '' + id_code = '' + print('--- Missing op {}: {}\'s {}'.format(missing_id, owner_name, resource_type_code_descriptions.get(id_code, ''))) + print('--- Request:') + print(json.dumps(op_req_map[missing_id])) + print('--- Response:') + print(json.dumps(op_resp_map[missing_id])) assert resp['status_code'] == 200, resp['content'] req = op_req_map[op_id] data = resp['content'] From aa5c059b5593c4455ca7226d6c2f36c255377569 Mon Sep 17 00:00:00 2001 From: Benjamin Pelletier Date: Tue, 22 Mar 2022 13:06:43 -0700 Subject: [PATCH 3/3] Fix logic error in test --- .../scd/test_operation_simple_heavy_traffic_concurrent.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py b/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py index e3240b260..59b3c2157 100644 --- a/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py +++ b/monitoring/prober/scd/test_operation_simple_heavy_traffic_concurrent.py @@ -27,7 +27,7 @@ BASE_URL = 'https://example.com/uss' # TODO(#742): Increase number of concurrent operations from 20 to 100 OP_TYPES = [register_resource_type(110 + i, 'Operational intent {}'.format(i)) for i in range(20)] -GROUP_SIZE = len(OP_TYPES) // 3 +GROUP_SIZE = len(OP_TYPES) // 3 + (1 if len(OP_TYPES) % 3 > 0 else 0) # Semaphore is added to limit the number of simultaneous requests, # default is 100. SEMAPHORE = asyncio.Semaphore(10)