Use fewer services in policy subset test
@@ -452,11 +452,12 @@ public class PolicyTestCase {
PolicyTestFrame frame = new PolicyTestFrame("docproc/cluster.default", manager);
frame.setMessage(new PutDocumentMessage(new DocumentPut(new DocumentPut(new Document(manager.getDocumentType("testdoc"),
new DocumentId("id:ns:testdoc::"))))));
+ int numberOfServices = 4;
- // Test requerying for adding nodes.
+ // Test re-querying for adding nodes.
frame.setHop(new HopSpec("test", "docproc/cluster.default/[SubsetService:2]/chain.default"));
Set<String> lst = new HashSet<>();
- for (int i = 1; i <= 10; ++i) {
+ for (int i = 1; i <= numberOfServices; ++i) {
frame.getNetwork().registerSession(i + "/chain.default");
assertTrue(frame.waitSlobrok("docproc/cluster.default/*/chain.default", i));
@@ -465,11 +466,11 @@ public class PolicyTestCase {
leaf.handleReply(new EmptyReply());
assertNotNull(frame.getReceptor().getReply(TIMEOUT));
}
- assertTrue(lst.size() > 1); // must have requeried
+ assertTrue(lst.size() > 1); // must have re-queried
// Test load balancing.
String prev = null;
- for (int i = 1; i <= 10; ++i) {
+ for (int i = 1; i <= numberOfServices; ++i) {
RoutingNode leaf = frame.select(1).get(0);
String next = leaf.getRoute().toString();
if (prev == null) {
@@ -482,25 +483,25 @@ public class PolicyTestCase {
assertNotNull(frame.getReceptor().getReply(TIMEOUT));
}
- // Test requerying for dropping nodes.
+ // Test re-querying for dropping nodes.
lst.clear();
- for (int i = 1; i <= 10; ++i) {
+ for (int i = 1; i <= numberOfServices; ++i) {
RoutingNode leaf = frame.select(1).get(0);
String route = leaf.getRoute().toString();
lst.add(route);
frame.getNetwork().unregisterSession(route.substring(frame.getIdentity().length() + 1));
- assertTrue(frame.waitSlobrok("docproc/cluster.default/*/chain.default", 10 - i));
+ assertTrue(frame.waitSlobrok("docproc/cluster.default/*/chain.default", numberOfServices - i));
Reply reply = new EmptyReply();
reply.addError(new Error(ErrorCode.NO_ADDRESS_FOR_SERVICE, route));
leaf.handleReply(reply);
assertNotNull(frame.getReceptor().getReply(TIMEOUT));
}
- assertEquals(10, lst.size());
+ assertEquals(numberOfServices, lst.size());
// Test merge behavior.
- frame.setHop(new HopSpec("test", "[SubsetService]"));
+ frame.setHop(new HopSpec("test", "[SubsetService:2]"));
frame.assertMergeOneReply("*");
frame.destroy();
