Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve tests #66

Merged
merged 30 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d8f545e
Simulate after configs test
Navarro-Jonathan Aug 4, 2023
c5ef63d
Test duplicated plan
Navarro-Jonathan Aug 4, 2023
d4fadb1
Test downloaded plan
Navarro-Jonathan Aug 4, 2023
4388374
Remove hard-coded /'s
Navarro-Jonathan Aug 4, 2023
9b9512c
Add scheduling integration tests
Navarro-Jonathan Aug 4, 2023
ee04ba7
Minor organizational change to integration tests
Navarro-Jonathan Aug 4, 2023
5c95c4f
test expansions
Navarro-Jonathan Aug 4, 2023
226472c
add stdout and stderr if we reach exit code check
Navarro-Jonathan Aug 4, 2023
43b8346
Split expansion and plans to their own files
Navarro-Jonathan Aug 5, 2023
4cca95c
Add README to integration tests
Navarro-Jonathan Aug 7, 2023
3fd5b72
Move session initialization to conftest
Navarro-Jonathan Aug 7, 2023
b7e921c
Add metadata tests
Navarro-Jonathan Aug 7, 2023
4453194
Start testing constraint
Navarro-Jonathan Aug 7, 2023
270697c
Remove unused variables
Navarro-Jonathan Aug 8, 2023
a16159d
Split scheduling tests into their own file
Navarro-Jonathan Aug 8, 2023
bc4f1ed
Add constraints tests
Navarro-Jonathan Aug 8, 2023
7bcb15a
split full_test and remove full_test
Navarro-Jonathan Aug 8, 2023
c9e63c6
Update names
Navarro-Jonathan Aug 8, 2023
f3ea046
Set up configuration in conftest
Navarro-Jonathan Aug 8, 2023
95eafb1
Remove unused imports
Navarro-Jonathan Aug 9, 2023
06c7907
Update README.md
Navarro-Jonathan Aug 9, 2023
39facd5
Clean plans in expansion test
Navarro-Jonathan Aug 9, 2023
a509043
Add configuration tests
Navarro-Jonathan Aug 9, 2023
513df60
Fix configuration tests
Navarro-Jonathan Aug 9, 2023
574b29c
Test against Aerie v1.7
Navarro-Jonathan Aug 10, 2023
a63225b
Test against Aerie 1.10
Navarro-Jonathan Aug 10, 2023
8d582aa
Test against 1.7.0
Navarro-Jonathan Aug 10, 2023
0ba16a5
Remove unnecessary argument in contraint test
Navarro-Jonathan Aug 23, 2023
5ad9dab
Remove duplicate duplicate
Navarro-Jonathan Aug 23, 2023
62beee6
Upload schedule for delete_all
Navarro-Jonathan Aug 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
POSTGRES_PASSWORD: '${AERIE_PASSWORD}'
POSTGRES_PORT: 5432
POSTGRES_USER: '${AERIE_USERNAME}'
image: 'ghcr.io/nasa-ammos/aerie-gateway:v1.6.2'
image: 'ghcr.io/nasa-ammos/aerie-gateway:v1.7.0'
ports: ['9000:9000']
restart: always
volumes:
Expand All @@ -40,7 +40,7 @@ services:
-Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=INFO
-Dorg.slf4j.simpleLogger.logFile=System.err
UNTRUE_PLAN_START: '2000-01-01T11:58:55.816Z'
image: 'ghcr.io/nasa-ammos/aerie-merlin:v1.6.2'
image: 'ghcr.io/nasa-ammos/aerie-merlin:v1.7.0'
ports: ['27183:27183']
restart: always
volumes:
Expand All @@ -60,7 +60,7 @@ services:
-Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=INFO
-Dorg.slf4j.simpleLogger.logFile=System.err
UNTRUE_PLAN_START: '2000-01-01T11:58:55.816Z'
image: 'ghcr.io/nasa-ammos/aerie-merlin-worker:v1.6.2'
image: 'ghcr.io/nasa-ammos/aerie-merlin-worker:v1.7.0'
ports: ['27187:8080']
restart: always
volumes:
Expand All @@ -81,7 +81,7 @@ services:
-Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG
-Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=INFO
-Dorg.slf4j.simpleLogger.logFile=System.err
image: 'ghcr.io/nasa-ammos/aerie-scheduler:v1.6.2'
image: 'ghcr.io/nasa-ammos/aerie-scheduler:v1.7.0'
ports: ['27185:27185']
restart: always
volumes:
Expand All @@ -103,7 +103,7 @@ services:
JAVA_OPTS: >
-Dorg.slf4j.simpleLogger.log.com.zaxxer.hikari=INFO
-Dorg.slf4j.simpleLogger.logFile=System.err
image: 'ghcr.io/nasa-ammos/aerie-scheduler-worker:v1.6.2'
image: 'ghcr.io/nasa-ammos/aerie-scheduler-worker:v1.7.0'
ports: ['27189:8080']
restart: always
volumes:
Expand All @@ -123,7 +123,7 @@ services:
SEQUENCING_DB_USER: '${AERIE_USERNAME}'
SEQUENCING_LOCAL_STORE: /usr/src/app/sequencing_file_store
SEQUENCING_SERVER_PORT: 27184
image: 'ghcr.io/nasa-ammos/aerie-sequencing:v1.6.2'
image: 'ghcr.io/nasa-ammos/aerie-sequencing:v1.7.0'
ports: ['27184:27184']
restart: always
volumes:
Expand All @@ -147,7 +147,7 @@ services:
HASURA_GRAPHQL_LOG_LEVEL: info
HASURA_GRAPHQL_METADATA_DATABASE_URL: 'postgres://${AERIE_USERNAME}:${AERIE_PASSWORD}@postgres:5432/aerie_hasura'
HASURA_GRAPHQL_METADATA_DIR: /hasura-metadata
image: 'ghcr.io/nasa-ammos/aerie-hasura:v1.6.2'
image: 'ghcr.io/nasa-ammos/aerie-hasura:v1.7.0'
ports: ['8080:8080']
restart: always
postgres:
Expand All @@ -158,7 +158,7 @@ services:
POSTGRES_DB: postgres
POSTGRES_PASSWORD: '${POSTGRES_PASSWORD}'
POSTGRES_USER: '${POSTGRES_USER}'
image: 'ghcr.io/nasa-ammos/aerie-postgres:v1.6.2'
image: 'ghcr.io/nasa-ammos/aerie-postgres:v1.7.0'
ports: ['5432:5432']
restart: always
volumes:
Expand Down
32 changes: 32 additions & 0 deletions tests/integration_tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Test against an active instance of Aerie

