Search in sources :

Example 31 with MultipartReplyMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder in project openflowplugin by opendaylight.

the class OpendaylightGroupStatisticsServiceImplTest method testGetGroupFeatures.

@Test
public void testGetGroupFeatures() throws Exception {
    GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder().setNode(createNodeRef("unitProt:123"));
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyGroupFeaturesCaseBuilder().setMultipartReplyGroupFeatures(new MultipartReplyGroupFeaturesBuilder().setActionsBitmap(Collections.singletonList(new ActionType(true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false))).setCapabilities(new GroupCapabilities(true, false, false, false)).setTypes(new GroupTypes(true, false, false, false)).setMaxGroups(Collections.singletonList(5L)).build()).build()).build())).build();
    final Future<RpcResult<GetGroupFeaturesOutput>> resultFuture = groupStatisticsService.getGroupFeatures(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetGroupFeaturesOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPGROUPFEATURES, requestInput.getValue().getType());
}
Also used : MultipartReplyGroupFeaturesCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCaseBuilder) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes) GetGroupFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput) GroupCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities) ActionType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) GetGroupFeaturesInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MultipartReplyGroupFeaturesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeaturesBuilder) Test(org.junit.Test)

Example 32 with MultipartReplyMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder in project openflowplugin by opendaylight.

the class MultipartRequestCallbackTest method testOnSuccess3.

/**
 * Successfully added to collection.
 */
@Test
public void testOnSuccess3() throws Exception {
    final MultipartReplyMessage replyMessage = new MultipartReplyMessageBuilder().build();
    multipartRequestCallback.onSuccess(replyMessage);
    Mockito.verify(multiMsgCollector).addMultipartMsg(Matchers.eq(replyMessage), Matchers.eq(false), Matchers.any());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) Test(org.junit.Test)

Example 33 with MultipartReplyMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder in project openflowplugin by opendaylight.

the class AbstractCompatibleStatServiceTest method testHandleAndNotify.

@Test
public void testHandleAndNotify() throws Exception {
    GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput input = new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder().setNode(createNodeRef("unitProt:123")).setTableId(new TableId((short) 1)).build();
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyAggregateCaseBuilder().setMultipartReplyAggregate(new MultipartReplyAggregateBuilder().setByteCount(BigInteger.valueOf(11L)).setFlowCount(12L).setPacketCount(BigInteger.valueOf(13L)).build()).build()).build())).build();
    AggregatedFlowStatistics aggregatedStats = new AggregatedFlowStatisticsBuilder().setByteCount(new Counter64(BigInteger.valueOf(11L))).setFlowCount(new Counter32(12L)).setPacketCount(new Counter64(BigInteger.valueOf(13L))).build();
    Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.eq(deviceInfo), Matchers.any())).thenReturn(aggregatedStats);
    ListenableFuture<RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput>> resultFuture = service.handleAndNotify(input, notificationPublishService);
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput> result = resultFuture.get();
    Assert.assertTrue(result.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
    Mockito.verify(notificationPublishService, Mockito.timeout(500)).offerNotification(Matchers.any(AggregateFlowStatisticsUpdate.class));
}
Also used : TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput) AggregatedFlowStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) AggregateFlowStatisticsUpdate(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate) GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput) MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder) Test(org.junit.Test) AbstractStatsServiceTest(org.opendaylight.openflowplugin.impl.statistics.services.AbstractStatsServiceTest)

Example 34 with MultipartReplyMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder in project openflowplugin by opendaylight.

the class ConnectionAdapterImplStatisticsTest method testMessagePassCounter.

/**
 * Test counter for pass messages to consumer (counter US_MESSAGE_PASS has to be enabled).
 */
@Test
public void testMessagePassCounter() {
    if (!statCounters.isCounterEnabled(CounterEventTypes.US_MESSAGE_PASS)) {
        Assert.fail("Counter " + CounterEventTypes.US_MESSAGE_PASS + " is not enabled");
    }
    when(channel.pipeline()).thenReturn(pipeline);
    adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653), true, CHANNEL_OUTBOUND_QUEUE_SIZE);
    adapter.setMessageListener(messageListener);
    adapter.setSystemListener(systemListener);
    adapter.setConnectionReadyListener(readyListener);
    cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES).removalListener(REMOVAL_LISTENER).build();
    adapter.setResponseCache(cache);
    when(channel.disconnect()).thenReturn(channelFuture);
    DataObject message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    message = new ErrorMessageBuilder().build();
    adapter.consume(message);
    message = new ExperimenterMessageBuilder().build();
    adapter.consume(message);
    message = new FlowRemovedMessageBuilder().build();
    adapter.consume(message);
    message = new HelloMessageBuilder().build();
    adapter.consume(message);
    message = new MultipartReplyMessageBuilder().build();
    adapter.consume(message);
    message = new PacketInMessageBuilder().build();
    adapter.consume(message);
    message = new PortStatusMessageBuilder().build();
    adapter.consume(message);
    message = new EchoRequestMessageBuilder().build();
    adapter.consume(message);
    Assert.assertEquals("Wrong - bad counter value for ConnectionAdapterImpl consume method", 9, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue());
    adapter.disconnect();
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) PacketInMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) Test(org.junit.Test)

Example 35 with MultipartReplyMessageBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder in project openflowplugin by opendaylight.

the class MsgGeneratorTestUtils method makeMultipartDescReply.

public static MultipartReplyMessageBuilder makeMultipartDescReply(final long xid, final String value, final boolean hasNext) {
    final MultipartReplyDesc descValue = new MultipartReplyDescBuilder().setHwDesc(value).build();
    final MultipartReplyDescCase replyBody = new MultipartReplyDescCaseBuilder().setMultipartReplyDesc(descValue).build();
    MultipartReplyMessageBuilder messageBuilder = new MultipartReplyMessageBuilder().setMultipartReplyBody(replyBody).setXid(xid).setFlags(new MultipartRequestFlags(hasNext)).setType(MultipartType.OFPMPDESC);
    return messageBuilder;
}
Also used : MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) MultipartReplyDescCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder) MultipartReplyDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc) MultipartReplyDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCase) MultipartReplyDescBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder)

Aggregations

MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)39 Test (org.junit.Test)36 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)26 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)21 ByteBuf (io.netty.buffer.ByteBuf)20 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 MultipartReplyAggregateCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder)5 MultipartReplyAggregateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder)5 MultipartReply (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply)4 FutureCallback (com.google.common.util.concurrent.FutureCallback)3 List (java.util.List)3 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)3 MultipartReplyDescCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyDescCaseBuilder)3 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 Future (java.util.concurrent.Future)2 Assert (org.junit.Assert)2 Matchers (org.mockito.Matchers)2 Mock (org.mockito.Mock)2 Mockito (org.mockito.Mockito)2