<artifactId>topology-lldp-discovery</artifactId>
<packaging>bundle</packaging>
- <properties>
- <bundle.plugin.version>2.4.0</bundle.plugin.version>
- <guava.version>14.0.1</guava.version>
- <maven.clean.plugin.version>2.5</maven.clean.plugin.version>
- </properties>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
try {
nodeConnector = NodeMapping.toADNodeConnector(nodeConnectorRef);
} catch (ConstructionException e) {
- e.printStackTrace();
+ LOG.debug("Construction exception: %s",e.getMessage());
}
HashSet<Property> _aDNodeConnectorProperties = NodeMapping.toADNodeConnectorProperties((org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) entry.getValue());
this.publishNodeConnectorUpdate(nodeConnector, updateType, _aDNodeConnectorProperties);
<artifactId>nagasena-rta</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller.thirdparty</groupId>
- <artifactId>ganymed</artifactId>
- <scope>test</scope>
- </dependency>
-
+
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<artifactId>config-manager</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>forwardingrules-manager</artifactId>
+ <scope>test</scope>
+ <version>${mdsal.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller.md</groupId>
+ <artifactId>inventory-manager</artifactId>
+ <scope>test</scope>
+ <version>${mdsal.version}</version>
+ </dependency>
<dependency>
<groupId>commons-codec</groupId>
public static final String DEBUG_PORT = "6000";
/** base controller package */
public static final String CONTROLLER = "org.opendaylight.controller";
+ /** base controller.md package */
+ public static final String CONTROLLER_MD = "org.opendaylight.controller.md";
/** OFLibrary package */
public static final String OFLIBRARY = "org.opendaylight.openflowjava";
/** OFLibrary package */
mavenBundle(OFPLUGIN, "openflowplugin-api").versionAsInProject(),
mavenBundle(OFPLUGIN, "openflowplugin-extension-api").versionAsInProject(),
mavenBundle(OFPLUGIN, "openflowplugin").versionAsInProject(),
+ mavenBundle(CONTROLLER_MD, "forwardingrules-manager").versionAsInProject(),
+ mavenBundle(CONTROLLER_MD, "inventory-manager").versionAsInProject(),
mavenBundle("org.openexi", "nagasena").versionAsInProject()
);
}
--- /dev/null
+/**
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.openflow.md.it;
+
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.inject.Inject;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.ReadTransaction;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.test.sal.binding.it.TestHelper;
+import org.opendaylight.openflowjava.protocol.impl.clients.ClientEvent;
+import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler;
+import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient;
+import org.opendaylight.openflowjava.protocol.impl.clients.SleepEvent;
+import org.opendaylight.openflowjava.protocol.impl.clients.WaitForMessageEvent;
+import org.opendaylight.openflowjava.util.ByteBufUtils;
+import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor;
+import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DecNwTtlCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.dec.nw.ttl._case.DecNwTtlBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.ops4j.pax.exam.Configuration;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+import org.ops4j.pax.exam.util.Filter;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+/**
+ * covers basic handshake scenarios
+ */
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class OFPluginFlowTest {
+
+ static final Logger LOG = LoggerFactory
+ .getLogger(OFPluginFlowTest.class);
+
+ private static final ArrayBlockingQueue<Runnable> SCENARIO_POOL_QUEUE = new ArrayBlockingQueue<>(1);
+
+ @Inject @Filter(timeout=20000)
+ OpenflowPluginProvider openflowPluginProvider;
+
+ @Inject
+ BundleContext ctx;
+
+ @Inject @Filter(timeout=20000)
+ static DataBroker dataBroker;
+
+ @Inject @Filter(timeout=20000)
+ NotificationProviderService notificationService;
+
+ private SimpleClient switchSim;
+ private ThreadPoolLoggingExecutor scenarioPool;
+
+ /**
+ * test setup
+ * @throws InterruptedException
+ */
+ @Before
+ public void setUp() throws InterruptedException {
+ LOG.debug("openflowPluginProvider: "+openflowPluginProvider);
+ scenarioPool = new ThreadPoolLoggingExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, SCENARIO_POOL_QUEUE, "scenario");
+ //FIXME: plugin should provide service exposing startup result via future
+ Thread.sleep(5000);
+ }
+
+ /**
+ * test tear down
+ */
+ @After
+ public void tearDown() {
+ try {
+ LOG.debug("tearing down simulator");
+ switchSim.getScenarioDone().get(getFailSafeTimeout(), TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ String msg = "waiting for scenario to finish failed: "+e.getMessage();
+ LOG.error(msg, e);
+ Assert.fail(msg);
+ } finally {
+ scenarioPool.shutdownNow();
+ SCENARIO_POOL_QUEUE.clear();
+ }
+
+ try {
+ LOG.debug("checking if simulator succeeded to connect to controller");
+ boolean simulatorWasOnline = switchSim.getIsOnlineFuture().get(100, TimeUnit.MILLISECONDS);
+ Assert.assertTrue("simulator failed to connect to controller", simulatorWasOnline);
+ } catch (Exception e) {
+ String message = "simulator probably failed to connect to controller";
+ LOG.error(message, e);
+ Assert.fail(message);
+ }
+ }
+
+ final class TriggerTestListener implements DataChangeListener {
+
+ public TriggerTestListener() {
+ // NOOP
+ }
+
+ @Override
+ public void onDataChanged(
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> arg0) {
+ Set<InstanceIdentifier<?>> keySet = arg0.getCreatedData().keySet();
+ if (keySet.size() == 1) {
+ for (InstanceIdentifier<?> key : keySet) {
+ InstanceIdentifier<FlowCapableNode> neededKey =
+ key.firstIdentifierOf(FlowCapableNode.class);
+ if (neededKey != null) {
+ LOG.info("Node was added (brm) {}", neededKey);
+ writeFlow(createTestFlow(), neededKey);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * test basic integration with OFLib running the handshake
+ * @throws Exception
+ */
+ @Test
+ public void testFlowMod() throws Exception {
+ LOG.debug("testFlowMod integration test");
+ TriggerTestListener brmListener = new TriggerTestListener();
+
+ dataBroker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+ getWildcardPath(), brmListener, DataChangeScope.BASE);
+
+ switchSim = createSimpleClient();
+ switchSim.setSecuredClient(false);
+ Deque<ClientEvent> handshakeScenario = ScenarioFactory.createHandshakeScenarioVBM(
+ ScenarioFactory.VERSION_BITMAP_13, (short) 0, ScenarioFactory.VERSION_BITMAP_10_13, false);
+ handshakeScenario.addFirst(new SleepEvent(3000L));
+ ScenarioFactory.appendPostHandshakeScenario(handshakeScenario, true);
+ WaitForMessageEvent flowModEvent = new WaitForMessageEvent(ByteBufUtils
+ .hexStringToBytes(
+ "04 0e 00 58 00 00 00 05 00 00 00 00 00 00 00 0a "
+ + "00 00 00 00 00 00 00 0a 00 00 00 00 00 00 80 00 "
+ + "ff ff ff ff ff ff ff ff ff ff ff ff 00 01 00 00 "
+ + "00 01 00 16 80 00 0a 02 08 00 80 00 19 08 0a 00 "
+ + "00 01 ff ff ff 00 00 00 00 04 00 10 00 00 00 00 "
+ + "00 18 00 08 00 00 00 00"));
+ handshakeScenario.addFirst(flowModEvent);
+ ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
+ switchSim.setScenarioHandler(scenario);
+ scenarioPool.execute(switchSim);
+ LOG.info("finishing testFlowMod");
+ }
+
+ private static InstanceIdentifier<?> getWildcardPath() {
+ return InstanceIdentifier.create(Nodes.class).child(Node.class).augmentation(FlowCapableNode.class);
+ }
+
+ /**
+ * @return
+ */
+ private static SimpleClient createSimpleClient() {
+ return new SimpleClient("localhost", 6653);
+ }
+
+ /**
+ * @return timeout for case of failure
+ */
+ private static long getFailSafeTimeout() {
+ return 20000;
+ }
+
+
+ /**
+ * @return bundle options
+ */
+ @Configuration
+ public Option[] config() {
+ LOG.info("configuring...");
+ return options(
+ systemProperty("osgi.console").value("2401"),
+ systemProperty("osgi.bundles.defaultStartLevel").value("4"),
+ systemProperty("pax.exam.osgi.unresolved.fail").value("true"),
+
+ OFPaxOptionsAssistant.osgiConsoleBundles(),
+ OFPaxOptionsAssistant.loggingBudles(),
+
+ TestHelper.junitAndMockitoBundles(),
+ TestHelper.mdSalCoreBundles(),
+ TestHelper.configMinumumBundles(),
+ TestHelper.baseModelBundles(),
+ TestHelper.flowCapableModelBundles(),
+
+ OFPaxOptionsAssistant.ofPluginBundles());
+ }
+
+ static FlowBuilder createTestFlow() {
+ short tableId = 0;
+ FlowBuilder flow = new FlowBuilder();
+ flow.setMatch(createMatch1().build());
+ flow.setInstructions(createDecNwTtlInstructions().build());
+
+ FlowId flowId = new FlowId("127");
+ FlowKey key = new FlowKey(flowId);
+ if (null == flow.isBarrier()) {
+ flow.setBarrier(Boolean.FALSE);
+ }
+ BigInteger value = BigInteger.TEN;
+ flow.setCookie(new FlowCookie(value));
+ flow.setCookieMask(new FlowCookie(value));
+ flow.setHardTimeout(0);
+ flow.setIdleTimeout(0);
+ flow.setInstallHw(false);
+ flow.setStrict(false);
+ flow.setContainerName(null);
+ flow.setFlags(new FlowModFlags(false, false, false, false, true));
+ flow.setId(flowId);
+ flow.setTableId(tableId);
+
+ flow.setKey(key);
+ flow.setFlowName("Foo" + "X" + "f1");
+
+ return flow;
+ }
+
+ private static MatchBuilder createMatch1() {
+ MatchBuilder match = new MatchBuilder();
+ Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder();
+ Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.1/24");
+ ipv4Match.setIpv4Destination(prefix);
+ Ipv4Match i4m = ipv4Match.build();
+ match.setLayer3Match(i4m);
+
+ EthernetMatchBuilder eth = new EthernetMatchBuilder();
+ EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder();
+ ethTypeBuilder.setType(new EtherType(0x0800L));
+ eth.setEthernetType(ethTypeBuilder.build());
+ match.setEthernetMatch(eth.build());
+ return match;
+ }
+
+ private static InstructionsBuilder createDecNwTtlInstructions() {
+ DecNwTtlBuilder ta = new DecNwTtlBuilder();
+ DecNwTtl decNwTtl = ta.build();
+ ActionBuilder ab = new ActionBuilder();
+ ab.setAction(new DecNwTtlCaseBuilder().setDecNwTtl(decNwTtl).build());
+ ab.setKey(new ActionKey(0));
+ // Add our drop action to a list
+ List<Action> actionList = new ArrayList<Action>();
+ actionList.add(ab.build());
+
+ // Create an Apply Action
+ ApplyActionsBuilder aab = new ApplyActionsBuilder();
+ aab.setAction(actionList);
+
+ // Wrap our Apply Action in an Instruction
+ InstructionBuilder ib = new InstructionBuilder();
+ ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
+ ib.setKey(new InstructionKey(0));
+ ib.setOrder(0);
+
+ // Put our Instruction in a list of Instructions
+ InstructionsBuilder isb = new InstructionsBuilder();
+ List<Instruction> instructions = new ArrayList<Instruction>();
+ instructions.add(ib.build());
+ ib.setKey(new InstructionKey(0));
+ isb.setInstruction(instructions);
+ return isb;
+ }
+
+ static void writeFlow(FlowBuilder flow, InstanceIdentifier<FlowCapableNode> flowNodeIdent) {
+ ReadWriteTransaction modification = dataBroker.newReadWriteTransaction();
+ final InstanceIdentifier<Flow> path1 = flowNodeIdent.child(Table.class, new TableKey(flow.getTableId()))
+ .child(Flow.class, flow.getKey());
+ modification.merge(LogicalDatastoreType.CONFIGURATION, path1, flow.build(), true);
+ CheckedFuture<Void, TransactionCommitFailedException> commitFuture = modification.submit();
+ Futures.addCallback(commitFuture, new FutureCallback<Void>() {
+ @Override
+ public void onSuccess(Void aVoid) {
+ LOG.debug("Write of flow on device succeeded.");
+ }
+
+ @Override
+ public void onFailure(Throwable throwable) {
+ LOG.error("Write of flow on device failed.", throwable);
+ }
+ });
+ }
+
+ //TODO move to separate test util class
+ private final static Flow readFlow(InstanceIdentifier<Flow> flow) {
+ Flow searchedFlow = null;
+ ReadTransaction rt = dataBroker.newReadOnlyTransaction();
+ CheckedFuture<Optional<Flow>, ReadFailedException> flowFuture =
+ rt.read(LogicalDatastoreType.CONFIGURATION, flow);
+
+ try {
+ Optional<Flow> maybeFlow = flowFuture.checkedGet(500, TimeUnit.SECONDS);
+ if(maybeFlow.isPresent()) {
+ searchedFlow = maybeFlow.get();
+ }
+ } catch (TimeoutException e) {
+ LOG.error("Future timed out. Getting FLOW from DataStore failed.", e);
+ } catch (ReadFailedException e) {
+ LOG.error("Something wrong happened in DataStore. Getting FLOW for userId {} failed.", e);
+ }
+
+ return searchedFlow;
+ }
+}
import javax.inject.Inject;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
private static final Logger LOG = LoggerFactory
.getLogger(OFPluginToLibraryTest.class);
- private static final ArrayBlockingQueue<Runnable> SCENARIO_POOL_QUEUE = new ArrayBlockingQueue<>(1);
+ private final ArrayBlockingQueue<Runnable> SCENARIO_POOL_QUEUE = new ArrayBlockingQueue<>(1);
@Inject @Filter(timeout=20000)
OpenflowPluginProvider openflowPluginProvider;
@Before
public void setUp() throws InterruptedException {
LOG.debug("openflowPluginProvider: "+openflowPluginProvider);
+ switchSim = createSimpleClient();
scenarioPool = new ThreadPoolLoggingExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, SCENARIO_POOL_QUEUE, "scenario");
- //FIXME: plugin should provide service exposing startup result via future
- Thread.sleep(5000);
}
/**
*/
@After
public void tearDown() {
- try {
- LOG.debug("tearing down simulator");
- switchSim.getScenarioDone().get(getFailSafeTimeout(), TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- String msg = "waiting for scenario to finish failed: "+e.getMessage();
- LOG.error(msg, e);
- Assert.fail(msg);
- } finally {
- scenarioPool.shutdownNow();
- SCENARIO_POOL_QUEUE.clear();
- }
-
- try {
- LOG.debug("checking if simulator succeeded to connect to controller");
- boolean simulatorWasOnline = switchSim.getIsOnlineFuture().get(100, TimeUnit.MILLISECONDS);
- Assert.assertTrue("simulator failed to connect to controller", simulatorWasOnline);
- } catch (Exception e) {
- String message = "simulator probably failed to connect to controller";
- LOG.error(message, e);
- Assert.fail(message);
- }
+ SimulatorAssistant.waitForSwitchSimulatorOn(switchSim);
+ SimulatorAssistant.tearDownSwitchSimulatorAfterScenario(switchSim, scenarioPool, getFailSafeTimeout());
}
/**
public void handshakeOk1() throws Exception {
LOG.debug("handshakeOk1 integration test");
- switchSim = createSimpleClient();
switchSim.setSecuredClient(false);
Deque<ClientEvent> handshakeScenario = ScenarioFactory.createHandshakeScenarioVBM(
- ScenarioFactory.VERSION_BITMAP_13, (short) 0, ScenarioFactory.VERSION_BITMAP_10_13);
+ ScenarioFactory.VERSION_BITMAP_13, (short) 0, ScenarioFactory.VERSION_BITMAP_10_13, true);
ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
switchSim.setScenarioHandler(scenario);
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
-import org.junit.Assert;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.opendaylight.controller.test.sal.binding.it.TestHelper;
import org.opendaylight.openflowjava.protocol.impl.clients.ScenarioHandler;
import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient;
+import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorUpdated;
@RunWith(PaxExam.class)
public class SalIntegrationTest {
- private static final Logger LOG = LoggerFactory.getLogger(SalIntegrationTest.class);
+ static final Logger LOG = LoggerFactory.getLogger(SalIntegrationTest.class);
+ private final ArrayBlockingQueue<Runnable> SCENARIO_POOL_QUEUE = new ArrayBlockingQueue<>(1);
+ private ThreadPoolLoggingExecutor scenarioPool;
+ private SimpleClient switchSim;
+ private Runnable finalCheck;
+
@Inject
BundleContext ctx;
/**
* @return timeout for case of failure
*/
- private static long getFailSafeTimeout() {
+ static long getFailSafeTimeout() {
return 30000;
}
*/
@Before
public void setUp() throws InterruptedException {
- //FIXME: plugin should provide service exposing startup result via future
- Thread.sleep(6000);
+ switchSim = new SimpleClient("localhost", 6653);
+ scenarioPool = new ThreadPoolLoggingExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, SCENARIO_POOL_QUEUE, "scenario");
}
-
+
+ /**
+ * test tear down
+ */
+ @After
+ public void tearDown() {
+ SimulatorAssistant.waitForSwitchSimulatorOn(switchSim);
+ SimulatorAssistant.tearDownSwitchSimulatorAfterScenario(switchSim, scenarioPool, getFailSafeTimeout());
+
+ if (finalCheck != null) {
+ LOG.info("starting final check");
+ finalCheck.run();
+ }
+ }
+
/**
* test basic integration with OFLib running the handshake
*
LOG.debug("handshake integration test");
LOG.debug("openflowPluginProvider: " + openflowPluginProvider);
- SimpleClient switchSim = new SimpleClient("localhost", 6653);
switchSim.setSecuredClient(false);
ScenarioHandler scenario = new ScenarioHandler(ScenarioFactory.createHandshakeScenarioVBM(
- ScenarioFactory.VERSION_BITMAP_13, (short) 0, ScenarioFactory.VERSION_BITMAP_10_13));
+ ScenarioFactory.VERSION_BITMAP_13, (short) 0, ScenarioFactory.VERSION_BITMAP_10_13, true));
switchSim.setScenarioHandler(scenario);
- switchSim.run();
-
- try {
- LOG.debug("tearing down simulator");
- switchSim.getScenarioDone().get(getFailSafeTimeout(), TimeUnit.MILLISECONDS);
- } catch (Exception e) {
- String msg = "waiting for scenario to finish failed: "+e.getMessage();
- LOG.error(msg, e);
- Assert.fail(msg);
- }
-
- try {
- LOG.debug("checking if simulator succeeded to connect to controller");
- boolean simulatorWasOnline = switchSim.getIsOnlineFuture().get(100, TimeUnit.MILLISECONDS);
- Assert.assertTrue("simulator failed to connect to controller", simulatorWasOnline);
- } catch (Exception e) {
- String message = "simulator probably failed to connect to controller";
- LOG.error(message, e);
- Assert.fail(message);
- }
-
- Thread.sleep(1000);
- assertEquals(1, listener.nodeUpdated.size());
- assertNotNull(listener.nodeUpdated.get(0));
+ scenarioPool.execute(switchSim);
+
+ finalCheck = new Runnable() {
+ @Override
+ public void run() {
+ assertEquals(1, listener.nodeUpdated.size());
+ assertNotNull(listener.nodeUpdated.get(0));
+ }
+ };
}
/**
*/
public abstract class ScenarioFactory {
+ /** default sleep time [ms] - at scenario end */
+ public static final int DEFAULT_SCENARIO_SLEEP = 2000;
/** version bitmap hex-string containing version 1.3 */
public static final String VERSION_BITMAP_13 = "00 01 00 08 00 00 00 10";
/** version bitmap hex-string containing versions: 1.0 + 1.3 */
* @param switchVersionBitmap
* @param auxId
* @param pluginVersionBitmap
+ * @param addSleep if true - then add final sleep {@link #DEFAULT_SCENARIO_SLEEP}
* @return stack filled with Handshake messages
*/
public static Deque<ClientEvent> createHandshakeScenarioVBM(
- String switchVersionBitmap, short auxId, String pluginVersionBitmap) {
+ String switchVersionBitmap, short auxId, String pluginVersionBitmap, boolean addSleep) {
Deque<ClientEvent> stack = new ArrayDeque<>();
stack.addFirst(new SendEvent(ByteBufUtils
+ "00 01 02 03 04 05 06 07 " + "00 01 02 03 01 "
+ Integer.toHexString(auxId)
+ " 00 00 00 01 02 03 00 01 02 03")));
- addSleep(stack);
+
+ if (addSleep) {
+ addSleep(stack);
+ }
+
return stack;
}
-
+
+ /**
+ * @param stack
+ * @param addSleep if true - then add final sleep {@link #DEFAULT_SCENARIO_SLEEP}
+ * @return
+ */
+ public static Deque<ClientEvent> appendPostHandshakeScenario(Deque<ClientEvent> stack, boolean addSleep) {
+ stack.addFirst(new WaitForMessageEvent(ByteBufUtils
+ .hexStringToBytes("04 12 00 10 00 00 00 01 "+
+ "00 0d 00 00 00 00 00 00" )));
+ stack.addFirst(new WaitForMessageEvent(ByteBufUtils
+ .hexStringToBytes("04 12 00 10 00 00 00 02 "+
+ "00 08 00 00 00 00 00 00" )));
+ stack.addFirst(new WaitForMessageEvent(ByteBufUtils
+ .hexStringToBytes("04 12 00 10 00 00 00 03 "+
+ "00 0b 00 00 00 00 00 00" )));
+ stack.addFirst(new WaitForMessageEvent(ByteBufUtils
+ .hexStringToBytes("04 12 00 10 00 00 00 04 "+
+ "00 00 00 00 00 00 00 00" )));
+
+ if (addSleep) {
+ addSleep(stack);
+ }
+
+ return stack;
+ }
+
/**
* @param stack
*/
private static void addSleep(Deque<ClientEvent> stack) {
- stack.addFirst(new SleepEvent(2000));
+ stack.addFirst(new SleepEvent(DEFAULT_SCENARIO_SLEEP));
}
/**
--- /dev/null
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.openflowplugin.openflow.md.it;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.junit.Assert;
+import org.opendaylight.openflowjava.protocol.impl.clients.SimpleClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public abstract class SimulatorAssistant {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(SimulatorAssistant.class);
+
+ /**
+ * @param switchSim
+ * @throws InterruptedException
+ */
+ public static void waitForSwitchSimulatorOn(SimpleClient switchSim) {
+ try {
+ switchSim.getIsOnlineFuture().get(6, TimeUnit.SECONDS); // intentionally ignoring future inner value
+ } catch (TimeoutException | ExecutionException | InterruptedException e) {
+ LOG.error("failed to start switch simulator: {}", e.getMessage(), e);
+ Assert.fail("failed to start switch simulator");
+ }
+ }
+
+ /**
+ * @param switchSim
+ * @param scenarioPool
+ * @param failsafeTimeout
+ */
+ public static void tearDownSwitchSimulatorAfterScenario(SimpleClient switchSim, ThreadPoolExecutor scenarioPool, long failsafeTimeout) {
+ try {
+ LOG.debug("tearing down simulator");
+ switchSim.getScenarioDone().get(failsafeTimeout, TimeUnit.MILLISECONDS);
+ } catch (Exception e) {
+ String msg = "waiting for scenario to finish failed: "+e.getMessage();
+ LOG.error(msg, e);
+ Assert.fail(msg);
+ } finally {
+ scenarioPool.shutdownNow();
+ scenarioPool.purge();
+ }
+
+ try {
+ LOG.debug("checking if simulator succeeded to connect to controller");
+ boolean simulatorWasOnline = switchSim.getIsOnlineFuture().get(100, TimeUnit.MILLISECONDS);
+ Assert.assertTrue("simulator failed to connect to controller", simulatorWasOnline);
+ } catch (Exception e) {
+ String message = "simulator probably failed to connect to controller";
+ LOG.error(message, e);
+ Assert.fail(message);
+ }
+ }
+
+}
package org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.match;
+import static org.opendaylight.openflowjava.util.ByteBufUtils.macAddressToString;
+
import com.google.common.base.Optional;
import com.google.common.base.Splitter;
import java.math.BigInteger;
}
} else if (ofMatch.getOxmMatchField().equals(EthSrc.class)) {
MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
+ final MaskMatchEntry sourceMask = ofMatch.getAugmentation(MaskMatchEntry.class);
if (macAddressMatchEntry != null) {
EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
ethSourceBuilder.setAddress(macAddressMatchEntry.getMacAddress());
+ if (sourceMask != null) {
+ ethSourceBuilder.setMask(new MacAddress(macAddressToString(sourceMask.getMask())));
+ }
ethMatchBuilder.setEthernetSource(ethSourceBuilder.build());
matchBuilder.setEthernetMatch(ethMatchBuilder.build());
}
} else if (ofMatch.getOxmMatchField().equals(EthDst.class)) {
MacAddressMatchEntry macAddressMatchEntry = ofMatch.getAugmentation(MacAddressMatchEntry.class);
+ final MaskMatchEntry destinationMask = ofMatch.getAugmentation(MaskMatchEntry.class);
if (macAddressMatchEntry != null) {
EthernetDestinationBuilder ethDestinationBuilder = new EthernetDestinationBuilder();
ethDestinationBuilder.setAddress(macAddressMatchEntry.getMacAddress());
+ if (destinationMask != null) {
+ ethDestinationBuilder.setMask(new MacAddress(macAddressToString(destinationMask.getMask())));
+ }
ethMatchBuilder.setEthernetDestination(ethDestinationBuilder.build());
matchBuilder.setEthernetMatch(ethMatchBuilder.build());
}
QueueKeeper<V> queueKeeper) {
AutoCloseable registration = sourceRegistrator.registerMessageSource(queueKeeper);
queueKeeper.setPollRegistration(registration);
+ sourceRegistrator.getHarvesterHandle().ping();
}
}
macAddressBuilder.setMacAddress(new MacAddress("00:00:00:00:00:01"));\r
entriesBuilder.addAugmentation(MacAddressMatchEntry.class, macAddressBuilder.build());\r
maskBuilder = new MaskMatchEntryBuilder();\r
- maskBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 2});\r
+ maskBuilder.setMask(new byte[]{0, 0, 0, 0, 1, 1});\r
entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
entries.add(entriesBuilder.build());\r
entriesBuilder = new MatchEntriesBuilder();\r
macAddressBuilder.setMacAddress(new MacAddress("00:00:00:00:00:02"));\r
entriesBuilder.addAugmentation(MacAddressMatchEntry.class, macAddressBuilder.build());\r
maskBuilder = new MaskMatchEntryBuilder();\r
- maskBuilder.setMask(new byte[]{0, 0, 0, 0, 0, 3});\r
+ maskBuilder.setMask(new byte[]{0, 0, 0, 0, 2, 2});\r
entriesBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
entries.add(entriesBuilder.build());\r
entriesBuilder = new MatchEntriesBuilder();\r
Assert.assertEquals("Wrong metadata mask", new BigInteger(1, new byte[]{0, 0, 0, 0, 0, 0, 0, 1}),\r
builtMatch.getMetadata().getMetadataMask());\r
Assert.assertEquals("Wrong eth dst", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getAddress());\r
-// Assert.assertEquals("Wrong eth dst mask", new MacAddress("00:00:00:00:00:01"), builtMatch.getEthernetMatch().getEthernetDestination().getMask());\r
+ Assert.assertEquals("Wrong eth dst mask", new MacAddress("00:00:00:00:01:01"), builtMatch.getEthernetMatch().getEthernetDestination().getMask());\r
Assert.assertEquals("Wrong eth src", new MacAddress("00:00:00:00:00:02"), builtMatch.getEthernetMatch().getEthernetSource().getAddress());\r
-// Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:00:03"), builtMatch.getEthernetMatch().getEthernetSource().getMask());\r
+ Assert.assertEquals("Wrong eth src mask", new MacAddress("00:00:00:00:02:02"), builtMatch.getEthernetMatch().getEthernetSource().getMask());\r
Assert.assertEquals("Wrong vlan id", 4, builtMatch.getVlanMatch().getVlanId().getVlanId().getValue().intValue());\r
Assert.assertEquals("Wrong vlan id entries", true, builtMatch.getVlanMatch().getVlanId().isVlanIdPresent());\r
Ipv4Match ipv4Match = (Ipv4Match) builtMatch.getLayer3Match();\r
<artifactId>nagasena-rta</artifactId>
<version>${exi.nagasena.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller.thirdparty</groupId>
- <artifactId>ganymed</artifactId>
- <version>1.2.0-SNAPSHOT</version>
- </dependency>
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<groupId>org.opendaylight.controller.model</groupId>
<artifactId>model-inventory</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.openflowjava</groupId>
+ <artifactId>util</artifactId>
+ </dependency>
</dependencies>
<build>
*/
package org.opendaylight.openflowplugin.testcommon;
+import static org.opendaylight.openflowjava.util.ByteBufUtils.macAddressToString;
+
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
-
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
abstract class AbstractDropTest implements PacketProcessingListener, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(AbstractDropTest.class);
- private static final AtomicIntegerFieldUpdater<AbstractDropTest> SENT_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "_sent");
- private volatile int _sent;
+ protected static final Integer PRIORITY = 4;
+ protected static final Long BUFFER_ID = 0L;
+ protected static final Integer HARD_TIMEOUT = 300;
+ protected static final Integer IDLE_TIMEOUT = 240;
+ protected static final short TABLE_ID = 0;
+
+ private static final AtomicIntegerFieldUpdater<AbstractDropTest> SENT_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "sent");
+ private volatile int sent;
- private static final AtomicIntegerFieldUpdater<AbstractDropTest> RCVD_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "_rcvd");
- private volatile int _rcvd;
+ private static final AtomicIntegerFieldUpdater<AbstractDropTest> RCVD_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "rcvd");
+ private volatile int rcvd;
- private static final AtomicIntegerFieldUpdater<AbstractDropTest> EXCS_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "_excs");
- private volatile int _excs;
+ private static final AtomicIntegerFieldUpdater<AbstractDropTest> EXCS_UPDATER = AtomicIntegerFieldUpdater.newUpdater(AbstractDropTest.class, "excs");
+ private volatile int excs;
public final DropTestStats getStats() {
- return new DropTestStats(this._sent, this._rcvd, this._excs);
+ return new DropTestStats(this.sent, this.rcvd, this.excs);
}
public final void clearStats(){
- this._sent = 0;
- this._rcvd = 0;
- this._excs = 0;
+ this.sent = 0;
+ this.rcvd = 0;
+ this.excs = 0;
}
@Override
try {
final byte[] rawPacket = notification.getPayload();
-
- // LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} payload {}",
- // nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(rawPacket));
-
final byte[] srcMac = Arrays.copyOfRange(rawPacket, 6, 12);
- //LOG.debug("onPacketReceived - received Packet on Node {} and NodeConnector {} srcMac {}",
- // nodeKey.getId(), ncKey.getId(), Hex.encodeHexString(srcMac));
-
final MatchBuilder match = new MatchBuilder();
final EthernetMatchBuilder ethernetMatch = new EthernetMatchBuilder();
final EthernetSourceBuilder ethSourceBuilder = new EthernetSourceBuilder();
//TODO: use HEX, use binary form
//Hex.decodeHex("000000000001".toCharArray());
- ethSourceBuilder.setAddress(new MacAddress(DropTestUtils.macToString(srcMac)));
+ ethSourceBuilder.setAddress(new MacAddress(macAddressToString(srcMac)));
ethernetMatch.setEthernetSource(ethSourceBuilder.build());
match.setEthernetMatch(ethernetMatch.build());
import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicLong;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.slf4j.LoggerFactory;
/**
- * provides cbench responder behavior: upon packetIn arrival addFlow action is sent out to
+ * provides cbench responder behavior: upon packetIn arrival addFlow action is sent out to
* device using dataStore strategy (FRM involved)
*/
public class DropTestCommiter extends AbstractDropTest {
- private final static Logger LOG = LoggerFactory.getLogger(DropTestCommiter.class);
-
+ private static final Logger LOG = LoggerFactory.getLogger(DropTestCommiter.class);
+
private DataBroker dataService;
-
- private static final AtomicLong idCounter = new AtomicLong();
+
+ private static final AtomicLong ID_COUNTER = new AtomicLong();
private static final ThreadLocal<FlowBuilder> BUILDER = new ThreadLocal<FlowBuilder>() {
@Override
protected FlowBuilder initialValue() {
final FlowBuilder fb = new FlowBuilder();
- fb.setPriority(4);
- fb.setBufferId(0L);
+ fb.setPriority(PRIORITY);
+ fb.setBufferId(BUFFER_ID);
final FlowCookie cookie = new FlowCookie(BigInteger.TEN);
fb.setCookie(cookie);
fb.setCookieMask(cookie);
- fb.setTableId((short) 0);
- fb.setHardTimeout(300);
- fb.setIdleTimeout(240);
+ fb.setTableId(TABLE_ID);
+ fb.setHardTimeout(HARD_TIMEOUT);
+ fb.setIdleTimeout(IDLE_TIMEOUT);
fb.setFlags(new FlowModFlags(false, false, false, false, false));
return fb;
}
private NotificationProviderService notificationService;
private ListenerRegistration<NotificationListener> notificationRegistration;
-
+
/**
* start listening on packetIn
*/
public void start() {
notificationRegistration = notificationService.registerNotificationListener(this);
}
-
+
/**
* @param dataService the dataService to set
*/
final FlowBuilder fb = BUILDER.get();
fb.setMatch(match);
fb.setInstructions(instructions);
- fb.setId(new FlowId(String.valueOf(fb.hashCode()) +"."+ String.valueOf(idCounter.getAndIncrement())));
-
+ fb.setId(new FlowId(String.valueOf(fb.hashCode()) +"."+ ID_COUNTER.getAndIncrement()));
+
// Construct the flow instance id
final InstanceIdentifier<Flow> flowInstanceId =
- InstanceIdentifier.builder(Nodes.class) // File under nodes
- .child(Node.class, node) // A particular node identified by nodeKey
- .augmentation(FlowCapableNode.class) // That is flow capable, only FlowCapableNodes have tables
- .child(Table.class, new TableKey((short) 0)) // In the table identified by TableKey
- .child(Flow.class, new FlowKey(fb.getId())) // A flow identified by flowKey
+ // File under nodes
+ InstanceIdentifier.builder(Nodes.class)
+ // A particular node identified by nodeKey
+ .child(Node.class, node)
+ // That is flow capable, only FlowCapableNodes have tables
+ .augmentation(FlowCapableNode.class)
+ // In the table identified by TableKey
+ .child(Table.class, new TableKey((short) 0))
+ // A flow identified by flowKey
+ .child(Flow.class, new FlowKey(fb.getId()))
.build();
final Flow flow = fb.build();
transaction.submit();
LOG.debug("onPacketReceived - About to write flow commited");
}
-
+
@Override
public void close() {
try {
* provides activation and deactivation of drop responder service - responds on packetIn
*/
public class DropTestDsProvider implements AutoCloseable {
- private final static Logger LOG = LoggerFactory.getLogger(DropTestDsProvider.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DropTestDsProvider.class);
private DataBroker dataService;
private NotificationProviderService notificationService;
active = false;
}
}
-
+
/**
* @return the active
*/
* provides activation and deactivation of drop responder service - responds on packetIn
*/
public class DropTestRpcProvider implements AutoCloseable {
- private final static Logger LOG = LoggerFactory.getLogger(DropTestDsProvider.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DropTestDsProvider.class);
private SalFlowService flowService;
private NotificationProviderService notificationService;
active = false;
}
}
-
+
/**
* @return the active
*/
*/
package org.opendaylight.openflowplugin.testcommon;
-import java.math.BigInteger;
+import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.BUFFER_ID;
+import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.HARD_TIMEOUT;
+import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.IDLE_TIMEOUT;
+import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.PRIORITY;
+import static org.opendaylight.openflowplugin.testcommon.AbstractDropTest.TABLE_ID;
+import java.math.BigInteger;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
import org.slf4j.LoggerFactory;
/**
- * provides cbench responder behavior: upon packetIn arrival addFlow action is sent out to
+ * provides cbench responder behavior: upon packetIn arrival addFlow action is sent out to
* device using {@link SalFlowService} strategy
*/
public class DropTestRpcSender extends AbstractDropTest {
- private final static Logger LOG = LoggerFactory.getLogger(DropTestRpcSender.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DropTestRpcSender.class);
private SalFlowService flowService;
-
+
/**
* @param flowService the flowService to set
*/
protected AddFlowInputBuilder initialValue() {
final AddFlowInputBuilder fb = new AddFlowInputBuilder();
- fb.setPriority(4);
- fb.setBufferId(0L);
+ fb.setPriority(PRIORITY);
+ fb.setBufferId(BUFFER_ID);
final FlowCookie cookie = new FlowCookie(BigInteger.TEN);
fb.setCookie(cookie);
fb.setCookieMask(cookie);
- fb.setTableId((short) 0);
- fb.setHardTimeout(300);
- fb.setIdleTimeout(240);
+ fb.setTableId(TABLE_ID);
+ fb.setHardTimeout(HARD_TIMEOUT);
+ fb.setIdleTimeout(IDLE_TIMEOUT);
fb.setFlags(new FlowModFlags(false, false, false, false, false));
return fb;
private NotificationProviderService notificationService;
private ListenerRegistration<NotificationListener> notificationRegistration;
-
+
/**
* start listening on packetIn
*/
// Construct the flow instance id
final InstanceIdentifier<Node> flowInstanceId = InstanceIdentifier
- .builder(Nodes.class) // File under nodes
- .child(Node.class, node).build(); // A particular node identified by nodeKey
+ // File under nodes
+ .builder(Nodes.class)
+ // A particular node identified by nodeKey
+ .child(Node.class, node).build();
fb.setNode(new NodeRef(flowInstanceId));
// Add flow
public void setNotificationService(NotificationProviderService notificationService) {
this.notificationService = notificationService;
}
-
+
@Override
public void close() {
try {
package org.opendaylight.openflowplugin.testcommon;
public class DropTestStats {
- private final int _rcvd;
- private final int _sent;
- private final int _excs;
- private final String _message;
-
- public DropTestStats(int sent, int rcvd) {
- this._sent = sent;
- this._rcvd = rcvd;
- this._excs = 0;
- this._message = null;
- }
-
- public DropTestStats(int sent, int rcvd, int excs) {
- this._sent = sent;
- this._rcvd = rcvd;
- this._excs = excs;
- this._message = null;
- }
-
- public DropTestStats(String message) {
- this._sent = -1;
- this._rcvd = -1;
- this._excs = -1;
- this._message = message;
- }
-
- public int getSent() { return this._sent; }
- public int getRcvd() { return this._rcvd; }
- public String getMessage() { return this._message; };
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
- if (this._message == null) {
- result.append("Rcvd: " + this._rcvd);
- result.append(", Sent: " + this._sent);
- result.append("; Exceptions: " + this._excs);
- } else {
- result.append(this._message);
- }
-
- return result.toString();
- }
-
+ private final int rcvd;
+ private final int sent;
+ private final int excs;
+ private final String message;
+
+ public DropTestStats(int sent, int rcvd) {
+ this.sent = sent;
+ this.rcvd = rcvd;
+ this.excs = 0;
+ this.message = null;
+ }
+
+ public DropTestStats(int sent, int rcvd, int excs) {
+ this.sent = sent;
+ this.rcvd = rcvd;
+ this.excs = excs;
+ this.message = null;
+ }
+
+ public DropTestStats(String message) {
+ this.sent = -1;
+ this.rcvd = -1;
+ this.excs = -1;
+ this.message = message;
+ }
+
+ public int getSent() { return this.sent; }
+ public int getRcvd() { return this.rcvd; }
+ public String getMessage() { return this.message; }
+
+ @Override
+ public String toString() {
+ StringBuilder result = new StringBuilder();
+ if (this.message == null) {
+ result.append("Rcvd: ");
+ result.append(this.rcvd);
+ result.append(", Sent: ");
+ result.append(this.sent);
+ result.append("; Exceptions: ");
+ result.append(this.excs);
+ } else {
+ result.append(this.message);
+ }
+
+ return result.toString();
+ }
+
}
+++ /dev/null
-/**
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.openflowplugin.testcommon;
-
-import com.google.common.base.Preconditions;
-import com.google.common.primitives.UnsignedBytes;
-
-public class DropTestUtils {
- private static final char[] HEX = "0123456789ABCDEF".toCharArray();
-
- private static final void appendByte(final StringBuilder sb, final byte b) {
- int v = UnsignedBytes.toInt(b);
- sb.append(HEX[v >>> 4]);
- sb.append(HEX[v & 15]);
- }
-
- public static String macToString(final byte[] mac) {
- Preconditions.checkArgument(mac.length == 6);
-
- final StringBuilder sb = new StringBuilder(17);
- appendByte(sb, mac[0]);
-
- for (int i = 1; i < mac.length; i++) {
- sb.append(':');
- appendByte(sb, mac[i]);
- }
-
- return sb.toString();
- }
-}