@ClassRule
public static final DropwizardAppRule<MRServiceConfiguration> RULE =
new DropwizardAppRule<MRServiceConfiguration>(MRService.class, ResourceHelpers.resourceFilePath("testing.yml"));
classrule as described in the docs to start up the server before the test is run.
Everything runs great, if I run one test class at a time. If I run all the test classes I have, then the number of open connections to the database keeps increasing, till they are exhausted and tests start failing. Surefire starts and stops the dropwizard service with every new class, but the connections remain.
I believe that the database pool is not being 'managed' in this case and hence the connections stick around. The connections are all released when the surefire process finishes.
Need a clue on how to 'manage' the pool, so that the connections are released at the end of every class.
-Sam--
You received this message because you are subscribed to the Google Groups "dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
@ClassRule
public static final DropwizardAppRule<MRServiceConfiguration> RULE =
new DropwizardAppRule<MRServiceConfiguration>(MRService.class, ResourceHelpers.resourceFilePath("testing.yml"));
Everything runs great, if I run one test class at a time. If I run all the test classes I have, then the number of open connections to the database keeps increasing, till they are exhausted and tests start failing.
Another possibility might be to force Maven surefire (or failsafe - same thing but for the ingrationtest phase), to run each test in a brand new JVM instance. I believe there is a flag in Maven to enable this, and it might be the easiest solution.
I am using dropwizard 0.8.2 and have written many Integration tests that run against a real postgres server.
@ClassRule
public static final DropwizardAppRule<MRServiceConfiguration> RULE =
new DropwizardAppRule<MRServiceConfiguration>(MRService.class, ResourceHelpers.resourceFilePath("testing.yml"));
Is there a way to 'stop' a DW application? In particular, to tell it to release its connection pool?
I tend to define an interface like this:public interface StartStopLifecycle {void start();void shutdown();void shutdownNow();}
Any idea how I invoke its stop() method?
Ok, so I think this is the answer. Put this code in your @AfterClass method on your tests:
| dataSource: | |
| abandonWhenPercentageFull: 9 | |
| removeAbandonedTimeout: 2 | |
| removeAbandoned: true |
Two of my colleagues discovered a permanent fix to this. I've written a gist: https://gist.github.com/yunspace/98602ced01dc7d774378The key is in these 3 settings:
dataSource: abandonWhenPercentageFull: 9 removeAbandonedTimeout: 2 removeAbandoned: true