2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.openflow.md.core.sal;
11 import com.google.common.base.Optional;
12 import com.google.common.util.concurrent.CheckedFuture;
13 import com.google.common.util.concurrent.Futures;
14 import com.google.common.util.concurrent.MoreExecutors;
15 import java.math.BigInteger;
16 import java.util.ArrayList;
17 import java.util.List;
18 import java.util.concurrent.ExecutionException;
19 import java.util.concurrent.Executors;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23 import org.mockito.Matchers;
24 import org.mockito.Mock;
25 import org.mockito.Mockito;
26 import org.mockito.runners.MockitoJUnitRunner;
27 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
28 import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
29 import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
30 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
31 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
32 import org.opendaylight.openflowplugin.api.OFConstants;
33 import org.opendaylight.openflowplugin.api.openflow.md.core.ConnectionConductor;
34 import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher;
35 import org.opendaylight.openflowplugin.api.openflow.md.core.session.IMessageDispatchService;
36 import org.opendaylight.openflowplugin.api.openflow.md.core.session.SessionContext;
37 import org.opendaylight.openflowplugin.api.openflow.statistics.MessageSpy;
38 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager;
39 import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory;
40 import org.opendaylight.openflowplugin.openflow.md.core.session.OFSessionUtil;
41 import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
42 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
43 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
44 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowHashIdMapping;
45 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
46 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
47 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
48 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
49 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
50 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
51 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
52 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInputBuilder;
53 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutput;
54 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowOutputBuilder;
55 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
56 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
57 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder;
58 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder;
59 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder;
60 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder;
61 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableInputBuilder;
62 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowStatisticsFromFlowTableOutputBuilder;
63 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesInputBuilder;
64 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder;
65 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
66 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableOutputBuilder;
67 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder;
68 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutputBuilder;
69 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
70 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig;
71 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortFeatures;
72 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni;
73 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.PortBuilder;
74 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.Port;
75 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortKey;
76 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.queue.rev130925.QueueId;
77 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
78 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
79 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
80 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
81 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
82 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.AddGroupInputBuilder;
83 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
84 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
85 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutput;
86 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupOutputBuilder;
87 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder;
88 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsInputBuilder;
89 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetAllGroupStatisticsOutputBuilder;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionInputBuilder;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupDescriptionOutputBuilder;
92 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInputBuilder;
93 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutputBuilder;
94 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInputBuilder;
95 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsOutputBuilder;
96 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
97 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
98 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
99 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
100 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
101 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
102 import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
103 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterInputBuilder;
104 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.RemoveMeterInputBuilder;
105 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterInputBuilder;
106 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutput;
107 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.UpdateMeterOutputBuilder;
108 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.meter.update.UpdatedMeterBuilder;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutputBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsInputBuilder;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterStatisticsOutputBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesInputBuilder;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterFeaturesOutputBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInputBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutputBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInput;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput;
124 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GroupModInput;
125 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MeterModInput;
126 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
127 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput;
128 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortInputBuilder;
129 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutput;
130 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.UpdatePortOutputBuilder;
131 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.port.update.UpdatedPortBuilder;
132 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsInputBuilder;
133 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetAllNodeConnectorsStatisticsOutputBuilder;
134 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsInputBuilder;
135 import org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.GetNodeConnectorStatisticsOutputBuilder;
136 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsInputBuilder;
137 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromAllPortsOutputBuilder;
138 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortInputBuilder;
139 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetAllQueuesStatisticsFromGivenPortOutputBuilder;
140 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortInputBuilder;
141 import org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.GetQueueStatisticsFromGivenPortOutputBuilder;
142 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
143 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder;
144 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
145 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
146 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableConfig;
147 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.feature.prop.type.table.feature.prop.type.ApplySetfieldBuilder;
148 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
149 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
150 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
151 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.TablePropertiesBuilder;
152 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeatureProperties;
153 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesBuilder;
154 import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.table.features.table.properties.TableFeaturePropertiesKey;
155 import org.opendaylight.yangtools.yang.binding.DataContainer;
156 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
157 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
158 import org.opendaylight.yangtools.yang.common.RpcResult;
159 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
162 * simple NPE smoke test
164 @RunWith(MockitoJUnitRunner.class)
165 public class ModelDrivenSwitchImplTest {
167 private ModelDrivenSwitchImpl mdSwitchOF10;
168 private ModelDrivenSwitchImpl mdSwitchOF13;
171 private SessionContext context;
173 private ConnectionConductor conductor;
175 private IMessageDispatchService messageDispatchService;
177 private GetFeaturesOutput features;
179 private MessageSpy<DataContainer> messageSpy;
181 private DataBroker dataBroker;
183 private ReadWriteTransaction rwTx;
185 private EntityOwnershipService entityOwnershipService;
188 * @throws java.lang.Exception
191 public void setUp() throws Exception {
192 Mockito.when(context.getPrimaryConductor()).thenReturn(conductor);
193 Mockito.when(context.getMessageDispatchService()).thenReturn(messageDispatchService);
194 Mockito.when(conductor.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_0)
195 .thenReturn(OFConstants.OFP_VERSION_1_3);
196 Mockito.when(context.getFeatures()).thenReturn(features);
197 Mockito.when(features.getDatapathId()).thenReturn(BigInteger.valueOf(1));
200 OFSessionUtil.getSessionManager().setRpcPool(MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(10)));
201 OFSessionUtil.getSessionManager().setMessageSpy(messageSpy);
202 OFSessionUtil.getSessionManager().setDataBroker(dataBroker);
204 CheckedFuture<Optional<FlowHashIdMapping>, ReadFailedException> dummyReadFuture
205 = Futures.<Optional<FlowHashIdMapping>,ReadFailedException>immediateCheckedFuture(Optional.<FlowHashIdMapping>absent());
206 Mockito.when(rwTx.read(Matchers.<LogicalDatastoreType>any(), Matchers.<InstanceIdentifier<FlowHashIdMapping>>any())).thenReturn(dummyReadFuture);
207 Mockito.when(dataBroker.newReadWriteTransaction()).thenReturn(rwTx);
210 OpenflowPortsUtil.init();
212 final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
213 mdSwitchOF10 = new ModelDrivenSwitchImpl(null, null, context, convertorManager);
214 mdSwitchOF13 = new ModelDrivenSwitchImpl(null, null, context, convertorManager);
219 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#addFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput)}
221 * @throws ExecutionException
222 * @throws InterruptedException
225 public void testAddFlow() throws InterruptedException, ExecutionException {
226 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
227 updateFlowOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
228 RpcResult<UpdateFlowOutput> result = RpcResultBuilder.success(updateFlowOutput.build()).build();
230 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
231 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
233 AddFlowInputBuilder input = new AddFlowInputBuilder();
234 input.setMatch(createMatch());
236 Mockito.when(features.getVersion()).thenReturn((short)1);
237 mdSwitchOF10.addFlow(input.build()).get();
238 Mockito.when(features.getVersion()).thenReturn((short)4);
239 mdSwitchOF13.addFlow(input.build()).get();
240 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
241 Matchers.any(FlowModInput.class),
242 Matchers.any(SwitchConnectionDistinguisher.class));
247 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#removeFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput)}
249 * @throws ExecutionException
250 * @throws InterruptedException
253 public void testRemoveFlow() throws InterruptedException, ExecutionException {
254 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
255 updateFlowOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
256 RpcResult<UpdateFlowOutput> result = RpcResultBuilder.success(updateFlowOutput.build()).build();
258 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
259 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
261 RemoveFlowInputBuilder input = new RemoveFlowInputBuilder();
262 input.setMatch(createMatch());
264 Mockito.when(features.getVersion()).thenReturn((short)1);
265 mdSwitchOF10.removeFlow(input.build()).get();
266 Mockito.when(features.getVersion()).thenReturn((short)4);
267 mdSwitchOF13.removeFlow(input.build()).get();
268 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
269 Matchers.any(FlowModInput.class),
270 Matchers.any(SwitchConnectionDistinguisher.class));
276 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#updateFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput)}
278 * @throws ExecutionException
279 * @throws InterruptedException
282 public void testUpdateFlow() throws InterruptedException, ExecutionException {
283 UpdateFlowOutputBuilder updateFlowOutput = new UpdateFlowOutputBuilder();
284 updateFlowOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
285 RpcResult<UpdateFlowOutput> result = RpcResultBuilder.success(updateFlowOutput.build()).build();
287 messageDispatchService.flowMod(Matchers.any(FlowModInput.class),
288 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
290 UpdateFlowInputBuilder input = new UpdateFlowInputBuilder();
291 UpdatedFlowBuilder updatedFlow = new UpdatedFlowBuilder();
292 updatedFlow.setBarrier(false);
293 updatedFlow.setMatch(createMatch());
294 updatedFlow.setPriority(65);
295 updatedFlow.setFlags(new FlowModFlags(true, false, true, false, true));
296 input.setUpdatedFlow(updatedFlow.build());
297 OriginalFlowBuilder originalFlowBuilder = new OriginalFlowBuilder();
298 originalFlowBuilder.setMatch(createMatch());
299 originalFlowBuilder.setPriority(65);
300 originalFlowBuilder.setFlags(new FlowModFlags(true, false, true, false, true));
301 input.setOriginalFlow(originalFlowBuilder.build());
302 KeyedInstanceIdentifier<Flow, FlowKey> dummyIdentifier = InstanceIdentifier.create(Nodes.class)
303 .child(Node.class, new NodeKey(new NodeId("openflow:1")))
304 .augmentation(FlowCapableNode.class)
305 .child(Table.class, new TableKey((short)0))
306 .child(Flow.class, new FlowKey(new FlowId("1")));
307 input.setFlowRef(new FlowRef(dummyIdentifier));
309 Mockito.when(features.getVersion()).thenReturn((short)1);
310 mdSwitchOF10.updateFlow(input.build()).get();
311 Mockito.when(features.getVersion()).thenReturn((short)4);
312 mdSwitchOF13.updateFlow(input.build()).get();
313 Mockito.verify(messageDispatchService, Mockito.times(2)).flowMod(
314 Matchers.any(FlowModInput.class),
315 Matchers.any(SwitchConnectionDistinguisher.class));
320 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
321 * addGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
324 * @throws ExecutionException
325 * @throws InterruptedException
328 public void testAddGroup() throws InterruptedException, ExecutionException {
329 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
330 updateGroupOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
331 RpcResult<UpdateGroupOutput> result = RpcResultBuilder.success(updateGroupOutput.build()).build();
333 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
334 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
336 AddGroupInputBuilder input = new AddGroupInputBuilder();
337 input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
338 input.setGroupId(new GroupId(789L));
340 mdSwitchOF10.addGroup(input.build()).get();
341 mdSwitchOF13.addGroup(input.build()).get();
342 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
343 Matchers.any(GroupModInput.class),
344 Matchers.any(SwitchConnectionDistinguisher.class));
349 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
350 * updateGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
353 * @throws ExecutionException
354 * @throws InterruptedException
357 public void testUpdateGroup() throws InterruptedException, ExecutionException {
358 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
359 updateGroupOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
360 RpcResult<UpdateGroupOutput> result = RpcResultBuilder.success(updateGroupOutput.build()).build();
362 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
363 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
365 UpdateGroupInputBuilder input = new UpdateGroupInputBuilder();
366 UpdatedGroupBuilder updatedGroupBuilder = new UpdatedGroupBuilder();
367 updatedGroupBuilder.setGroupId(new GroupId(789L));
368 updatedGroupBuilder.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
369 input.setUpdatedGroup(updatedGroupBuilder.build());
371 mdSwitchOF10.updateGroup(input.build()).get();
372 mdSwitchOF13.updateGroup(input.build()).get();
373 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
374 Matchers.any(GroupModInput.class),
375 Matchers.any(SwitchConnectionDistinguisher.class));
380 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
381 * removeGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.
384 * @throws ExecutionException
385 * @throws InterruptedException
388 public void testRemoveGroup() throws InterruptedException, ExecutionException {
389 UpdateGroupOutputBuilder updateGroupOutput = new UpdateGroupOutputBuilder();
390 updateGroupOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
391 RpcResult<UpdateGroupOutput> result = RpcResultBuilder.success(updateGroupOutput.build()).build();
393 messageDispatchService.groupMod(Matchers.any(GroupModInput.class),
394 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
396 RemoveGroupInputBuilder input = new RemoveGroupInputBuilder();
397 input.setGroupId(new GroupId(789L));
398 input.setGroupType(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupFf);
400 mdSwitchOF10.removeGroup(input.build()).get();
401 mdSwitchOF13.removeGroup(input.build()).get();
402 Mockito.verify(messageDispatchService, Mockito.times(2)).groupMod(
403 Matchers.any(GroupModInput.class),
404 Matchers.any(SwitchConnectionDistinguisher.class));
409 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
410 * addMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
413 * @throws ExecutionException
414 * @throws InterruptedException
417 public void testAddMeter() throws InterruptedException, ExecutionException {
418 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
419 updateMeterOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
420 RpcResult<UpdateMeterOutput> result = RpcResultBuilder.success(updateMeterOutput.build()).build();
422 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
423 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
425 AddMeterInputBuilder input = new AddMeterInputBuilder();
426 input.setMeterId(new MeterId(78L));
428 mdSwitchOF10.addMeter(input.build()).get();
429 mdSwitchOF13.addMeter(input.build()).get();
430 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
431 Matchers.any(MeterModInput.class),
432 Matchers.any(SwitchConnectionDistinguisher.class));
437 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
438 * updateMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
441 * @throws ExecutionException
442 * @throws InterruptedException
445 public void testUpdtateMeter() throws InterruptedException, ExecutionException {
446 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
447 updateMeterOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
448 RpcResult<UpdateMeterOutput> result = RpcResultBuilder.success(updateMeterOutput.build()).build();
450 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
451 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
453 UpdateMeterInputBuilder input = new UpdateMeterInputBuilder();
454 UpdatedMeterBuilder updatedMeterBuilder = new UpdatedMeterBuilder();
455 updatedMeterBuilder.setMeterId(new MeterId(89L));
456 updatedMeterBuilder.setBarrier(false);
457 input.setUpdatedMeter(updatedMeterBuilder.build());
459 mdSwitchOF10.updateMeter(input.build()).get();
460 mdSwitchOF13.updateMeter(input.build()).get();
461 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
462 Matchers.any(MeterModInput.class),
463 Matchers.any(SwitchConnectionDistinguisher.class));
468 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
469 * removeMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.
472 * @throws ExecutionException
473 * @throws InterruptedException
476 public void testRemoveMeter() throws InterruptedException, ExecutionException {
477 UpdateMeterOutputBuilder updateMeterOutput = new UpdateMeterOutputBuilder();
478 updateMeterOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
479 RpcResult<UpdateMeterOutput> result = RpcResultBuilder.success(updateMeterOutput.build()).build();
481 messageDispatchService.meterMod(Matchers.any(MeterModInput.class),
482 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
484 RemoveMeterInputBuilder input = new RemoveMeterInputBuilder();
485 input.setMeterId(new MeterId(89L));
487 mdSwitchOF10.removeMeter(input.build()).get();
488 mdSwitchOF13.removeMeter(input.build()).get();
489 Mockito.verify(messageDispatchService, Mockito.times(2)).meterMod(
490 Matchers.any(MeterModInput.class),
491 Matchers.any(SwitchConnectionDistinguisher.class));
496 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
497 * getAllGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
498 * GetAllGroupStatisticsInput)}
500 * @throws ExecutionException
501 * @throws InterruptedException
504 public void testGetAllGroupStatistics() throws InterruptedException, ExecutionException {
505 GetAllGroupStatisticsOutputBuilder getAllGroupStatistcsOutput = new GetAllGroupStatisticsOutputBuilder();
506 getAllGroupStatistcsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
507 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
509 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
510 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
512 GetAllGroupStatisticsInputBuilder input = new GetAllGroupStatisticsInputBuilder();
514 mdSwitchOF10.getAllGroupStatistics(input.build()).get();
515 mdSwitchOF13.getAllGroupStatistics(input.build()).get();
516 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
517 Matchers.any(MultipartRequestInput.class),
518 Matchers.any(SwitchConnectionDistinguisher.class));
523 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
524 * getGroupDescription(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
525 * GetGroupDescriptionInput)}
527 * @throws ExecutionException
528 * @throws InterruptedException
531 public void testGetGroupDescription() throws InterruptedException, ExecutionException {
532 GetGroupDescriptionOutputBuilder getGroupDescOutput = new GetGroupDescriptionOutputBuilder();
533 getGroupDescOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
534 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
536 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
537 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
539 GetGroupDescriptionInputBuilder input = new GetGroupDescriptionInputBuilder();
541 mdSwitchOF10.getGroupDescription(input.build()).get();
542 mdSwitchOF13.getGroupDescription(input.build()).get();
543 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
544 Matchers.any(MultipartRequestInput.class),
545 Matchers.any(SwitchConnectionDistinguisher.class));
550 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
551 * getGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
552 * GetGroupFeaturesInput)}
554 * @throws ExecutionException
555 * @throws InterruptedException
558 public void testGetGroupFeatures() throws InterruptedException, ExecutionException {
559 GetGroupFeaturesOutputBuilder getGroupFeaturesOutput = new GetGroupFeaturesOutputBuilder();
560 getGroupFeaturesOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
561 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
563 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
564 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
566 GetGroupFeaturesInputBuilder input = new GetGroupFeaturesInputBuilder();
568 mdSwitchOF10.getGroupFeatures(input.build()).get();
569 mdSwitchOF13.getGroupFeatures(input.build()).get();
570 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
571 Matchers.any(MultipartRequestInput.class),
572 Matchers.any(SwitchConnectionDistinguisher.class));
577 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
578 * getGroupStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.
579 * GetGroupStatisticsInput)}
581 * @throws ExecutionException
582 * @throws InterruptedException
584 //TODO GetGroupStatistics why NPE?
586 public void testGetGroupStatistics() throws InterruptedException, ExecutionException {
587 GetGroupStatisticsOutputBuilder getGroupStatsOutput = new GetGroupStatisticsOutputBuilder();
588 getGroupStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
589 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
591 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
592 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
594 GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder();
595 input.setGroupId(new GroupId(42L));
597 mdSwitchOF10.getGroupStatistics(input.build()).get();
598 mdSwitchOF13.getGroupStatistics(input.build()).get();
599 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
600 Matchers.any(MultipartRequestInput.class),
601 Matchers.any(SwitchConnectionDistinguisher.class));
606 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
607 * getAllMeterConfigStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
608 * GetAllMeterConfigStatisticsInput)}
610 * @throws ExecutionException
611 * @throws InterruptedException
614 public void testGetAllMeterConfigStatistics() throws InterruptedException, ExecutionException {
615 GetAllMeterConfigStatisticsOutputBuilder getAllMeterConfigStatsOutput =
616 new GetAllMeterConfigStatisticsOutputBuilder();
617 getAllMeterConfigStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
618 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
620 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
621 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
623 GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder();
625 mdSwitchOF10.getAllMeterConfigStatistics(input.build()).get();
626 mdSwitchOF13.getAllMeterConfigStatistics(input.build()).get();
627 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
628 Matchers.any(MultipartRequestInput.class),
629 Matchers.any(SwitchConnectionDistinguisher.class));
634 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
635 * getAllMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
636 * GetAllMeterStatisticsInput)}
638 * @throws ExecutionException
639 * @throws InterruptedException
642 public void testGetAllMeterStatistics() throws InterruptedException, ExecutionException {
643 GetAllMeterStatisticsOutputBuilder getAllMeterStatisticsOutput =
644 new GetAllMeterStatisticsOutputBuilder();
645 getAllMeterStatisticsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
646 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
648 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
649 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
651 GetAllMeterStatisticsInputBuilder input = new GetAllMeterStatisticsInputBuilder();
653 mdSwitchOF10.getAllMeterStatistics(input.build()).get();
654 mdSwitchOF13.getAllMeterStatistics(input.build()).get();
655 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
656 Matchers.any(MultipartRequestInput.class),
657 Matchers.any(SwitchConnectionDistinguisher.class));
662 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
663 * getMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
664 * GetMeterFeaturesInput)}
666 * @throws ExecutionException
667 * @throws InterruptedException
670 public void testGetMeterFeatures() throws InterruptedException, ExecutionException {
671 GetMeterFeaturesOutputBuilder getMeterFeaturesOutput =
672 new GetMeterFeaturesOutputBuilder();
673 getMeterFeaturesOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
674 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
676 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
677 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
679 GetMeterFeaturesInputBuilder input = new GetMeterFeaturesInputBuilder();
681 mdSwitchOF10.getMeterFeatures(input.build()).get();
682 mdSwitchOF13.getMeterFeatures(input.build()).get();
683 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
684 Matchers.any(MultipartRequestInput.class),
685 Matchers.any(SwitchConnectionDistinguisher.class));
690 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
691 * getMeterStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.
692 * GetMeterStatisticsInput)}
694 * @throws ExecutionException
695 * @throws InterruptedException
698 public void testGetMeterStatistics() throws InterruptedException, ExecutionException {
699 GetMeterStatisticsOutputBuilder getMeterStatsOutput = new GetMeterStatisticsOutputBuilder();
700 getMeterStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
701 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
703 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
704 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
706 GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder();
707 input.setMeterId(new MeterId(42L));
709 mdSwitchOF10.getMeterStatistics(input.build()).get();
710 mdSwitchOF13.getMeterStatistics(input.build()).get();
711 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
712 Matchers.any(MultipartRequestInput.class),
713 Matchers.any(SwitchConnectionDistinguisher.class));
718 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
719 * getAllNodeConnectorsStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
720 * GetAllNodeConnectorsStatisticsInput)}
722 * @throws ExecutionException
723 * @throws InterruptedException
726 public void testGetAllNodeConnectorsStatistics() throws InterruptedException, ExecutionException {
727 GetAllNodeConnectorsStatisticsOutputBuilder getAllNodeConnectorsStatsOutput =
728 new GetAllNodeConnectorsStatisticsOutputBuilder();
729 getAllNodeConnectorsStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
730 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();;
732 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
733 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
735 GetAllNodeConnectorsStatisticsInputBuilder input = new GetAllNodeConnectorsStatisticsInputBuilder();
737 mdSwitchOF10.getAllNodeConnectorsStatistics(input.build()).get();
738 mdSwitchOF13.getAllNodeConnectorsStatistics(input.build()).get();
739 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
740 Matchers.any(MultipartRequestInput.class),
741 Matchers.any(SwitchConnectionDistinguisher.class));
746 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
747 * getNodeConnectorStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.port.statistics.rev131214.
748 * GetNodeConnectorStatisticsInput)}
750 * @throws ExecutionException
751 * @throws InterruptedException
754 public void testGetNodeConnectorStatistics() throws InterruptedException, ExecutionException {
755 GetNodeConnectorStatisticsOutputBuilder getNodeConnectorStatsOutput =
756 new GetNodeConnectorStatisticsOutputBuilder();
757 getNodeConnectorStatsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
758 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
760 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
761 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
763 GetNodeConnectorStatisticsInputBuilder input = new GetNodeConnectorStatisticsInputBuilder();
764 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
766 Mockito.when(features.getVersion()).thenReturn((short)1);
767 mdSwitchOF10.getNodeConnectorStatistics(input.build()).get();
768 Mockito.when(features.getVersion()).thenReturn((short)4);
769 mdSwitchOF13.getNodeConnectorStatistics(input.build()).get();
770 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
771 Matchers.any(MultipartRequestInput.class),
772 Matchers.any(SwitchConnectionDistinguisher.class));
777 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
778 * updatePort(org.opendaylight.yang.gen.v1.urn.opendaylight.port.service.rev131107.
781 * @throws ExecutionException
782 * @throws InterruptedException
785 public void testUpdatePort() throws InterruptedException, ExecutionException {
786 UpdatePortOutputBuilder updatePortOutput = new UpdatePortOutputBuilder();
787 updatePortOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
788 RpcResult<UpdatePortOutput> result = RpcResultBuilder.success(updatePortOutput.build()).build();
790 messageDispatchService.portMod(Matchers.any(PortModInput.class),
791 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
793 UpdatePortInputBuilder input = new UpdatePortInputBuilder();
795 PortBuilder portBuilder = new PortBuilder();
796 List<Port> ports = new ArrayList<Port>();
797 ports.add(createPort());
798 portBuilder.setPort(ports);
799 UpdatedPortBuilder updatedPortBuilder = new UpdatedPortBuilder();
800 updatedPortBuilder.setPort(portBuilder.build());
801 input.setUpdatedPort(updatedPortBuilder.build());
803 mdSwitchOF10.updatePort(input.build()).get();
804 mdSwitchOF13.updatePort(input.build()).get();
805 Mockito.verify(messageDispatchService, Mockito.times(2)).portMod(
806 Matchers.any(PortModInput.class),
807 Matchers.any(SwitchConnectionDistinguisher.class));
810 private static Port createPort() {
811 org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder port =
812 new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder();
814 port.setPortName("TestingPort01");
815 port.setMask(new PortConfig(true, true, true, true));
816 port.setConfiguration(new PortConfig(true, true, true, true));
817 port.setAdvertisedFeatures(new PortFeatures(true, true, true, true,
818 false, false, false, false,
819 true, true, true, true,
820 false, false, false, false));
821 port.setPortNumber(new PortNumberUni(42L));
822 port.setHardwareAddress(new MacAddress("01:23:45:67:89:ab"));
823 port.setBarrier(true);
824 port.setContainerName("TestContainer");
825 port.setPortModOrder(25L);
826 port.setKey(new PortKey(25L));
832 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
833 * updateTable(org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.
836 * @throws ExecutionException
837 * @throws InterruptedException
840 public void testUpdateTable() throws InterruptedException, ExecutionException {
841 UpdateTableOutputBuilder updateTableOutput = new UpdateTableOutputBuilder();
842 updateTableOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
843 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
845 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
846 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
848 UpdateTableInputBuilder input = new UpdateTableInputBuilder();
849 input.setUpdatedTable(createUpdateTable());
851 mdSwitchOF10.updateTable(input.build()).get();
852 mdSwitchOF13.updateTable(input.build()).get();
853 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
854 Matchers.any(MultipartRequestInput.class),
855 Matchers.any(SwitchConnectionDistinguisher.class));
858 private static UpdatedTable createUpdateTable() {
859 UpdatedTableBuilder updatedTableBuilder = new UpdatedTableBuilder();
860 TableFeaturesBuilder tableFeaturesBuilder = new TableFeaturesBuilder();
861 tableFeaturesBuilder.setConfig(new TableConfig(true));
862 tableFeaturesBuilder.setKey(new TableFeaturesKey((short) 42));
863 tableFeaturesBuilder.setMaxEntries(42L);
864 tableFeaturesBuilder.setMetadataMatch(BigInteger.valueOf(42424242));
865 tableFeaturesBuilder.setMetadataWrite(BigInteger.valueOf(42424242));
866 tableFeaturesBuilder.setName("testTableFeatures");
867 tableFeaturesBuilder.setTableId((short) 41);
869 TablePropertiesBuilder tablePropertiesBuilder = new TablePropertiesBuilder();
870 TableFeaturePropertiesBuilder tableFeaturePropertiesBuilder = new TableFeaturePropertiesBuilder();
871 tableFeaturePropertiesBuilder.setKey(new TableFeaturePropertiesKey(45));
872 tableFeaturePropertiesBuilder.setOrder(44);
873 tableFeaturePropertiesBuilder.setTableFeaturePropType(new ApplySetfieldBuilder().build());
874 List<TableFeatureProperties> tableFeatureProperties = new ArrayList<TableFeatureProperties>();
875 tableFeatureProperties.add(tableFeaturePropertiesBuilder.build());
876 tablePropertiesBuilder.setTableFeatureProperties(tableFeatureProperties);
878 tableFeaturesBuilder.setTableProperties(tablePropertiesBuilder.build());
879 List<TableFeatures> tableFeatures = new ArrayList<TableFeatures>();
880 tableFeatures.add(tableFeaturesBuilder.build());
881 updatedTableBuilder.setTableFeatures(tableFeatures);
882 return updatedTableBuilder.build();
887 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
888 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
889 * GetAllFlowStatisticsFromFlowTableInput)}
891 * @throws ExecutionException
892 * @throws InterruptedException
895 public void testGetAllFlowStatisticsFromFlowTable() throws InterruptedException, ExecutionException {
896 GetAllFlowStatisticsFromFlowTableOutputBuilder allFlowStatisticsFromFlowTableOutput =
897 new GetAllFlowStatisticsFromFlowTableOutputBuilder();
898 allFlowStatisticsFromFlowTableOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
899 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
901 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
902 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
904 GetAllFlowStatisticsFromFlowTableInputBuilder input = new GetAllFlowStatisticsFromFlowTableInputBuilder();
905 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
907 mdSwitchOF10.getAllFlowStatisticsFromFlowTable(input.build()).get();
908 mdSwitchOF13.getAllFlowStatisticsFromFlowTable(input.build()).get();
909 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
910 Matchers.any(MultipartRequestInput.class),
911 Matchers.any(SwitchConnectionDistinguisher.class));
916 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
917 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
918 * GetAllFlowStatisticsFromFlowTableInput)}
920 * @throws ExecutionException
921 * @throws InterruptedException
924 public void testGetAllFlowsStatisticsFromAllFlowTables() throws InterruptedException, ExecutionException {
925 GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder allFlowStatisticsFromAllFlowTablesOutput =
926 new GetAllFlowsStatisticsFromAllFlowTablesOutputBuilder();
927 allFlowStatisticsFromAllFlowTablesOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
928 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
930 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
931 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
933 GetAllFlowsStatisticsFromAllFlowTablesInputBuilder input =
934 new GetAllFlowsStatisticsFromAllFlowTablesInputBuilder();
936 mdSwitchOF10.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
937 mdSwitchOF13.getAllFlowsStatisticsFromAllFlowTables(input.build()).get();
938 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
939 Matchers.any(MultipartRequestInput.class),
940 Matchers.any(SwitchConnectionDistinguisher.class));
945 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
946 * getAllFlowStatisticsFromFlowTable(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
947 * GetAllFlowStatisticsFromFlowTableInput)}
949 * @throws ExecutionException
950 * @throws InterruptedException
953 public void testGetFlowStatisticsFromFlowTables() throws InterruptedException, ExecutionException {
954 GetFlowStatisticsFromFlowTableOutputBuilder flowStatisticsFromFlowTablesOutput =
955 new GetFlowStatisticsFromFlowTableOutputBuilder();
956 flowStatisticsFromFlowTablesOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
957 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
959 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
960 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
962 GetFlowStatisticsFromFlowTableInputBuilder input =
963 new GetFlowStatisticsFromFlowTableInputBuilder();
964 input.setMatch(createMatch());
966 mdSwitchOF10.getFlowStatisticsFromFlowTable(input.build()).get();
967 mdSwitchOF13.getFlowStatisticsFromFlowTable(input.build()).get();
968 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
969 Matchers.any(MultipartRequestInput.class),
970 Matchers.any(SwitchConnectionDistinguisher.class));
973 private static Match createMatch() {
974 MatchBuilder matchBuilder = new MatchBuilder();
975 EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
976 EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
977 ethernetDestinationBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
978 ethernetDestinationBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
979 ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
980 EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
981 ethernetSourceBuilder.setAddress(new MacAddress("01:23:45:67:89:ab"));
982 ethernetSourceBuilder.setMask(new MacAddress("01:23:45:67:89:ab"));
983 ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
984 ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(new EtherType(42L)).build());
985 matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
986 return matchBuilder.build();
991 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
992 * getAggregateFlowStatisticsFromFlowTableForAllFlows(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
993 * GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput)}
995 * @throws ExecutionException
996 * @throws InterruptedException
999 public void testGetAggregateFlowStatisticsFromFlowTableForAllFlows() throws InterruptedException,
1000 ExecutionException {
1001 GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder aggregateFlowStatisticsOutput =
1002 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutputBuilder();
1003 aggregateFlowStatisticsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1004 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1006 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1007 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1009 GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder input =
1010 new GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder();
1011 input.setTableId(new org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId((short) 42));
1013 mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
1014 mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForAllFlows(input.build()).get();
1015 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1016 Matchers.any(MultipartRequestInput.class),
1017 Matchers.any(SwitchConnectionDistinguisher.class));
1022 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1023 * getAggregateFlowStatisticsFromFlowTableForGivenMatch(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.
1024 * GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput)}
1026 * @throws ExecutionException
1027 * @throws InterruptedException
1030 public void testGetAggregateFlowStatisticsFromFlowTableForGivenMatch() throws InterruptedException,
1031 ExecutionException {
1032 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder aggregateFlowStatisticsForMatchOutput =
1033 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutputBuilder();
1034 aggregateFlowStatisticsForMatchOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1035 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1037 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1038 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1040 GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder input =
1041 new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder();
1042 input.setMatch(createMatch());
1043 input.setCookie(new FlowCookie(BigInteger.valueOf(123456)));
1044 input.setCookieMask(new FlowCookie(BigInteger.valueOf(123456)));
1045 input.setOutGroup(44L);
1046 input.setOutPort(BigInteger.valueOf(12563));
1048 mdSwitchOF10.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1049 mdSwitchOF13.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build()).get();
1050 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1051 Matchers.any(MultipartRequestInput.class),
1052 Matchers.any(SwitchConnectionDistinguisher.class));
1057 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1058 * getFlowTablesStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.
1059 * GetFlowTablesStatisticsInput)}
1061 * @throws ExecutionException
1062 * @throws InterruptedException
1065 public void testGetFlowTablesStatistics() throws InterruptedException, ExecutionException {
1066 GetFlowTablesStatisticsOutputBuilder flowTableStatisticsOutput =
1067 new GetFlowTablesStatisticsOutputBuilder();
1068 flowTableStatisticsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1069 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1071 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1072 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1074 GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder();
1076 mdSwitchOF10.getFlowTablesStatistics(input.build()).get();
1077 mdSwitchOF13.getFlowTablesStatistics(input.build()).get();
1078 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1079 Matchers.any(MultipartRequestInput.class),
1080 Matchers.any(SwitchConnectionDistinguisher.class));
1085 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1086 * getAllQueuesStatisticsFromAllPorts(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1087 * GetAllQueuesStatisticsFromAllPortsInput)}
1089 * @throws ExecutionException
1090 * @throws InterruptedException
1093 public void testGetAllQueuesStatisticsFromAllPorts() throws InterruptedException, ExecutionException {
1094 GetAllQueuesStatisticsFromAllPortsOutputBuilder allQueuesStatisticsAllPortsOutput =
1095 new GetAllQueuesStatisticsFromAllPortsOutputBuilder();
1096 allQueuesStatisticsAllPortsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1097 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1099 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1100 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1102 GetAllQueuesStatisticsFromAllPortsInputBuilder input =
1103 new GetAllQueuesStatisticsFromAllPortsInputBuilder();
1105 mdSwitchOF10.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1106 mdSwitchOF13.getAllQueuesStatisticsFromAllPorts(input.build()).get();
1107 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1108 Matchers.any(MultipartRequestInput.class),
1109 Matchers.any(SwitchConnectionDistinguisher.class));
1114 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1115 * getAllQueuesStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1116 * GetAllQueuesStatisticsFromGivenPortInput)}
1118 * @throws ExecutionException
1119 * @throws InterruptedException
1122 public void testGetAllQueuesStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1123 GetAllQueuesStatisticsFromGivenPortOutputBuilder allQueuesStatisticsGivenPortsOutput =
1124 new GetAllQueuesStatisticsFromGivenPortOutputBuilder();
1125 allQueuesStatisticsGivenPortsOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1126 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1128 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1129 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1131 GetAllQueuesStatisticsFromGivenPortInputBuilder input =
1132 new GetAllQueuesStatisticsFromGivenPortInputBuilder();
1133 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1135 Mockito.when(features.getVersion()).thenReturn((short)1);
1136 mdSwitchOF10.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1137 Mockito.when(features.getVersion()).thenReturn((short)4);
1138 mdSwitchOF13.getAllQueuesStatisticsFromGivenPort(input.build()).get();
1139 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1140 Matchers.any(MultipartRequestInput.class),
1141 Matchers.any(SwitchConnectionDistinguisher.class));
1146 * {@link org.opendaylight.openflowplugin.openflow.md.core.sal.ModelDrivenSwitchImpl#
1147 * getQueueStatisticsFromGivenPort(org.opendaylight.yang.gen.v1.urn.opendaylight.queue.statistics.rev131216.
1148 * GetQueueStatisticsFromGivenPortInput)}
1150 * @throws ExecutionException
1151 * @throws InterruptedException
1154 public void testGetQueueStatisticsFromGivenPort() throws InterruptedException, ExecutionException {
1155 GetQueueStatisticsFromGivenPortOutputBuilder queuesStatisticsGivenPortOutput =
1156 new GetQueueStatisticsFromGivenPortOutputBuilder();
1157 queuesStatisticsGivenPortOutput.setTransactionId(new TransactionId(BigInteger.valueOf(42)));
1158 RpcResult<Void> result = RpcResultBuilder.success((Void)null).build();
1160 messageDispatchService.multipartRequest(Matchers.any(MultipartRequestInput.class),
1161 Matchers.any(SwitchConnectionDistinguisher.class))).thenReturn(Futures.immediateFuture(result));
1163 GetQueueStatisticsFromGivenPortInputBuilder input =
1164 new GetQueueStatisticsFromGivenPortInputBuilder();
1165 input.setNodeConnectorId(new NodeConnectorId("openflow:12:8"));
1166 input.setQueueId(new QueueId(55L));
1168 Mockito.when(features.getVersion()).thenReturn((short)1);
1169 mdSwitchOF10.getQueueStatisticsFromGivenPort(input.build()).get();
1170 Mockito.when(features.getVersion()).thenReturn((short)4);
1171 mdSwitchOF13.getQueueStatisticsFromGivenPort(input.build()).get();
1172 Mockito.verify(messageDispatchService, Mockito.times(2)).multipartRequest(
1173 Matchers.any(MultipartRequestInput.class),
1174 Matchers.any(SwitchConnectionDistinguisher.class));