<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>
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);
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));
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));
+ }
+ };
}
/**
--- /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());
}
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>