Closed Karmak23 closed 10 years ago
Well, the problem here is that mongoadmin runs fine without any relational db as long as it is set to
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.dummy'
}
}
The only problem is that the admin tends to use contenttypes all over the place. So in order to make the admin run without any kind of relational db mongoadmin tries to figure out if there is a relational db and if there isn't then uses the contenttypes provided by mongoengine. I think the auth system needs them at least.
I do very much agree though that the current test for a relational db sucks and I'd love to have a better (and more robust) test. I do remember that just catching every error the database might throw makes running syncdb next to impossible. Ah, well seems I need to figure out a better test now.
If you can tell jenkins to just catch and ignore it you should be fine though (maybe set HAS_RELATIONAL_DB
to False
too).
Correct me if I'm wrong, but I feel like setting the default database engine to dummy
will imply the same for the test database ? It is obviously not what we want, but I will investigate this on my side.
I tend to think the same about HAS_RELATIONAL_DB
In fact, we have a relational db, but only for the tests.
I have no idea but I suppose you'll get the same for tests. And, well, I can't tell you what you want of course, only the state the code is in. Which isn't all that great apparently.
And the only reason HAS_RELATIONAL_DB
is there is because it didn't really work for me without. I'm a bit amazed that you got it working without any relational db.
But I take a look at it tomorrow and hopefully come up with a better way to test this.
Give d5633d2cc5c194be48cf4ceb6b95ad0e071de5b3 a try. If you add MONGOADMIN_CHECK_CONTENTTYPE = False
to settings.py it should not try to figure out wether a relational db is there or not. I'd actually like to make the real test more robust, but failed miserably. So I hope this works for you too.
Latest commit works, regarding this issue, on my already setup project.
The subsequent question is: is there a way to simply delay this test, like with a *_lazy()
function ? Because the crash still arise when I start a Django project from scratch.
The main problem beiing that even with a relational database and everything correctly configured, ./manage createdb
will fail because the ContentType
model has not created the SQL table yet. This happens a lot in our environment, either in Jenkins which always start from scratch to be sure the project is completely installable at any time, or when (re-)deploying a full preview environment to test new features.
I understand that I can either temporarily remove mongoadmin
from INSTALLED_APPS
or define MONGOADMIN_CHECK_CONTENTTYPE = False
until createdb
is done, but this is still awkward: you would have to document somewhere that any project starting from scratch with mongoadmin
included will fail to start, and provide these 2 possible workarounds.
Aww, I thought createdb
would run without issue and the problem was that Jenkins just didn't create a database. I do wonder if there is a pattern I'm missing that runs tests like this only once but later.
Thinking a bit more about this I think looking at the database setting and assuming that the ContentType
stuff only needs replacement if the DB is explicitly set to dummy is the way to go. This is how it works at the moment anyway. Only uglier...
I close this issue because I didn't have time to test further this particular config. I will reopen it if I hit the bug again.
Hi,
on our jenkins server, there is no "real" django database at all: we just need the test one created on the fly by
./manage.py test
or./manage.py jenkins
. Still, the latest version ofmongoadmin
crashes:If we
git reset --hard HEAD~2
themongoadmin/
repository, everything is fine again.So the problem lies in one of your latest 2 patches. I didn't have the time to investigate the "why", but at a glance
ContentType.objects.all()[0]
seems to be a little too much assumption that a relational DB exists with Django's own tables (we don't even runsyncdb
on the jenkins machine because it will be run for the test database anyway).regards,
Olivier