django / django-docker-box

Run the Django test suite across all supported databases and python versions
120 stars 37 forks source link

Test suite failing under PostgresSQL due to missing collation #21

Closed hannseman closed 4 years ago

hannseman commented 4 years ago

I'm not able to run the test suite under PostgreSQL with POSTGRES_VERSION=9.6, ~but they seem to fail with newer versions as well.~

I might be missing something here but it could also be something introduced by https://github.com/django/django/pull/13207.

https://github.com/django/django/pull/13207/files#diff-9385ef62a9e10556c6768c66e8f6e2ebR62

$ docker-compose run --rm postgres
Creating network "django-docker-box_default" with the default driver
Creating volume "django-docker-box_oracle" with default driver
Creating django-docker-box_memcached2_1  ... done
Creating django-docker-box_postgres-db_1 ... done
Creating django-docker-box_memcached_1   ... done
Creating django-docker-box_postgres_run  ... done
wait-for-it.sh: waiting 20 seconds for postgres-db:5432
wait-for-it.sh: postgres-db:5432 is available after 3 seconds
Testing against Django installed in '/tests/django/django' with up to 6 processes
Creating test database for alias 'default'...
Traceback (most recent call last):
  File "/tests/django/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
psycopg2.errors.UndefinedObject: collation "sv-x-icu" for encoding "UTF8" does not exist
LINE 1: ...al NOT NULL PRIMARY KEY, "char_field" varchar(10) COLLATE "s...
                                                             ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "tests/runtests.py", line 589, in <module>
    options.timing,
  File "tests/runtests.py", line 320, in django_tests
    extra_tests=extra_tests,
  File "/tests/django/django/test/runner.py", line 717, in run_tests
    old_config = self.setup_databases(aliases=databases)
  File "/tests/django/django/test/runner.py", line 637, in setup_databases
    debug_sql=self.debug_sql, parallel=self.parallel, **kwargs
  File "/tests/django/django/test/utils.py", line 183, in setup_databases
    serialize=connection.settings_dict['TEST'].get('SERIALIZE', True),
  File "/tests/django/django/db/backends/base/creation.py", line 77, in create_test_db
    run_syncdb=True,
  File "/tests/django/django/core/management/__init__.py", line 172, in call_command
    return command.execute(*args, **defaults)
  File "/tests/django/django/core/management/base.py", line 394, in execute
    output = self.handle(*args, **options)
  File "/tests/django/django/core/management/base.py", line 89, in wrapped
    res = handle_func(*args, **kwargs)
  File "/tests/django/django/core/management/commands/migrate.py", line 214, in handle
    self.sync_apps(connection, executor.loader.unmigrated_apps)
  File "/tests/django/django/core/management/commands/migrate.py", line 349, in sync_apps
    editor.create_model(model)
  File "/tests/django/django/db/backends/base/schema.py", line 329, in create_model
    self.execute(sql, params or None)
  File "/tests/django/django/db/backends/base/schema.py", line 143, in execute
    cursor.execute(sql, params)
  File "/tests/django/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/tests/django/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/tests/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/tests/django/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/tests/django/django/db/backends/utils.py", line 82, in _execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: collation "sv-x-icu" for encoding "UTF8" does not exist
LINE 1: ...al NOT NULL PRIMARY KEY, "char_field" varchar(10) COLLATE "s...
hannseman commented 4 years ago

Looks like support for ICU collations was introduced in Postgres 10: https://wiki.postgresql.org/wiki/New_in_postgres_10#ICU_Collation_Support

Setting POSTGRES_VERSION=10 fixes this error.

hannseman commented 4 years ago

Not an issue with django-docker-box - see https://code.djangoproject.com/ticket/32073