joelittlejohn / embedmongo-maven-plugin

Maven plugin wrapper for the flapdoodle.de embedded MongoDB API
Apache License 2.0
88 stars 51 forks source link

Incomplete db initialization before starting integration tests. #12

Closed dmgcodevil closed 11 years ago

dmgcodevil commented 11 years ago

Hi John. I have some problem with usage embedded mongodb in integration tests for my rest services (i use jersey) . I found what when I use common mongodb (as single process ) then all my tests work correctly, by when i use plugin i get several failed test . I think what no enough time for starting mongodb process and initialization data for test, therefore my rest-services return wrong result. How I can add additional time for starting embedded mongodb before tests run?

dmgcodevil commented 11 years ago

I resolved my problem by turn set "logging" param to "none".

joelittlejohn commented 11 years ago

I've never seen the behaviour you describe. What exactly are you expecting to happen during the waiting period? Could you be more specific about what happens when your app is trying to interact with mongo? Does the app fail to insert documents?

I'm also not sure why setting the logging parameter to 'none' would solve this. Are you sure this is what solved your problem?

dmgcodevil commented 11 years ago

Yes. Set logging to 'none' solved my problem. I guess 'console' or 'file' mode increase mongodb initialization time. For example initialization is not finished yet but the tests was started.

joelittlejohn commented 11 years ago

Could you give me some more insight into exactly what errors you were seeing?

dmgcodevil commented 11 years ago

I am not received any errors, just some tests are failed. Number of failed test periodically changed and this signalized what problem not in tests. Now all works correctly and successfully builds on jenkins.

joelittlejohn commented 11 years ago

Could you help me understand how some tests failed? Where they expecting data to be present that wasn't there? Did they attempt to write data to the database but were unable?

dmgcodevil commented 11 years ago

So, for first I use TestNG framework for my tests. In method which declared with @BeforeMethod annotation i added some code for initialization necessary data for my tests . How I said I created tests for my RESTful services which implemented with Jersey framework. Each test sends request to specify url, retrieves and checks data from response. Look for process steps in general:

  1. Initialize data and store into mongodb.
  2. Sends request and retrieve data through rest.
  3. Checks the data.
joelittlejohn commented 11 years ago

So are you saying that step 1 completes successfully but step 3 indicates that the data being returned is not correct? What exactly is missing? Is any of the data stored during step 1 present during step 3?

I wonder if you could get more information by using a write concern when you initialize/store your data. It might help us understand why this data is not being saved.

joelittlejohn commented 11 years ago

Not enough information here to go on I'm afraid. If others start complaining of similar problems then I'll try to investigate further but so far it appears that this problem is not being seen elsewhere.