Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "interfaces/automated_testing"]
path = interfaces/automated_testing
url = https://github.com/interuss/automated_testing_interfaces
[submodule "schemas/ed318"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BenjaminPelletier This looks OK to me, but I'd like your opinion about importing this repo as a submodule this way and in this directory in order to track the ED318 schema.

path = schemas/ed318
url = git@github.com:UASGeoZones/ED-318.git
1 change: 1 addition & 0 deletions monitoring/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ WORKDIR /app/monitoring

# Add core content from repo
ADD ./interfaces /app/interfaces
ADD ./schemas /app/schemas
ADD ./monitoring /app/monitoring

# Add health check to the /app root and make it executable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ v1:
test_run:
resources:
resource_declarations:
source_document:
source_document_ed269:
resource_type: resources.eurocae.ed269.source_document.SourceDocument
specification:
url: file://./test_data/che/geoawareness/cis_source_sample.json
url: file://./test_data/che/geoawareness/cis_source_sample_ed269.json
source_document_ed318:
resource_type: resources.eurocae.ed318.source_document.SourceDocument
specification:
url: file://./test_data/che/geoawareness/cis_source_sample_ed318.json
action:
test_suite:
suite_type: suites.uspace.geo_awareness_cis
resources:
source_document: source_document
source_document_ed269: source_document_ed269
source_document_ed318: source_document_ed318
execution:
stop_fast: true
artifacts:
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from implicitdict import ImplicitDict

from monitoring.uss_qualifier import fileio
from monitoring.uss_qualifier.resources.resource import Resource


class SourceDocumentSpecification(ImplicitDict):
url: str
"""Url of the ED-318 document to verify"""


class SourceDocument(Resource[SourceDocumentSpecification]):
specification: SourceDocumentSpecification

raw_document: str
"""Content of the document"""

def __init__(
self, specification: SourceDocumentSpecification, resource_origin: str
):
super().__init__(specification, resource_origin)
self.specification = specification
self.raw_document = fileio.load_content(specification.url)
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# EUROCAE ED-318 UAS geographical zone model test scenario

## Overview

This scenario verifies that a JSON document complies with the ED-318 UAS Geographical Zone Model for Geo-Awareness purpose.

## Resources

### source_document

The file or url of the document to be tested.

## ED-318 data model compliance test case

### Valid source test step

#### 🛑 Valid JSON check

The JSON file is properly formatted and can be read successfully.

#### 🛑 Valid schema and values check

The file respects the ED-318 schema and values are valid.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import json
import pathlib

import referencing
from jsonschema import ValidationError, validate
from referencing.exceptions import NoSuchResource

import monitoring
from monitoring.uss_qualifier.resources.eurocae.ed318.source_document import (
SourceDocument,
)
from monitoring.uss_qualifier.scenarios.scenario import TestScenario
from monitoring.uss_qualifier.suites.suite import ExecutionContext


class SourceDataModelValidation(TestScenario):
source_document: SourceDocument
schema_registry: referencing.Registry = referencing.Registry()
schema: dict

def __init__(self, source_document: SourceDocument):
super().__init__()
self.source_document = source_document

# create a JSON schema registry for ED318 schemas
def retrieve_schema(uri: str) -> referencing.Resource:
# the $ref in the schemas are relative paths, this function allows resolving them
repo_root = pathlib.Path(str(monitoring.__file__)).parent.parent
schema_path = repo_root / "schemas" / "ed318" / "schema" / uri
if not schema_path.exists():
raise NoSuchResource(ref=str(schema_path))
with open(schema_path) as schema:
return referencing.Resource.from_contents(json.load(schema))

self.schema_registry = referencing.Registry(retrieve=retrieve_schema)
self.schema = self.schema_registry.get_or_retrieve(
"Schema_GeoZones.json"
).value.contents

def run(self, context: ExecutionContext):
self.begin_test_scenario(context)

self.record_note(
"Document",
f"Ready at {self.source_document.specification.url}",
)

self.begin_test_case("ED-318 data model compliance")
self.begin_test_step("Valid source")

data = None
with self.check(
"Valid JSON",
[self.source_document.specification.url],
) as check:
try:
data = json.loads(self.source_document.raw_document)
except json.decoder.JSONDecodeError as e:
check.record_failed(
summary="Unable to deserialize the document as JSON",
details=str(e),
)

if data:
with self.check(
"Valid schema and values", [self.source_document.specification.url]
) as check:
try:
validate(
instance=data, schema=self.schema, registry=self.schema_registry
)
except ValidationError as e:
check.record_failed(
summary="Invalid format error",
details=str(e),
)

self.end_test_step()
self.end_test_case()
self.end_test_scenario()
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## [Actions](../README.md#actions)

1. Scenario: [EUROCAE ED-269 UAS geographical zone model](../../scenarios/eurocae/ed269/source_data_model.md) ([`scenarios.eurocae.ed269.source_data_model.SourceDataModelValidation`](../../scenarios/eurocae/ed269/source_data_model.py))
2. Scenario: [EUROCAE ED-318 UAS geographical zone model](../../scenarios/eurocae/ed318/source_data_model.md) ([`scenarios.eurocae.ed318.source_data_model.SourceDataModelValidation`](../../scenarios/eurocae/ed318/source_data_model.py))

## [Checked requirements](../README.md#checked-requirements)

Expand Down
10 changes: 8 additions & 2 deletions monitoring/uss_qualifier/suites/uspace/geo_awareness_cis.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
name: U-Space Common Information Service
resources:
source_document: resources.eurocae.ed269.source_document.SourceDocument
source_document_ed269: resources.eurocae.ed269.source_document.SourceDocument
source_document_ed318: resources.eurocae.ed318.source_document.SourceDocument
actions:
- test_scenario:
scenario_type: scenarios.eurocae.ed269.source_data_model.SourceDataModelValidation
resources:
source_document: source_document
source_document: source_document_ed269
on_failure: Abort
- test_scenario:
scenario_type: scenarios.eurocae.ed318.source_data_model.SourceDataModelValidation
resources:
source_document: source_document_ed318
on_failure: Abort
Loading
Loading