import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import java.util.Stack;
+import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
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.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.OpenflowPluginProvider;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
private static final Logger LOG = LoggerFactory
.getLogger(OFPluginToLibraryTest.class);
+ private static final ArrayBlockingQueue<Runnable> SCENARIO_POOL_QUEUE = new ArrayBlockingQueue<>(1);
+
@Inject @Filter(timeout=20000)
OpenflowPluginProvider openflowPluginProvider;
BundleContext ctx;
private SimpleClient switchSim;
+ private ThreadPoolLoggingExecutor scenarioPool;
/**
* test setup
@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);
}
String msg = "waiting for scenario to finish failed: "+e.getMessage();
LOG.error(msg, e);
Assert.fail(msg);
+ } finally {
+ scenarioPool.shutdownNow();
+ SCENARIO_POOL_QUEUE.clear();
}
- //TODO: dump errors of plugin (by exploiting ErrorHandler)
-
try {
LOG.debug("checking if simulator succeeded to connect to controller");
boolean simulatorWasOnline = switchSim.getIsOnlineFuture().get(100, TimeUnit.MILLISECONDS);
ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
switchSim.setScenarioHandler(scenario);
- switchSim.run();
+ scenarioPool.execute(switchSim);
}
/**
ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
switchSim.setScenarioHandler(scenario);
- switchSim.run();
+ scenarioPool.execute(switchSim);
}
/**
ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
switchSim.setScenarioHandler(scenario);
- switchSim.run();
+ scenarioPool.execute(switchSim);
}
/**
ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
switchSim.setScenarioHandler(scenario);
- switchSim.run();
+ scenarioPool.execute(switchSim);
}
/**
ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
switchSim.setScenarioHandler(scenario);
- switchSim.run();
+ scenarioPool.execute(switchSim);
}
/**
ScenarioHandler scenario = new ScenarioHandler(handshakeScenario);
switchSim.setScenarioHandler(scenario);
- switchSim.run();
+ scenarioPool.execute(switchSim);
}
/**
+ " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+ " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"
+ " 00 00")));
- stack.add(0, new WaitForMessageEvent(ByteBufUtils
- .hexStringToBytes("01 05 00 08 00 00 01 69")));
-
- stack.add(0, new SendEvent(
- ByteBufUtils
- .hexStringToBytes("01 06 00 80 00 00 01 69 cc 4e 24 1c 4a 00 00 00"
- + " 00 00 01 00 01 00 00 00 00 00 00 07 00 00 01 0f"
- + " 00 61 cc 4e 24 1c 4a 60 65 74 68 33 2f 31 00 00"
- + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
- + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40"
- + " 00 62 cc 4e 24 1c 4a 61 65 74 68 33 2f 32 00 00"
- + " 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 01"
- + " 00 00 01 40 00 00 01 40 00 00 01 40 00 00 01 40")));
stack.add(0, new SleepEvent(5000));