use of org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult in project open-kilda by telstra.
the class ValidationServiceImplTest method validateRules.
@Test
public void validateRules() {
ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
List<FlowSpeakerData> actualFlows = Lists.newArrayList(FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000001L)).priority(1).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000001L)).priority(2).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000002L)).priority(1).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000002L)).priority(2).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000004L)).priority(1).build());
List<FlowSpeakerData> expectedFlows = Lists.newArrayList(FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000001L)).priority(1).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000002L)).priority(3).build(), FlowSpeakerData.builder().cookie(new Cookie(0x8000000000000003L)).priority(1).build());
ValidateRulesResult response = validationService.validateRules(SWITCH_ID_A, actualFlows, expectedFlows);
assertEquals(ImmutableSet.of(0x8000000000000001L), new HashSet<>(response.getProperRules()));
assertEquals(ImmutableSet.of(0x8000000000000001L, 0x8000000000000002L), new HashSet<>(response.getMisconfiguredRules()));
assertEquals(ImmutableSet.of(0x8000000000000003L), new HashSet<>(response.getMissingRules()));
assertEquals(ImmutableSet.of(0x8000000000000004L), new HashSet<>(response.getExcessRules()));
}
use of org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult in project open-kilda by telstra.
the class ValidationServiceImplTest method validateRulesEmpty.
@Test
public void validateRulesEmpty() {
ValidationService validationService = new ValidationServiceImpl(persistenceManager().build());
ValidateRulesResult response = validationService.validateRules(SWITCH_ID_A, emptyList(), emptyList());
assertTrue(response.getMissingRules().isEmpty());
assertTrue(response.getProperRules().isEmpty());
assertTrue(response.getExcessRules().isEmpty());
}
use of org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult in project open-kilda by telstra.
the class SwitchValidateFsm method validateRules.
private void validateRules(List<FlowSpeakerData> expectedRules) {
log.info("Validate rules (switch={}, key={})", getSwitchId(), key);
ValidateRulesResult results = validationService.validateRules(getSwitchId(), validationContext.getActualOfFlows(), expectedRules);
validationContext = validationContext.toBuilder().ofFlowsValidationReport(results).build();
}
use of org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult in project open-kilda by telstra.
the class SwitchValidateServiceImplTest method setUp.
@Before
public void setUp() {
RepositoryFactory repositoryFactory = Mockito.mock(RepositoryFactory.class);
FlowPathRepository flowPathRepository = Mockito.mock(FlowPathRepository.class);
SwitchRepository switchRepository = Mockito.mock(SwitchRepository.class);
when(switchRepository.findById(eq(SWITCH_ID))).thenReturn(Optional.of(SWITCH_1));
when(switchRepository.findById(eq(SWITCH_ID_MISSING))).thenReturn(Optional.empty());
LagLogicalPortRepository lagLogicalPortRepository = Mockito.mock(LagLogicalPortRepository.class);
when(repositoryFactory.createFlowPathRepository()).thenReturn(flowPathRepository);
when(repositoryFactory.createSwitchRepository()).thenReturn(switchRepository);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
service = new SwitchValidateServiceImpl(carrier, persistenceManager, validationService, ruleManager);
request = SwitchValidateRequest.builder().switchId(SWITCH_ID).processMeters(true).build();
flowSpeakerData = FlowSpeakerData.builder().ofVersion(OfVersion.OF_13).cookie(new Cookie(1L)).table(OfTable.INPUT).priority(10).match(emptySet()).instructions(Instructions.builder().build()).flags(emptySet()).build();
meterSpeakerData = MeterSpeakerData.builder().meterId(new MeterId(32)).rate(10000).burst(10500).ofVersion(OfVersion.OF_13).flags(Sets.newHashSet(MeterFlag.KBPS, MeterFlag.BURST, MeterFlag.STATS)).build();
when(validationService.validateRules(any(), any(), any())).thenReturn(new ValidateRulesResult(newHashSet(flowSpeakerData.getCookie().getValue()), emptySet(), emptySet(), emptySet()));
when(validationService.validateMeters(any(), any(), any())).thenReturn(new ValidateMetersResult(emptyList(), emptyList(), emptyList(), emptyList()));
}
use of org.openkilda.wfm.topology.switchmanager.model.ValidateRulesResult in project open-kilda by telstra.
the class SwitchSyncFsmTest method getModifyDefaultMetersWithMissingRulesTest.
@Test
public void getModifyDefaultMetersWithMissingRulesTest() {
ValidateRulesResult validateRulesResult = new ValidateRulesResult(newHashSet(COOKIE_1), newHashSet(), newHashSet(), newHashSet(COOKIE_2));
ArrayList<MeterInfoEntry> misconfiguredMeters = newArrayList(MeterInfoEntry.builder().cookie(COOKIE_1).meterId(METER_ID_1).build(), MeterInfoEntry.builder().cookie(COOKIE_2).meterId(METER_ID_2).build(), MeterInfoEntry.builder().cookie(COOKIE_3).meterId(METER_ID_3).build());
ValidateMetersResult validateMetersResult = new ValidateMetersResult(newArrayList(), misconfiguredMeters, newArrayList(), newArrayList());
ValidationResult validationResult = new ValidationResult(new ArrayList<>(), true, validateRulesResult, validateMetersResult, EMPTY_VALIDATE_GROUPS_RESULT, EMPTY_LOGICAL_PORTS_RESULT);
SwitchSyncFsm fsm = new SwitchSyncFsm(null, null, null, new SwitchValidateRequest(SWITCH_ID, true, true, true), validationResult);
List<Long> modifyMeters = fsm.getModifyDefaultMeters();
assertEquals(1, modifyMeters.size());
assertEquals(METER_ID_3, modifyMeters.get(0).longValue());
}
Aggregations