As guessed, the build slow down was due to dropping the DB before and
after each test. I changed the tests to drop collections instead (see
diff.txt) and the build and tests run in 1 minute. Dropping collections is
effectively same as dropping DB as far as tests are concerned, so I think
we should go with this change to have a speedy build. Could someone apply
this change for me please? Thanks.
-Mete
On 11/16/12 9:51 AM, "Mete Atamel" <[email protected]> wrote:
>Hi Jukka,
>
>Thanks for setting this up. One minor issue though. The MongoMK build used
>to take around 2 minutes (see withoutJukkasChanges.txt) but with your
>changes from yesterday, it takes around 8.5 minutes (see
>withJukkasChanges.txt). Tests take much longer. This is probably due to
>how databases/collections are created/dropped in MongoMK tests, maybe it's
>being done too many times or something similar. I'll take a look.
>
>-Mete
>
>On 11/16/12 9:13 AM, "Jukka Zitting" <[email protected]> wrote:
>
>>Hi,
>>
>>As you may have noticed from the past few commits, I'm working on
>>better integrating the MongoMK to our normal build. The idea is to
>>always build the MongoMK components so we wouldn't need the extra
>>-Pmongomk profile anymore. To do this I'm instructing the test cases
>>that depend on a MongoDB instance being available to be automatically
>>skipped (instead of failing the build) when such an instance is not
>>found.
>>
>>See below for relevant details I added to the README.
>>
>>BR,
>>
>>Jukka Zitting
>>
>>----
>>
>>MongoDB integration
>>-------------------
>>
>>Parts of the Oak build expects a MongoDB instance to be available for
>>testing. By default a MongoDB instance running on localhost is expected,
>>and the relevant tests are simply skipped if such an instance is not
>>found.
>>You can also configure the build to use custom MongoDB settings with the
>>following properties (shown with their default values):
>>
>> -Dmongo.host=127.0.0.1
>> -Dmongo.port=27017
>> -Dmongo.db=MongoMKDB
>> -Dmongo.db2=MongoMKDB2
>>
>>Note that the configured test databases will be *dropped* by the test
>>cases.
>
diff --git
oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/AbstractMongoConnectionTest.java
oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/AbstractMongoConnectionTest.java
index 8ec7979..c9a700d 100644
---
oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/AbstractMongoConnectionTest.java
+++
oak-mongomk/src/test/java/org/apache/jackrabbit/mongomk/AbstractMongoConnectionTest.java
@@ -17,12 +17,15 @@
package org.apache.jackrabbit.mongomk;
import org.apache.jackrabbit.mongomk.impl.MongoConnection;
+import org.apache.jackrabbit.mongomk.impl.MongoNodeStore;
+import org.apache.jackrabbit.mongomk.impl.blob.MongoBlobStore;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.BeforeClass;
import com.mongodb.BasicDBObject;
+import com.mongodb.DB;
/**
* Base class for test cases that need a {@link MongoConnection}
@@ -59,13 +62,20 @@ public class AbstractMongoConnectionTest {
@Before
public void setUpConnection() throws Exception {
- // the database will get automatically recreated
- mongoConnection.getDB().dropDatabase();
+ // Collections will get automatically recreated
+ dropCollections();
}
@After
public void tearDownConnection() throws Exception {
- mongoConnection.getDB().dropDatabase();
+ dropCollections();
}
+ private void dropCollections() {
+ DB db = mongoConnection.getDB();
+ db.getCollection(MongoBlobStore.COLLECTION_BLOBS).drop();
+ db.getCollection(MongoNodeStore.COLLECTION_COMMITS).drop();
+ db.getCollection(MongoNodeStore.COLLECTION_NODES).drop();
+ db.getCollection(MongoNodeStore.COLLECTION_SYNC).drop();
+ }
}