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

The equivalent of LETTUCE_USE_TEST_DATABASE #52

Closed
ramast opened this issue Sep 15, 2016 · 5 comments
Closed

The equivalent of LETTUCE_USE_TEST_DATABASE #52

ramast opened this issue Sep 15, 2016 · 5 comments

Comments

@ramast
Copy link

ramast commented Sep 15, 2016

Test cases tend to be extremely slow when destroying and create new DB after each feature (postgres).
We use LETTUCE_USE_TEST_DATABASE = False in lettuce to prevent the continuous destruction/creation and use hooks to clear the DB tables after each scenario.

How do I achieve same thing with Aloe?
Right now I keep getting

Creating test database for alias 'default'...
Type 'yes' if you would like to try deleting the test database 'test_app_test', or 'no' to cancel: Got an error creating the test database: database "test_app_test" already exists

@koterpillar
Copy link
Member

I can't reproduce this behavior, here's the example output with two features being run:

$ ./manage.py harvest -v 2
nosetests -v --verbosity=2
Creating test database for alias 'default' ('file:memorydb_default?mode=memory&cache=shared')...
Operations to perform:
  Synchronize unmigrated apps: aloe_django, messages, staticfiles
  Apply all migrations: admin, auth, contenttypes, sessions
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying sessions.0001_initial... OK
View page (exampleapp.features.hello: Hello World) ... ok
View page (exampleapp.features.hello2: Hello World) ... ok

----------------------------------------------------------------------
Ran 2 tests in 1.147s

OK
Destroying test database for alias 'default' ('file:memorydb_default?mode=memory&cache=shared')...

As you can see, the test database is only created and destroyed once. Are you sure there's no hooks that try to flush the database or do anything else to it?

@ramast
Copy link
Author

ramast commented Sep 20, 2016

Yes, you are right. I wasn't accurate in my original post.
I wanted to disable the database creation/deletion all together because its a time consuming process when u have so many migration files.
LETTUCE_USE_TEST_DATABASE flag in lettuce cause the engine to use the test DB instead of creating / destroying its DB.

I've overcame that by subclassing the test runner and override setup_databases and teardown_databases to make them do nothing.

That solved the problem for me but I feel it would've been nicer if that settings flag is supported here to keep same behavior as lettuce

@koterpillar
Copy link
Member

Using the development database for tests is bad practice and will not be supported, as the tests must run from a clean state. You can try --keepdb (but see #47).

@ramast
Copy link
Author

ramast commented Sep 20, 2016

I agree that tests must be run from a clean state, in fact in our case each feature file must be run in clean state (with whole DB empty).
Unfortunately we can't do that by dropping/creating DB after each feature because of the time it takes so we revert to resetting all DB tables after each run.

I've solved the problem by inheriting from TestRunner so I am fine if this ticket will be closed, just stating why people might not want to teardown their DB

@koterpillar
Copy link
Member

I know too well that the database creation can take a long time, this is why --keepdb exists.

I'll check that LETTUCE_USE_TEST_DATABASE is mentioned in the porting docs.

@koterpillar koterpillar changed the title What is the equvilent of LETTUCE_USE_TEST_DATABASE The equivalent of LETTUCE_USE_TEST_DATABASE Sep 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants