You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:25:40 UTC

[sling-org-apache-sling-discovery-base] annotated tag org.apache.sling.discovery.base-1.0.2 created (now 362e82b)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git.


      at 362e82b  (tag)
 tagging 0fbea42f40e64ebbf9be99f06c8c5b1cda0b1aeb (commit)
      by Stefan Egli
      on Mon Nov 2 15:58:51 2015 +0000

- Log -----------------------------------------------------------------
org.apache.sling.discovery.base-1.0.2
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 976d955  SLING-5173 : introducing discovery.base which is the sharable parts of discovery.impl for discovery.oak - eg it includes topology connectors and base classes - plus it also includes many it-kind tests of discovery.impl
     new 973f209  SLING-5173 : fixed getSocketConnectionTimeout to a more proper getSocketConnectTimeout
     new e375668  SLING-5173 : rename commons impl packages to base as they are meant for reuse by discovery.impl and discovery.oak - plus avoid using abstract component class with scr annotations - use abstract getters instead - plus some more fine-tuning of log messages - plus make discovery.impl's Config also implement DiscoveryLiteConfig - plus properly handle binds happening before activate in DiscoveryServiceImpl
     new 117b474  SLING-5173 related : minor wording fix
     new c854b64  SLING-5173 : fixed test logic
     new c2d2fec  SLING-5196 : using maven-bundle-plugin 2.5.3 to remain backwards-compatibility
     new 64c9956  SLING-5173 : using discovery.commons 1.0.0
     new a40c75a  [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.0.0
     new 2341062  [maven-release-plugin] prepare for next development iteration
     new 4a397a1  update discovery dependencies to next snapshot versions until release versions available in maven central
     new d54675c  @no-jira : improve test stability
     new 246e567  SLING-5214: include millis in testing log formats
     new 6e20b46  SLING-5200 : add possibility of injecting delays into particular places during simulation, eg in resourceResolver.commit
     new 3e1f21d  SLING-5126 : another test variant added
     new 479ea55  SLING-5126 / SLING-5195 related: fixing a test
     new 65362f2  SLING-5216 / SLING-5195 : more test cases added
     new 568f6d9  SLING-5216 / SLING-5195 : more test cases added
     new f129180  SLING-5224 : increasing wait time from 100ms to 1000ms to avoid test failure on jenkins
     new b9c1fd9  SLING-5224 : more logging for testBoostrap
     new c49512e  SLING-5216 : another VotingHandler test case added - changed analyzeVotings return value for this - but no other changes to the analyzeVotings algo or code
     new 3279a2c  SLING-5241 : increasing wait time for receiving an event from 0.5s to 1.0s
     new 632c604  @no-jira using discovery.commons 1.0.2
     new 983e345  [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.0.2
     new 0fbea42  [maven-release-plugin] copy for tag org.apache.sling.discovery.base-1.0.2

The 24 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-discovery-base] 12/16: SLING-5216 : another VotingHandler test case added - changed analyzeVotings return value for this - but no other changes to the analyzeVotings algo or code

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit c49512ef2904206acda6224fcc60bf2b46e3bb47
Author: Stefan Egli <st...@apache.org>
AuthorDate: Mon Nov 2 14:41:59 2015 +0000

    SLING-5216 : another VotingHandler test case added - changed analyzeVotings return value for this - but no other changes to the analyzeVotings algo or code
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1712016 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/discovery/base/its/setup/mock/MockedResource.java | 3 +++
 .../sling/discovery/base/its/setup/mock/MockedResourceResolver.java    | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java
index a0b5efe..bbd459d 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java
@@ -33,6 +33,7 @@ import javax.jcr.PropertyIterator;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
+import javax.jcr.Value;
 
 import org.apache.sling.api.resource.ModifiableValueMap;
 import org.apache.sling.api.resource.SyntheticResource;
@@ -193,6 +194,8 @@ public class MockedResource extends SyntheticResource {
                             node.setProperty(arg0, c);
                         } else if (arg1 instanceof Long) {
                             node.setProperty(arg0, (Long)arg1);
+                        } else if (arg1 == null) {
+                            node.setProperty(arg0, (Value)null);
                         } else {
                             throw new UnsupportedOperationException();
                         }
diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java
index aa94ff4..e4a49a1 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java
@@ -34,6 +34,7 @@ import javax.jcr.Repository;
 import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
+import javax.jcr.Value;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.sling.api.resource.LoginException;
@@ -287,6 +288,8 @@ public class MockedResourceResolver implements ResourceResolver {
                         child.setProperty(entry.getKey(), (Boolean)entry.getValue());
                     } else if (entry.getValue() instanceof Calendar) {
                         child.setProperty(entry.getKey(), (Calendar)entry.getValue());
+                    } else if (entry.getValue() == null) {
+                        child.setProperty(entry.getKey(), (Value)null);
                     } else {
                         throw new UnsupportedOperationException("Not implemented (entry.getValue(): "+entry.getValue()+")");
                     }

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 05/16: SLING-5200 : add possibility of injecting delays into particular places during simulation, eg in resourceResolver.commit

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 6e20b4666d1aae86b6500f17c8d294297c4a1e3d
Author: Stefan Egli <st...@apache.org>
AuthorDate: Thu Oct 29 13:09:39 2015 +0000

    SLING-5200 : add possibility of injecting delays into particular places during simulation, eg in resourceResolver.commit
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1711246 13f79535-47bb-0310-9956-ffa450edef68
---
 .../discovery/base/its/setup/VirtualInstance.java  | 16 +++-
 .../base/its/setup/VirtualInstanceBuilder.java     |  7 ++
 .../base/its/setup/mock/ArtificialDelay.java       | 92 ++++++++++++++++++++++
 .../setup/mock/DummyResourceResolverFactory.java   | 73 +++++++++++++++++
 .../discovery/base/its/setup/mock/MockFactory.java | 34 +-------
 .../base/its/setup/mock/MockedResource.java        |  2 +-
 .../its/setup/mock/MockedResourceResolver.java     | 19 ++++-
 7 files changed, 206 insertions(+), 37 deletions(-)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstance.java b/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstance.java
index 9e10871..2a12483 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstance.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstance.java
@@ -30,23 +30,22 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
-import javax.jcr.Session;
 import javax.servlet.Servlet;
 
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.api.resource.ResourceResolverFactory;
-import org.apache.sling.commons.testing.jcr.RepositoryProvider;
 import org.apache.sling.discovery.InstanceDescription;
 import org.apache.sling.discovery.PropertyProvider;
 import org.apache.sling.discovery.TopologyEventListener;
 import org.apache.sling.discovery.base.commons.BaseDiscoveryService;
 import org.apache.sling.discovery.base.commons.ClusterViewService;
-import org.apache.sling.discovery.base.commons.ViewChecker;
 import org.apache.sling.discovery.base.commons.UndefinedClusterViewException;
+import org.apache.sling.discovery.base.commons.ViewChecker;
 import org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistry;
 import org.apache.sling.discovery.base.connectors.ping.ConnectorRegistry;
 import org.apache.sling.discovery.base.connectors.ping.TopologyConnectorClientInformation;
 import org.apache.sling.discovery.base.connectors.ping.TopologyConnectorServlet;
+import org.apache.sling.discovery.base.its.setup.mock.ArtificialDelay;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.server.nio.SelectChannelConnector;
@@ -100,6 +99,8 @@ public class VirtualInstance {
 
     private final VirtualInstanceBuilder builder;
 
+    private final ArtificialDelay delay;
+
     private class ViewCheckerRunner implements Runnable {
 
     	private final int intervalInSeconds;
@@ -143,6 +144,7 @@ public class VirtualInstance {
         this.builder = builder;
     	this.slingId = builder.getSlingId();
         this.debugName = builder.getDebugName();
+        this.delay = builder.getDelay();
         logger.info("<init>: starting slingId="+slingId+", debugName="+debugName);
 
         osgiMock = new OSGiMock();
@@ -180,6 +182,10 @@ public class VirtualInstance {
         osgiMock.activateAll();
     }
     
+    public void setDelay(String operationDescriptor, long delayMillis) {
+        delay.setDelay(operationDescriptor, delayMillis);
+    }
+    
     @Override
     public String toString() {
         return "a [Test]Instance[slingId="+slingId+", debugName="+debugName+"]";
@@ -371,4 +377,8 @@ public class VirtualInstance {
         return builder;
     }
 
+    public String getDebugName() {
+        return debugName;
+    }
+
 }
diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstanceBuilder.java b/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstanceBuilder.java
index fb287d6..c3c55f7 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstanceBuilder.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/VirtualInstanceBuilder.java
@@ -32,6 +32,7 @@ import org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegis
 import org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistryImpl;
 import org.apache.sling.discovery.base.connectors.ping.ConnectorRegistry;
 import org.apache.sling.discovery.base.connectors.ping.ConnectorRegistryImpl;
+import org.apache.sling.discovery.base.its.setup.mock.ArtificialDelay;
 import org.apache.sling.discovery.base.its.setup.mock.FailingScheduler;
 import org.apache.sling.discovery.commons.providers.spi.base.DummySlingSettingsService;
 import org.apache.sling.settings.SlingSettingsService;
@@ -74,10 +75,15 @@ public abstract class VirtualInstanceBuilder {
     protected boolean ownRepository;
     private int minEventDelay = 1;
     protected VirtualInstanceBuilder hookedToBuilder;
+    protected final ArtificialDelay delay = new ArtificialDelay();
 
     public VirtualInstanceBuilder() {
     }
     
+    public ArtificialDelay getDelay() {
+        return delay;
+    }
+    
     public VirtualInstanceBuilder newRepository(String path, boolean resetRepo) throws Exception {
         createNewRepository();
         ownRepository = true;
@@ -170,6 +176,7 @@ public abstract class VirtualInstanceBuilder {
 
     public VirtualInstanceBuilder setDebugName(String debugName) {
         this.debugName = debugName;
+        delay.setDebugName(debugName);
         return this;
     }
 
diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/ArtificialDelay.java b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/ArtificialDelay.java
new file mode 100644
index 0000000..e4ab7b9
--- /dev/null
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/ArtificialDelay.java
@@ -0,0 +1,92 @@
+/*
+ * 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.sling.discovery.base.its.setup.mock;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * General purpose delay object that can be passed around and 
+ * plugged in various places identified by an 'operationDescriptor'
+ * which can be used to inject delays at runtime
+ * @author egli
+ *
+ */
+public class ArtificialDelay {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private final Map<String,Long> operationsMap = new ConcurrentHashMap<String, Long>();
+
+    private String debugName;
+    
+    private final Object syncObj = new Object();
+    
+    public void setDebugName(String debugName) {
+        this.debugName = debugName;
+    }
+
+    public void setDelay(String operationDescriptor, long delayMillis) {
+        operationsMap.put(operationDescriptor, delayMillis);
+        synchronized(syncObj) {
+            syncObj.notifyAll();
+        }
+    }
+    
+    public void delay(String operationDescriptor) {
+        Long delayMillis = operationsMap.get(operationDescriptor);
+        if (delayMillis == null) {
+            return;
+        }
+        if (delayMillis <= 0) {
+            return;
+        }
+        logger.info("delay: delaying ["+debugName+"] '"+operationDescriptor+"' for "+delayMillis+"ms...");
+        final long start = System.currentTimeMillis();
+        synchronized(syncObj) {
+            while(true) {
+                delayMillis = operationsMap.get(operationDescriptor);
+                if (delayMillis == null) {
+                    logger.info("delay: delaying ["+debugName+"]'"+operationDescriptor+"' for "+delayMillis+"ms done.");
+                    return;
+                }
+                if (delayMillis <= 0) {
+                    logger.info("delay: delaying ["+debugName+"]'"+operationDescriptor+"' for "+delayMillis+"ms done.");
+                    return;
+                }
+                final long end = start + delayMillis;
+                long remaining = end - System.currentTimeMillis();
+                if (remaining <= 0) {
+                    break;
+                }
+                try {
+                    logger.info("delay: delaying ["+debugName+"] '"+operationDescriptor+"' now for "+remaining+"ms...");
+                    syncObj.wait(remaining);
+                } catch (InterruptedException e) {
+                    logger.error("delay: got interrupted: "+e, e);
+                }
+            }
+        }
+        logger.info("delay: delaying ["+debugName+"]'"+operationDescriptor+"' for "+delayMillis+"ms done.");
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyResourceResolverFactory.java b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyResourceResolverFactory.java
new file mode 100644
index 0000000..ab1f2a1
--- /dev/null
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/DummyResourceResolverFactory.java
@@ -0,0 +1,73 @@
+/*
+ * 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.sling.discovery.base.its.setup.mock;
+
+import java.util.Map;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.jcr.api.SlingRepository;
+
+/** Factored out of MockFactory: simple implementation
+ * of a ResourceResolverFactory that uses MockedResourceResolver's
+ * mechanism of auto-creating a repository via
+ * RepositoryProvider.instance().getRepository()
+ */
+public class DummyResourceResolverFactory implements ResourceResolverFactory {
+
+    private SlingRepository repository;
+    private ArtificialDelay delay;
+
+    public DummyResourceResolverFactory() {
+        
+    }
+    
+    public void setSlingRepository(SlingRepository repository) {
+        this.repository = repository;
+    }
+    
+    public void setArtificialDelay(ArtificialDelay delay) {
+        this.delay = delay;
+    }
+    
+    @Override
+    public ResourceResolver getResourceResolver(Map<String, Object> authenticationInfo) throws LoginException {
+        throw new IllegalStateException("not yet implemented");
+    }
+
+    @Override
+    public ResourceResolver getAdministrativeResourceResolver(Map<String, Object> authenticationInfo) throws LoginException {
+        try {
+            MockedResourceResolver mockedResourceResolver = 
+                    new MockedResourceResolver(repository, delay);
+            repository = (SlingRepository) mockedResourceResolver.getRepository();
+            return mockedResourceResolver;
+        } catch (RepositoryException e) {
+            throw new LoginException(e);
+        }
+    }
+
+    public SlingRepository getSlingRepository() {
+        return repository;
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockFactory.java b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockFactory.java
index f4e2404..c7fb766 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockFactory.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockFactory.java
@@ -24,11 +24,8 @@ import java.util.Properties;
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.jcr.api.SlingRepository;
 import org.apache.sling.settings.SlingSettingsService;
-import org.hamcrest.Description;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
-import org.jmock.api.Action;
-import org.jmock.api.Invocation;
 import org.jmock.integration.junit4.JUnit4Mockery;
 import org.jmock.lib.action.ReturnValueAction;
 import org.jmock.lib.action.VoidAction;
@@ -41,37 +38,14 @@ public class MockFactory {
 
     public static ResourceResolverFactory mockResourceResolverFactory()
             throws Exception {
-    	return mockResourceResolverFactory(null);
+        return mockResourceResolverFactory(null);
     }
 
     public static ResourceResolverFactory mockResourceResolverFactory(final SlingRepository repositoryOrNull)
             throws Exception {
-        Mockery context = new JUnit4Mockery();
-
-        final ResourceResolverFactory resourceResolverFactory = context
-                .mock(ResourceResolverFactory.class);
-        // final ResourceResolver resourceResolver = new MockResourceResolver();
-        // final ResourceResolver resourceResolver = new
-        // MockedResourceResolver();
-
-        context.checking(new Expectations() {
-            {
-                allowing(resourceResolverFactory)
-                        .getAdministrativeResourceResolver(null);
-                will(new Action() {
-
-                    public Object invoke(Invocation invocation)
-                            throws Throwable {
-                    	return new MockedResourceResolver(repositoryOrNull);
-                    }
-
-                    public void describeTo(Description arg0) {
-                        arg0.appendText("whateva - im going to create a new mockedresourceresolver");
-                    }
-                });
-            }
-        });
-        return resourceResolverFactory;
+        DummyResourceResolverFactory factory = new DummyResourceResolverFactory();
+        factory.setSlingRepository(repositoryOrNull);
+        return factory;
     }
 
     public static SlingSettingsService mockSlingSettingsService(
diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java
index 040842b..b71cc23 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java
@@ -123,7 +123,7 @@ public class MockedResource extends SyntheticResource {
                 ValueMap valueMap = new ValueMapDecorator(map);
                 return (AdapterType) valueMap;
             } catch (Exception e) {
-                e.printStackTrace();
+                logger.error("adaptTo failed with : "+e, e);
                 return null;
             }
         } else if (type.equals(ModifiableValueMap.class)) {
diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java
index 9d9fd13..aa94ff4 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResourceResolver.java
@@ -43,21 +43,31 @@ import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.commons.testing.jcr.RepositoryProvider;
 import org.apache.sling.commons.testing.jcr.RepositoryUtil;
 import org.apache.sling.jcr.api.SlingRepository;
+import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class MockedResourceResolver implements ResourceResolver {
 
-	private final SlingRepository repository;
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    private final SlingRepository repository;
 
 	private Session session;
 
     private List<MockedResource> resources = new LinkedList<MockedResource>();
 
+    private final ArtificialDelay delay;
+
     public MockedResourceResolver() throws RepositoryException {
-    	this(null);
+    	this(null, null);
     }
 
     public MockedResourceResolver(SlingRepository repositoryOrNull) throws RepositoryException {
+        this(repositoryOrNull, null);
+    }
+    
+    public MockedResourceResolver(SlingRepository repositoryOrNull, ArtificialDelay delay) throws RepositoryException {
+        this.delay = delay;
     	if (repositoryOrNull==null) {
     		this.repository = RepositoryProvider.instance().getRepository();
     		Session adminSession = null;
@@ -86,7 +96,7 @@ public class MockedResourceResolver implements ResourceResolver {
         }
     }
 
-    private Repository getRepository() {
+    public Repository getRepository() {
     	return repository;
     }
 
@@ -301,6 +311,9 @@ public class MockedResourceResolver implements ResourceResolver {
     }
 
     public void commit() throws PersistenceException {
+        if (delay!=null) {
+            delay.delay("pre.commit");
+        }
         try {
             this.session.save();
         } catch (final RepositoryException re) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 09/16: SLING-5216 / SLING-5195 : more test cases added

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 568f6d9f171081a42366201ef6332efd322019ff
Author: Stefan Egli <st...@apache.org>
AuthorDate: Thu Oct 29 19:06:49 2015 +0000

    SLING-5216 / SLING-5195 : more test cases added
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1711334 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/discovery/base/its/AbstractDiscoveryServiceTest.java | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/AbstractDiscoveryServiceTest.java b/src/test/java/org/apache/sling/discovery/base/its/AbstractDiscoveryServiceTest.java
index c2142f1..e68ce79 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/AbstractDiscoveryServiceTest.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/AbstractDiscoveryServiceTest.java
@@ -43,12 +43,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
-    this is to get more assurance that things work:
-        
-        * have an agent that periodically scans getTopology and makes assumptions
-        * have a listener that makes assumptions too
-        * these two might be able to communicate with each other to make even more assumptions..
-        * combine the above with coming and going instances, with slow ones etc etc
+ * This base tests for discovery.impl and .oak simulates instances
+ * that are coming and going, have a slow repository (and other bad-weather
+ * scenarios), and make assumptions on both getTopology() to always be correct
+ * as well as handleTopologyEvent to be properly delivered to.
  */
 public abstract class AbstractDiscoveryServiceTest {
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 01/16: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 2341062f4ad73c7daad27a73d5b5b916ab222739
Author: Stefan Egli <st...@apache.org>
AuthorDate: Mon Oct 26 16:18:42 2015 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1710648 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 378bab9..a96ff51 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,15 +29,15 @@
 
     <artifactId>org.apache.sling.discovery.base</artifactId>
     <packaging>bundle</packaging>
-    <version>1.0.0</version>
+    <version>1.0.1-SNAPSHOT</version>
 
     <name>Apache Sling Discovery Base</name>
     <description>Contains Connector and Properties support that some implementations might choose to build upon</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.0.0</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.discovery.base-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 11/16: SLING-5224 : more logging for testBoostrap

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit b9c1fd9003447eac88e4dc7adc17f59d696c2d04
Author: Stefan Egli <st...@apache.org>
AuthorDate: Mon Nov 2 10:22:14 2015 +0000

    SLING-5224 : more logging for testBoostrap
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1711931 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java b/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
index 619e76a..b8bb14b 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
@@ -276,7 +276,9 @@ public abstract class AbstractSingleInstanceTest {
         Thread.sleep(1000);
         instance.heartbeatsAndCheckView();
         Thread.sleep(1000);
+        logger.info("testBoostrap: dumping repo...");
         instance.dumpRepo();
+        logger.info("testBoostrap: dumping listener...");
         ada.dump();
         assertEquals(0, ada.getUnexpectedCount());
         assertEquals(1, ada.getEvents().size());

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 02/16: update discovery dependencies to next snapshot versions until release versions available in maven central

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 4a397a1e6e4f65f054f5b6a158267d9bbd989fa4
Author: Stefan Seifert <ss...@apache.org>
AuthorDate: Mon Oct 26 22:05:15 2015 +0000

    update discovery dependencies to next snapshot versions until release versions available in maven central
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1710708 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index a96ff51..56af493 100644
--- a/pom.xml
+++ b/pom.xml
@@ -151,7 +151,7 @@
  		<dependency>
 			<groupId>org.apache.sling</groupId>
 			<artifactId>org.apache.sling.discovery.commons</artifactId>
-			<version>1.0.0</version>
+			<version>1.0.1-SNAPSHOT</version>
   		</dependency>
         <!-- besides including discovery.commons' normal jar above, 
               for testing a few test helper classes are also reused.
@@ -159,7 +159,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.discovery.commons</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
             <scope>test</scope>
             <type>test-jar</type>
         </dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 15/16: [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.0.2

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 983e34518249d66b602ce179192fe586645badbe
Author: Stefan Egli <st...@apache.org>
AuthorDate: Mon Nov 2 15:58:37 2015 +0000

    [maven-release-plugin] prepare release org.apache.sling.discovery.base-1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1712056 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 4b802ab..eb8daa6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,15 +29,15 @@
 
     <artifactId>org.apache.sling.discovery.base</artifactId>
     <packaging>bundle</packaging>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.2</version>
 
     <name>Apache Sling Discovery Base</name>
     <description>Contains Connector and Properties support that some implementations might choose to build upon</description>
 
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base</connection>
-        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/discovery/base</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.0.2</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.0.2</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.discovery.base-1.0.2</url>
     </scm>
 
     <build>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 13/16: SLING-5241 : increasing wait time for receiving an event from 0.5s to 1.0s

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 3279a2cd61733c59dedf78b8589a826770a816da
Author: Stefan Egli <st...@apache.org>
AuthorDate: Mon Nov 2 14:46:39 2015 +0000

    SLING-5241 : increasing wait time for receiving an event from 0.5s to 1.0s
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1712022 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java b/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
index b8bb14b..d0b93e2 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
@@ -202,7 +202,7 @@ public abstract class AbstractSingleInstanceTest {
         assertingTopologyEventListener.addExpected(Type.TOPOLOGY_INIT);
         logger.info("testTopologyEventListeners: binding the event listener");
         instance.bindTopologyEventListener(assertingTopologyEventListener);
-        Thread.sleep(500); // SLING-4755: async event sending requires some minimal wait time nowadays
+        Thread.sleep(1000); // SLING-4755: async event sending requires some minimal wait time nowadays
         assertEquals(0, assertingTopologyEventListener.getRemainingExpectedCount());
 
         final String propertyName = UUID.randomUUID().toString();

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 10/16: SLING-5224 : increasing wait time from 100ms to 1000ms to avoid test failure on jenkins

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit f129180d5c9269cc270cc3927df5f2fa8c0126e7
Author: Stefan Egli <st...@apache.org>
AuthorDate: Mon Nov 2 09:05:28 2015 +0000

    SLING-5224 : increasing wait time from 100ms to 1000ms to avoid test failure on jenkins
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1711913 13f79535-47bb-0310-9956-ffa450edef68
---
 .../apache/sling/discovery/base/its/AbstractSingleInstanceTest.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java b/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
index 324772a..619e76a 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
@@ -137,8 +137,8 @@ public abstract class AbstractSingleInstanceTest {
         instance.bindPropertyProvider(pp, propertyName);
 
         instance.heartbeatsAndCheckView();
-        // wait 100ms for the vote to happen
-        Thread.sleep(100);
+        // wait 1000ms for the vote to happen
+        Thread.sleep(1000);
         assertEquals(propertyValue,
                 instance.getClusterViewService().getLocalClusterView()
                         .getInstances().get(0).getProperty(propertyName));

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 06/16: SLING-5126 : another test variant added

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 3e1f21d277efe890627517fecd80a61af8a572a1
Author: Stefan Egli <st...@apache.org>
AuthorDate: Thu Oct 29 14:17:14 2015 +0000

    SLING-5126 : another test variant added
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1711272 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/discovery/base/its/AbstractClusterLoadTest.java     | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterLoadTest.java b/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterLoadTest.java
index 1e934fd..7667335 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterLoadTest.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterLoadTest.java
@@ -136,7 +136,12 @@ public abstract class AbstractClusterLoadTest {
 
     @Test
     public void testSevenInstances() throws Throwable {
-    	doTest(7, 10);
+        doTest(7, 10);
+    }
+    
+    @Test
+    public void testEightInstances() throws Throwable {
+        doTest(8, 50);
     }
 
     private void doTest(final int size, final int loopCnt) throws Throwable {
@@ -167,7 +172,7 @@ public abstract class AbstractClusterLoadTest {
 		}
         VirtualInstanceBuilder builder = newBuilder()
                 .newRepository("/var/discovery/impl/ClusterLoadTest/doTest-"+size+"-"+loopCnt+"/", true)
-                .setDebugName("firstInstance")
+                .setDebugName("firstInstance-"+size+"_"+loopCnt)
                 .setConnectorPingTimeout(3)
                 .setConnectorPingInterval(20)
                 .setMinEventDelay(0);
@@ -177,7 +182,7 @@ public abstract class AbstractClusterLoadTest {
 		for(int i=1; i<size; i++) {
 		    VirtualInstanceBuilder builder2 = newBuilder()
 		            .useRepositoryOf(builder)
-		            .setDebugName("subsequentInstance-"+i)
+		            .setDebugName("subsequentInstance-"+i+"-"+size+"_"+loopCnt)
 	                .setConnectorPingTimeout(3)
 	                .setMinEventDelay(0)
 	                .setConnectorPingInterval(20);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 08/16: SLING-5216 / SLING-5195 : more test cases added

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 65362f2aeb7305a363db7afdb6b7454a2cd04420
Author: Stefan Egli <st...@apache.org>
AuthorDate: Thu Oct 29 19:03:04 2015 +0000

    SLING-5216 / SLING-5195 : more test cases added
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1711331 13f79535-47bb-0310-9956-ffa450edef68
---
 .../base/its/AbstractDiscoveryServiceTest.java     | 375 +++++++++++++++++++++
 .../base/its/setup/mock/MockedResource.java        |   2 +-
 2 files changed, 376 insertions(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/AbstractDiscoveryServiceTest.java b/src/test/java/org/apache/sling/discovery/base/its/AbstractDiscoveryServiceTest.java
new file mode 100644
index 0000000..c2142f1
--- /dev/null
+++ b/src/test/java/org/apache/sling/discovery/base/its/AbstractDiscoveryServiceTest.java
@@ -0,0 +1,375 @@
+/*
+ * 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.sling.discovery.base.its;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Random;
+
+import org.apache.sling.discovery.InstanceDescription;
+import org.apache.sling.discovery.TopologyEvent;
+import org.apache.sling.discovery.TopologyEvent.Type;
+import org.apache.sling.discovery.TopologyEventListener;
+import org.apache.sling.discovery.TopologyView;
+import org.apache.sling.discovery.base.its.setup.VirtualInstance;
+import org.apache.sling.discovery.base.its.setup.VirtualInstanceBuilder;
+import org.apache.sling.testing.tools.retry.RetryLoop;
+import org.apache.sling.testing.tools.retry.RetryLoop.Condition;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+    this is to get more assurance that things work:
+        
+        * have an agent that periodically scans getTopology and makes assumptions
+        * have a listener that makes assumptions too
+        * these two might be able to communicate with each other to make even more assumptions..
+        * combine the above with coming and going instances, with slow ones etc etc
+ */
+public abstract class AbstractDiscoveryServiceTest {
+
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    class Tester implements TopologyEventListener, Runnable {
+        
+        private final VirtualInstance instance;
+        private final Thread thread;
+
+        private TopologyEvent previousEvent;
+        
+        private List<String> failures = new LinkedList<String>();
+        
+        private volatile boolean stopped = false;
+        private final long pollingSleep;
+        
+        private boolean running = true;
+        
+        Tester(VirtualInstance instance, long pollingSleep) throws Throwable {
+            this.instance = instance;
+            this.pollingSleep = pollingSleep;
+            instance.bindTopologyEventListener(this);
+            thread = new Thread(this);
+            thread.setName("Tester-"+instance.getDebugName()+"-thread");
+            thread.setDaemon(true);
+            thread.start();
+        }
+
+        private synchronized void assertNoFailures() {
+            if (failures.size()==0) {
+                return;
+            }
+            fail("got "+failures.size()+" failures, the first one thereof: "+failures.get(0));
+        }
+        
+        private synchronized boolean hasFailures() {
+            return failures.size()!=0;
+        }
+        
+        private synchronized void asyncFail(String msg) {
+            failures.add(msg);
+        }
+
+        @Override
+        public void run() {
+            while(!stopped) {
+                try{
+                    TopologyView topo = instance.getDiscoveryService().getTopology();
+                    Thread.sleep(pollingSleep);
+                } catch(Throwable th) {
+                    asyncFail("Got a Throwable: "+th);
+                    return;
+                }
+            }
+        }
+
+        @Override
+        public void handleTopologyEvent(TopologyEvent event) {
+            if (hasFailures()) {
+                // then stop
+                return;
+            }
+            logger.info("handleTopologyEvent["+instance.getDebugName()+"]: "+event);
+            if (previousEvent == null) {
+                // then we're expecting a TOPOLOGY_INIT
+                if (event.getType()!=Type.TOPOLOGY_INIT) {
+                    asyncFail("expected an INIT as the first, but got: "+event);
+                    return;
+                }
+            } else if (previousEvent.getType() == Type.TOPOLOGY_CHANGED
+                    || previousEvent.getType() == Type.PROPERTIES_CHANGED) {
+                // then expecting a TOPOLOGY_CHANGING or PROPERTIES_CHANGED
+                if (event.getType()==Type.TOPOLOGY_CHANGING) {
+                    // perfect
+                } else if (event.getType()==Type.PROPERTIES_CHANGED) {
+                    // perfect
+                } else {
+                    asyncFail("expected a CHANGING or PROPERTIES_CHANGED, but got: "+event);
+                    return;
+                }
+            } else if (previousEvent.getType() == Type.TOPOLOGY_CHANGING) {
+                // then expecting a TOPOLOGY_CHANGED
+                if (event.getType()!=Type.TOPOLOGY_CHANGED) {
+                    asyncFail("expected a CHANGED after CHANGING, but got: "+event);
+                    return;
+                }
+            }
+            previousEvent = event;
+        }
+
+        public void shutdown() throws Exception {
+            stopped = true;
+            instance.stop();
+            running = false;
+        }
+
+        public void restart() throws Exception {
+            instance.startViewChecker((int) instance.getConfig().getConnectorPingInterval());
+            running = true;
+        }
+
+        public void pause() throws Throwable {
+            instance.stopViewChecker();
+            running = false;
+        }
+        
+    }
+    
+    List<Tester> testers = new LinkedList<Tester>();
+    
+    public abstract VirtualInstanceBuilder newBuilder();
+    
+    @Before
+    public void setUp() throws Exception {
+        testers.clear();
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+        for (Tester tester : testers) {
+            tester.shutdown();
+        }
+    }
+    
+    Tester newInstance(String debugName, int interval, int timeout, long pollingSleep, VirtualInstance base) throws Throwable {
+        VirtualInstanceBuilder builder = newBuilder();
+        builder.setDebugName(debugName);
+        if (base == null) {
+            builder.newRepository("/var/discovery/testing/", true);
+        } else {
+            builder.useRepositoryOf(base);
+        }
+        builder.setConnectorPingInterval(interval);
+        builder.setConnectorPingTimeout(timeout);
+        builder.setMinEventDelay(1);
+        VirtualInstance instance = builder.build();
+        Tester t = new Tester(instance, pollingSleep);
+        testers.add(t);
+        instance.startViewChecker(interval);
+        return t;
+    }
+    
+    private void assertStableTopology(Tester... instances) {
+        for (Tester tester : instances) {
+            logger.info("asserting tester: "+tester.instance.getDebugName());
+            TopologyEvent lastEvent = tester.previousEvent;
+            Type type = lastEvent.getType();
+            if (type == Type.TOPOLOGY_CHANGED || type == Type.TOPOLOGY_INIT) {
+                // fine
+            } else {
+                fail("wrong type, expected CHANGED or INIT, got: "+type);
+            }
+            assertNotNull(lastEvent.getNewView());
+            assertEquals(instances.length, lastEvent.getNewView().getInstances().size());
+            TopologyView t = tester.instance.getDiscoveryService().getTopology();
+            assertTrue(t.isCurrent());
+            assertEquals(instances.length, t.getInstances().size());
+        }
+    }
+
+    private boolean isStableTopology(Tester... instances) {
+        for (Tester tester : instances) {
+            TopologyEvent lastEvent = tester.previousEvent;
+            if (lastEvent == null) {
+                return false;
+            }
+            Type type = lastEvent.getType();
+            if (type == Type.TOPOLOGY_CHANGED || type == Type.TOPOLOGY_INIT) {
+                // fine
+            } else {
+                return false;
+            }
+            TopologyView newView = lastEvent.getNewView();
+            if (newView == null) {
+                return false;
+            }
+            if (instances.length != newView.getInstances().size()) {
+                return false;
+            }
+            TopologyView t = tester.instance.getDiscoveryService().getTopology();
+            if (!t.isCurrent()) {
+                return false;
+            }
+            if (instances.length != t.getInstances().size()) {
+                return false;
+            }
+            for (Tester t2 : instances) {
+                boolean foundMatch = false;
+                for (InstanceDescription id : t.getInstances()) {
+                    if (t2.instance.getSlingId().equals(id.getSlingId())) {
+                        foundMatch = true;
+                        break;
+                    }
+                }
+                if (!foundMatch) {
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+    @Test
+    public void testSingleInstance() throws Throwable {
+        Tester single = newInstance("single", 1, 4, 50, null);
+        single.instance.dumpRepo();
+        startRetryLoop(testers, 10);
+        single.assertNoFailures();
+        assertStableTopology(single);
+    }
+    
+    @Test
+    public void testTwoInstances() throws Throwable {
+        Tester i1 = newInstance("i1", 1, 4, 100, null);
+        Tester i2 = newInstance("i2", 1, 4, 100, i1.instance);
+        startRetryLoop(testers, 10);
+        i1.instance.dumpRepo();
+        i1.assertNoFailures();
+        i2.assertNoFailures();
+        assertStableTopology(i1, i2);
+    }
+
+    @Test
+    public void testTenInstances() throws Throwable {
+        Tester i1 = newInstance("i1", 1, 6, 250, null);
+        for(int i=2; i<=10; i++) {
+            Tester in = newInstance("i"+i, 1, 6, 250, i1.instance);
+        }
+        startRetryLoop(testers, 10);
+        i1.instance.dumpRepo();
+        i1.assertNoFailures();
+        assertStableTopology(testers.toArray(new Tester[0]));
+    }
+
+    @Test
+    public void testTwentyInstances() throws Throwable {
+        Tester i1 = newInstance("i1", 1, 20, 1000, null);
+        for(int i=2; i<=20; i++) {
+            Tester in = newInstance("i"+i, 1, 20, 1000, i1.instance);
+        }
+        startRetryLoop(testers, 40);
+        i1.instance.dumpRepo();
+        i1.assertNoFailures();
+        assertStableTopology(testers.toArray(new Tester[0]));
+    }
+
+    @Test
+    public void testThirtyInstances() throws Throwable {
+        Tester i1 = newInstance("i1", 4, 60, 1000, null);
+        for(int i=2; i<=30; i++) {
+            Tester in = newInstance("i"+i, 4, 60, 2000, i1.instance);
+            Thread.sleep(1000);
+        }
+        startRetryLoop(testers, 100);
+        i1.instance.dumpRepo();
+        i1.assertNoFailures();
+        assertStableTopology(testers.toArray(new Tester[0]));
+    }
+    
+    private void startRetryLoop(final List<Tester> testers, int retryTimeoutSeconds) {
+        startRetryLoop(retryTimeoutSeconds, testers.toArray(new Tester[0]));
+    }
+    
+    private void startRetryLoop(int retryTimeoutSeconds, final Tester... testers) {
+        new RetryLoop(new Condition() {
+
+            @Override
+            public String getDescription() {
+                // TODO Auto-generated method stub
+                return null;
+            }
+
+            @Override
+            public boolean isTrue() throws Exception {
+                if (!isStableTopology(testers)) {
+                    return false;
+                }
+                for (Tester tester : testers) {
+                    tester.assertNoFailures();
+                }
+                logger.info("retryLoop: declaring stable topology with "+testers.length);
+                return true;
+            }
+            
+        }, retryTimeoutSeconds /*seconds*/, 1000/*millis*/);        
+    }
+    
+    @Test
+    public void testStartStopFiesta() throws Throwable {
+        final Tester[] instances = new Tester[8];
+        instances[0] = newInstance("i1", 1, 10, 1000, null);
+        for(int i=2; i<=8; i++) {
+            instances[i-1] = newInstance("i"+i, 1, 10, 1000, instances[0].instance);
+            Thread.sleep(600);
+        }
+        startRetryLoop(15, instances);
+        for (Tester tester : instances) {
+            tester.assertNoFailures();
+        }
+        assertStableTopology(testers.toArray(new Tester[0]));
+        Random r = new Random(123432141);
+        for(int i=0; i<10; i++) {
+            logger.info("testStartStopFiesta : loop "+i);
+            final List<Tester> alive = new LinkedList<Tester>();
+            int keepAlive = r.nextInt(instances.length);
+            for(int j=0; j<instances.length; j++) {
+                if (j == keepAlive || r.nextBoolean()) {
+                    instances[j].restart();
+                    alive.add(instances[j]);
+                } else {
+                    instances[j].pause();
+                }
+            }
+            logger.info("testStartStopFiesta : loop "+i+", alive-cnt: "+alive.size());
+            startRetryLoop(alive, 30);
+            for (Tester tester : instances) {
+                tester.assertNoFailures();
+            }
+            
+            assertStableTopology(alive.toArray(new Tester[0]));
+        }
+    }
+}
diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java
index b71cc23..a0b5efe 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/mock/MockedResource.java
@@ -123,7 +123,7 @@ public class MockedResource extends SyntheticResource {
                 ValueMap valueMap = new ValueMapDecorator(map);
                 return (AdapterType) valueMap;
             } catch (Exception e) {
-                logger.error("adaptTo failed with : "+e, e);
+                logger.error("adaptTo failed with : "+e);
                 return null;
             }
         } else if (type.equals(ModifiableValueMap.class)) {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 04/16: SLING-5214: include millis in testing log formats

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 246e5673565eb70b8ebc024d8e98eded3778a0d9
Author: Stefan Egli <st...@apache.org>
AuthorDate: Thu Oct 29 12:34:37 2015 +0000

    SLING-5214: include millis in testing log formats
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1711236 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/discovery/base/its/setup/WithholdingAppender.java  | 2 +-
 src/test/resources/log4j.properties                                     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/setup/WithholdingAppender.java b/src/test/java/org/apache/sling/discovery/base/its/setup/WithholdingAppender.java
index a294be6..c70ff50 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/setup/WithholdingAppender.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/setup/WithholdingAppender.java
@@ -44,7 +44,7 @@ public class WithholdingAppender extends WriterAppender {
     public static WithholdingAppender install() {
         LogManager.getRootLogger().removeAllAppenders();
         final WithholdingAppender withholdingAppender = new WithholdingAppender(
-                new PatternLayout("%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m\n"));
+                new PatternLayout("%d{dd.MM.yyyy HH:mm:ss.SSS} *%-5p* [%t] %c{1}: %m\n"));
         LogManager.getRootLogger().addAppender(withholdingAppender);
         return withholdingAppender;
     }
diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties
index 7db291c..ec467a0 100644
--- a/src/test/resources/log4j.properties
+++ b/src/test/resources/log4j.properties
@@ -23,4 +23,4 @@ log4j.logger.org.apache.jackrabbit.core.TransientRepository=WARN
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
 #log4j.appender.stdout.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m (%F, line %L)\n
-log4j.appender.stdout.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss} *%-5p* [%t] %c{1}: %m\n
+log4j.appender.stdout.layout.ConversionPattern=%d{dd.MM.yyyy HH:mm:ss.SSS} *%-5p* [%t] %c{1}: %m\n

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 16/16: [maven-release-plugin] copy for tag org.apache.sling.discovery.base-1.0.2

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 0fbea42f40e64ebbf9be99f06c8c5b1cda0b1aeb
Author: Stefan Egli <st...@apache.org>
AuthorDate: Mon Nov 2 15:58:51 2015 +0000

    [maven-release-plugin] copy for tag org.apache.sling.discovery.base-1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.discovery.base-1.0.2@1712057 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 07/16: SLING-5126 / SLING-5195 related: fixing a test

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 479ea55dc5ac3e347f021f333f06c5a30e8bd5c6
Author: Stefan Egli <st...@apache.org>
AuthorDate: Thu Oct 29 14:17:56 2015 +0000

    SLING-5126 / SLING-5195 related: fixing a test
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1711275 13f79535-47bb-0310-9956-ffa450edef68
---
 .../discovery/base/its/AbstractClusterTest.java    | 30 +++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java b/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java
index 31c3b36..044f556 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java
@@ -444,8 +444,22 @@ public abstract class AbstractClusterTest {
         for(int i=0; i<25; i++) {
             runHeartbeatOnceWith(instance1Restarted, instance2, instance3, instance5);
             instance1.getViewChecker().checkView();
-            assertTrue(pingConnector(instance3, instance2));
-            assertTrue(pingConnector(instance5, instance2));
+            // we used to do:
+            //assertTrue(pingConnector(instance3, instance2));
+            // but that could fail with the introduction of marking
+            // an establishedView as failing upon detecting a view change
+            // when the view changes, we're sending TOPOLOGY_CHANGING to listeners
+            // so getTopology() should also return isCurrent==false - which
+            // means that doing a ping will also fail, cos that wants to 
+            // get a current topology to send as an announcement.
+            // which is a long way of saying: we cannot do an assert here
+            // since instance3 *can* have an undefined cluster view..
+            try{
+                pingConnector(instance3, instance2);
+            } catch(UndefinedClusterViewException ucve) {
+                // ignore
+            }
+            pingConnector(instance5, instance2);
             final TopologyView topology = instance3.getDiscoveryService().getTopology();
             InstanceDescription i3 = null;
             for (Iterator<InstanceDescription> it = topology.getInstances().iterator(); it.hasNext();) {
@@ -592,7 +606,17 @@ public abstract class AbstractClusterTest {
                 .setMinEventDelay(MIN_EVENT_DELAY).build();
         for(int i=0; i<3; i++) {
             runHeartbeatOnceWith(instance1Restarted, instance2, instance3, instance4, instance5);
-            assertTrue(pingConnector(instance3, instance2));
+            Thread.sleep(250);
+            // since instance4 just started - hooked to instance3 
+            // it is possible that it doesn't just have a topology
+            // yet - so we cannot do:
+            //assertTrue(pingConnector(instance3, instance2));
+            // but instead do
+            try{
+                pingConnector(instance3, instance2);
+            } catch(UndefinedClusterViewException ucve) {
+                // ignore
+            }
             assertTrue(pingConnector(instance5, instance2));
         }
 

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 03/16: @no-jira : improve test stability

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit d54675c4c2197db64efa833ef9747ef2f562694f
Author: Stefan Egli <st...@apache.org>
AuthorDate: Tue Oct 27 09:07:36 2015 +0000

    @no-jira : improve test stability
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1710750 13f79535-47bb-0310-9956-ffa450edef68
---
 .../java/org/apache/sling/discovery/base/its/AbstractClusterTest.java    | 1 +
 .../org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java b/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java
index 08ead70..31c3b36 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/AbstractClusterTest.java
@@ -781,6 +781,7 @@ public abstract class AbstractClusterTest {
         // -> corresponds to starting to ping
         instance3.heartbeatsAndCheckView();
         instance3.heartbeatsAndCheckView();
+        Thread.sleep(1000);
         pingConnector(instance3, instance1);
         // make asserts on the topology
         instance1.dumpRepo();
diff --git a/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java b/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
index 52a60b8..324772a 100644
--- a/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
+++ b/src/test/java/org/apache/sling/discovery/base/its/AbstractSingleInstanceTest.java
@@ -164,6 +164,7 @@ public abstract class AbstractSingleInstanceTest {
         instance.heartbeatsAndCheckView();
         
         final String propertyValue = UUID.randomUUID().toString();
+        Thread.sleep(2000);
         doTestProperty(UUID.randomUUID().toString(), propertyValue, propertyValue);
 
         doTestProperty("", propertyValue, null);

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-discovery-base] 14/16: @no-jira using discovery.commons 1.0.2

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.discovery.base-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-base.git

commit 632c6048463481719617bb770c61fcae86152d8b
Author: Stefan Egli <st...@apache.org>
AuthorDate: Mon Nov 2 15:57:03 2015 +0000

    @no-jira using discovery.commons 1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/discovery/base@1712055 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 56af493..4b802ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -151,7 +151,7 @@
  		<dependency>
 			<groupId>org.apache.sling</groupId>
 			<artifactId>org.apache.sling.discovery.commons</artifactId>
-			<version>1.0.1-SNAPSHOT</version>
+			<version>1.0.2</version>
   		</dependency>
         <!-- besides including discovery.commons' normal jar above, 
               for testing a few test helper classes are also reused.
@@ -159,7 +159,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.discovery.commons</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>1.0.2</version>
             <scope>test</scope>
             <type>test-jar</type>
         </dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.