mreutegg commented on code in PR #7:
URL:
https://github.com/apache/sling-org-apache-sling-discovery-oak/pull/7#discussion_r925647750
##########
src/test/java/org/apache/sling/discovery/oak/its/setup/SimulatedLeaseCollection.java:
##########
@@ -114,6 +123,17 @@ private int getClusterNodeId(SimulatedLease lease) {
return getClusterNodeId(lease.getSlingId(),
lease.getClusterNodeIdHint());
}
+ int getClusterNodeId(String slingId) {
+ if (clusterNodeIds == null) {
+ return -1;
+ }
Review Comment:
`clusterNodeIds` is never null. Remove those lines.
```suggestion
```
##########
src/test/java/org/apache/sling/discovery/oak/its/setup/SimulatedLeaseCollection.java:
##########
@@ -70,6 +70,15 @@ public void incSeqNum(int amount) {
public synchronized void hooked(SimulatedLease lease) {
leases.add(lease);
+// if (leases.size() > 1) {
+// incSeqNum();
+// }
Review Comment:
Remove?
```suggestion
```
##########
src/test/java/org/apache/sling/discovery/oak/OakDiscoveryServiceTest.java:
##########
@@ -597,6 +613,87 @@ public void testSingleStart() throws Exception {
assertEquals(1, listener1.countEvents());
}
+ @Test
+ public void testSlowLeaderOnChange() throws Exception {
+ // a leader reacting slow with syncToken update risks loosing
+ // the leader flag. this test should ensure it's fine as long
+ // as it is within minEventDelay
+ OakVirtualInstanceBuilder builder1 =
+ (OakVirtualInstanceBuilder) new OakVirtualInstanceBuilder()
+ .setDebugName("instance1")
+ .newRepository("/foo1/barrio/foo1/", true)
+ .setConnectorPingInterval(999999)
+ .setConnectorPingTimeout(999999);
+ builder1.getConfig().setMinEventDelay(6);
+ builder1.getConfig().setJoinerDelaySeconds(1);
+ builder1.getConfig().setSyncTokenEnabled(true);
+ builder1.getConfig().setSuppressPartiallyStartedInstance(true);
+
+ // 1. start instance 1 normally -> call builder1.build()
+ VirtualInstance instance1 = builder1.build();
+ DummyListener listener1 = new DummyListener();
+ OakDiscoveryService discoveryService1 = (OakDiscoveryService)
instance1.getDiscoveryService();
+ discoveryService1.bindTopologyEventListener(listener1);
+ instance1.heartbeatsAndCheckView();
+ assertEquals(0, listener1.countEvents());
+ instance1.heartbeatsAndCheckView();
+ assertEquals(1, listener1.countEvents());
+
+ OakVirtualInstanceBuilder builder2 =
+ (OakVirtualInstanceBuilder) new OakVirtualInstanceBuilder()
+ .setDebugName("instance2")
+ .useRepositoryOf(builder1)
+ .setConnectorPingInterval(999999)
+ .setConnectorPingTimeout(999999);
+ builder2.getConfig().setMinEventDelay(6);
+ builder2.getConfig().setJoinerDelaySeconds(1);
+ builder2.getConfig().setSyncTokenEnabled(true);
+ builder2.getConfig().setSuppressPartiallyStartedInstance(true);
+
+ // 2. start instance 2 normally -> call builder1.build()
Review Comment:
```suggestion
// 2. start instance 2 normally -> call builder2.build()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]