Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

Test Template #301

Open
wants to merge 147 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
33731c2
Adding experimental module.
toddroper Jul 7, 2023
04d9a16
Removing experimental router.
toddroper Jul 7, 2023
a5e6412
Removed project from autogen orm.
toddroper Jul 11, 2023
bab4cb0
Removed project from autogen schema.
toddroper Jul 11, 2023
37e303a
Updated id to orm_id.
toddroper Jul 11, 2023
d874341
Added function to convert plural to singular.
toddroper Jul 11, 2023
e05ded1
Removing old project router.
toddroper Jul 11, 2023
b140e54
Adding project module.
toddroper Jul 11, 2023
08756ef
Removed more items from autogen schema.
toddroper Jul 11, 2023
dfd66a5
Removed more items from autogen orm.
toddroper Jul 11, 2023
6089822
Updated ProvenanceType location in query helpers.
toddroper Jul 11, 2023
0ae7767
Removing person router.
toddroper Jul 11, 2023
6e93cb7
Updated ResourceType import location.
toddroper Jul 11, 2023
f67c325
Updated ProvenanceType location.
toddroper Jul 11, 2023
0e32e71
Adding person module.
toddroper Jul 11, 2023
2b9adfa
Removed TDS from modules.
toddroper Jul 12, 2023
a6d2a02
Moved QualifierXref to Dataset model file.
toddroper Jul 12, 2023
1cdb15b
Updated dataset lib with new QualifierXref location.
toddroper Jul 12, 2023
a943c9a
Removed QualifierXref and external classes from ORM.
toddroper Jul 12, 2023
864fd6f
Merge down main.
toddroper Jul 12, 2023
9203328
Removed Qualifier from orm.
toddroper Jul 12, 2023
8f54f97
Removed unused classes from schema.
toddroper Jul 12, 2023
93652ea
Added Qualifier class to Dataset model file.
toddroper Jul 12, 2023
166fc72
More ORM/Schema updates.
toddroper Jul 12, 2023
06a0070
Fixed linter issue.
toddroper Jul 12, 2023
21ee090
Moved column types to new enum file.
toddroper Jul 12, 2023
c4e4180
Moved enums to db package.
toddroper Jul 12, 2023
8a95bd3
Moved declaritive base to db package.
toddroper Jul 12, 2023
0ace1fe
Removed orm from seed_data script.
toddroper Jul 12, 2023
0154cd7
More items removed from orm and schema files.
toddroper Jul 12, 2023
928aa3c
Added model framework to model model file.
toddroper Jul 12, 2023
f8097fc
Updated model framework location.
toddroper Jul 12, 2023
8d7b0ba
Updated more framework locations.
toddroper Jul 12, 2023
f1ae0e2
Fixed enum location.
toddroper Jul 12, 2023
4498d04
Updated base location in db helpers.
toddroper Jul 12, 2023
36daa26
Updated base location to prevent circular import.
toddroper Jul 12, 2023
945daeb
Moved Feature to Dataset model file.
toddroper Jul 12, 2023
baba434
Updated project asset location.
toddroper Jul 12, 2023
4e53739
Fixed concept schema file.
toddroper Jul 12, 2023
06c117c
Updated dataset lib, removed final schema/orm items.
toddroper Jul 12, 2023
240aeb6
Removing Qualifier from schema.
toddroper Jul 12, 2023
eaf446b
Added payloads to dataset model.
toddroper Jul 12, 2023
d7f3e51
Code clean up.
toddroper Jul 12, 2023
0ed9742
Cleaned up schema package's resource file.
toddroper Jul 12, 2023
390ea0f
Cleaned up schema package's project file.
toddroper Jul 12, 2023
abe10ad
Cleaned up model utils.
toddroper Jul 12, 2023
4e3c0bf
Converted schema Feature class to modular structure.
toddroper Jul 12, 2023
c10053d
Converted model to use modular structure.
toddroper Jul 12, 2023
1bfc4c4
Fixed Publication location in external router.
toddroper Jul 12, 2023
d017aad
Removing autogen module.
toddroper Jul 12, 2023
8e5e4cb
Removing external router.
toddroper Jul 13, 2023
033e3d6
Fixed ES error in project controller.
toddroper Jul 13, 2023
cfc24a1
Fixed duplicate relationship on Person model.
toddroper Jul 13, 2023
21abcca
Adding external module.
toddroper Jul 13, 2023
d377e3e
Moving disabled operations method to model controller for retention.
toddroper Jul 13, 2023
c9cf857
Removed op code from old router.
toddroper Jul 13, 2023
eb9041a
Removing model router.
toddroper Jul 13, 2023
54adbdc
Removed unused response function.
toddroper Jul 13, 2023
f582e55
Adding model framework module.
toddroper Jul 13, 2023
bff38c6
Removed routers package.
toddroper Jul 13, 2023
f75f961
Removed old router logic.
toddroper Jul 13, 2023
15086d2
Fixing CodeQL warning.
toddroper Jul 13, 2023
48c5376
Linter clean up.
toddroper Jul 13, 2023
0bdb744
Linter clean up 1.
toddroper Jul 13, 2023
b416661
Converted general error to general db error for linter.
toddroper Jul 13, 2023
039a26f
Linter sweep.
toddroper Jul 13, 2023
7a757a4
Added bypass when module is not a route object.
toddroper Jul 13, 2023
6a6ab3c
Merge branch 'main' into dev/0.6.0
toddroper Jul 17, 2023
44d6506
Fixing merge conflicts.
toddroper Jul 31, 2023
4de4bca
Moving tests to old_tests.
toddroper Jul 31, 2023
16e5c87
Adding test deps.
toddroper Aug 1, 2023
064a5ac
Added new tests.
toddroper Aug 1, 2023
b0d684e
Cleaned up docker file.
toddroper Aug 8, 2023
8cd51f2
Cleaned up docker file.
toddroper Aug 8, 2023
712593a
Refactored relational db for testing.
toddroper Aug 8, 2023
b9b5d65
Updated migrate env for testing.
toddroper Aug 8, 2023
c8a5522
Refactored provenance migration for testing.
toddroper Aug 8, 2023
e56e268
Refactored init for testing.
toddroper Aug 8, 2023
941d8f7
Refactored model migration for testing.
toddroper Aug 8, 2023
e7e51ae
Refactored project asset migration for testing.
toddroper Aug 8, 2023
ce1abef
Refactored artifact enum migration for testing.
toddroper Aug 8, 2023
b1e0273
Refactored publication migration for testing.
toddroper Aug 8, 2023
fe013f7
Added profiles to docker compose.
toddroper Aug 8, 2023
76d873e
Added test deps.
toddroper Aug 8, 2023
5bc43fa
Updated poetry.lock file.
toddroper Aug 8, 2023
6f057db
Added sql items to settings for test.
toddroper Aug 8, 2023
250ccaf
Fixed model created response code.
toddroper Aug 8, 2023
d86d95d
Fixed model tests.
toddroper Aug 8, 2023
0782ce8
Adding enum handler for migrations.
toddroper Aug 8, 2023
58c0ec7
Adding test script.
toddroper Aug 8, 2023
b8c1b93
Adding test docker file.
toddroper Aug 8, 2023
9cfbb34
Adding test override file.
toddroper Aug 8, 2023
386cf63
Adding override file to ignore.
toddroper Aug 8, 2023
cc6de43
Fixed naming to match modules.
toddroper Aug 8, 2023
d0f6e70
Finished cleaning up model test.
toddroper Aug 8, 2023
dbdf020
Updated test env.
toddroper Aug 8, 2023
a4393df
Fixed put response in model configurations.
toddroper Aug 8, 2023
3832a6f
Fixed post response in workflows.
toddroper Aug 8, 2023
3e1bfc9
Fixed put response in projects.
toddroper Aug 8, 2023
722dab8
Adding additional tests.
toddroper Aug 8, 2023
3cc711a
Merging dowm main.
toddroper Aug 8, 2023
2297952
Fixing linter issue.
toddroper Aug 8, 2023
a267722
Moving pytest to own workflow.
toddroper Aug 8, 2023
15082c8
Adding test workflow.
toddroper Aug 8, 2023
387afdf
Fixed workflow title.
toddroper Aug 8, 2023
e968b41
More tweaks.
toddroper Aug 8, 2023
f33b604
Setting up override.
toddroper Aug 8, 2023
0f49036
Cleaning up docker compose. Moving local services to override.
toddroper Aug 8, 2023
da8a65b
Adding local override.
toddroper Aug 8, 2023
3cd39ce
Removing local dependencies.
toddroper Aug 8, 2023
eeaa4ef
Removed mounts.
toddroper Aug 8, 2023
2af4d92
Added exit flag to compose job.
toddroper Aug 8, 2023
98fbc33
Cleaned up test override.
toddroper Aug 9, 2023
13b5771
Increased ES timeout.
toddroper Aug 9, 2023
b754cca
Fixed the stuff I should not have removed.
toddroper Aug 9, 2023
0059e96
Updated timeout for ES again.
toddroper Aug 9, 2023
8fdd6ff
Another timeout test.
toddroper Aug 9, 2023
5aea311
Added ES volume to local override.
toddroper Aug 9, 2023
1a20021
Added ES index auto create option for testing.
toddroper Aug 9, 2023
ea6a299
Added test init.
toddroper Aug 9, 2023
edf97c5
Added TDS_HOST_PORT to sample env.
toddroper Aug 9, 2023
6250397
Added additional test props to set up.
toddroper Aug 9, 2023
a51c10c
Fixed workflow test.
toddroper Aug 9, 2023
3b0d9dc
Added ES init to test flow.
toddroper Aug 9, 2023
421e3e7
Added check for failed tests.
toddroper Aug 9, 2023
0625d0f
Reverted timeout increase.
toddroper Aug 9, 2023
d2f8655
Fixed quote issue.
toddroper Aug 9, 2023
8f5bc72
Removed unneeded fail check.
toddroper Aug 9, 2023
55823b8
Cleaned up step names.
toddroper Aug 9, 2023
b8f2bc8
Reimplented test step for publish.
toddroper Aug 9, 2023
a47da29
Unified names.
toddroper Aug 9, 2023
99ad5d6
Cleaned up duplicated items in testing override.
toddroper Aug 9, 2023
6fc9392
Removing enum migration.
toddroper Aug 9, 2023
e1bf54a
Minor enum update.
toddroper Aug 9, 2023
7b00bdb
Added neo4j as migration dep.
toddroper Aug 9, 2023
2d54d7d
Removed postgres enums.
toddroper Aug 9, 2023
475445e
Fixed base install in main dockerfile.
toddroper Aug 9, 2023
0aa3428
Merge branch 'main' into feat/test-template
toddroper Aug 9, 2023
c3bae43
Fixed down version.
toddroper Aug 9, 2023
5db215d
Merge branch 'main' into feat/test-template
toddroper Aug 11, 2023
92f9034
Merge branch 'main' into feat/test-template
toddroper Aug 16, 2023
9a2fc4d
Fixed pylint and test issues.
toddroper Aug 16, 2023
e67823a
Added code id to pytest.
toddroper Aug 16, 2023
5f67e96
Adding code tests.
toddroper Aug 16, 2023
bed830e
Added timestamp to code response.
toddroper Aug 16, 2023
25e54ed
Added timestamp to code response.
toddroper Aug 16, 2023
db6c7a2
Added repo url to code test conf.
toddroper Aug 16, 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
2 changes: 0 additions & 2 deletions .github/workflows/correctness.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@ jobs:
run: poetry run pylint ./tds
- name: Pylint alembic
run: poetry run pylint ./migrate
- name: Pytest
run: poetry run pytest
9 changes: 6 additions & 3 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
formatting:
uses: ./.github/workflows/formatting.yaml

test:
uses: ./.github/workflows/test.yaml

# Call the Tag Generator to generate an image tag to use
tag-generator:
uses: darpa-askem/.github/.github/workflows/tag-generator.yaml@main
Expand All @@ -27,9 +30,9 @@ jobs:
# Build and Publish all targets associated with specified group
bake:
needs:
# Temorarily remove these to allow build while we fix testing
# - correctness
# - formatting
- correctness
- formatting
- test
- tag-generator
uses: darpa-askem/.github/.github/workflows/bake-publish.yml@main
with:
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Test
on:
workflow_call:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v1
- name: Set up test.
run: |
cp api.env.sample api.env
cp docker/overrides/docker-compose.testing.override.yml docker-compose.override.yml
- name: Run Test Suite
run: |
docker-compose --env-file api.env --profile tds-testing up --abort-on-container-exit --build

- name: Clean Up
if: always()
run: docker-compose --env-file api.env --profile tds-testing down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ api.env
# Minio
.minio.sys
data/askem-staging-data-service
migrate/seeds/files/*.csv
migrate/seeds/files/*.csv
docker-compose.override.yml
1 change: 1 addition & 0 deletions api.env.sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
TDS_HOST_PORT=8001
SQL_URL=rdb
SQL_PORT=5432
SQL_USER=dev
Expand Down
94 changes: 4 additions & 90 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,6 @@ networks:
driver: bridge
name: data-annotation-stack
services:
rdb:
container_name: data-service-rdb
image: "postgres:15.1"
ports:
- 8032:$SQL_PORT
environment:
- POSTGRES_PASSWORD=$SQL_PASSWORD
- POSTGRES_USER=$SQL_USER
- POSTGRES_DB=$SQL_DB
volumes:
- tds_data:/var/lib/postgresql/data
networks:
- data-api
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${SQL_USER} -d ${SQL_DB}" ]
interval: 10s
timeout: 5s
retries: 5
api:
container_name: data-service-api
build:
Expand All @@ -39,51 +21,8 @@ services:
networks:
- data-annotation-stack
- data-api
depends_on:
migrations:
condition: service_completed_successfully
graphdb:
condition: service_started
minio:
condition: service_started
volumes:
- $PWD/tds:/api/tds
- $PWD/migrate:/api/migrate
graphdb:
build:
context: ./
dockerfile: docker/Dockerfile.neo4j
ports:
- 7474:7474
- 7687:7687
environment:
- NEO4J_AUTH=$NEO4J_AUTH
- NEO4J_dbms_memory_pagecache_size=512M
volumes:
- neo4j_data:/data
depends_on:
rdb:
condition: service_healthy
migrations:
condition: service_completed_successfully
networks:
- data-api
minio:
build:
context: ./
dockerfile: docker/Dockerfile.minio
environment:
MINIO_ROOT_USER: $MINIO_USER
MINIO_ROOT_PASSWORD: $MINIO_PWD
ports:
- 9000:9000
- 9001:9001
volumes:
- $PWD/data:/data
networks:
- data-api
- data-annotation-stack
elasticsearch:
profiles: ["local", "tds-testing"]
image: elasticsearch:${STACK_VERSION}
environment:
- discovery.type=single-node
Expand All @@ -100,42 +39,17 @@ services:
healthcheck:
test: curl http://localhost:9200/_cluster/health?wait_for_status=yellow || exit 1
interval: 10s
timeout: 20s
retries: 5
kibana:
depends_on:
- elasticsearch
image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
volumes:
- kibanadata:/usr/share/kibana/data
ports:
- ${KIBANA_PORT}:5601
environment:
- SERVERNAME=kibana
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- ELASTICSEARCH_USERNAME=kibana_system
- ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD}
mem_limit: ${MEM_LIMIT}
networks:
- data-api
- data-annotation-stack
timeout: 10s
retries: 10
migrations:
profiles: ["tds-api-only", "tds-api", "local"]
container_name: data-service-migrations
build:
context: ./
dockerfile: docker/Dockerfile.migrations
entrypoint: /run_migrations.sh
env_file:
- api.env
# volumes:
# - $PWD/migrate:/migrate
depends_on:
rdb:
condition: service_healthy
elasticsearch:
condition: service_healthy
minio:
condition: service_started
networks:
- data-api
volumes:
Expand Down
10 changes: 3 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ WORKDIR /api
ADD poetry.lock poetry.lock
ADD pyproject.toml pyproject.toml
RUN poetry config virtualenvs.create false
RUN poetry install --no-root
COPY tests tests
COPY tds tds
COPY tds tds
COPY graph_relations.json graph_relations.json
RUN mkdir /api/tests && touch /api/tests/test.py
RUN poetry install --no-dev

# Poetry complains if the README doesn't exist
COPY README.md README.md
COPY migrate migrate
RUN poetry install --only-root
EXPOSE 8000
CMD ["poetry", "run", "tds"]
17 changes: 17 additions & 0 deletions docker/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM python:3.10
RUN apt update 2> /dev/null
RUN apt install -y postgresql postgresql-contrib sqlite3
RUN pip install poetry
WORKDIR /api
ADD poetry.lock poetry.lock
ADD pyproject.toml pyproject.toml
RUN poetry config virtualenvs.create false
COPY tests tests
COPY tds tds
COPY tds /tds_package/tds
RUN find tds_package/tds/modules \! -name "model.py" -mindepth 2 -maxdepth 2 -print | xargs rm -rf
COPY graph_relations.json graph_relations.json

COPY migrate migrate
COPY docker/scripts/tds_test.sh tds_test.sh
RUN poetry install
100 changes: 100 additions & 0 deletions docker/overrides/docker-compose.local.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
version: "3.9"
services:
rdb:
profiles: [ "tds-api", "local" ]
container_name: data-service-rdb
image: "postgres:15.1"
ports:
- 8032:$SQL_PORT
environment:
- POSTGRES_PASSWORD=$SQL_PASSWORD
- POSTGRES_USER=$SQL_USER
- POSTGRES_DB=$SQL_DB
volumes:
- tds_data:/var/lib/postgresql/data
networks:
- data-api
healthcheck:
test: [ "CMD-SHELL", "pg_isready -U ${SQL_USER} -d ${SQL_DB}" ]
interval: 10s
timeout: 5s
retries: 5
minio:
profiles: [ "local" ]
build:
context: ./
dockerfile: docker/Dockerfile.minio
environment:
MINIO_ROOT_USER: $MINIO_USER
MINIO_ROOT_PASSWORD: $MINIO_PWD
ports:
- 9000:9000
- 9001:9001
volumes:
- $PWD/data:/data
networks:
- data-api
- data-annotation-stack
graphdb:
profiles: [ "tds-api", "local" ]
build:
context: ./
dockerfile: docker/Dockerfile.neo4j
ports:
- 7474:7474
- 7687:7687
environment:
- NEO4J_AUTH=$NEO4J_AUTH
- NEO4J_dbms_memory_pagecache_size=512M
volumes:
- neo4j_data:/data
depends_on:
rdb:
condition: service_healthy
migrations:
condition: service_completed_successfully
networks:
- data-api
migrations:
depends_on:
rdb:
condition: service_healthy
elasticsearch:
condition: service_healthy
minio:
condition: service_started
volumes:
- $PWD/migrate:/migrate
api:
depends_on:
migrations:
condition: service_completed_successfully
graphdb:
condition: service_started
minio:
condition: service_started
volumes:
- $PWD/tests:/api/tests
- $PWD/tds:/api/tds
- $PWD/migrate:/api/migrate
elasticsearch:
volumes:
- elasticsearch_data:/usr/share/elasticsearch/data
kibana:
profiles: [ "local" ]
depends_on:
- elasticsearch
image: docker.elastic.co/kibana/kibana:${STACK_VERSION}
volumes:
- kibanadata:/usr/share/kibana/data
ports:
- ${KIBANA_PORT}:5601
environment:
- SERVERNAME=kibana
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
- ELASTICSEARCH_USERNAME=kibana_system
- ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD}
mem_limit: ${MEM_LIMIT}
networks:
- data-api
- data-annotation-stack
16 changes: 16 additions & 0 deletions docker/overrides/docker-compose.testing.override.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.9"
services:
api:
container_name: data-service-api-testing
build:
context: ./
dockerfile: docker/Dockerfile.test
environment:
- NEO4J_ENABLED
- SQL_CONN_STR=sqlite:///test.db
- SEED_DATA=false
- SQL_NOW_STATEMENT=CURRENT_TIMESTAMP
depends_on:
elasticsearch:
condition: service_healthy
entrypoint: ["bash", "/api/tds_test.sh"]
7 changes: 7 additions & 0 deletions docker/scripts/tds_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

alembic -c migrate/alembic.ini upgrade head
python migrate/scripts/start_elasticsearch.py
pytest tests/
#touch /logger.log
#tail -f /logger.log
3 changes: 3 additions & 0 deletions migrate/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def setup_context() -> str:
url = config.get_main_option("sqlalchemy.url")
url = re.sub(r"\${(.+?)}", lambda m: tokens[m.group(1)], url)

if os.getenv("SQL_CONN_STR", None):
url = os.getenv("SQL_CONN_STR")

return url


Expand Down
Loading