## WARNING
These tests will delete and modify data permanently. Expect the localhost instance of Aerie to be modified heavily. These test will delete all models.

See: [localhost configuration](files/configuration/localhost_config.json)

## Tests

### [Configurations test](test_configurations.py)
- Configuration initialization is in conftest.py to ensure all tests use localhost
- These tests will end with the localhost configuration active
- Test all `configurations` commands

### [Models test](test_models.py)
- Test all `models` commands

### [Plans test](test_plans.py)
- Test all `plans` commands
- Tests simulations and `plans download...` commands as well

### [Scheduling test](test_scheduling.py)
- Test all `scheduling` commands

### [Expansion test](test_expansion.py)
- Test all `expansion` commands

### [Metadata test](test_metadata.py)
- Test all `metadata` commands

### [Constraints test](test_constraints.py)
- Test all `constraints` commands
57 changes: 57 additions & 0 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Configure persistent session and configuration
# Note that we're setting global variables here rather than using pytest.VARIABLE
# The scope is global either way, but this allows for easier debugging, type hints, and autofill
import os
import sys

from aerie_cli.aerie_client import AerieClient
from aerie_cli.aerie_host import AerieHostSession, AuthMethod
from aerie_cli.commands.configurations import delete_all_persistent_files, upload_configurations, deactivate_session, activate_session
from aerie_cli.utils.sessions import get_active_session_client

# in case src_path is not from aeri-cli src and from site-packages
src_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__)) + "/../src")
sys.path.insert(0, src_path)

GRAPHQL_URL = "http://localhost:8080/v1/graphql"
GATEWAY_URL = "http://localhost:9000"
AUTH_URL = "http://localhost:9000/auth/login"
AUTH_METHOD = AuthMethod.AERIE_NATIVE
USERNAME = "a"
PASSWORD = "a"
# This should only ever be set to the admin secret for a local instance of aerie
HASURA_ADMIN_SECRET = os.environ.get("HASURA_GRAPHQL_ADMIN_SECRET")

session = AerieHostSession.session_helper(
AUTH_METHOD,
GRAPHQL_URL,
GATEWAY_URL,
AUTH_URL,
USERNAME,
PASSWORD
)
session.session.headers["x-hasura-admin-secret"] = HASURA_ADMIN_SECRET
client = AerieClient(session)

DOWNLOADED_FILE_NAME = "downloaded_file.test"

TEST_DIR = os.path.dirname(os.path.abspath(__file__))

FILES_PATH = os.path.join(TEST_DIR, "files")

# Configuration Variables
CONFIGURATIONS_PATH = os.path.join(FILES_PATH, "configuration")
CONFIGURATION_PATH = os.path.join(CONFIGURATIONS_PATH, "localhost_config.json")

# Resets the configurations and adds localhost
deactivate_session()
delete_all_persistent_files()
upload_configurations(CONFIGURATION_PATH)
activate_session("localhost")
persisent_client = None
try:
persisent_client = get_active_session_client()
except:
raise RuntimeError("Configuration is not active!")
assert persisent_client.host_session.gateway_url == GATEWAY_URL,\
"Aerie instances are mismatched. Ensure test URLs are the same."
3 changes: 3 additions & 0 deletions tests/integration_tests/files/constraints/constraint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default (): Constraint => {

}
3 changes: 3 additions & 0 deletions tests/integration_tests/files/goals/goal1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default (): Goal => {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"schemas": [
{ "key": "STRING_EXAMPLE", "schema": { "type": "string" } },
{ "key": "LONG_STRING_EXAMPLE", "schema": { "type": "long_string" } }
]
}
10 changes: 8 additions & 2 deletions tests/integration_tests/files/plans/create_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"foo": "arg1",
"num": 5
"initialPlantCount": 2,
"initialProducer": "nobody",
"initialDataPath": "/etc/os-release",
"initialConditions": {
"flag": "A",
"fruit": 3,
"peel": 3
}
}
10 changes: 8 additions & 2 deletions tests/integration_tests/files/plans/update_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"foo": "arg2",
"num": 5
"initialPlantCount": 3,
"initialProducer": "somebody",
"initialDataPath": "/etc/os-release",
"initialConditions": {
"flag": "B",
"fruit": 2,
"peel": 2
}
}
Loading