00:00.21 | *** join/#storm shaunm (n=shaunm@c-98-212-133-244.hsd1.il.comcast.net) |
05:06.53 | *** join/#storm seiflotfy1 (n=seif@41.234.7.5) |
08:17.03 | *** join/#storm jukart (i=lovely@81.189.156.94) |
10:51.11 | *** join/#storm WebMaven_ (n=webmaven@c-68-35-136-143.hsd1.nm.comcast.net) |
11:00.42 | *** join/#storm aantn (n=natan@bzq-79-180-17-113.red.bezeqint.net) |
11:00.45 | aantn | hello |
11:01.29 | aantn | I'm seeing some oddities when using multiple storm databases from the same application |
11:01.53 | aantn | are there any known problems with using multiple storm databases? |
11:06.10 | jamesh | aantn: if you describe your problems maybe we can help |
11:12.13 | aantn | jamesh: we have several unit tests that use a storm database |
11:12.43 | aantn | the setUp method creates the database and the tearDown method closes it |
11:13.16 | aantn | what's weird is that some of the tests fail depending on whether other tests were run first or not |
11:13.39 | aantn | each test should be using it's own database, so which other tests are run shouldn't matter |
11:14.02 | jamesh | how are you creating the database? |
11:15.02 | aantn | db = create_database(storm_url) |
11:15.02 | aantn | store = Store(db) |
11:15.37 | jamesh | so, create_database() just creates a Database object (used to represent information needed to connect to said database) |
11:15.47 | aantn | storm_url is "sqlite:/tmp/unittest.sqlite" |
11:16.00 | jamesh | if your test is modifying the underlying database, you should revert those changes in the tearDown() |
11:16.08 | jamesh | if you don't commit, this can be as simple as store.rollback() |
11:16.14 | jamesh | if you do commit, it gets a bit more complicated |
11:16.37 | aantn | jamesh: what's wrong with just calling store.close() and then creating a new database for the next test? |
11:16.50 | aantn | jamesh: the old database file is deleted first |
11:16.55 | jamesh | hmm |
11:17.06 | jamesh | for sqlite, I'd expect deleting the file to be enough |
11:18.08 | aantn | jamesh: the unittest file is on launchpad here http://bazaar.launchpad.net/~zeitgeist/zeitgeist/trunk/annotate/head%3A/test/zeitgeist-engine-engine-test.py |
11:19.27 | jamesh | aantn: that looks like it should be fine |
11:20.02 | aantn | jamesh: yeah, there's something wrong with it though, and as far as I can tell it's not in any of our code |
11:20.09 | jamesh | one option would be to create a temporary directory for each test with mkdtemp() and put the database there |
11:20.33 | jamesh | then use shutil.rmtree() in the tearDown after closing the database |
11:20.38 | aantn | jamesh: I'm trying that now, but it's stills strange |
11:20.45 | aantn | jamesh: I'll let you know if it fixes it |
11:21.03 | jamesh | aantn: what sort of errors are you getting? |
11:22.21 | jamesh | the new "2a" bzr format took one of my repos from 1.1G to 134M |
11:22.26 | jamesh | pretty good |
11:24.28 | aantn | jamesh: one of the unit tests is failing (which is fine) but it stops failing if we remove the other unit tests |
11:24.42 | jamesh | what sort of failure? |
11:25.38 | aantn | jamesh: one of the asserts fails |
11:26.09 | jamesh | I kind of guessed that. I was wondering what the failure was in case it was relevant to the problem |
11:26.31 | aantn | jamesh: I thought that the problem was in our code, and then someone noticed that it stops failing if we don't run any of the other tests first |
11:27.10 | jamesh | well, that usually indicates that your tests aren't properly isolated |
11:27.43 | jamesh | usually a test that updates some global state and does not clean up correctly |
11:28.02 | aantn | jamesh: I know :( |
11:28.33 | aantn | the only global variable is the database |
11:28.34 | jamesh | (changes on the filesystem can be global state, which is why limiting the test to a temporary directory can help) |
11:29.28 | aantn | jamesh: what do you mean? |
11:30.44 | jamesh | aantn: here's an example from one of my projects (not Storm related): http://bazaar.launchpad.net/~jamesh/pygpgme/trunk/annotate/head%3A/gpgme/tests/util.py |
11:31.43 | jamesh | a temporary directory is created for each test, and GPG is configured to look for its config file there. |
11:32.12 | aantn | jamesh: right |
11:32.37 | jamesh | the temporary directory is removed in the test tear down, so there is no way for those changes to impact subsequent tests |
11:33.12 | aantn | jamesh: we're doing the same thing though |
11:33.33 | jamesh | aantn: your code appears to be using the same paths for every test |
11:33.44 | aantn | jamesh: yeah |
11:33.58 | aantn | the file is still deleted every time |
11:34.18 | jamesh | aantn: another issue: don't put asserts in setUp() |
11:34.30 | aantn | jamesh: ok |
11:34.32 | jamesh | pyunit doesn't call tearDown() for tests that fail in setUp() |
11:34.46 | aantn | thanks, I didn't know that |
11:35.06 | jamesh | if any of the failures you saw happened in a setUp(), that could be the cause of your test isolation problem |
11:35.38 | aantn | jamesh: they don't |
11:36.37 | jamesh | aantn: what I was suggesting is that rather than have each test use "sqlite:/tmp/unittest.sqlite", you might have the first use sqlite:/tmp/tmp.XXXX/unittest.sqlite, the second use sqlite:/tmp/tmp.YYYY/unittest.sqlite, etc |
11:37.15 | aantn | jamesh: OK, I'm trying it now |
11:37.32 | jamesh | the path produced by mkdtemp() is going to be new, so it might avoid the problem |
11:43.24 | aantn | jamesh: it's still failing |
12:07.19 | *** join/#storm sidnei (n=sidnei@plone/dreamcatcher) |
12:35.43 | *** join/#storm niemeyer (n=niemeyer@200-103-135-47.ctame705.dsl.brasiltelecom.net.br) |
13:14.52 | *** join/#storm goschtl (n=goschtl@p5B0BFD78.dip.t-dialin.net) |
13:37.21 | *** join/#storm aantn (n=natan@bzq-79-180-17-113.red.bezeqint.net) |
14:08.48 | *** join/#storm shaunm (n=shaunm@proxyserver.wolfram.com) |
14:27.13 | *** join/#storm andrea-bs (n=andrea@ubuntu/member/beeseek.developer.andrea-bs) |
14:53.24 | *** join/#storm rockstar (n=rockstar@starscream.eventuallyanyway.com) |
15:38.50 | *** join/#storm andrea-bs (n=andrea@host127-102-dynamic.30-79-r.retail.telecomitalia.it) |
15:53.27 | *** join/#storm jukart (n=jukart@d91-128-122-26.cust.tele2.at) |
16:52.33 | *** join/#storm kanika_vats (n=kanika_v@59.176.111.34) |
17:32.00 | *** join/#storm sidnei (n=sidnei@plone/dreamcatcher) |
18:40.08 | *** join/#storm vvinet (n=vince@smtpin.revolutionlinux.com) |
19:56.29 | *** join/#storm vvinet (n=vince@smtpin.revolutionlinux.com) |
21:30.56 | *** join/#storm sidnei (n=sidnei@plone/dreamcatcher) |
23:22.35 | *** join/#storm shaunm (n=shaunm@c-98-212-133-244.hsd1.il.comcast.net) |