Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[uss_qualifier] Adding the interactions and invalid op checks steps #376

Merged
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e2e55c8
Adding the interactions and invalid op checks steps
punamverma Nov 29, 2023
84c59cc
Added mock_uss to prep_planners doc
punamverma Nov 29, 2023
83e1e08
fix format
punamverma Nov 29, 2023
2ddb964
Fix doc
punamverma Nov 29, 2023
1a6622f
Adding missing code
punamverma Nov 29, 2023
ce4488e
Adding missing mock_uss resource to PrepareFlightPlanners
punamverma Nov 30, 2023
2aa5f05
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Nov 30, 2023
a44b49e
Fix per PR comments
punamverma Dec 1, 2023
907cbfe
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Dec 1, 2023
c2e8bf6
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Dec 1, 2023
9687ac2
Removing post check for a particular url
punamverma Dec 1, 2023
83a40d8
Fixing check details
punamverma Dec 1, 2023
3a8bdc4
Adding 5 s back, removing url check no post interactions
punamverma Dec 1, 2023
3df884c
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Dec 2, 2023
42cceda
Wait only for checking POST notifications
punamverma Dec 2, 2023
8fdcb69
Fix per PR comments
punamverma Dec 4, 2023
8797056
Fix per PR review
punamverma Dec 4, 2023
9abdf23
Fix format
punamverma Dec 4, 2023
fbae1b1
Refactoring code, removed wait time for other than post interactions …
punamverma Dec 6, 2023
40bc79c
querying for interactions optimistically
punamverma Dec 7, 2023
22931da
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Dec 7, 2023
d282151
Fix passing ref id
punamverma Dec 7, 2023
f892e01
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Dec 7, 2023
2c7dba1
Update monitoring/uss_qualifier/scenarios/astm/utm/data_exchange_vali…
punamverma Dec 8, 2023
b330dff
Fix per review comments
punamverma Dec 8, 2023
1fcbafa
Fix per review
punamverma Dec 8, 2023
fca841f
Adding missing code for Query
punamverma Dec 8, 2023
688dd4c
Fixed documentation for wait time as per PR comments
punamverma Dec 11, 2023
e9b0566
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Dec 11, 2023
1405f0e
Adding subscription check with GET request check
punamverma Dec 12, 2023
694ff22
Fixed per PR comments
punamverma Dec 13, 2023
4bcb865
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Dec 13, 2023
1f588ec
Fix per review
punamverma Dec 14, 2023
75d57b1
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Dec 14, 2023
62f1155
Removing args from comments
punamverma Dec 14, 2023
844fb4b
Conditional call of GET request based on notification
punamverma Dec 14, 2023
7999f53
Refining check message
punamverma Dec 14, 2023
aa89491
Removing else condition, and renaming test step and check as discussed
punamverma Dec 15, 2023
ee8d6cb
Merge branch 'main' into interactions_and_invalid_op_checks
punamverma Dec 15, 2023
2e4d228
Changing method name per review
punamverma Dec 16, 2023
d09dab5
fixing the condition for GET request check
punamverma Dec 16, 2023
2ce1399
Want to trigger CI run that failed on netrid test
punamverma Dec 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions monitoring/monitorlib/clients/flight_planning/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,12 @@ def clear_area(self, area: Volume4D) -> TestPreparationActivityResponse:
* PlanningActivityError
"""
raise NotImplementedError()

@abstractmethod
def get_base_url(self) -> str:
"""
Get the base_url associated with this FlightPlannerClient
Returns:

"""
raise NotImplementedError
3 changes: 3 additions & 0 deletions monitoring/monitorlib/clients/flight_planning/client_scd.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,6 @@ def clear_area(self, area: Volume4D) -> TestPreparationActivityResponse:
errors = [f"[{resp.outcome.timestamp}]: {resp.outcome.message}"]

return TestPreparationActivityResponse(errors=errors, queries=[query])

def get_base_url(self):
return self._session.get_prefix_url()
3 changes: 3 additions & 0 deletions monitoring/monitorlib/clients/flight_planning/client_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,6 @@ def clear_area(self, area: Volume4D) -> TestPreparationActivityResponse:
errors = [resp.outcome.message]

return TestPreparationActivityResponse(errors=errors, queries=[query])

def get_base_url(self):
return self._session.get_prefix_url()
40 changes: 31 additions & 9 deletions monitoring/uss_qualifier/resources/astm/f3548/v21/dss.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from __future__ import annotations

import uuid
from typing import Tuple, List, Optional
from urllib.parse import urlparse
from typing import Tuple, List, Dict, Optional

from urllib.parse import urlparse
from implicitdict import ImplicitDict

from monitoring.monitorlib import infrastructure, fetch
Expand Down Expand Up @@ -95,6 +94,31 @@ def get_full_op_intent(
op_intent_ref: OperationalIntentReference,
uss_participant_id: Optional[str] = None,
) -> Tuple[OperationalIntent, fetch.Query]:
result, query = self.get_full_op_intent_without_validation(
op_intent_ref,
uss_participant_id,
)
if query.status_code != 200:
result = None
else:
result = ImplicitDict.parse(
query.response.json, GetOperationalIntentDetailsResponse
).operational_intent
return result, query

def get_full_op_intent_without_validation(
BenjaminPelletier marked this conversation as resolved.
Show resolved Hide resolved
self,
op_intent_ref: OperationalIntentReference,
uss_participant_id: Optional[str] = None,
) -> Tuple[Dict, fetch.Query]:
"""
GET OperationalIntent without validating, as invalid data expected for negative tests
Args:
op_intent_ref:
BenjaminPelletier marked this conversation as resolved.
Show resolved Hide resolved
uss_participant_id:
Returns:
returns the response json when query is successful
"""
url = f"{op_intent_ref.uss_base_url}/uss/v1/operational_intents/{op_intent_ref.id}"
query = fetch.query_and_describe(
BenjaminPelletier marked this conversation as resolved.
Show resolved Hide resolved
self.client,
Expand All @@ -104,12 +128,10 @@ def get_full_op_intent(
uss_participant_id,
scope=SCOPE_SC,
)
if query.status_code != 200:
result = None
else:
result = ImplicitDict.parse(
query.response.json, GetOperationalIntentDetailsResponse
).operational_intent
result = None
if query.status_code == 200:
result = query.response.json

return result, query

def put_op_intent(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from typing import Optional, Dict

from monitoring.monitorlib.clients.flight_planning.flight_info_template import (
FlightInfoTemplate,
)
from monitoring.monitorlib.temporal import TimeDuringTest, Time
from monitoring.monitorlib.temporal import TimeDuringTest
from urllib.parse import urlsplit
import arrow
from implicitdict import StringBasedDateTime

from monitoring.monitorlib.temporal import Time
from monitoring.monitorlib.clients.flight_planning.client import FlightPlannerClient
from monitoring.uss_qualifier.resources.astm.f3548.v21 import DSSInstanceResource
from monitoring.uss_qualifier.resources.astm.f3548.v21.dss import DSSInstance
Expand All @@ -25,7 +27,12 @@
plan_flight_intent_expect_failed,
)
from monitoring.uss_qualifier.scenarios.astm.utm.test_steps import OpIntentValidator

from monitoring.uss_qualifier.scenarios.astm.utm.data_exchange_validation.test_steps.expected_interactions_test_steps import (
expect_interuss_post_interactions,
expect_interuss_get_interactions,
expect_no_interuss_post_interactions,
precondition_no_post_interaction,
)
from monitoring.monitorlib.clients.mock_uss.mock_uss_scd_injection_api import (
MockUssFlightBehavior,
)
Expand Down Expand Up @@ -138,6 +145,8 @@ def _tested_uss_plans_deconflicted_flight_near_existing_flight(
):
times[TimeDuringTest.TimeOfEvaluation] = Time(arrow.utcnow().datetime)
flight_2 = self.flight_2.resolve(times)

planning_time = Time(arrow.utcnow().datetime)
BenjaminPelletier marked this conversation as resolved.
Show resolved Hide resolved
with OpIntentValidator(
self,
self.control_uss_client,
Expand All @@ -152,17 +161,18 @@ def _tested_uss_plans_deconflicted_flight_near_existing_flight(
flight_2,
)

validator.expect_shared(flight_2)
flight_2_oi_ref = validator.expect_shared(flight_2)

self.begin_test_step(
"Precondition - check tested_uss has no subscription in flight 2 area"
self._precondition_no_post_interaction(
self.control_uss,
planning_time,
"Precondition - check tested_uss has no subscription in flight 2 area",
)
# ToDo - Add the test step details
self.end_test_step()

times[TimeDuringTest.TimeOfEvaluation] = Time(arrow.utcnow().datetime)
flight_1 = self.flight_1.resolve(times)

planning_time = Time(arrow.utcnow().datetime)
BenjaminPelletier marked this conversation as resolved.
Show resolved Hide resolved
with OpIntentValidator(
self,
self.tested_uss_client,
Expand All @@ -176,18 +186,26 @@ def _tested_uss_plans_deconflicted_flight_near_existing_flight(
self.tested_uss_client,
flight_1,
)

validator.expect_shared(
flight_1,
)

self.begin_test_step("Validate flight2 GET interaction")
# ToDo - Add the test step details
self.end_test_step()

self.begin_test_step("Validate flight1 Notification sent to Control_uss")
# ToDo - Add the test step details
self.end_test_step()
control_uss_domain = self.control_uss.base_url
BenjaminPelletier marked this conversation as resolved.
Show resolved Hide resolved
expect_interuss_get_interactions(
self,
self.control_uss,
planning_time,
control_uss_domain,
flight_2_oi_ref.id,
"Validate flight2 GET interaction",
)
expect_interuss_post_interactions(
self,
self.control_uss,
planning_time,
control_uss_domain,
"Validate flight1 Notification sent to Control_uss",
)

delete_flight(
self, "Delete tested_uss flight", self.tested_uss_client, self.flight_1_id
Expand All @@ -213,52 +231,83 @@ def _tested_uss_unable_to_plan_flight_near_invalid_shared_existing_flight(

additional_fields = {"behavior": behavior}

_, self.flight_2_id = plan_flight(
planning_time = Time(arrow.utcnow().datetime)
BenjaminPelletier marked this conversation as resolved.
Show resolved Hide resolved
with OpIntentValidator(
self,
"Control_uss plans flight 2, sharing invalid operational intent data",
self.control_uss_client,
flight_info,
additional_fields,
)

self.begin_test_step(
"Validate flight 2 shared operational intent with invalid data"
)
# ToDo - Add the test step details
self.end_test_step()
self.dss,
"Validate flight 2 shared operational intent with invalid data",
self._intents_extent,
) as validator:
_, self.flight_2_id = plan_flight(
self,
"Control_uss plans flight 2, sharing invalid operational intent data",
self.control_uss_client,
flight_info,
additional_fields,
)
flight_2_oi_ref = validator.expect_shared_with_invalid_data(flight_info)

self.begin_test_step(
"Precondition - check tested_uss has no subscription in flight 2 area"
self._precondition_no_post_interaction(
self.control_uss,
planning_time,
"Precondition - check tested_uss has no subscription in flight 2 area",
)
# ToDo - Add the test step details
self.end_test_step()

times[TimeDuringTest.TimeOfEvaluation] = Time(arrow.utcnow().datetime)
flight_1 = self.flight_1.resolve(times)

_, self.flight_1_id = plan_flight_intent_expect_failed(
planning_time = Time(arrow.utcnow().datetime)
BenjaminPelletier marked this conversation as resolved.
Show resolved Hide resolved
with OpIntentValidator(
self,
"Tested_uss attempts to plan flight 1, expect failure",
self.tested_uss_client,
flight_1,
)

self.begin_test_step("Validate flight 1 not shared by tested_uss")
# ToDo - Add the test step details
self.end_test_step()

self.begin_test_step("Validate flight 2 GET interaction")
# ToDo - Add the test step details
self.end_test_step()
self.dss,
"Validate flight 1 not shared by tested_uss",
self._intents_extent,
) as validator:
_, self.flight_1_id = plan_flight_intent_expect_failed(
self,
"Tested_uss attempts to plan flight 1, expect failure",
self.tested_uss_client,
flight_1,
)
validator.expect_not_shared()

self.begin_test_step("Validate flight 1 Notification not sent to Control_uss")
# ToDo - Add the test step details
self.end_test_step()
control_uss_domain = self.control_uss.base_url
expect_interuss_get_interactions(
self,
self.control_uss,
planning_time,
control_uss_domain,
flight_2_oi_ref.id,
"Validate flight 2 GET interaction",
)
expect_no_interuss_post_interactions(
self,
self.control_uss,
planning_time,
"Validate flight 1 Notification not sent to Control_uss",
)

delete_flight(
self, "Delete Control_uss flight", self.control_uss_client, self.flight_2_id
)

def _precondition_no_post_interaction(
self,
mock_uss: MockUSSClient,
st: StringBasedDateTime,
test_step: str,
):
self.begin_test_step(test_step)

mock_uss_sent_notification = precondition_no_post_interaction(
self, mock_uss, st
)
if mock_uss_sent_notification:
msg = f"As a precondition for the scenario tests, there should have been no post made to {posted_to_url}"
raise ScenarioCannotContinueError(msg)
BenjaminPelletier marked this conversation as resolved.
Show resolved Hide resolved
self.end_test_step()

def cleanup(self):
self.begin_cleanup()
cleanup_flights_fp_client(
Expand Down
Loading
Loading