use of io.fabric8.gateway.loadbalancer.StickyLoadBalancer in project fabric8 by jboss-fuse.
the class LoadBalancerTest method testStickyLoadBalancer.
@Test
public void testStickyLoadBalancer() throws Exception {
assertLoadBalancerWorksOnEmptyOrSingletonServices(new StickyLoadBalancer());
LoadBalancer loadBalancer = new StickyLoadBalancer();
Set<String> allRequests = new HashSet<String>();
int numberOfClients = 10;
for (int i = 0; i < numberOfClients; i++) {
clientRequestKey = "newClient:" + i;
List<String> results = performRequests(loadBalancer);
Set<String> set = asSet(results);
assertTrue("All values should be the same for client: " + clientRequestKey + " but got: " + set, set.size() == 1);
allRequests.addAll(set);
}
// now we should have a reasonable number of different overall answers.
assertTrue("Across " + numberOfClients + " we should have most of the values: " + allRequests, allRequests.size() > 1);
}
Aggregations