diff --git a/.env b/.env index 1c873033..6adc12b6 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ -DOCKER_TAG=v1.12.0 +DOCKER_TAG=v1.13.0 REPOSITORY_DOCKER_URL=ghcr.io/nasa-ammos AERIE_USERNAME=aerie diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index afd34c2c..be382ff8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,6 @@ env: HASURA_GRAPHQL_JWT_SECRET: "${{secrets.HASURA_GRAPHQL_JWT_SECRET}}" POSTGRES_USER: "${{secrets.POSTGRES_USER}}" POSTGRES_PASSWORD: "${{secrets.POSTGRES_PASSWORD}}" - DOCKER_TAG: "v1.12.0" REPOSITORY_DOCKER_URL: "ghcr.io/nasa-ammos" jobs: @@ -48,6 +47,7 @@ jobs: strategy: matrix: python-version: [ "3.6.15", "3.11" ] + aerie-version: ["1.13.0"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -59,7 +59,9 @@ jobs: python -m pip install --upgrade pip pip install pytest pip install . - - name: Set up aerie instance + - name: Set up instance of Aerie ${{ matrix.aerie-version }} + env: + DOCKER_TAG: v${{ matrix.aerie-version }} # Prefix 'v' used in Aerie Docker image tags run: | docker compose -f docker-compose-test.yml up -d docker images @@ -68,6 +70,8 @@ jobs: run: sleep 60s shell: bash - name: Run integration tests + env: + AERIE_VERSION: ${{ matrix.aerie-version }} run: | cd tests pytest integration_tests diff --git a/src/aerie_cli/aerie_client.py b/src/aerie_cli/aerie_client.py index 5c742115..a0c35bb4 100644 --- a/src/aerie_cli/aerie_client.py +++ b/src/aerie_cli/aerie_client.py @@ -1630,15 +1630,29 @@ def get_constraint_by_id(self, id): def get_constraint_violations(self, plan_id): get_violations_query = """ - query ($plan_id: Int!){ - constraintViolations(planId: $plan_id) { - violations + query ($plan_id: Int!) { + constraintResults: constraintViolations(planId: $plan_id) { + constraintId + constraintName + type + resourceIds + violations { + activityInstanceIds + windows { + start + end + } + } + gaps { + start + end + } } } """ resp = self.aerie_host.post_to_graphql(get_violations_query, plan_id=plan_id) - return resp["violations"] + return resp def get_resource_types(self, model_id: int) -> List[ResourceType]: """Get resource types (value schema) diff --git a/tests/integration_tests/README.md b/tests/integration_tests/README.md index 5105ba84..a9790914 100644 --- a/tests/integration_tests/README.md +++ b/tests/integration_tests/README.md @@ -10,7 +10,7 @@ See: [localhost configuration](files/configuration/localhost_config.json) To set up a local test environment, use the test environment and docker-compose files in the root of the repo: ``` -docker compose --env-file test.env -f docker-compose-test.yml up +docker compose -f docker-compose-test.yml up ``` Invoke the tests using `pytest` from the `tests/integration_tests` directory. diff --git a/tests/integration_tests/conftest.py b/tests/integration_tests/conftest.py index 77660114..35a45def 100644 --- a/tests/integration_tests/conftest.py +++ b/tests/integration_tests/conftest.py @@ -40,6 +40,11 @@ FILES_PATH = os.path.join(TEST_DIR, "files") CONFIGURATIONS_PATH = os.path.join(FILES_PATH, "configuration") CONFIGURATION_PATH = os.path.join(CONFIGURATIONS_PATH, "localhost_config.json") +MODELS_PATH = os.path.join(FILES_PATH, "models") +MODEL_VERSION = os.environ.get("AERIE_VERSION", "1.13.0") +MODEL_JAR = os.path.join(MODELS_PATH, f"banananation-{MODEL_VERSION}.jar") +MODEL_NAME = "banananation" +MODEL_VERSION = "0.0.1" # Login to add additional users to the `users` table for username in ADDITIONAL_USERS: diff --git a/tests/integration_tests/files/constraints/constraint.ts b/tests/integration_tests/files/constraints/constraint.ts index d6d85775..160ae3dc 100644 --- a/tests/integration_tests/files/constraints/constraint.ts +++ b/tests/integration_tests/files/constraints/constraint.ts @@ -1,3 +1,4 @@ export default (): Constraint => { - -} \ No newline at end of file + return Discrete.Resource('/flag').equal('B') + } + \ No newline at end of file diff --git a/tests/integration_tests/files/models/banananation-1.12.0.jar b/tests/integration_tests/files/models/banananation-1.13.0.jar similarity index 90% rename from tests/integration_tests/files/models/banananation-1.12.0.jar rename to tests/integration_tests/files/models/banananation-1.13.0.jar index 9b552691..26d343c4 100644 Binary files a/tests/integration_tests/files/models/banananation-1.12.0.jar and b/tests/integration_tests/files/models/banananation-1.13.0.jar differ diff --git a/tests/integration_tests/test_constraints.py b/tests/integration_tests/test_constraints.py index 8cbbd335..1b04ce1d 100644 --- a/tests/integration_tests/test_constraints.py +++ b/tests/integration_tests/test_constraints.py @@ -1,6 +1,6 @@ from typer.testing import CliRunner -from .conftest import client +from .conftest import client, MODEL_JAR, MODEL_NAME, MODEL_VERSION from aerie_cli.__main__ import app from aerie_cli.schemas.client import ActivityPlanCreate @@ -16,10 +16,6 @@ FILES_PATH = os.path.join(TEST_DIR, "files") # Model Variables -MODELS_PATH = os.path.join(FILES_PATH, "models") -MODEL_JAR = os.path.join(MODELS_PATH, "banananation-1.12.0.jar") -MODEL_NAME = "banananation" -MODEL_VERSION = "0.0.1" model_id = -1 # Plan Variables @@ -52,6 +48,7 @@ def set_up_environment(request): plan_to_create.name += arrow.utcnow().format("YYYY-MM-DDTHH-mm-ss") global plan_id plan_id = client.create_activity_plan(model_id, plan_to_create) + client.simulate_plan(plan_id) def test_constraint_upload(): result = runner.invoke(app, ["constraints", "upload"], @@ -80,20 +77,23 @@ def test_constraint_update(): f"{result.stderr}" assert "Updated constraint" in result.stdout -def test_constraint_delete(): - result = runner.invoke(app, ["constraints", "delete"], - input=str(constraint_id) + "\n", +def test_constraint_violations(): + result = runner.invoke(app, ["constraints", "violations"], + input=str(plan_id) + "\n", catch_exceptions=False,) assert result.exit_code == 0,\ f"{result.stdout}"\ f"{result.stderr}" - assert f"Successfully deleted constraint {str(constraint_id)}" in result.stdout -def test_constraint_violations(): - result = runner.invoke(app, ["constraints", "violations"], - input=str(plan_id) + "\n", + # Check that a constraint violation is returned with the open bracket and curly brace + # (The integration test constraint should report a violation) + assert "Constraint violations: [{" in result.stdout + +def test_constraint_delete(): + result = runner.invoke(app, ["constraints", "delete"], + input=str(constraint_id) + "\n", catch_exceptions=False,) assert result.exit_code == 0,\ f"{result.stdout}"\ f"{result.stderr}" - assert "Constraint violations: " in result.stdout + assert f"Successfully deleted constraint {str(constraint_id)}" in result.stdout diff --git a/tests/integration_tests/test_expansion.py b/tests/integration_tests/test_expansion.py index e96c79ff..c8d68b27 100644 --- a/tests/integration_tests/test_expansion.py +++ b/tests/integration_tests/test_expansion.py @@ -8,7 +8,7 @@ from aerie_cli.__main__ import app from aerie_cli.schemas.client import ActivityPlanCreate -from .conftest import client +from .conftest import client, MODEL_JAR, MODEL_NAME, MODEL_VERSION runner = CliRunner(mix_stderr = False) @@ -19,10 +19,6 @@ DOWNLOADED_FILE_NAME = "downloaded_file.test" # Model Variables -MODELS_PATH = os.path.join(FILES_PATH, "models") -MODEL_JAR = os.path.join(MODELS_PATH, "banananation-1.12.0.jar") -MODEL_NAME = "banananation" -MODEL_VERSION = "0.0.1" model_id = -1 # Plan Variables diff --git a/tests/integration_tests/test_models.py b/tests/integration_tests/test_models.py index f61556e2..36171ace 100644 --- a/tests/integration_tests/test_models.py +++ b/tests/integration_tests/test_models.py @@ -4,7 +4,7 @@ from aerie_cli.__main__ import app -from .conftest import client +from .conftest import client, MODEL_JAR, MODEL_NAME, MODEL_VERSION runner = CliRunner(mix_stderr = False) @@ -13,10 +13,6 @@ FILES_PATH = os.path.join(TEST_DIR, "files") # Model Variables -MODELS_PATH = os.path.join(FILES_PATH, "models") -MODEL_JAR = os.path.join(MODELS_PATH, "banananation-1.12.0.jar") -MODEL_NAME = "banananation" -MODEL_VERSION = "0.0.1" model_id = -1 def test_model_clean(): diff --git a/tests/integration_tests/test_plans.py b/tests/integration_tests/test_plans.py index 5d14fca4..16585426 100644 --- a/tests/integration_tests/test_plans.py +++ b/tests/integration_tests/test_plans.py @@ -7,7 +7,7 @@ from aerie_cli.__main__ import app from aerie_cli.commands import plans -from .conftest import client, DOWNLOADED_FILE_NAME, ADDITIONAL_USERS +from .conftest import client, DOWNLOADED_FILE_NAME, ADDITIONAL_USERS, MODEL_JAR, MODEL_NAME, MODEL_VERSION runner = CliRunner(mix_stderr = False) @@ -18,10 +18,6 @@ DOWNLOADED_FILE_NAME = "downloaded_file.test" # Model Variables -MODELS_PATH = os.path.join(FILES_PATH, "models") -MODEL_JAR = os.path.join(MODELS_PATH, "banananation-1.12.0.jar") -MODEL_NAME = "banananation" -MODEL_VERSION = "0.0.1" model_id = -1 # Plan Variables diff --git a/tests/integration_tests/test_scheduling.py b/tests/integration_tests/test_scheduling.py index 261e3a58..bd237ee0 100644 --- a/tests/integration_tests/test_scheduling.py +++ b/tests/integration_tests/test_scheduling.py @@ -8,7 +8,7 @@ from aerie_cli.__main__ import app from aerie_cli.schemas.client import ActivityPlanCreate -from .conftest import client +from .conftest import client, MODEL_JAR, MODEL_NAME, MODEL_VERSION runner = CliRunner(mix_stderr = False) @@ -19,10 +19,6 @@ DOWNLOADED_FILE_NAME = "downloaded_file.test" # Model Variables -MODELS_PATH = os.path.join(FILES_PATH, "models") -MODEL_JAR = os.path.join(MODELS_PATH, "banananation-1.12.0.jar") -MODEL_NAME = "banananation" -MODEL_VERSION = "0.0.1" model_id = 0 # Plan Variables