use of org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow in project open-kilda by telstra.
the class StubApplicationTests method addFlows.
@Test
public void addFlows() throws Exception {
pushFlow(testFlowVlan1001);
pushFlow(testFlowVxlan2002);
ListFlowsPayload listFlowsPayload = new ListFlowsPayload();
listFlowsPayload.getFlowIds().add(testFlowVlan1001.getFlowId());
listFlowsPayload.getFlowIds().add(testFlowVxlan2002.getFlowId());
MvcResult result = mockMvc.perform(get("/kafka/flow/").param("switchId", switchId)).andReturn();
mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk()).andExpect(content().json(objectWriter.writeValueAsString(listFlowsPayload)));
}
use of org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow in project open-kilda by telstra.
the class ActionServiceTest method shouldBecomeHealthyAndSendSyncRequest.
@Test
public void shouldBecomeHealthyAndSendSyncRequest() {
Duration tier2Failed = Duration.ofNanos(flow.getMaxLatencyTier2() * 2);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, tier2Failed);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, tier2Failed);
Duration healthy = Duration.ofNanos((long) (flow.getMaxLatency() * (1 - THRESHOLD)) - 5);
for (int i = 0; i < 10; i++) {
clock.adjust(Duration.ofSeconds(10));
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, healthy);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, healthy.minus(NANOSECOND));
service.processTick();
if (i == 0) {
assertTrue(service.fsms.values().stream().allMatch(fsm -> UNSTABLE.equals(fsm.getCurrentState())));
}
}
assertEquals(2, service.fsms.values().size());
assertTrue(service.fsms.values().stream().allMatch(fsm -> HEALTHY.equals(fsm.getCurrentState())));
FlowStats actual = flowStatsRepository.findByFlowId(flow.getFlowId()).orElseThrow(() -> new IllegalStateException("Flow not found"));
assertEquals(healthy.getNano(), actual.getForwardLatency().intValue());
assertEquals(healthy.minus(NANOSECOND).getNano(), actual.getReverseLatency().intValue());
verify(carrier, times(2)).sendFlowSyncRequest(flow.getFlowId());
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow in project open-kilda by telstra.
the class ActionServiceTest method shouldStayInHealthyState.
@Test
public void shouldStayInHealthyState() {
Duration latency = Duration.ofNanos(flow.getMaxLatency() - 10);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, latency);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, latency.minus(NANOSECOND));
latency = Duration.ofNanos((long) (flow.getMaxLatency() * (1 + THRESHOLD)) - 1);
for (int i = 0; i < 10; i++) {
clock.adjust(Duration.ofSeconds(10));
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, latency);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, latency.minus(NANOSECOND));
service.processTick();
}
assertEquals(2, service.fsms.values().size());
assertTrue(service.fsms.values().stream().allMatch(fsm -> HEALTHY.equals(fsm.getCurrentState())));
FlowStats actual = flowStatsRepository.findByFlowId(flow.getFlowId()).orElseThrow(() -> new IllegalStateException("Flow not found"));
assertEquals(latency.getNano(), actual.getForwardLatency().intValue());
assertEquals(latency.minus(NANOSECOND).getNano(), actual.getReverseLatency().intValue());
verifyNoMoreInteractions(carrier);
}
use of org.openkilda.server42.control.messaging.flowrtt.FlowRttControl.Flow in project open-kilda by telstra.
the class ActionServiceTest method shouldFailTier1AndSendRerouteRequest.
@Test
public void shouldFailTier1AndSendRerouteRequest() {
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, NANOSECOND);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, NANOSECOND);
Duration latency = Duration.ofNanos((long) (flow.getMaxLatency() * (1 + THRESHOLD)) + 5);
for (int i = 0; i < 10; i++) {
clock.adjust(Duration.ofSeconds(10));
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.FORWARD, latency);
service.processFlowLatencyMeasurement(flow.getFlowId(), FlowDirection.REVERSE, latency.minus(NANOSECOND));
service.processTick();
if (i == 0) {
assertTrue(service.fsms.values().stream().allMatch(fsm -> UNSTABLE.equals(fsm.getCurrentState())));
}
}
assertEquals(2, service.fsms.values().size());
assertTrue(service.fsms.values().stream().allMatch(fsm -> TIER_1_FAILED.equals(fsm.getCurrentState())));
FlowStats actual = flowStatsRepository.findByFlowId(flow.getFlowId()).orElseThrow(() -> new IllegalStateException("Flow not found"));
assertEquals(latency.getNano(), actual.getForwardLatency().intValue());
assertEquals(latency.minus(NANOSECOND).getNano(), actual.getReverseLatency().intValue());
verify(carrier, times(2)).sendFlowRerouteRequest(flow.getFlowId());
verifyNoMoreInteractions(carrier);
}
Aggregations