Closed dizballanze closed 6 years ago
@dizballanze I have not been able to reproduce this error. I have been experimenting with:
Can you provide some way to reproduce the error? If you are working on an open source project, I could try that directly. If not, it would be great if you could produce a small django project which simply reproduces the error.
If you could also provide me with your OS and component versions, that may help.
Also, what does your config file look like, and where is it located relative to your project?
I use packages and Python version as you described above.
Sometimes it raises described above error. In other tries, it raises a bunch of database errors for some of the tests while other tests pass. Some of the errors it raises:
File "/home/vagrant/venv/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute
return self.cursor.execute(sql)
psycopg2.DatabaseError: SSL error: decryption failed or bad record mac
I managed to fix this by setting ssl = false
in postgresql.conf
. But why this works with default test runner?
django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.
Many of psycopg2.IntegrityError
Just a hunch, as I don't know anything about Django, but this has the hallmarks of concurrency errors.
I had similar issues in another project, wherein green would through different errors on different runs, and using python -m unittest
instead didn't raise any errors at all. I figured out that it was because I hadn't considered the fact that green uses multiprocessing, and I was accessing the same the resources in different test modules. Could it be the same situation here?
It could be the same situation. For systems not designed for concurrent testing (django), I recommend specifying in your green configuration file to use only one process.
processes = 1
Please let me know if that helps. If it does, then I will add that advice to the Django section of the readme.
Hmm...if the multiprocessing ended up being the problem, it may be worth adding a feature to Green to auto-detect when it is running under Django and defaulting to 1 process in that case.
It works with processes = 1
.
But it's possible to run tests in parallel since version 1.9 with default Django test runner.
Okay, I'll go ahead and close this, then.
Maybe green
can support parallel tests in new versions of Django? I've tried to set --parallel
option of the Django test runner equal to processes
from green. It works but some tests still failing with database errors.
That would be cool. Does Django have any documentation about how a test runner can interact with Django to support parallel tests?
@CleanCut It is possible in the django documentation. https://docs.djangoproject.com/en/2.0/topics/testing/overview/ with the --parallel flag. BTW Thanks I had the same issue and processes=1 solved the issue.
@charlsagente Awesome, I'm so glad it solved the problem for you!
Also, thank you for the pointer to the --parallel
flag. I created #190 to track making Django integration more pleasant.
Hi, seems that green doesn't work with Django 2.0.