You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2013/11/12 15:05:20 UTC

svn commit: r1541068 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/ClusterJoinTest.java

Author: mreutegg
Date: Tue Nov 12 14:05:20 2013
New Revision: 1541068

URL: http://svn.apache.org/r1541068
Log:
OAK-1170: Inconsistent reads with concurrent benchmark tests
- add test, currently ignored.

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/ClusterJoinTest.java   (with props)

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/ClusterJoinTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/ClusterJoinTest.java?rev=1541068&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/ClusterJoinTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/ClusterJoinTest.java Tue Nov 12 14:05:20 2013
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.plugins.mongomk;
+
+import org.apache.jackrabbit.oak.plugins.mongomk.util.MongoConnection;
+import org.json.simple.JSONObject;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test case for OAK-1170.
+ */
+public class ClusterJoinTest extends AbstractMongoConnectionTest {
+
+    @Ignore
+    @Test
+    public void nodeJoins() throws Exception {
+        String rev1, rev2, rev3;
+        // perform manual background ops
+        mk.getNodeStore().setAsyncDelay(0);
+        rev1 = mk.commit("/", "+\"foo\":{}", null, null);
+
+        // start a new MongoMK instance. this instance sees /foo
+        // because it started after the commit on the first MongoMK
+        MongoMK mk2 = new MongoMK.Builder().setAsyncDelay(0)
+                .setMongoDB(new MongoConnection(HOST, PORT, DB).getDB()).open();
+
+        try {
+            // this creates a first commit from the second MongoMK instance
+            // the first MongoMK instance does not see this yet
+            mk2.commit("/", "+\"bar\":{}+\"bla\":{}", null, null);
+            // create a commit on the first MongoMK. this commit revision
+            // is higher than the previous commit on the second MongoMK
+            rev2 = mk.commit("/", "+\"baz\":{}+\"qux\":{}", null, null);
+            // @rev1 must only see /foo
+            assertChildNodeCount("/", rev1, 1);
+            // read children @rev2, should not contain /bar, /bla
+            // because there was no background read yet
+            JSONObject obj = parseJSONObject(mk.getNodes("/", rev2, 0, 0, 10, null));
+            // make changes from second MongoMK visible
+            mk2.runBackgroundOperations();
+            mk.runBackgroundOperations();
+            // check child nodes of previous getNodes() call
+            for (Object key : obj.keySet()) {
+                String name = key.toString();
+                if (name.startsWith(":")) {
+                    continue;
+                }
+                assertNodesExist(rev2, "/" + name);
+            }
+            // must only see /foo, /baz and /qux @rev2
+            assertEquals(3, obj.get(":childNodeCount"));
+            // @rev3 is after background read
+            rev3 = mk.getHeadRevision();
+            // now all nodes must be visible
+            obj = parseJSONObject(mk.getNodes("/", rev3, 0, 0, 10, null));
+            for (Object key : obj.keySet()) {
+                String name = key.toString();
+                if (name.startsWith(":")) {
+                    continue;
+                }
+                assertNodesExist(rev2, "/" + name);
+            }
+            // must only see all nodes @rev3
+            assertEquals(5, obj.get(":childNodeCount"));
+        } finally {
+            mk2.dispose();
+        }
+    }
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/mongomk/ClusterJoinTest.java
------------------------------------------------------------------------------
    svn:eol-style = native