use of com.alibaba.otter.shared.arbitrate.impl.setl.lb.ExtractRandomLoadBanlance in project otter by alibaba.
the class RandomLoadBalanceTest method testExtract.
@Test
public void testExtract() {
// 初始化节点
Mockit.setUpMock(ArbitrateConfigUtils.class, new Object() {
@Mock
public Pipeline getPipeline(Long pipelineId) {
Pipeline pipeline = new Pipeline();
pipeline.setId(pipelineId);
pipeline.setSelectNodes(sourceList);
pipeline.setExtractNodes(sourceList);
pipeline.setLoadNodes(targetList);
return pipeline;
}
});
ExtractRandomLoadBanlance extract = new ExtractRandomLoadBanlance(pipelineId);
extract.setNodeMonitor(nodeMonitor);
sleep(500L);
try {
Node n1 = extract.next();
Node n2 = extract.next();
Node n3 = extract.next();
Node n4 = extract.next();
System.out.printf("n1[%s] n2[%s] n3[%s] n4[%s]", n1.getId(), n2.getId(), n3.getId(), n4.getId());
want.bool(sourceList.contains(n1)).is(true);
want.bool(sourceList.contains(n2)).is(true);
want.bool(sourceList.contains(n3)).is(true);
want.bool(sourceList.contains(n4)).is(true);
} catch (InterruptedException e) {
want.fail();
}
}
Aggregations