1

I am running Django Unit tests on CircleCI with 1 container setup. The tests run fine when I do not add Django's --parallel argument. However, when I add --parallel=2 to the test run, it fails with this cryptic error below.

I've tried both versions: with and without --keepdb - both fail with exactly the same error. The code for _clode_test_db appears to suggest that passing --keepdb=True should fail fast and return. See django/db/backends/mysql/creation.py line: 29 here [https://github.com/django/django/pull/4761/files]

Would appreciate any ideas on what is going on here

Using existing clone for alias 'default' ('test_django_learned')...
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/core/management/commands/test.py", line 90, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/test/runner.py", line 532, in run_tests
    old_config = self.setup_databases()
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/test/runner.py", line 482, in setup_databases
    self.parallel, **kwargs
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/test/runner.py", line 733, in setup_databases
    keepdb=keepdb,
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 219, in clone_test_db
    self._clone_test_db(number, verbosity, keepdb)
  File "/home/circleci/sliderule/venv/lib/python2.7/site-packages/django/db/backends/mysql/creation.py", line 48, in _clone_test_db
    dump_proc = subprocess.Popen(dump_cmd, stdout=subprocess.PIPE)
  File "/usr/local/lib/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/local/lib/python2.7/subprocess.py", line 1024, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
Exited with code 1
rtindru
  • 5,107
  • 9
  • 41
  • 59

1 Answers1

1

I could reproduce it and debugged the problem in my ubuntu container by adding

sys.stderr.write("dump_cmd: %r" % dump_cmd)

to site-packages/django/db/backends/mysql/creation.py and it gave me

dump_cmd: ['mysqldump', '--user=root', '--password=pass', '--host=db', '--port=3306', 'test']

So probably your container is also missing mysqldump which I fixed with a simple sudo apt-get install mysql-client.

tuky
  • 61
  • 1
  • 3