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 st...@apache.org on 2015/08/27 17:08:44 UTC

svn commit: r1698181 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java

Author: stefanegli
Date: Thu Aug 27 15:08:44 2015
New Revision: 1698181

URL: http://svn.apache.org/r1698181
Log:
OAK-3292 : fix failing test on travis : when on a machine without a mac address, ClusterNodeInfo falls back to using random: prefix and later feels free enough to remove timed out random: entries upon creation of a new instance - this poses a problem for the fiesta test as that one tries to do very precise book-keeping of which instance is active/inactive etc - and when someone underneath removes an inactive instance, that is not noticable by the fiesta test. So the test now stops when it detects it is on such a floating machine

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java?rev=1698181&r1=1698180&r2=1698181&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/document/DocumentDiscoveryLiteServiceTest.java Thu Aug 27 15:08:44 2015
@@ -447,6 +447,16 @@ public class DocumentDiscoveryLiteServic
             }
         }
 
+        /** OAK-3292 : when on a machine without a mac address, the 'random:' prefix is used and instances
+         * that have timed out are automagially removed by ClusterNodeInfo.createInstance - that poses
+         * a problem to testing - so this method exposes whether the instance has such a 'random:' prefix
+         * and thus allows to take appropriate action
+         */
+        public boolean hasRandomMachineId() {
+            //TODO: this might not be the most stable way - but avoids having to change ClusterNodeInfo
+            return ns.getClusterInfo().toString().contains("random:");
+        }
+
     }
 
     interface Expectation {
@@ -925,6 +935,19 @@ public class DocumentDiscoveryLiteServic
                         workingDir = reactivatedWorkingDir;
                         logger.info("Case 0: creating instance");
                         final SimplifiedInstance newInstance = createInstance(workingDir);
+                        if (newInstance.hasRandomMachineId()) {
+                            // OAK-3292 : on an instance which has no networkInterface with a mac address,
+                            // the machineId chosen by ClusterNodeInfo will be 'random:'.. and
+                            // ClusterNodeInfo.createInstance will feel free to remove it when the lease
+                            // has timed out
+                            // that really renders it very difficult to continue testing here,
+                            // since this test is all about keeping track who became inactive etc 
+                            // and ClusterNodeInfo.createInstance removing it 'at a certain point' is difficult
+                            // and not very useful to test..
+                            //
+                            // so: stop testing at this point:
+                            return;
+                        }
                         newInstance.setLeastTimeout(5000);
                         newInstance.startSimulatingWrites(500);
                         logger.info("Case 0: created instance: " + newInstance.ns.getClusterId());
@@ -946,6 +969,19 @@ public class DocumentDiscoveryLiteServic
                     if (instances.size() < MAX_NUM_INSTANCES) {
                         logger.info("Case 1: creating instance");
                         final SimplifiedInstance newInstance = createInstance(workingDir);
+                        if (newInstance.hasRandomMachineId()) {
+                            // OAK-3292 : on an instance which has no networkInterface with a mac address,
+                            // the machineId chosen by ClusterNodeInfo will be 'random:'.. and
+                            // ClusterNodeInfo.createInstance will feel free to remove it when the lease
+                            // has timed out
+                            // that really renders it very difficult to continue testing here,
+                            // since this test is all about keeping track who became inactive etc 
+                            // and ClusterNodeInfo.createInstance removing it 'at a certain point' is difficult
+                            // and not very useful to test..
+                            //
+                            // so: stop testing at this point:
+                            return;
+                        }
                         newInstance.setLeastTimeout(5000);
                         newInstance.startSimulatingWrites(500);
                         logger.info("Case 1: created instance: " + newInstance.ns.getClusterId());