use of com.alibaba.csp.sentinel.slots.block.flow.TrafficShapingController in project Sentinel by alibaba.
the class DefaultControllerTest method testCanPassForQps.
@Test
public void testCanPassForQps() {
double threshold = 10;
TrafficShapingController controller = new DefaultController(threshold, RuleConstant.FLOW_GRADE_QPS);
Node node = mock(Node.class);
when(node.passQps()).thenReturn(threshold - 1).thenReturn(threshold);
assertTrue(controller.canPass(node, 1));
assertFalse(controller.canPass(node, 1));
}
use of com.alibaba.csp.sentinel.slots.block.flow.TrafficShapingController in project Sentinel by alibaba.
the class DefaultControllerTest method testCanPassForThreadCount.
@Test
public void testCanPassForThreadCount() {
int threshold = 8;
TrafficShapingController controller = new DefaultController(threshold, RuleConstant.FLOW_GRADE_THREAD);
Node node = mock(Node.class);
when(node.curThreadNum()).thenReturn(threshold - 1).thenReturn(threshold);
assertTrue(controller.canPass(node, 1));
assertFalse(controller.canPass(node, 1));
}
Aggregations