diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f90aff83743531905182b9a1829d5256efdf3869..6fc985bea8dd7e6245dddcbecca25a6740e13498 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,14 +25,14 @@ test-code: services: - postgres:14.0 variables: - POSTGRES_DB: atdb_ldv_ci - POSTGRES_USER: atdb_admin_ci - POSTGRES_PASSWORD: "atdb123_ci" + POSTGRES_DB: atdb_ldv_test_ci + POSTGRES_USER: atdb_admin_test_ci + POSTGRES_PASSWORD: "atdb123_test_ci" script: - cd atdb - pip install -r requirements/dev.txt - - python manage.py migrate --settings atdb.settings.ci - - python manage.py test --settings atdb.settings.ci + - python manage.py migrate --settings atdb.settings.test_ci + - python manage.py test --settings atdb.settings.test_ci # deploy to 'sdc-dev.astron.nl' diff --git a/README.md b/README.md index efc57cf994a8276a3a156b0fc3486af107bd97db..6f3b237b50523e1648756c5c14039dd1fad23a78 100644 --- a/README.md +++ b/README.md @@ -114,14 +114,14 @@ See the integration instructions in the [astronauth repo](https://git.astron.nl/ ### Running tests -To run tests, you can spin up a dedicated test database locally using the the provided `docker-compose-ci.yml` file. This test database will not interfere with your local development database. For example, you can run this command from the `atdb/docker` folder: +To run tests, you can spin up a dedicated test database locally using the the provided `docker-compose-test-local.yml` file. This test database will not interfere with your local development database. For example, you can run this command from the `atdb/docker` folder: -` docker compose -f .\docker-compose-ci.yml up -d` +` docker compose -f .\docker-compose-test-local.yml up -d` After spinning up the database, you can execute the tests with the following command: -`python manage.py test --settings atdb.settings.ci` +`python manage.py test --settings atdb.settings.test_local` -Dedicated settings for running the tests are provided in the `atdb/settings/ci.dev` file. For convenience, `test.bat` is provided to run the above command (Windows only). +Dedicated settings for running the tests are provided in the `atdb/settings/test_local.dev` file. For convenience, `test.bat` is provided to run the above command (Windows only). -Finally, these tests are also executed in the CI pipeline through the test stage in the `.gitlab-ci.yml` file. \ No newline at end of file +Finally, these tests are also executed in the CI pipeline through the test stage in the `.gitlab-ci.yml` file. For running the tests in the CI pipeline, the settings file `atdb/settings/test_ci.dev` is used. \ No newline at end of file diff --git a/atdb/atdb/settings/ci.py b/atdb/atdb/settings/test_ci.py similarity index 53% rename from atdb/atdb/settings/ci.py rename to atdb/atdb/settings/test_ci.py index 73a2d35aafc18f9dfeafb6d5ea27632a677de0ed..b5bc3777e209e43ec5ddea002eabfaa455a7530b 100644 --- a/atdb/atdb/settings/ci.py +++ b/atdb/atdb/settings/test_ci.py @@ -4,10 +4,10 @@ import os DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', - 'USER': 'atdb_admin_ci', - 'PASSWORD': 'atdb123_ci', - 'NAME': 'atdb_ldv_ci', - 'HOST': 'localhost', + 'USER': 'atdb_admin_test_ci', + 'PASSWORD': 'atdb123_test_ci', + 'NAME': 'atdb_ldv_test_ci', + 'HOST': 'postgres', 'PORT': '5432', }, } \ No newline at end of file diff --git a/atdb/atdb/settings/test_local.py b/atdb/atdb/settings/test_local.py new file mode 100644 index 0000000000000000000000000000000000000000..6a70e4faa113e04ccbe7856a226ce5738b6996fd --- /dev/null +++ b/atdb/atdb/settings/test_local.py @@ -0,0 +1,13 @@ +from atdb.settings.base import * +import os + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'USER': 'atdb_admin_test_local', + 'PASSWORD': 'atdb123_test_local', + 'NAME': 'atdb_ldv_test_local', + 'HOST': 'localhost', + 'PORT': '5555', + }, +} \ No newline at end of file diff --git a/atdb/docker/docker-compose-ci.yml b/atdb/docker/docker-compose-ci.yml deleted file mode 100644 index 5774918ffe2b110118ca030bddaabefbee49ca9c..0000000000000000000000000000000000000000 --- a/atdb/docker/docker-compose-ci.yml +++ /dev/null @@ -1,15 +0,0 @@ -version: '3.4' - -services: - atdb-ldv-db: - image: postgres:14 - container_name: atdb-ldv-ci - expose: - - "5432" - ports: - - "5432:5432" - environment: - POSTGRES_PASSWORD: atdb123_ci - POSTGRES_USER: atdb_admin_ci - POSTGRES_DB: atdb_ldv_ci - diff --git a/atdb/docker/docker-compose-test-local.yml b/atdb/docker/docker-compose-test-local.yml new file mode 100644 index 0000000000000000000000000000000000000000..b3692434bddf6e0607188e02b066a9063fd1b019 --- /dev/null +++ b/atdb/docker/docker-compose-test-local.yml @@ -0,0 +1,15 @@ +version: '3.4' + +services: + atdb-ldv-db: + image: postgres:14 + container_name: atdb-ldv-test-local + expose: + - "5432" + ports: + - "5555:5432" + environment: + POSTGRES_PASSWORD: atdb123_test_local + POSTGRES_USER: atdb_admin_test_local + POSTGRES_DB: atdb_ldv_test_local + diff --git a/atdb/test.bat b/atdb/test.bat index 7651983768db3b208332ccb6ef1d8577f1e4f980..73190d463de9efae9e19e40dea975b382553f847 100644 --- a/atdb/test.bat +++ b/atdb/test.bat @@ -1 +1 @@ -python manage.py test --settings atdb.settings.ci +python manage.py test --settings atdb.settings.test_local