Search in sources :

Example 1 with MetersEntriesMap

use of org.openkilda.testing.service.floodlight.model.MetersEntriesMap in project open-kilda by telstra.

the class FlowSteps method doesNotHaveMeter.

@Then("^meters '(.*)' does not have '(.*)'$")
public void doesNotHaveMeter(String metersAlias, String meterAlias) {
    MetersEntriesMap meters = topologyUnderTest.getAliasedObject(metersAlias);
    Entry<Integer, MeterEntry> meter = topologyUnderTest.getAliasedObject(meterAlias);
    assertFalse(meters.containsKey(meter.getKey()));
}
Also used : MeterEntry(org.openkilda.testing.service.floodlight.model.MeterEntry) MetersEntriesMap(org.openkilda.testing.service.floodlight.model.MetersEntriesMap) Then(cucumber.api.java.en.Then)

Example 2 with MetersEntriesMap

use of org.openkilda.testing.service.floodlight.model.MetersEntriesMap in project open-kilda by telstra.

the class FlowSteps method selectFirstMeter.

@And("^select first meter of '(.*)' and alias it as '(.*)'$")
public void selectFirstMeter(String metersAlias, String newMeterAlias) {
    MetersEntriesMap meters = topologyUnderTest.getAliasedObject(metersAlias);
    Entry<Integer, MeterEntry> firstMeter = meters.entrySet().iterator().next();
    topologyUnderTest.addAlias(newMeterAlias, firstMeter);
}
Also used : MeterEntry(org.openkilda.testing.service.floodlight.model.MeterEntry) MetersEntriesMap(org.openkilda.testing.service.floodlight.model.MetersEntriesMap) And(cucumber.api.java.en.And)

Example 3 with MetersEntriesMap

use of org.openkilda.testing.service.floodlight.model.MetersEntriesMap in project open-kilda by telstra.

the class StubServiceFactory method getFloodlightStub.

/**
 * Get a stub for {@link FloodlightService}. The instance is tied to the factory state.
 */
