Search in sources :

Example 11 with MeterConfig

use of org.openkilda.model.MeterConfig in project open-kilda by telstra.

the class MeterVerifyCommandTest method invalidBands0.

@Test
public void invalidBands0() {
    switchFeaturesSetup(sw, true);
    SettableFuture<List<OFMeterConfigStatsReply>> statsReplyProxy = setupMeterConfigStatsReply();
    // for command2
    setupMeterConfigStatsReply();
    replayAll();
    CompletableFuture<MeterVerifyReport> result = command.execute(commandProcessor);
    // make one more command with altered config, to produce meter config flags/bands
    MeterConfig invalidConfig = new MeterConfig(meterConfig.getId(), meterConfig.getBandwidth() + 1);
    MeterVerifyCommand command2 = new MeterVerifyCommand(command.getMessageContext(), command.getSwitchId(), invalidConfig);
    // must be executed, for let .setup() method to initialize all dependencies
    command2.execute(commandProcessor);
    OFMeterConfig reply = sw.getOFFactory().buildMeterConfig().setMeterId(meterConfig.getId().getValue()).setFlags(command2.makeMeterFlags()).setEntries(command2.makeMeterBands()).build();
    statsReplyProxy.set(wrapMeterStatsReply(reply));
    verifyErrorCompletion(result, SwitchIncorrectMeterException.class);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) MeterConfig(org.openkilda.model.MeterConfig) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) Test(org.junit.Test) AbstractSpeakerCommandTest(org.openkilda.floodlight.command.AbstractSpeakerCommandTest)

Example 12 with MeterConfig

use of org.openkilda.model.MeterConfig in project open-kilda by telstra.

the class MeterVerifyCommandTest method shouldVerifyInaccurateMeterBandwidth.

@Test
public void shouldVerifyInaccurateMeterBandwidth() throws Exception {
    MeterConfig validConfig = new MeterConfig(new MeterId(1), 100);
    MeterVerifyCommand command1 = new MeterVerifyCommand(new MessageContext(), mapSwitchId(dpId), validConfig);
    switchFeaturesSetup(sw, SwitchFeature.METERS, SwitchFeature.INACCURATE_METER);
    SettableFuture<List<OFMeterConfigStatsReply>> statsReplyProxy = setupMeterConfigStatsReply();
    // for command2
    setupMeterConfigStatsReply();
    replayAll();
    CompletableFuture<MeterVerifyReport> result = command1.execute(commandProcessor);
    // make one more command with altered config, to produce meter config flags/bands
    MeterConfig invalidConfig = new MeterConfig(validConfig.getId(), validConfig.getBandwidth() + 1);
    MeterVerifyCommand command2 = new MeterVerifyCommand(command1.getMessageContext(), command1.getSwitchId(), invalidConfig);
    // must be executed, for let .setup() method to initialize all dependencies
    command2.execute(commandProcessor);
    OFMeterConfig reply = sw.getOFFactory().buildMeterConfig().setMeterId(validConfig.getId().getValue()).setFlags(command2.makeMeterFlags()).setEntries(command2.makeMeterBands()).build();
    statsReplyProxy.set(wrapMeterStatsReply(reply));
    verifySuccessCompletion(result);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) MessageContext(org.openkilda.messaging.MessageContext) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) MeterConfig(org.openkilda.model.MeterConfig) OFMeterConfig(org.projectfloodlight.openflow.protocol.OFMeterConfig) MeterId(org.openkilda.model.MeterId) Test(org.junit.Test) AbstractSpeakerCommandTest(org.openkilda.floodlight.command.AbstractSpeakerCommandTest)

Aggregations

MeterConfig (org.openkilda.model.MeterConfig)12 OFMeterConfig (org.projectfloodlight.openflow.protocol.OFMeterConfig)8 MeterId (org.openkilda.model.MeterId)6 MessageContext (org.openkilda.messaging.MessageContext)5 FlowEndpoint (org.openkilda.model.FlowEndpoint)5 ArrayList (java.util.ArrayList)4 FlowSegmentWrapperCommand (org.openkilda.floodlight.command.flow.FlowSegmentWrapperCommand)4 RulesContext (org.openkilda.floodlight.model.RulesContext)4 ImmutableList (com.google.common.collect.ImmutableList)3 List (java.util.List)3 Test (org.junit.Test)3 AbstractSpeakerCommandTest (org.openkilda.floodlight.command.AbstractSpeakerCommandTest)3 SwitchId (org.openkilda.model.SwitchId)3 CompletableFuture (java.util.concurrent.CompletableFuture)2 Session (org.openkilda.floodlight.service.session.Session)2 OFMessage (org.projectfloodlight.openflow.protocol.OFMessage)2 Optional (java.util.Optional)1 Getter (lombok.Getter)1 IngressFlowSegmentRequest (org.openkilda.floodlight.api.request.IngressFlowSegmentRequest)1 OneSwitchFlowRequestFactory (org.openkilda.floodlight.api.request.factory.OneSwitchFlowRequestFactory)1