Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run Django tests #39

Closed
caseycesari opened this issue Apr 3, 2015 · 8 comments · Fixed by #41
Closed

Unable to run Django tests #39

caseycesari opened this issue Apr 3, 2015 · 8 comments · Fixed by #41
Assignees
Labels
Milestone

Comments

@caseycesari
Copy link
Member

I don't think this is related to our setup/configuration in context of running things on Jenkins, but I'm not totally sure.

+ vagrant ssh app -c 'cd /opt/app && envdir /etc/mmw.d/env ./manage.py test --noinput'
Creating test database for alias 'default'...
Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 90, in handle
    failures = test_runner.run_tests(test_labels)
  File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 210, in run_tests
    old_config = self.setup_databases()
  File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 166, in setup_databases
    **kwargs
  File "/usr/local/lib/python2.7/dist-packages/django/test/runner.py", line 370, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/creation.py", line 368, in create_test_db
    test_flush=True,
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 120, in call_command
    return command.execute(*args, **defaults)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 179, in handle
    created_models = self.sync_apps(connection, executor.loader.unmigrated_apps)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 317, in sync_apps
    cursor.execute(statement)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: relation "auth_user" does not exist
@caseycesari caseycesari added the bug label Apr 3, 2015
@kdeloach
Copy link
Contributor

kdeloach commented Apr 3, 2015

May have to run Django migrations first.

@caseycesari
Copy link
Member Author

This happens when running this line from test.sh on Jenkins

# Run the Django test suite with --noinput flag.
vagrant ssh app -c "cd /opt/app && envdir /etc/mmw.d/env ./manage.py test --noinput"

@caseycesari
Copy link
Member Author

Script is similar too NYC, not seeing migrations being run in that job though.

@caseycesari
Copy link
Member Author

Getting the same error locally.

@caseycesari
Copy link
Member Author

Running ./scripts/manage.sh syncdb does not fix the problem.

@caseycesari caseycesari added this to the 2015-04-09 milestone Apr 3, 2015
@caseycesari caseycesari self-assigned this Apr 3, 2015
@caseycesari
Copy link
Member Author

Might be something to do with the registration app and Django 1.8.

Similar issue reported here with a different app and Django 1.8: jazzband/django-oauth-toolkit#204

@caseycesari
Copy link
Member Author

The suggested work around in the above issue fixes the problem.

I added this to settings.py ...

REGISTRATION_MANAGER_MODEL = 'registration.RegistrationManager'
REGISTRATION_PROFILE_MODEL = 'registration.RegistrationProfile'

MIGRATION_MODULES = {
    'registration': 'mmw.migrations.registration',
}

... and then ran ./scripts/manage.sh makemigrations registration.

Not totally sure of the implications of this. Any insight @steventlamb?

@steventlamb
Copy link

As per our discussion and based on what I know, it looks like the added workaround is an acceptable solution to this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants