From 56e8b063bb9979e84924e3cc828e91acee289a8c Mon Sep 17 00:00:00 2001 From: Simon Liu <69875423+sliu008@users.noreply.github.com> Date: Thu, 3 Oct 2024 10:57:34 -0700 Subject: [PATCH 1/3] update tests with skip (#3326) * update tests with skip * add aquarius to skip temporal and fix typo name of files * fix word typo * add back skip spacial csv * remove git keep file --- tests/conftest.py | 2 +- tests/get_associations.py | 2 +- tests/skip/skip_spatial_ops.csv | 0 tests/skip/skip_spatial_uat.csv | 0 tests/skip/skip_temporal_ops.csv | 2 ++ tests/skip/skip_temporal_uat.csv | 2 ++ tests/verify_collection.py | 32 +++++++++++++++++++++++++++++--- 7 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 tests/skip/skip_spatial_ops.csv create mode 100644 tests/skip/skip_spatial_uat.csv create mode 100644 tests/skip/skip_temporal_ops.csv create mode 100644 tests/skip/skip_temporal_uat.csv diff --git a/tests/conftest.py b/tests/conftest.py index f44a9b15c1..37f59de3ca 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -79,7 +79,7 @@ def pytest_terminal_summary(terminalreporter, exitstatus, config): failed.extend([list(failed.keywords)[3] for failed in terminalreporter.stats.get('failed', [])]) success.extend([list(passed.keywords)[3] for passed in terminalreporter.stats.get('passed', [])]) - # Have temporal and spacial test if failed either one don't put in success + # Have temporal and spatial test if failed either one don't put in success # Convert lists to sets fail_set = set(failed) diff --git a/tests/get_associations.py b/tests/get_associations.py index 31028cd590..a9cb6c0f52 100644 --- a/tests/get_associations.py +++ b/tests/get_associations.py @@ -50,7 +50,7 @@ def get_associations(token, env): } service_concept_id = cmr.queries.ServiceQuery(mode=mode).provider('POCLOUD').name('PODAAC L2 Cloud Subsetter').get()[0].get('concept_id') - url = cmr.queries.CollectionQuery(mode=mode).service_concept_id(service_concept_id).provider('POCLOUD')._build_url() + url = cmr.queries.CollectionQuery(mode=mode).service_concept_id(service_concept_id)._build_url() collections_query = requests.get(url, headers=headers, params={'page_size': 2000}).json()['feed']['entry'] collections = [a.get('id') for a in collections_query] diff --git a/tests/skip/skip_spatial_ops.csv b/tests/skip/skip_spatial_ops.csv new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/skip/skip_spatial_uat.csv b/tests/skip/skip_spatial_uat.csv new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/skip/skip_temporal_ops.csv b/tests/skip/skip_temporal_ops.csv new file mode 100644 index 0000000000..d7177e14de --- /dev/null +++ b/tests/skip/skip_temporal_ops.csv @@ -0,0 +1,2 @@ +C2036882456-POCLOUD +C2205121315-POCLOUD \ No newline at end of file diff --git a/tests/skip/skip_temporal_uat.csv b/tests/skip/skip_temporal_uat.csv new file mode 100644 index 0000000000..38bbee652b --- /dev/null +++ b/tests/skip/skip_temporal_uat.csv @@ -0,0 +1,2 @@ +C1238658389-POCLOUD +C1238658392-POCLOUD \ No newline at end of file diff --git a/tests/verify_collection.py b/tests/verify_collection.py index 5eeb6f04e4..89e02bbe94 100644 --- a/tests/verify_collection.py +++ b/tests/verify_collection.py @@ -14,6 +14,7 @@ import pytest import requests import xarray +import csv from requests.auth import HTTPBasicAuth @@ -53,6 +54,25 @@ def request_session(): yield s +# Helper function to read a single CSV file and return a set of skip entries +def read_skip_list(csv_file): + with open(csv_file, newline='') as f: + reader = csv.reader(f) + return {row[0].strip() for row in reader} + + +# Fixture for the first skip list (skip_collections1.csv) +@pytest.fixture(scope="session") +def skip_temporal(env): + return read_skip_list(f"skip/skip_temporal_{env}.csv") + + +# Fixture for the second skip list (skip_collections2.csv) +@pytest.fixture(scope="session") +def skip_spatial(env): + return read_skip_list(f"skip/skip_spatial_{env}.csv") + + @pytest.fixture(scope="session") def bearer_token(env: str, request_session: requests.Session) -> str: tokens = [] @@ -367,9 +387,12 @@ def find_variable(ds, var_name): @pytest.mark.timeout(600) def test_spatial_subset(collection_concept_id, env, granule_json, collection_variables, - harmony_env, tmp_path: pathlib.Path, bearer_token): + harmony_env, tmp_path: pathlib.Path, bearer_token, skip_spatial): test_spatial_subset.__doc__ = f"Verify spatial subset for {collection_concept_id} in {env}" + if collection_concept_id in skip_spatial: + pytest.skip(f"Known collection to skip for spatial testing {collection_concept_id}") + logging.info("Using granule %s for test", granule_json['meta']['concept-id']) # Compute a box that is smaller than the granule extent bounding box @@ -523,8 +546,11 @@ def group_walk(groups, nc_d, current_group): @pytest.mark.timeout(600) def test_temporal_subset(collection_concept_id, env, granule_json, collection_variables, - harmony_env, tmp_path: pathlib.Path, bearer_token): - test_spatial_subset.__doc__ = f"Verify spatial subset for {collection_concept_id} in {env}" + harmony_env, tmp_path: pathlib.Path, bearer_token, skip_temporal): + test_spatial_subset.__doc__ = f"Verify temporal subset for {collection_concept_id} in {env}" + + if collection_concept_id in skip_temporal: + pytest.skip(f"Known collection to skip for temporal testing {collection_concept_id}") logging.info("Using granule %s for test", granule_json['meta']['concept-id']) From 3b437e069aa11c2fdd3699c207193cf033a133e1 Mon Sep 17 00:00:00 2001 From: Simon Liu <69875423+sliu008@users.noreply.github.com> Date: Mon, 7 Oct 2024 12:58:31 -0700 Subject: [PATCH 2/3] fix where tests are run for verify (#3328) --- .github/workflows/verify.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index e83c0ff78c..2566a3bfb1 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -35,16 +35,20 @@ jobs: run: | echo "test_env=$(python -c "print('${{ github.head_ref }}'.split('/')[1])")" >> $GITHUB_OUTPUT echo "concept_id=$(python -c "print('${{ github.head_ref }}'.split('/')[2])")" >> $GITHUB_OUTPUT + - name: install + - id: install + run: | + poetry install - name: Execute tests id: run-tests + working-directory: tests env: TEST_ENV: ${{ steps.get-env-ccid.outputs.test_env }} CONCEPT_ID: ${{ steps.get-env-ccid.outputs.concept_id }} CMR_USER: ${{ secrets.CMR_USER }} CMR_PASS: ${{ secrets.CMR_PASS }} run: | - poetry install - poetry run pytest tests/verify_collection.py --concept_id $CONCEPT_ID --env $TEST_ENV --junitxml=$GITHUB_WORKSPACE/test-results/test_report.xml --html=$GITHUB_WORKSPACE/test-results/test_report.html || true + poetry run pytest verify_collection.py --concept_id $CONCEPT_ID --env $TEST_ENV --junitxml=$GITHUB_WORKSPACE/test-results/test_report.xml --html=$GITHUB_WORKSPACE/test-results/test_report.html || true - name: Publish Test Results id: publish-test uses: EnricoMi/publish-unit-test-result-action@v2 From 369da4dc7261a3d8bf8b876defb902a15271e53b Mon Sep 17 00:00:00 2001 From: Simon Liu <69875423+sliu008@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:11:00 -0700 Subject: [PATCH 3/3] Feature/fix verify (#3329) * fix where tests are run for verify * fix error * fix typo in verify.yml --- .github/workflows/verify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 2566a3bfb1..c4f3c4aaa3 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -36,7 +36,7 @@ jobs: echo "test_env=$(python -c "print('${{ github.head_ref }}'.split('/')[1])")" >> $GITHUB_OUTPUT echo "concept_id=$(python -c "print('${{ github.head_ref }}'.split('/')[2])")" >> $GITHUB_OUTPUT - name: install - - id: install + id: install run: | poetry install - name: Execute tests