Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Cleanup After Test Case test step fragment

This fragment can be used by test cases that need to clean up after themselves by deleting the OIRs and subscriptions created during the test.

## [Delete OIRs](./fragments/oir/crud/delete_query.md)

## [Delete Subscriptions](./fragments/sub/crud/delete_query.md)
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,25 @@ def delete_oir_query(
)
# Failure of the query has a severity that will interrupt the test:
# no need to return anything


def get_oir_query(
scenario: TestScenarioType, dss: DSSInstance, oir_id: EntityID
) -> Tuple[OperationalIntentReference, Query]:
"""
Issue a request to get an OIR by ID to the DSS instance, wrapped in a check documented in `get_query.md`.
"""
with scenario.check(
"Get operational intent reference by ID", dss.participant_id
) as check:
try:
oir, query = dss.get_op_intent_reference(oir_id)
scenario.record_query(query)
return oir, query
except QueryError as qe:
scenario.record_queries(qe.queries)
check.record_failed(
summary="Could not get operational intent reference",
details=f"Failed to get operational intent reference with error code {qe.cause_status_code}: {qe.msg}",
query_timestamps=qe.query_timestamps,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from uas_standards.astm.f3548.v21.api import OperationalIntentReference, Subscription

from monitoring.monitorlib.fetch.rid import FetchedSubscription
from monitoring.monitorlib.mutate.scd import MutatedSubscription
from monitoring.uss_qualifier.resources.astm.f3548.v21.dss import DSSInstance
from monitoring.uss_qualifier.resources.astm.f3548.v21.subscription_params import (
Expand Down Expand Up @@ -33,3 +34,44 @@ def sub_create_query(
query_timestamps=[sub.request.timestamp],
)
return sub.subscription, sub.operational_intent_references, sub


def sub_get_query(
scenario: TestScenarioType,
dss: DSSInstance,
sub_id: str,
) -> Tuple[Subscription, FetchedSubscription]:
with scenario.check("Get Subscription by ID", dss.participant_id) as check:
fetched_sub = dss.get_subscription(sub_id)
scenario.record_query(fetched_sub)
if not fetched_sub.success:
check.record_failed(
summary="Subscription query failed",
details=f"Failed to query subscription {sub_id} referenced by oid {self._oir_a_id} with code {fetched_sub.response.status_code}. Message: {fetched_sub.error_message}",
query_timestamps=fetched_sub.query_timestamps,
)
return None

return fetched_sub.subscription, fetched_sub


def sub_delete_query(
scenario: TestScenarioType,
dss: DSSInstance,
sub_id: str,
sub_version: str,
) -> Tuple[Subscription, List[OperationalIntentReference], MutatedSubscription]:
"""Implements check documented in `delete_query.md`."""
with scenario.check(
"Subscription can be deleted",
[dss.participant_id],
) as check:
sub = dss.delete_subscription(sub_id, sub_version)
scenario.record_query(sub)
if not sub.success:
check.record_failed(
summary="Delete subscription query failed",
details=f"Failed to delete a subscription on DSS instance with code {sub.status_code}: {sub.error_message}",
query_timestamps=[sub.request.timestamp],
)
return sub.subscription, sub.operational_intent_references, sub
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,12 @@ or **[astm.f3548.v21.DSS0005,5](../../../../requirements/astm/f3548/v21.md)**.

#### [No implicit subscription was attached](./fragments/oir/oir_has_no_subscription.md)

### [Cleanup After Test Case test step](./fragments/oir/crud/delete_query.md)

## Implicit subscriptions are properly deleted when required by OIR mutation test case

This test case verifies that implicit subscriptions are properly removed if they become unnecessary following the mutation of an OIR.

### Ensure clean workspace test step

<!-- TODO(Shastick): Why do we need to reclean the workspace at this point? We already ensured it was clean before starting the test; don't we know exactly what happened in the test and therefore know that it's already clean (or something failed)? If a previous test case created something that we don't need/want in later test cases, the original test case should clean up at the end of the test case. -->

#### [Clean any existing OIRs with known test IDs](clean_workspace_op_intents.md)

#### [Clean any existing subscriptions with known test IDs](clean_workspace_subs.md)

### Create two OIRs with implicit subscription test step

Creates two OIRs with an implicit subscription, which will then be replaced by an explicitly created subscription
Expand Down Expand Up @@ -186,18 +180,12 @@ This step updates the OIR to not use any subscription, and expects the implicit
If the implicit subscription that was attached to the OIR is still present after the OIR is updated to use another subscription,
the DSS is failing to properly manage implicit subscriptions for OIRs, and is therefore in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

### [Cleanup After Test Case test step](./cleanup_after_testcase_oir_subs.md)

## Implicit subscriptions are expanded as needed test case

This test case checks that a DSS will properly expand an implicit subscription to cover an OIR that is being attached to it.

### Ensure clean workspace test step

<!-- TODO(Shastick): Why do we need to reclean the workspace at this point? We already ensured it was clean before starting the test; don't we know exactly what happened in the test and therefore know that it's already clean (or something failed)? If a previous test case created something that we don't need/want in later test cases, the original test case should clean up at the end of the test case. -->

#### [Clean any existing OIRs with known test IDs](clean_workspace_op_intents.md)

#### [Clean any existing subscriptions with known test IDs](clean_workspace_subs.md)

### Create an OIR with implicit subscription test step

Create an OIR with which interactions will be tested and request an implicit
Expand Down Expand Up @@ -225,18 +213,12 @@ in which case the DSS is in violation of **[astm.f3548.v21.DSS0005,1](../../../.

Ensure that the attached implicit subscription has been expanded

### [Cleanup After Test Case test step](./fragments/oir/crud/delete_query.md)

## Existing implicit subscription can replace an OIR's explicit subscription test case

This test case verifies that an implicit subscription can be used to replace an explicit subscription attached to an OIR.

### Ensure clean workspace test step

Reset the workspace for this test case.

#### [Clean any existing OIRs with known test IDs](clean_workspace_op_intents.md)

#### [Clean any existing subscriptions with known test IDs](clean_workspace_subs.md)

### [Create an explicit subscription test step](./fragments/sub/crud/create_query.md)

Create an explicit subscription to be initially set on the first OIR created in this test case
Expand Down Expand Up @@ -267,18 +249,12 @@ Confirm that the query to replace the second OIR's explicit subscription with th

#### [First OIR is now attached to the specified implicit subscription](fragments/oir/oir_has_expected_subscription.md)

### [Cleanup After Test Case test step](./cleanup_after_testcase_oir_subs.md)

## Existing implicit subscription can be attached to OIR without subscription test case

This test case verifies that an implicit subscription can be attached to an OIR that is not currently attached to any subscription.

### Ensure clean workspace test step

Reset the workspace for this test case.

#### [Clean any existing OIRs with known test IDs](clean_workspace_op_intents.md)

#### [Clean any existing subscriptions with known test IDs](clean_workspace_subs.md)

### [Create OIR with no subscription test step](./fragments/oir/crud/create_query.md)

#### [OIR is not attached to an implicit subscription](./fragments/oir/oir_has_no_subscription.md)
Expand All @@ -301,19 +277,13 @@ Confirms that the DSS properly attached the first OIR to the implicit subscripti

#### [First OIR is now attached to the specified implicit subscription](fragments/oir/oir_has_expected_subscription.md)

### [Cleanup After Test Case test step](./fragments/oir/crud/delete_query.md)

## OIR without subscription can be mutated without a new subscription being attached test case

This test case ensures that, when a client mutates an OIR not attached to any subscription without specifiying either
a subscription identifier nor parameters for an implicit subscription, the DSS under test will correctly keep the OIR unattached to any subscription.

### Ensure clean workspace test step

Reset the workspace for this test case.

#### [Clean any existing OIRs with known test IDs](clean_workspace_op_intents.md)

#### [Clean any existing subscriptions with known test IDs](clean_workspace_subs.md)

### Create OIR with no subscription test step

#### [Create OIR](./fragments/oir/crud/create_query.md)
Expand All @@ -326,6 +296,37 @@ Reset the workspace for this test case.

#### [OIR is not attached to any subscription](./fragments/oir/oir_has_no_subscription.md)

### [Cleanup After Test Case test step](./fragments/oir/crud/delete_query.md)

## Request new implicit subscription when mutating an OIR with existing explicit subscription test case

This test case ensures that a DSS properly allows a client to request that a new implicit subscription be created for an existing OIR
with an explicit subscription attached.

### [Create an explicit subscription test step](./fragments/sub/crud/create_query.md)

### [Create OIR with explicit subscription test step](./fragments/oir/crud/create_query.md)

#### [OIR is attached to the expected subscription](./fragments/oir/oir_has_expected_subscription.md)

### [Mutate OIR to request new implicit subscription test step](./fragments/oir/crud/update_query.md)

### Validate that the OIR is now attached to an implicit subscription test step

#### [Get OIR](./fragments/oir/crud/read_query.md)

#### 🛑 OIR is attached to a new subscription check

If the DSS under test fails to attach the OIR to a subscription that is different from the one it is currently attached to when it is requested to do so,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

#### [Get subscription](./fragments/sub/crud/read_query.md)

#### 🛑 OIR is now attached to an implicit subscription check

If the DSS under test fails to attach the OIR to an implicit subscription (which may either already exist or be newly created) when it is requested to do so,
it is in violation of **[astm.f3548.v21.DSS0005,1](../../../../requirements/astm/f3548/v21.md)**.

## Cleanup

### [Remove OIRs created during this test](clean_workspace_op_intents.md)
Expand Down
Loading
Loading