Skip to content

Add System Tests for the Resource Discovery Building Block #7

Description

@james-hinton

Wire up the existing resource-discovery notebook to the system test framework. We already have this working for OpenEO, need the same pattern for Resource Discovery (in the branch parameterised-notebook-tests https://github.com/EOEPCA/system-test/tree/parameterised-notebook-tests)

How it works

The system tests use papermill to execute Jupyter notebooks and extract test results. This part is already working, so the intention will be to reuse this existing flow but for the Resource Discovery Building Block:

  1. Notebook cells have a comment on the first line like # endpoint_collections or # verify_ingestion https://github.com/EOEPCA/deployment-guide/blob/main/notebooks/examples/openeo/openeo.ipynb
  2. wrap_cells.py has a custom ExecutePreprocessor that detects these comments and wraps the cell in with test_cell('endpoint_collections'): https://github.com/EOEPCA/system-test/blob/parameterised-notebook-tests/test/wrap_cells.py
  3. test_cell (in helpers.py) is a context manager that catches success/failure and logs to a test_results dict https://github.com/EOEPCA/deployment-guide/blob/main/notebooks/examples/modules/helpers.py
  4. End of notebook dumps test_results to a JSON file see end of openeo notebook
  5. pytest reads that JSON and has individual test functions that assert on each result https://github.com/EOEPCA/system-test/blob/parameterised-notebook-tests/test/openeo/test_openeo.py#L56

Please see the openeo example for it working (copied from links above):

What needs doing

Two repos involved:

*1. deployment-guide repo: https://github.com/EOEPCA/deployment-guide/tree/main/notebooks/examples/resource-discovery

  • Add # test_name comments to the first line of cells that should be tested i.e. # endpoint_landing_page.

  • Add papermill parameters near the top (these get injected at runtime):

# Parameters
resource_discovery_domain = "https://resource-catalogue.develop.eoepca.org"
log_output_file = "resource_discovery_log.json"
  • Add the JSON dump at the end of the notebook:
if test_results:
    for test, result in test_results.items():
        print(f"{test}: {result['status']} - {result['message']}")
    json.dump(test_results, open(log_output_file, "w"), indent=2)

2. system-test repo (this repo):

  • Create test/resource-discovery/__init__.py
  • Create test/resource-discovery/test_resource_discovery.py following the pattern in test/openeo/test_openeo.py

The pytest file should:

Acceptance Criteria:

  • Resource discovery notebook has # test_name markers on key cells
  • pytest wrapper exists in system-test repo
  • Running the test executes the notebook and reports pass/fail for each tagged cell

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions