Skip to content

Commit

Permalink
Drop role service DB schema before tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jirik committed Dec 20, 2023
1 parent 8875c87 commit 50e91cc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,12 @@ test:
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml rm -f layman_test
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml up -d postgresql
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps layman_test bash -c "bash ensure-test-data.sh && python3 src/assert_db.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps -u root layman_test bash -c "cd src && python3 -B setup_geoserver.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps -u root layman_test bash -c "cd src && python3 -B drop_layman_role_service_schema.py && python3 -B setup_geoserver.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml up --force-recreate --no-deps -d celery_worker_test
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --name layman_test_run_1 layman_test

test-fast:
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps -u root layman_test bash -c "cd src && python3 -B drop_layman_role_service_schema.py && python3 -B setup_geoserver.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps --name layman_test_run_1 layman_test

test-separated:
Expand All @@ -226,11 +227,12 @@ test-separated:
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml rm -f layman_test
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml up -d postgresql
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps layman_test bash -c "bash ensure-test-data.sh && python3 src/assert_db.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps -u root layman_test bash -c "cd src && python3 -B setup_geoserver.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps -u root layman_test bash -c "cd src && python3 -B drop_layman_role_service_schema.py && python3 -B setup_geoserver.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml up --force-recreate --no-deps -d celery_worker_test
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --name layman_test_run_1 -e "TEST_TYPE=$(test_type)" layman_test bash -c "bash test_separated.sh $(max_fail)"

test-separated-fast:
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps -u root layman_test bash -c "cd src && python3 -B drop_layman_role_service_schema.py && python3 -B setup_geoserver.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps --name layman_test_run_1 -e "TEST_TYPE=$(test_type)" layman_test bash -c "bash test_separated.sh $(max_fail)"

test-static:
Expand All @@ -247,7 +249,7 @@ test-static:
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml rm -f layman_test
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml up -d postgresql
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps layman_test bash -c "bash ensure-test-data.sh && python3 src/assert_db.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps -u root layman_test bash -c "cd src && python3 -B setup_geoserver.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --no-deps -u root layman_test bash -c "cd src && python3 -B drop_layman_role_service_schema.py && python3 -B setup_geoserver.py"
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml up --force-recreate --no-deps -d celery_worker_test
docker compose -f docker-compose.deps.yml -f docker-compose.test.yml run --rm --name layman_test_run_1 layman_test bash -c "bash test_static.sh"

Expand Down
19 changes: 19 additions & 0 deletions src/drop_layman_role_service_schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import psycopg2
import layman_settings as settings


def main():
print(f"Drop Layman role service DB schema.")

# Layman DB
conn = psycopg2.connect(**settings.PG_CONN)
conn.autocommit = True
cur = conn.cursor()
cur.execute(f"""
DROP SCHEMA IF EXISTS "{settings.LAYMAN_INTERNAL_ROLE_SERVICE_SCHEMA}" CASCADE;
""")
conn.commit()


if __name__ == "__main__":
main()

0 comments on commit 50e91cc

Please sign in to comment.