public FloodlightService getFloodlightStub() {
    FloodlightService serviceMock = mock(FloodlightService.class);
    when(serviceMock.getFlows(any())).thenAnswer(invocation -> {
        SwitchId switchId = (SwitchId) invocation.getArguments()[0];
        String switchVersion = topologyDefinition.getActiveSwitches().stream().filter(sw -> sw.getDpId().equals(switchId)).map(Switch::getOfVersion).findAny().orElse("OF_13");
        return buildFlowEntries(switchId, switchVersion);
    });
    when(serviceMock.getMeters(any())).then((Answer<MetersEntriesMap>) invocation -> {
        SwitchId switchId = (SwitchId) invocation.getArguments()[0];
        MetersEntriesMap result = new MetersEntriesMap();
        flows.values().forEach(flowPair -> {
            if (flowPair.getLeft().getSourceSwitch().equals(switchId) || flowPair.getRight().getSourceSwitch().equals(switchId)) {
                MeterEntry entry = new MeterEntry(emptyList(), flowPair.getLeft().getMeterId(), singletonList(new MeterBand(flowPair.getLeft().getBandwidth(), 0, "", 1)), "");
                result.put(entry.getMeterId(), entry);
            }
        });
        return result;
    });
    when(serviceMock.getSwitches()).then((Answer<List<SwitchEntry>>) invocation -> topologyDefinition.getActiveSwitches().stream().map(sw -> SwitchEntry.builder().switchId(sw.getDpId()).ofVersion(sw.getOfVersion()).build()).collect(toList()));
    return serviceMock;
}
Also used : Arrays(java.util.Arrays) SwitchChangeType(org.openkilda.messaging.info.event.SwitchChangeType) FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) Collections.singletonList(java.util.Collections.singletonList) Switch(org.openkilda.testing.model.topology.TopologyDefinition.Switch) FlowApplyActions(org.openkilda.testing.service.floodlight.model.FlowApplyActions) NorthboundService(org.openkilda.testing.service.northbound.NorthboundService) Map(java.util.Map) LocalTime(java.time.LocalTime) Exam(org.openkilda.testing.service.traffexam.model.Exam) SwitchLocationDto(org.openkilda.northbound.dto.v1.switches.SwitchLocationDto) FlowEntry(org.openkilda.testing.service.floodlight.model.FlowEntry) RulesValidationResult(org.openkilda.northbound.dto.v1.switches.RulesValidationResult) Collections.emptyList(java.util.Collections.emptyList) FlowDto(org.openkilda.messaging.model.FlowDto) FlowMatchField(org.openkilda.testing.service.floodlight.model.FlowMatchField) ASwitchFlow(org.openkilda.testing.service.lockkeeper.model.ASwitchFlow) Host(org.openkilda.testing.service.traffexam.model.Host) List(java.util.List) Stream(java.util.stream.Stream) FlowPairDto(org.openkilda.messaging.model.FlowPairDto) RulesSyncResult(org.openkilda.northbound.dto.v1.switches.RulesSyncResult) Mockito.mock(org.mockito.Mockito.mock) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) ExamReport(org.openkilda.testing.service.traffexam.model.ExamReport) MeterBand(org.openkilda.testing.service.floodlight.model.MeterBand) SerializationUtils(org.apache.commons.lang3.SerializationUtils) HashMap(java.util.HashMap) IslChangeType(org.openkilda.messaging.info.event.IslChangeType) ArrayList(java.util.ArrayList) Answer(org.mockito.stubbing.Answer) FlowEntriesMap(org.openkilda.testing.service.floodlight.model.FlowEntriesMap) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) MetersEntriesMap(org.openkilda.testing.service.floodlight.model.MetersEntriesMap) TopologyDefinition(org.openkilda.testing.model.topology.TopologyDefinition) FloodlightService(org.openkilda.testing.service.floodlight.FloodlightService) Mockito.when(org.mockito.Mockito.when) PathNode(org.openkilda.messaging.info.event.PathNode) MeterEntry(org.openkilda.testing.service.floodlight.model.MeterEntry) TraffExamService(org.openkilda.testing.service.traffexam.TraffExamService) Collectors.toList(java.util.stream.Collectors.toList) SwitchId(org.openkilda.model.SwitchId) LockKeeperService(org.openkilda.testing.service.lockkeeper.LockKeeperService) SwitchEntry(org.openkilda.testing.service.floodlight.model.SwitchEntry) FlowState(org.openkilda.messaging.payload.flow.FlowState) SwitchDto(org.openkilda.northbound.dto.v1.switches.SwitchDto) Bandwidth(org.openkilda.testing.service.traffexam.model.Bandwidth) FlowInstructions(org.openkilda.testing.service.floodlight.model.FlowInstructions) MeterBand(org.openkilda.testing.service.floodlight.model.MeterBand) Switch(org.openkilda.testing.model.topology.TopologyDefinition.Switch) MeterEntry(org.openkilda.testing.service.floodlight.model.MeterEntry) FloodlightService(org.openkilda.testing.service.floodlight.FloodlightService) SwitchId(org.openkilda.model.SwitchId) Collections.singletonList(java.util.Collections.singletonList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) ArrayList(java.util.ArrayList) Collectors.toList(java.util.stream.Collectors.toList) MetersEntriesMap(org.openkilda.testing.service.floodlight.model.MetersEntriesMap)

Aggregations

MeterEntry (org.openkilda.testing.service.floodlight.model.MeterEntry)3 MetersEntriesMap (org.openkilda.testing.service.floodlight.model.MetersEntriesMap)3 And (cucumber.api.java.en.And)1 Then (cucumber.api.java.en.Then)1 LocalTime (java.time.LocalTime)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors.toList (java.util.stream.Collectors.toList)1 Stream (java.util.stream.Stream)1 SerializationUtils (org.apache.commons.lang3.SerializationUtils)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.when (org.mockito.Mockito.when)1 Answer (org.mockito.stubbing.Answer)1 IslChangeType (org.openkilda.messaging.info.event.IslChangeType)1