diff --git a/.github/workflows/test-functional-microstack.yaml b/.github/workflows/test-functional-microstack.yaml index d2ac51a6..eac7cc2b 100644 --- a/.github/workflows/test-functional-microstack.yaml +++ b/.github/workflows/test-functional-microstack.yaml @@ -20,9 +20,7 @@ jobs: - name: Install ColdFront and plugin run: | - python -m pip install --upgrade pip - pip install -r test-requirements.txt - pip install -e . + ./ci/setup.sh - name: Install and start Ceph RadosGW run: | diff --git a/ci/run_functional_tests_openshift.sh b/ci/run_functional_tests_openshift.sh index 2aa9125d..a1418c72 100755 --- a/ci/run_functional_tests_openshift.sh +++ b/ci/run_functional_tests_openshift.sh @@ -16,6 +16,7 @@ export DJANGO_SETTINGS_MODULE="local_settings" export FUNCTIONAL_TESTS="True" export OS_API_URL="https://onboarding-onboarding.cluster.local:6443" export PYTHONWARNINGS="ignore:Unverified HTTPS request" +export DB_URL="postgres://postgres:postgres@localhost:5432/postgres" coverage run --source="." -m django test coldfront_plugin_cloud.tests.functional.openshift diff --git a/ci/run_functional_tests_openstack.sh b/ci/run_functional_tests_openstack.sh index b6aa1c67..3d92968e 100755 --- a/ci/run_functional_tests_openstack.sh +++ b/ci/run_functional_tests_openstack.sh @@ -20,6 +20,7 @@ export DJANGO_SETTINGS_MODULE="local_settings" export FUNCTIONAL_TESTS="True" export OS_AUTH_URL="https://localhost:5000" export PYTHONWARNINGS="ignore:Unverified HTTPS request" +export DB_URL="postgres://postgres:postgres@localhost:5432/postgres" coverage run --source="." -m django test coldfront_plugin_cloud.tests.functional.openstack coverage run --source="." -m django test coldfront_plugin_cloud.tests.functional.esi diff --git a/ci/run_unit_tests.sh b/ci/run_unit_tests.sh index 26de492f..2ea96f3e 100755 --- a/ci/run_unit_tests.sh +++ b/ci/run_unit_tests.sh @@ -7,6 +7,7 @@ if [[ ! "${CI}" == "true" ]]; then fi export DJANGO_SETTINGS_MODULE="local_settings" +export DB_URL="postgres://postgres:postgres@localhost:5432/postgres" coverage run --source="." -m django test coldfront_plugin_cloud.tests.unit coverage report diff --git a/ci/setup.sh b/ci/setup.sh index 76d242a5..09966352 100755 --- a/ci/setup.sh +++ b/ci/setup.sh @@ -2,6 +2,9 @@ set -xe +sudo systemctl start postgresql.service +sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';" + # If running on Github actions, don't create a virtualenv if [[ ! "${CI}" == "true" ]]; then virtualenv -p python3 /tmp/coldfront_venv diff --git a/src/coldfront_plugin_cloud/tests/unit/test_migrate_field_of_science.py b/src/coldfront_plugin_cloud/tests/unit/test_migrate_field_of_science.py index 8bc11f1a..a439ba83 100644 --- a/src/coldfront_plugin_cloud/tests/unit/test_migrate_field_of_science.py +++ b/src/coldfront_plugin_cloud/tests/unit/test_migrate_field_of_science.py @@ -1,6 +1,7 @@ import uuid import tempfile +from django.db import connection from django.core.management import call_command from coldfront.core.project.models import Project from coldfront.core.field_of_science.models import FieldOfScience @@ -9,6 +10,17 @@ class TestFixAllocation(base.TestBase): + def setUp(self) -> None: + """ + Because Coldfront manually sets the IDs of FieldOfScience (FOS) entries, this creates a mismatch + between the actual FOS IDs and the sequence that Postgres uses to auto-increment them + """ + super().setUp() + with connection.cursor() as cursor: + cursor.execute( + 'SELECT setval(pg_get_serial_sequence(\'field_of_science_fieldofscience\',\'id\'), coalesce(max("id"), 1), max("id") IS NOT null) FROM "field_of_science_fieldofscience";' + ) + def test_command_output(self): old_fos_1 = self.new_field_of_science() old_fos_2 = self.new_field_of_science() diff --git a/test-requirements.txt b/test-requirements.txt index 3d041edd..6161d07c 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -6,3 +6,4 @@ python-keystoneclient python-novaclient python-neutronclient python-swiftclient +psycopg2