-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for case that has been uploaded from komodo-releases repo
- Loading branch information
Showing
4 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Build and test fmu-sumo-uploader | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
schedule: | ||
- cron: "6 7 * * *" | ||
|
||
jobs: | ||
build_pywheels: | ||
name: PY ${{ matrix.python-version }} on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
python-version: ["3.8", "3.9", "3.10", "3.11"] | ||
os: [ubuntu-latest, windows-latest] | ||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Azure Login | ||
uses: Azure/login@v1 | ||
with: | ||
client-id: f96c150d-cacf-4257-9cc9-54b2c68ec4ce | ||
tenant-id: 3aa4a235-b6e2-48d5-9195-7fcf05b459b0 | ||
subscription-id: 87897772-fb27-495f-ae40-486a2df57baa | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install fmu-sumo etc | ||
run: > | ||
python -m pip install --upgrade pip && | ||
python -m pip install .[test] | ||
- name: Run tests | ||
shell: bash | ||
run: | | ||
az --version | ||
az account list | ||
pip show sumo-wrapper-python | ||
pip show fmu-sumo | ||
pip show openvds | ||
python -c 'import sys; print(sys.platform)' | ||
python -c 'import os; import sys; print(os.path.dirname(sys.executable))' | ||
access_token=$(az account get-access-token --scope api://88d2b022-3539-4dda-9e66-853801334a86/.default --query accessToken --output tsv) | ||
export ACCESS_TOKEN=$access_token | ||
pytest -s --timeout=500 ./tests/test_uploads_from_komodo_repo.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
""" Verifies SUMO uploads that has been run by Github Actions in the komodo-releases repo. | ||
https://github.com/equinor/komodo-releases/blob/main/.github/workflows/run_drogon.yml | ||
""" | ||
import os | ||
import sys | ||
from datetime import datetime, timedelta | ||
import pytest | ||
import time | ||
from pathlib import Path | ||
import logging | ||
import subprocess | ||
import json | ||
import yaml | ||
|
||
from fmu.sumo.explorer import Explorer | ||
|
||
if not sys.platform.startswith("darwin"): | ||
import openvds | ||
|
||
# Run the tests from the root dir | ||
TEST_DIR = Path(__file__).parent / "../" | ||
os.chdir(TEST_DIR) | ||
|
||
ENV = "dev" | ||
|
||
logger = logging.getLogger(__name__) | ||
logger.setLevel(level="DEBUG") | ||
|
||
|
||
# class SumoConnection: | ||
# def __init__(self, env, token=None): | ||
# self.env = env | ||
# self._connection = None | ||
# self.token = token | ||
|
||
# @property | ||
# def connection(self): | ||
# if self._connection is None: | ||
# self._connection = uploader.SumoConnection( | ||
# env=self.env, token=self.token) | ||
# return self._connection | ||
|
||
|
||
def _get_latest_case(): | ||
"""Returns latest f_scout_ci case that was uploaded from komodo-releases""" | ||
cases = sumo.cases | ||
cases = cases.filter(user="f_scout_ci") | ||
assert (len(cases) > 0) | ||
newest_date = "1000-01-01T00:00:00.000Z" | ||
newest_case = cases[0] | ||
for case in cases: | ||
metadata = case.metadata | ||
if metadata["_sumo"]["timestamp"] > newest_date: | ||
newest_date = metadata["_sumo"]["timestamp"] | ||
newest_case = case | ||
|
||
print ("Newest case: ", newest_case.uuid, " ", newest_case.name) | ||
return newest_case | ||
|
||
|
||
sumo = Explorer(env=ENV) | ||
case = _get_latest_case() | ||
|
||
|
||
### TESTS ### | ||
|
||
def test_case_exists(): | ||
assert(case) | ||
|
||
def test_case_have_enough_children_in_total(): | ||
# We know that komodo-releases uploads 111 child objects in total | ||
number_of_children = len(case.cubes) + len(case.polygons) + len(case.surfaces) + len(case.dictionaries) + len(case.tables) | ||
assert(number_of_children > 110) | ||
|
||
def test_case_have_enough_surfaces(): | ||
assert(len(case.surfaces) > 53) | ||
|
||
def test_case_have_enough_cubes(): | ||
assert(len(case.cubes) > 9) | ||
|
||
def test_case_have_enough_tables(): | ||
assert(len(case.tables) > 6) | ||
|
||
def test_case_have_enough_polygons(): | ||
assert(len(case.polygons) > 5) | ||
|
||
def test_case_have_enough_dictionaries(): | ||
assert(len(case.dictionaries) > 0) | ||
|
||
|