Skip to content

Commit

Permalink
Merge pull request #88 from NASA-AMMOS/feature--aerie-version-matrix
Browse files Browse the repository at this point in the history
Aerie 1.13.0 + Integration test with multiple Aerie versions
  • Loading branch information
cartermak authored Oct 19, 2023
2 parents d83e67d + f0b79ff commit 3968acf
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DOCKER_TAG=v1.12.0
DOCKER_TAG=v1.13.0
REPOSITORY_DOCKER_URL=ghcr.io/nasa-ammos

AERIE_USERNAME=aerie
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -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
Expand Down
22 changes: 18 additions & 4 deletions src/aerie_cli/aerie_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 3 additions & 2 deletions tests/integration_tests/files/constraints/constraint.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default (): Constraint => {

}
return Discrete.Resource('/flag').equal('B')
}

Binary file not shown.
26 changes: 13 additions & 13 deletions tests/integration_tests/test_constraints.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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
6 changes: 1 addition & 5 deletions tests/integration_tests/test_expansion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
6 changes: 1 addition & 5 deletions tests/integration_tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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():
Expand Down
6 changes: 1 addition & 5 deletions tests/integration_tests/test_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down
6 changes: 1 addition & 5 deletions tests/integration_tests/test_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit 3968acf

Please sign in to comment.