Skip to content

Commit

Permalink
Conditional call of GET request based on notification
Browse files Browse the repository at this point in the history
  • Loading branch information
punamverma committed Dec 14, 2023
1 parent 62f1155 commit 844fb4b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ In order to run this test scenario, we need tested_uss to trigger GET operationa
But, if there is a subscription by tested_uss, that would trigger notification of flight 2 to tested_uss.
Some USSes will not make a GET request to control_uss for flight 2 details, while planning a nearby flight,
if they got a notification for flight2. Hence, if a USS didn't make a GET request, we will only fail it if didn't get
a notification, or else, a precondition for the test will not be met.
a notification, or else, a precondition for the test will not be met. Some USSes might make a GET request despite getting
a notification, but as it would not be clear whether invalid information through notification or GET request was used for planning,
the test will be not be continued.

### [Tested_uss plans flight 1 test step](../../../flight_planning/plan_flight_intent.md)
The test driver attempts to plan flight 1 via the tested USS. It checks if any conflicts with flight 2
Expand Down Expand Up @@ -76,7 +78,9 @@ In order to run this test scenario, we need tested_uss to trigger GET operationa
But, if there is a subscription by tested_uss, that would trigger notification of flight 2 to tested_uss.
Some USSes will not make a GET request to control_uss for flight 2 details, while planning a nearby flight,
if they got a notification for flight2. Hence, if a USS didn't make a GET request, we will only fail it if didn't get
a notification, or else, a precondition for the test will not be met.
a notification, or else, a precondition for the test will not be met. Some USSes might make a GET request despite getting
a notification, but as it would not be clear whether invalid information through notification or GET request was used for planning,
the test will be not be continued.

### [Tested_uss attempts to plan flight 1, expect failure test step](test_steps/plan_flight_intent_expect_failed.md)
The test driver attempts to plan the flight 1 via the tested_uss. It checks if any conflicts with flight 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,21 @@ def _tested_uss_plans_deconflicted_flight_near_existing_flight(
flight_1,
)

get_requested, already_notified = expect_get_requests_to_mock_uss(
self,
self.control_uss,
planning_time,
self.control_uss.base_url,
flight_2_oi_ref.id,
self.tested_uss_client.participant_id,
tested_uss_notified,
"Validate flight2 GET interaction",
)

if get_requested == False and already_notified == True:
if tested_uss_notified:
expect_get_requests_to_mock_uss(
self,
self.control_uss,
planning_time,
self.control_uss.base_url,
flight_2_oi_ref.id,
self.tested_uss_client.participant_id,
"Validate flight2 GET interaction",
)
else:
msg = (
f"GET request was not made by tested_uss, as it was notified of flight2, due to an existing subscription. "
f"Tested_uss was notified of flight2, due to an existing subscription. Hence, not checking for the GET requests."
f"Whether a GET request is made or not, it would be unclear clear if tested_uss used the information from notification or GET request for planning."
f"As this test is for checking GET requests validation, we cannot continue the test."
f"See documentation of test step - Check for notification to tested_uss due to subscription in flight 2 area"
)
raise ScenarioCannotContinueError(msg)
Expand Down Expand Up @@ -298,19 +299,23 @@ def _tested_uss_unable_to_plan_flight_near_invalid_shared_existing_flight(
)
validator.expect_not_shared()

get_requested, already_notified = expect_get_requests_to_mock_uss(
self,
self.control_uss,
planning_time,
self.control_uss.base_url,
flight_2_oi_ref.id,
self.tested_uss_client.participant_id,
tested_uss_notified,
"Validate flight 2 GET interaction",
)

if get_requested == False and already_notified == True:
msg = f"GET request was not made by tested_uss, as it was notified of flight2, due to an exisitng subscription."
if tested_uss_notified:
expect_get_requests_to_mock_uss(
self,
self.control_uss,
planning_time,
self.control_uss.base_url,
flight_2_oi_ref.id,
self.tested_uss_client.participant_id,
"Validate flight 2 GET interaction",
)
else:
msg = (
f"Tested_uss was notified of flight2, due to an existing subscription. Hence, not checking for the GET requests."
f"Whether a GET request is made or not, it would be unclear clear if tested_uss used the information from notification or GET request for planning."
f"As this test is for checking GET requests validation, we cannot continue the test."
f"See documentation of test step - Check for notification to tested_uss due to subscription in flight 2 area"
)
raise ScenarioCannotContinueError(msg)

expect_no_interuss_post_interactions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,22 +107,15 @@ def expect_get_requests_to_mock_uss(
mock_uss_base_url: str,
id: str,
participant_id: str,
already_notified_other_uss: bool,
test_step: str,
) -> Tuple[bool, bool]:
):
"""
This step checks a GET request was made to mock_uss for an existing entity, from time 'st' to now
Args:
mock_uss_base_url: url of the mock_uss that is managing the entity
id: entity id
participant_id: id of the participant responsible to send GET request
already_notified_other_uss: If True, then a subscription existed that caused mock_uss to send notification
Returns:
get_requested: bool, already_notified_other_uss: bool
[False, True] when GET request not made due to a notification already sent by mock_uss
[True, True|False] when GET request made
[False, False] other uss failed to make a GET request
"""
scenario.begin_test_step(test_step)
interactions, query = _get_interuss_interactions_with_check(scenario, mock_uss, st)
Expand All @@ -135,8 +128,6 @@ def expect_get_requests_to_mock_uss(
get_requested = True
break
if not get_requested:
if already_notified_other_uss:
return get_requested, already_notified_other_uss
with scenario.check("Expect GET request", [participant_id]) as check:
check.record_failed(
summary=f"No GET request received at {mock_uss_base_url} for {id} ",
Expand All @@ -145,7 +136,6 @@ def expect_get_requests_to_mock_uss(
query_timestamps=[query.request.timestamp],
)
scenario.end_test_step()
return get_requested, already_notified_other_uss


def _get_interuss_interactions_with_check(
Expand Down Expand Up @@ -202,10 +192,6 @@ def is_uss_interaction(interaction: Interaction, excl_sub: str) -> bool:
for interaction in all_interactions:
if is_uss_interaction(interaction, exclude_sub):
interuss_interactions.append(interaction)
logger.debug(
f"Interuss interaction reported : {interaction.query.request.method} {interaction.query.request.url} "
f"with response {interaction.query.response.status_code}"
)

return interuss_interactions, query

Expand Down

0 comments on commit 844fb4b

Please sign in to comment.