2 * Copyright © 2015 Red Hat, 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.ovsdb.openstack.netvirt.sfc.it;
11 import static org.junit.Assert.assertNotEquals;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertNull;
14 import static org.junit.Assert.assertTrue;
15 import static org.junit.Assert.fail;
16 import static org.ops4j.pax.exam.CoreOptions.composite;
17 import static org.ops4j.pax.exam.CoreOptions.maven;
18 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
19 import static org.ops4j.pax.exam.CoreOptions.propagateSystemProperties;
20 import static org.ops4j.pax.exam.CoreOptions.vmOption;
21 import static org.ops4j.pax.exam.CoreOptions.when;
22 import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
23 import static org.ops4j.pax.exam.MavenUtils.asInProject;
24 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
25 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
26 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
28 import java.io.IOException;
29 import java.util.ArrayList;
30 import java.util.Iterator;
31 import java.util.List;
33 import java.util.Properties;
34 import java.util.concurrent.atomic.AtomicBoolean;
36 import org.junit.After;
37 import org.junit.Assert;
38 import org.junit.Before;
39 import org.junit.Ignore;
40 import org.junit.Test;
41 import org.junit.runner.RunWith;
42 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
43 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
44 import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
45 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
46 import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
47 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
48 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
49 import org.opendaylight.ovsdb.openstack.netvirt.sfc.NshUtils;
50 import org.opendaylight.ovsdb.openstack.netvirt.sfc.SfcUtils;
51 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.RenderedServicePathUtils;
52 import org.opendaylight.ovsdb.openstack.netvirt.sfc.standalone.openflow13.SfcClassifier;
53 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.AclUtils;
54 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.ClassifierUtils;
55 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.NetvirtConfigUtils;
56 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.ServiceFunctionChainUtils;
57 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.ServiceFunctionForwarderUtils;
58 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.ServiceFunctionPathUtils;
59 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.ServiceFunctionUtils;
60 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.SfcConfigUtils;
61 import org.opendaylight.ovsdb.openstack.netvirt.sfc.it.utils.NetvirtSfcUtils;
62 import org.opendaylight.ovsdb.openstack.netvirt.sfc.workaround.services.FlowNames;
63 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
64 import org.opendaylight.ovsdb.utils.it.utils.ItUtils;
65 import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
66 import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
67 import org.opendaylight.ovsdb.utils.mdsal.utils.NotifyingDataChangeListener;
68 import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
69 import org.opendaylight.ovsdb.utils.it.utils.NodeInfo;
70 import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
71 import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
72 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName;
73 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SftType;
74 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInputBuilder;
75 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
76 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
77 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathKey;
78 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.rendered.service.path.RenderedServicePathHop;
79 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
80 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
81 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
82 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder;
83 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChains;
84 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.ServiceFunctionChainsBuilder;
85 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChain;
86 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.ServiceFunctionChainBuilder;
87 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunction;
88 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfc.rev140701.service.function.chain.grouping.service.function.chain.SfcServiceFunctionBuilder;
89 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders;
90 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwardersBuilder;
91 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
92 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
93 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
94 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPathsBuilder;
95 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
96 import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPathBuilder;
97 import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.of.renderer.rev151123.SfcOfRendererConfig;
98 import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.sfc.of.renderer.rev151123.SfcOfRendererConfigBuilder;
99 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
100 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessListsBuilder;
101 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.AclBuilder;
102 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.AccessListEntriesBuilder;
103 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.AceBuilder;
104 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.ActionsBuilder;
105 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.MatchesBuilder;
106 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
107 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
108 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
109 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
110 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
111 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.providers.config.rev160109.NetvirtProvidersConfig;
112 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.providers.config.rev160109.NetvirtProvidersConfigBuilder;
113 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
114 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.ClassifiersBuilder;
115 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.ClassifierBuilder;
116 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.SffsBuilder;
117 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.SffBuilder;
118 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev150105.Sfc;
119 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev150105.SfcBuilder;
120 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
121 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeRef;
122 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.bridge.attributes.ControllerEntry;
123 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo;
124 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
125 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
126 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
127 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
128 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
129 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
130 import org.opendaylight.yangtools.concepts.Builder;
131 import org.opendaylight.yangtools.yang.binding.DataObject;
132 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
133 import org.ops4j.pax.exam.Configuration;
134 import org.ops4j.pax.exam.Option;
135 import org.ops4j.pax.exam.junit.PaxExam;
136 import org.ops4j.pax.exam.karaf.options.LogLevelOption;
137 import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
138 import org.ops4j.pax.exam.options.MavenUrlReference;
139 import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
140 import org.ops4j.pax.exam.spi.reactors.PerClass;
141 import org.slf4j.Logger;
142 import org.slf4j.LoggerFactory;
144 import com.google.common.collect.Maps;
146 @RunWith(PaxExam.class)
147 @ExamReactorStrategy(PerClass.class)
148 public class NetvirtSfcIT extends AbstractMdsalTestBase {
149 private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcIT.class);
150 private static final int MDSAL_TIMEOUT = 10000;
151 private static final int NO_MDSAL_TIMEOUT = 0;
152 private static AclUtils aclUtils = new AclUtils();
153 private static ClassifierUtils classifierUtils = new ClassifierUtils();
154 private static NetvirtSfcUtils netvirtSfcUtils = new NetvirtSfcUtils();
155 private static ServiceFunctionUtils serviceFunctionUtils = new ServiceFunctionUtils();
156 private static ServiceFunctionForwarderUtils serviceFunctionForwarderUtils = new ServiceFunctionForwarderUtils();
157 private static ServiceFunctionChainUtils serviceFunctionChainUtils = new ServiceFunctionChainUtils();
158 private static ServiceFunctionPathUtils serviceFunctionPathUtils = new ServiceFunctionPathUtils();
159 private static RenderedServicePathUtils renderedServicePathUtils = new RenderedServicePathUtils();
160 private static SfcConfigUtils sfcConfigUtils = new SfcConfigUtils();
161 private static NetvirtConfigUtils netvirtConfigUtils = new NetvirtConfigUtils();
162 private static MdsalUtils mdsalUtils;
163 private static AtomicBoolean setup = new AtomicBoolean(false);
164 private static SouthboundUtils southboundUtils;
165 private static SfcUtils sfcUtils;
166 private static String addressStr;
167 private static String portStr;
168 private static String connectionType;
169 private static String controllerStr;
170 private static boolean ovsdb_wait = false;
171 private static String userSpaceEnabled = "no";
172 private static PipelineOrchestrator pipelineOrchestrator;
173 private static Southbound southbound;
174 private static DataBroker dataBroker;
175 private static ItUtils itUtils;
176 public static final String CONTROLLER_IPADDRESS = "ovsdb.controller.address";
177 public static final String SERVER_IPADDRESS = "ovsdbserver.ipaddress";
178 public static final String SERVER_PORT = "ovsdbserver.port";
179 public static final String CONNECTION_TYPE = "ovsdbserver.connection";
180 public static final String CONNECTION_TYPE_ACTIVE = "active";
181 public static final String CONNECTION_TYPE_PASSIVE = "passive";
182 public static final String DEFAULT_SERVER_PORT = "6640";
183 public static final String USERSPACE_ENABLED = "ovsdb.userspace.enabled";
184 public static final String INTEGRATION_BRIDGE_NAME = "br-int";
185 private static final String NETVIRT_TOPOLOGY_ID = "netvirt:1";
186 private static final String OVSDB_TRACE = "ovsdb.trace";
187 private static final String OVSDB_WAIT = "ovsdb.wait";
188 private static final String SF1NAME = "firewall-72";
189 private static final String SF2NAME = "dpi-72";
190 private static final String SF1IP = "10.2.1.1";//"192.168.50.70";//"192.168.120.31";
191 private static final String SF2IP = "10.2.1.2";
192 private static final String SF1DPLNAME = "sf1";
193 private static final String SF2DPLNAME = "sf2";
194 // Use 192.168.50.70 when running against vagrant vm for workaround testing, eg. netvirtsfc-env
195 // Use 192.168.1.129 (or whatever address is dhcp'ed) for tacker-vm
196 // "192.168.50.70"; "127.0.0.1"; "192.168.1.129";
197 private static final String SFF1IP = "192.168.50.70";
198 private static final String SFF2IP = "127.0.0.1";
199 private static final String SFF1NAME = "sff1";
200 private static final String SFF2NAME = "sff2";
201 private static final String SFFDPL1NAME = "vxgpe";
202 private static final String SFFDPL2NAME = "vxgpe";
203 private static final String SN1NAME = "ovsdb1";
204 private static final String SN2NAME = "ovsdb2";
205 private static final String BRIDGE1NAME= "br-int";
206 private static final String BRIDGE2NAME= "br-int";
207 private static final String ACLNAME= "httpAcl";
208 private static final String RULENAME= "httpRule";
209 private static final String SFCNAME = "SFC";
210 private static final String SFCPATH = "SFC-Path";
211 private static final String RSPNAME = SFCPATH + "_rsp";
212 private static final String SFCSF1NAME = "firewall-abstract";
213 private static final SftType SFCSF1TYPE = new SftType("firewall");
214 private static final int GPEUDPPORT = 6633;
217 public String getModuleName() {
218 return "netvirt-sfc-impl";
222 public String getInstanceName() {
223 return "netvirt-sfc-impl";
227 public MavenUrlReference getFeatureRepo() {
229 .groupId("org.opendaylight.ovsdb")
230 .artifactId("openstack.net-virt-sfc-features-test")
231 .classifier("features")
233 .versionAsInProject();
237 public String getFeatureName() {
238 return "odl-ovsdb-sfc-test";
243 public Option[] config() {
244 Option[] parentOptions = super.config();
245 Option[] propertiesOptions = getPropertiesOptions();
246 Option[] otherOptions = getOtherOptions();
247 Option[] options = new Option[parentOptions.length + propertiesOptions.length + otherOptions.length];
248 System.arraycopy(parentOptions, 0, options, 0, parentOptions.length);
249 System.arraycopy(propertiesOptions, 0, options, parentOptions.length, propertiesOptions.length);
250 System.arraycopy(otherOptions, 0, options, parentOptions.length + propertiesOptions.length,
251 otherOptions.length);
255 private Option[] getOtherOptions() {
256 return new Option[] {
258 mavenBundle("org.opendaylight.ovsdb", "utils.mdsal-openflow")
259 .version(asInProject())
261 configureConsole().startLocalConsole(),
262 //vmOption("-verbose:class"),
263 vmOption("-javaagent:../jars/org.jacoco.agent.jar=destfile=../../jacoco-it.exec"),
268 public Option[] getPropertiesOptions() {
269 return new Option[] {
270 propagateSystemProperties(SERVER_IPADDRESS, SERVER_PORT, CONNECTION_TYPE,
271 CONTROLLER_IPADDRESS, OVSDB_TRACE, OVSDB_WAIT, USERSPACE_ENABLED),
276 public Option getLoggingOption() {
278 when(Boolean.getBoolean(OVSDB_TRACE)).useOptions(
279 editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
280 "log4j.logger.org.opendaylight.ovsdb",
281 LogLevelOption.LogLevel.TRACE.name())),
282 //editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
283 // "log4j.logger.org.opendaylight.ovsdb",
284 // LogLevelOption.LogLevel.TRACE.name()),
285 editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
286 "log4j.logger.org.opendaylight.ovsdb.library",
287 LogLevel.INFO.name()),
288 editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
289 logConfiguration(NetvirtSfcIT.class),
290 LogLevel.INFO.name()),
291 editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
292 "log4j.logger.org.opendaylight.ovsdb.openstack.netvirt.sfc",
293 LogLevel.TRACE.name()),
294 editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
295 "log4j.logger.org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13",
296 LogLevel.TRACE.name()),
297 editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
298 "log4j.logger.org.opendaylight.sfc",
299 LogLevel.TRACE.name()),
300 super.getLoggingOption());
303 protected String usage() {
304 return "Integration Test needs a valid connection configuration as follows :\n"
305 + "active connection : mvn -Dovsdbserver.ipaddress=x.x.x.x -Dovsdbserver.port=yyyy verify\n"
306 + "passive connection : mvn -Dovsdbserver.connection=passive verify\n";
309 private void getProperties() {
310 Properties props = System.getProperties();
311 addressStr = props.getProperty(SERVER_IPADDRESS);
312 portStr = props.getProperty(SERVER_PORT, DEFAULT_SERVER_PORT);
313 connectionType = props.getProperty(CONNECTION_TYPE, "active");
314 controllerStr = props.getProperty(CONTROLLER_IPADDRESS, "0.0.0.0");
315 userSpaceEnabled = props.getProperty(USERSPACE_ENABLED, "no");
316 LOG.info("setUp: Using the following properties: mode= {}, ip:port= {}:{}, controller ip: {}, " +
317 "userspace.enabled: {}",
318 connectionType, addressStr, portStr, controllerStr, userSpaceEnabled);
319 if (connectionType.equalsIgnoreCase(CONNECTION_TYPE_ACTIVE)) {
320 if (addressStr == null) {
324 LOG.info("getProperties {}: {}", OVSDB_TRACE, props.getProperty(OVSDB_TRACE));
325 LOG.info("getProperties {}: {}", OVSDB_WAIT, props.getProperty(OVSDB_WAIT));
326 if (props.getProperty(OVSDB_WAIT) != null && props.getProperty(OVSDB_WAIT).equals("true")) {
333 public void setup() {
335 LOG.info("Skipping setUp, already initialized");
342 } catch (Exception e) {
343 LOG.warn("Failed to setup test", e);
344 fail("Failed to setup test: " + e);
349 dataBroker = getDatabroker(getProviderContext());
350 itUtils = new ItUtils(dataBroker);
351 mdsalUtils = new MdsalUtils(dataBroker);
352 assertNotNull("mdsalUtils should not be null", mdsalUtils);
353 southboundUtils = new SouthboundUtils(mdsalUtils);
354 sfcUtils = new SfcUtils(mdsalUtils);
355 assertTrue("Did not find " + NETVIRT_TOPOLOGY_ID, getNetvirtTopology());
356 southbound = (Southbound) ServiceHelper.getGlobalInstance(Southbound.class, this);
357 assertNotNull("southbound should not be null", southbound);
358 pipelineOrchestrator =
359 (PipelineOrchestrator) ServiceHelper.getGlobalInstance(PipelineOrchestrator.class, this);
360 assertNotNull("pipelineOrchestrator should not be null", pipelineOrchestrator);
366 public void teardown() {
370 private ProviderContext getProviderContext() {
371 ProviderContext providerContext = null;
372 for (int i=0; i < 60; i++) {
373 providerContext = getSession();
374 if (providerContext != null) {
379 } catch (InterruptedException e) {
380 LOG.warn("Interrupted while waiting for provider context", e);
384 assertNotNull("providercontext should not be null", providerContext);
385 /* One more second to let the provider finish initialization */
388 } catch (InterruptedException e) {
389 LOG.warn("Interrupted while waiting for other provider", e);
391 return providerContext;
394 private DataBroker getDatabroker(ProviderContext providerContext) {
395 DataBroker dataBroker = providerContext.getSALService(DataBroker.class);
396 assertNotNull("dataBroker should not be null", dataBroker);
400 private Boolean getNetvirtTopology() {
401 LOG.info("getNetvirtTopology: looking for {}...", NETVIRT_TOPOLOGY_ID);
402 Boolean found = false;
403 final TopologyId topologyId = new TopologyId(new Uri(NETVIRT_TOPOLOGY_ID));
404 InstanceIdentifier<Topology> path =
405 InstanceIdentifier.create(NetworkTopology.class).child(Topology.class, new TopologyKey(topologyId));
406 for (int i = 0; i < 60; i++) {
407 Topology topology = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, path);
408 if (topology != null) {
409 LOG.info("getNetvirtTopology: found {}...", NETVIRT_TOPOLOGY_ID);
413 LOG.info("getNetvirtTopology: still looking ({})...", i);
416 } catch (InterruptedException e) {
417 LOG.warn("Interrupted while waiting for {}", NETVIRT_TOPOLOGY_ID, e);
424 private AccessListsBuilder accessListsBuilder() {
425 return accessListsBuilder(false);
428 private AccessListsBuilder accessListsBuilder(boolean renderRsp) {
429 String ruleName = RULENAME;
430 String sfcName = SFCNAME;
431 MatchesBuilder matchesBuilder = aclUtils.matchesBuilder(new MatchesBuilder(), 80);
432 LOG.info("Matches: {}", matchesBuilder.build());
433 ActionsBuilder actionsBuilder = aclUtils.actionsBuilder(new ActionsBuilder(), sfcName, renderRsp);
434 AceBuilder accessListEntryBuilder =
435 aclUtils.aceBuilder(new AceBuilder(), ruleName, matchesBuilder, actionsBuilder);
436 AccessListEntriesBuilder accessListEntriesBuilder =
437 aclUtils.accessListEntriesBuidler(new AccessListEntriesBuilder(), accessListEntryBuilder);
438 AclBuilder accessListBuilder =
439 aclUtils.aclBuilder(new AclBuilder(), ACLNAME, accessListEntriesBuilder);
440 AccessListsBuilder accessListsBuilder =
441 aclUtils.accesslistsbuilder(new AccessListsBuilder(), accessListBuilder);
442 LOG.info("AccessLists: {}", accessListsBuilder.build());
443 return accessListsBuilder;
447 public void testAccessLists() throws InterruptedException {
448 testModel(accessListsBuilder(), AccessLists.class, 0);
451 private ClassifiersBuilder classifiersBuilder() {
452 SffBuilder sffBuilder = classifierUtils.sffBuilder(new SffBuilder(), SFF1NAME);
453 SffsBuilder sffsBuilder = classifierUtils.sffsBuilder(new SffsBuilder(), sffBuilder);
454 ClassifierBuilder classifierBuilder = classifierUtils.classifierBuilder(new ClassifierBuilder(),
455 "classifierName", ACLNAME, sffsBuilder);
456 ClassifiersBuilder classifiersBuilder = classifierUtils.classifiersBuilder(new ClassifiersBuilder(),
458 LOG.info("Classifiers: {}", classifiersBuilder.build());
459 return classifiersBuilder;
463 public void testClassifiers() throws InterruptedException {
464 testModel(classifiersBuilder(), Classifiers.class, 0);
467 private SfcBuilder netvirtSfcBuilder() {
468 return netvirtSfcUtils.sfcBuilder(new SfcBuilder(), "sfc");
472 public void testNetvirtSfcModel() throws InterruptedException {
473 testModel(netvirtSfcBuilder(), Sfc.class, 0);
476 private <T extends DataObject> void testModelPut(Builder<T> builder, Class<T> clazz) {
477 InstanceIdentifier<T> path = InstanceIdentifier.create(clazz);
478 assertTrue(mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, path, builder.build()));
479 T result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
480 assertNotNull(clazz.getSimpleName() + " should not be null", result);
483 private <T extends DataObject> void testModelDelete(Builder<T> builder, Class<T> clazz)
484 throws InterruptedException {
485 InstanceIdentifier<T> path = InstanceIdentifier.create(clazz);
486 assertTrue("Failed to remove " + clazz.getSimpleName(),
487 mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, path));
488 T result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
489 assertNull(clazz.getSimpleName() + " should be null", result);
492 private <T extends DataObject> void testModel(Builder<T> builder, Class<T> clazz, long wait)
493 throws InterruptedException {
494 testModelPut(builder, clazz);
496 testModelDelete(builder, clazz);
499 private <T extends DataObject> void testModel(Builder<T> builder, Class<T> clazz)
500 throws InterruptedException {
501 testModelPut(builder, clazz);
503 testModelDelete(builder, clazz);
506 private ServiceFunctionsBuilder serviceFunctionsBuilder() {
507 String sf1Name = SF1NAME;
508 String sf1Ip = SF1IP;
509 String sff1Name = SFF1NAME;
510 String sf1DplName = SF1DPLNAME;
511 int port = GPEUDPPORT;
513 ServiceFunctionBuilder serviceFunctionBuilder =
514 serviceFunctionUtils.serviceFunctionBuilder(sf1Ip, port, sf1DplName, sff1Name, sf1Name);
515 List<ServiceFunction> serviceFunctionList = serviceFunctionUtils.list(
516 new ArrayList<ServiceFunction>(), serviceFunctionBuilder);
518 ServiceFunctionsBuilder serviceFunctionsBuilder =
519 serviceFunctionUtils.serviceFunctionsBuilder(new ServiceFunctionsBuilder(),
520 serviceFunctionList);
521 LOG.info("ServiceFunctions: {}", serviceFunctionsBuilder.build());
522 return serviceFunctionsBuilder;
525 private ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder() {
526 return serviceFunctionForwardersBuilder(null);
529 private ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder(OvsdbNodeRef ovsdbNodeRef) {
530 String sf1Name = SF1NAME;
531 String sf1Ip = SF1IP;
532 String sf1DplName = SF1DPLNAME;
533 String sff1Ip = SFF1IP;
534 String sff1Name = SFF1NAME;
535 String sffDpl1Name = SFFDPL1NAME;
536 String sn1Name = SN1NAME;
537 String bridge1Name= BRIDGE1NAME;
538 int port = GPEUDPPORT;
540 ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder =
541 serviceFunctionForwarderUtils.serviceFunctionForwarderBuilder(
542 sff1Name, sff1Ip, port, sffDpl1Name, sf1Ip, sn1Name, bridge1Name, sf1Name, sf1DplName,
544 List<ServiceFunctionForwarder> serviceFunctionForwarderList = serviceFunctionForwarderUtils.list(
545 new ArrayList<ServiceFunctionForwarder>(), serviceFunctionForwarderBuilder);
547 ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder =
548 serviceFunctionForwarderUtils.serviceFunctionForwardersBuilder(
549 new ServiceFunctionForwardersBuilder(), serviceFunctionForwarderList);
550 LOG.info("ServiceFunctionForwarders: {}", serviceFunctionForwardersBuilder.build());
551 return serviceFunctionForwardersBuilder;
554 private ServiceFunctionChainsBuilder serviceFunctionChainsBuilder() {
555 String sf1Name = SFCSF1NAME;
556 SftType sfType = SFCSF1TYPE;
557 String sfcName = SFCNAME;
559 SfcServiceFunctionBuilder sfcServiceFunctionBuilder = serviceFunctionChainUtils.sfcServiceFunctionBuilder(
560 new SfcServiceFunctionBuilder(), sf1Name, sfType);
561 List<SfcServiceFunction> sfcServiceFunctionList =
562 serviceFunctionChainUtils.list(new ArrayList<SfcServiceFunction>(), sfcServiceFunctionBuilder);
564 ServiceFunctionChainBuilder serviceFunctionChainBuilder =
565 serviceFunctionChainUtils.serviceFunctionChainBuilder(
566 new ServiceFunctionChainBuilder(), sfcName, false, sfcServiceFunctionList);
567 ServiceFunctionChainsBuilder serviceFunctionChainsBuilder =
568 serviceFunctionChainUtils.serviceFunctionChainsBuilder(
569 new ServiceFunctionChainsBuilder(),
570 serviceFunctionChainUtils.list(new ArrayList<ServiceFunctionChain>(),
571 serviceFunctionChainBuilder));
572 LOG.info("ServiceFunctionChains: {}", serviceFunctionChainBuilder.build());
573 return serviceFunctionChainsBuilder;
576 private ServiceFunctionPathsBuilder serviceFunctionPathsBuilder() {
577 String sfpName = SFCPATH;
578 String sfcName = SFCNAME;
579 short startingIndex = 255;
581 ServiceFunctionPathBuilder serviceFunctionPathBuilder =
582 serviceFunctionPathUtils.serviceFunctionPathBuilder(
583 new ServiceFunctionPathBuilder(), sfpName, sfcName, startingIndex, false);
584 ServiceFunctionPathsBuilder serviceFunctionPathsBuilder =
585 serviceFunctionPathUtils.serviceFunctionPathsBuilder(
586 serviceFunctionPathUtils.list(new ArrayList<ServiceFunctionPath>(),
587 serviceFunctionPathBuilder));
588 LOG.info("ServiceFunctionPaths: {}", serviceFunctionPathsBuilder.build());
589 return serviceFunctionPathsBuilder;
592 private SfcOfRendererConfigBuilder sfcOfRendererConfigBuilder(short tableOffset, short egressTable) {
593 SfcOfRendererConfigBuilder sfcOfRendererConfigBuilder =
594 sfcConfigUtils.sfcOfRendererConfigBuilder(new SfcOfRendererConfigBuilder(), tableOffset, egressTable);
595 LOG.info("SfcOfRendererConfig: {}", sfcOfRendererConfigBuilder.build());
596 return sfcOfRendererConfigBuilder;
599 private NetvirtProvidersConfigBuilder netvirtProvidersConfigBuilder(short tableOffset) {
600 NetvirtProvidersConfigBuilder netvirtProvidersConfigBuilder =
601 netvirtConfigUtils.netvirtProvidersConfigBuilder(new NetvirtProvidersConfigBuilder(), tableOffset);
602 LOG.info("NetvirtProvidersConfig: {}", netvirtProvidersConfigBuilder.build());
603 return netvirtProvidersConfigBuilder;
607 public void testSfcModel() throws InterruptedException {
609 testModel(serviceFunctionsBuilder(), ServiceFunctions.class, timeout);
610 testModel(serviceFunctionForwardersBuilder(), ServiceFunctionForwarders.class, timeout);
611 testModel(serviceFunctionChainsBuilder(), ServiceFunctionChains.class, timeout);
612 testModel(serviceFunctionPathsBuilder(), ServiceFunctionPaths.class, timeout);
616 public void testSfcModels() throws InterruptedException {
617 testModel(serviceFunctionsBuilder(), ServiceFunctions.class);
618 testModel(serviceFunctionForwardersBuilder(), ServiceFunctionForwarders.class);
619 testModel(serviceFunctionChainsBuilder(), ServiceFunctionChains.class);
620 testModel(serviceFunctionPathsBuilder(), ServiceFunctionPaths.class);
622 testModel(accessListsBuilder(), AccessLists.class);
623 testModel(classifiersBuilder(), Classifiers.class);
627 * Test that the NetvirtSfc SfcClassifierService is added to the Netvirt pipeline. The test
628 * sets the table offset and verifies the correct flow is programmed with the offset.
631 public void testNetvirtSfcPipeline() throws InterruptedException {
632 short netvirtTableOffset = 1;
633 testModelPut(netvirtProvidersConfigBuilder(netvirtTableOffset), NetvirtProvidersConfig.class);
635 NodeInfo nodeInfo = itUtils.createNodeInfo(SouthboundUtils.getConnectionInfo(addressStr, portStr), waitList);
638 String flowId = "DEFAULT_PIPELINE_FLOW_" + pipelineOrchestrator.getTable(Service.SFC_CLASSIFIER);
639 verifyFlow(nodeInfo.datapathId, flowId, Service.SFC_CLASSIFIER);
641 nodeInfo.disconnect();
645 * Test the full NetvirtSfc functionality by creating everything needed to realize a chain and
646 * then verify all flows have been created.
647 * NOTE: This test requires an OVS with the NSH v8 patch, otherwise it will fail miserably.
648 * @throws InterruptedException
651 public void testNetvirtSfcAll() throws Exception {
652 if (userSpaceEnabled.equals("yes")) {
653 LOG.info("testNetvirtSfcAll: skipping test because userSpaceEnabled {}", userSpaceEnabled);
657 String sfpName = SFCPATH;
658 String sfcName = SFCNAME;
659 short startingIndex = 255;
661 short netvirtTableOffset = 1;
662 testModelPut(netvirtProvidersConfigBuilder(netvirtTableOffset), NetvirtProvidersConfig.class);
663 short sfcTableoffset = 150;
664 short egressTable = pipelineOrchestrator.getTable(Service.SFC_CLASSIFIER);
665 testModelPut(sfcOfRendererConfigBuilder(sfcTableoffset, egressTable), SfcOfRendererConfig.class);
667 NodeInfo nodeInfo = itUtils.createNodeInfo(SouthboundUtils.getConnectionInfo(addressStr, portStr), waitList);
670 String flowId = "DEFAULT_PIPELINE_FLOW_" + pipelineOrchestrator.getTable(Service.SFC_CLASSIFIER);
671 verifyFlow(nodeInfo.datapathId, flowId, Service.SFC_CLASSIFIER);
673 Map<String, String> externalIds = Maps.newHashMap();
674 externalIds.put("attached-mac", "f6:00:00:0f:00:01");
675 southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, SF1DPLNAME, "internal", null, externalIds);
677 externalIds.put("attached-mac", "f6:00:00:0c:00:01");
678 southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, "vm1", "internal");
680 externalIds.put("attached-mac", "f6:00:00:0c:00:02");
681 southboundUtils.addTerminationPoint(nodeInfo.bridgeNode, "vm2", "internal");
683 InstanceIdentifier<TerminationPoint> tpIid =
684 southboundUtils.createTerminationPointInstanceIdentifier(nodeInfo.bridgeNode, SFFDPL1NAME);
685 final NotifyingDataChangeListener portOperationalListener =
686 new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, tpIid, waitList);
687 portOperationalListener.registerDataChangeListener(dataBroker);
689 InstanceIdentifier<RenderedServicePath> rspIid = sfcUtils.getRspId(RSPNAME);
690 final NotifyingDataChangeListener rspOperationalListener =
691 new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, rspIid, waitList);
692 rspOperationalListener.registerDataChangeListener(dataBroker);
694 OvsdbBridgeAugmentation bridgeAugmentation = southbound.extractBridgeAugmentation(nodeInfo.bridgeNode);
695 OvsdbNodeRef ovsdbNodeRef = null;
696 if (bridgeAugmentation != null) {
697 ovsdbNodeRef = bridgeAugmentation.getManagedBy();
700 testModelPut(serviceFunctionsBuilder(), ServiceFunctions.class);
701 testModelPut(serviceFunctionForwardersBuilder(ovsdbNodeRef), ServiceFunctionForwarders.class);
702 testModelPut(serviceFunctionChainsBuilder(), ServiceFunctionChains.class);
703 testModelPut(serviceFunctionPathsBuilder(), ServiceFunctionPaths.class);
705 testModelPut(accessListsBuilder(false), AccessLists.class);
706 testModelPut(classifiersBuilder(), Classifiers.class);
707 ServiceFunctionPathBuilder serviceFunctionPathBuilder =
708 serviceFunctionPathUtils.serviceFunctionPathBuilder(
709 new ServiceFunctionPathBuilder(), sfpName, sfcName, startingIndex, false);
710 SfcProviderRenderedPathAPI.createRenderedServicePathAndState(serviceFunctionPathBuilder.build(),
711 renderedServicePathUtils.createRenderedPathInputBuilder(new CreateRenderedPathInputBuilder(),
712 SFCPATH, RSPNAME).build());
714 portOperationalListener.waitForCreation();
715 long vxGpeOfPort = southbound.getOFPort(nodeInfo.bridgeNode, SFFDPL1NAME);
716 assertNotEquals("vxGpePort was not found", 0, vxGpeOfPort);
718 rspOperationalListener.waitForCreation();
719 RenderedServicePath rsp = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, rspIid);
720 assertNotNull("RSP was not found", rsp);
722 flowId = FlowNames.getSfcIngressClass(RULENAME, rsp.getPathId(), rsp.getStartingIndex());
723 verifyFlow(nodeInfo.datapathId, flowId, Service.SFC_CLASSIFIER);
724 RenderedServicePathHop lastHop = sfcUtils.getLastHop(rsp);
725 short lastServiceindex = (short)((lastHop.getServiceIndex()).intValue() - 1);
726 flowId = FlowNames.getSfcEgressClass(vxGpeOfPort, rsp.getPathId(), lastServiceindex);
727 verifyFlow(nodeInfo.datapathId, flowId, Service.SFC_CLASSIFIER);
728 flowId = FlowNames.getSfcEgressClassBypass(rsp.getPathId(), lastServiceindex, 1);
729 verifyFlow(nodeInfo.datapathId, flowId, Service.CLASSIFIER);
730 flowId = FlowNames.getArpResponder(SF1IP);
731 verifyFlow(nodeInfo.datapathId, flowId, Service.ARP_RESPONDER);
732 // Only verify these flows if NetVirt adds them and not SFC
733 //flowId = FlowNames.getSfEgress(GPEUDPPORT);
734 //verifyFlow(nodeInfo.datapathId, flowId, Service.SFC_CLASSIFIER);
735 //flowId = FlowNames.getSfIngress(GPEUDPPORT, SF1IP);
736 //verifyFlow(nodeInfo.datapathId, flowId, Service.CLASSIFIER.getTable());
738 LOG.info("check for flows!!!!!!!!!!!!!");
740 InstanceIdentifier<Flow> flowIid = createFlowIid(nodeInfo.datapathId, flowId,
741 pipelineOrchestrator.getTable(Service.CLASSIFIER));
743 final NotifyingDataChangeListener flowConfigurationListener =
744 new NotifyingDataChangeListener(LogicalDatastoreType.CONFIGURATION, flowIid, waitList);
745 flowConfigurationListener.registerDataChangeListener(dataBroker);
746 final NotifyingDataChangeListener flowOperationalListener =
747 new NotifyingDataChangeListener(LogicalDatastoreType.OPERATIONAL, flowIid, waitList);
748 flowOperationalListener.registerDataChangeListener(dataBroker);
751 rspOperationalListener.waitForDeletion();
752 rsp = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, rspIid);
753 assertNull("RSP should not be found", rsp);
755 flowConfigurationListener.waitForDeletion();
756 Flow flow = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, flowIid);
757 assertNull("Flow should not be found in CONFIGURATION " + flowIid, flow);
759 flowOperationalListener.waitForDeletion();
760 flow = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, flowIid);
761 assertNull("Flow should not be found in OPERATIONAL " + flowIid, flow);
763 nodeInfo.disconnect();
766 private void deleteRsp(String rspName) {
767 RenderedServicePathKey renderedServicePathKey =
768 new RenderedServicePathKey(RspName.getDefaultInstance(rspName));
769 InstanceIdentifier<RenderedServicePath> path =
770 InstanceIdentifier.create(RenderedServicePaths.class)
771 .child(RenderedServicePath.class, renderedServicePathKey);
772 mdsalUtils.delete(LogicalDatastoreType.OPERATIONAL, path);
776 * Test the standalone NetvirtSfc implementation
777 * NOTE: This test requires an OVS with the NSH v8 patch, otherwise it will fail miserably.
778 * @throws InterruptedException
782 public void testStandalone() throws InterruptedException {
783 String bridgeName = "sw1";
784 ConnectionInfo connectionInfo = SouthboundUtils.getConnectionInfo(addressStr, portStr);
785 assertNotNull("connection failed", southboundUtils.connectOvsdbNode(connectionInfo));
786 Node ovsdbNode = southboundUtils.getOvsdbNode(connectionInfo);
787 assertNotNull("node is not connected", ovsdbNode);
789 String controllerTarget = "tcp:192.168.50.1:6653";
790 List<ControllerEntry> setControllerEntry = southboundUtils.createControllerEntry(controllerTarget);
791 Assert.assertTrue(southboundUtils.addBridge(connectionInfo, null, bridgeName, null, true,
792 SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null,
793 setControllerEntry, null, "00:00:00:00:00:00:00:01"));
794 assertTrue("Controller " + SouthboundUtils.connectionInfoToString(connectionInfo)
795 + " is not connected", itUtils.isControllerConnected(connectionInfo));
797 Node bridgeNode = southbound.getBridgeNode(ovsdbNode, bridgeName);
798 assertNotNull("bridge " + bridgeName + " was not found", bridgeNode);
799 long datapathId = southbound.getDataPathId(bridgeNode);
800 String datapathIdString = southbound.getDatapathId(bridgeNode);
801 LOG.info("testNetVirt: bridgeNode: {}, datapathId: {} - {}", bridgeNode, datapathIdString, datapathId);
802 assertNotEquals("datapathId was not found", datapathId, 0);
804 SfcClassifier sfcClassifier = new SfcClassifier(dataBroker, southbound, mdsalUtils);
805 //sfcClassifier.programLocalInPort(datapathId, "4096", (long)1, (short)0, (short)50, true);
807 NshUtils nshUtils = new NshUtils(new Ipv4Address("192.168.50.71"), new PortNumber(6633),
808 (long)10, (short)255, (long)4096, (long)4096);
809 MatchesBuilder matchesBuilder = aclUtils.matchesBuilder(new MatchesBuilder(), 80);
810 sfcClassifier.programSfcClassiferFlows(datapathId, (short)0, "test", matchesBuilder.build(),
811 nshUtils, (long)2, true);
813 //nshUtils = new NshUtils(null, null, (long)10, (short)253, 0, 0);
814 //sfcClassifier.programEgressSfcClassiferFlows(datapathId, (short)0, "test", null,
815 // nshUtils, (long)2, (long)3, true);
817 //NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
818 //FlowBuilder flowBuilder = getLocalInPortFlow(datapathId, "4096", (long) 1,
819 // pipelineOrchestrator.getTable(Service.CLASSIFIER));
820 //Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
821 //assertNotNull("Could not find flow in config", flow);
822 //flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
823 //assertNotNull("Could not find flow in operational", flow);
825 //MatchBuilder matchBuilder = sfcClassifier.buildMatch(matchesBuilder.build());
826 //NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
827 //FlowBuilder flowBuilder = getSfcClassifierFlow(datapathId,
828 // pipelineOrchestrator.getTable(Service.CLASSIFIER), "test", null,
829 // nshUtils, (long) 2, matchBuilder);
830 //Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
831 //assertNotNull("Could not find flow in config", flow);
832 //flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
833 //assertNotNull("Could not find flow in operational", flow);
835 //nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
836 //flowBuilder = getEgressSfcClassifierFlow(datapathId,
837 //pipelineOrchestrator.getTable(Service.CLASSIFIER),
838 //"test", nshUtils, (long) 2);
839 //flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
840 //assertNotNull("Could not find flow in config", flow);
841 //flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
842 //assertNotNull("Could not find flow in operational", flow);
844 LOG.info("***** Go look for flows *****");
846 assertTrue(southboundUtils.deleteBridge(connectionInfo, bridgeName));
848 assertTrue(southboundUtils.deleteBridge(connectionInfo, INTEGRATION_BRIDGE_NAME));
850 assertTrue(southboundUtils.disconnectOvsdbNode(connectionInfo));
853 private InstanceIdentifier<Flow> createFlowIid(long datapathId, String flowId, short table) {
854 org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder nodeBuilder =
855 FlowUtils.createNodeBuilder(datapathId);
856 FlowBuilder flowBuilder =
857 FlowUtils.initFlowBuilder(new FlowBuilder(), flowId, table);
858 return FlowUtils.createFlowPath(flowBuilder, nodeBuilder);
861 private Flow getFlow (
862 FlowBuilder flowBuilder,
863 org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder nodeBuilder,
864 LogicalDatastoreType store) throws InterruptedException {
867 for (int i = 0; i < 10; i++) {
868 LOG.info("getFlow try {} from {}: looking for flow: {}, node: {}",
869 i, store, flowBuilder.build(), nodeBuilder.build());
870 flow = FlowUtils.getFlow(flowBuilder, nodeBuilder, dataBroker.newReadOnlyTransaction(), store);
872 LOG.info("getFlow try {} from {}: found flow: {}", i, store, flow);
880 private void verifyFlow(long datapathId, String flowId, short table) throws InterruptedException {
881 org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder nodeBuilder =
882 FlowUtils.createNodeBuilder(datapathId);
883 FlowBuilder flowBuilder =
884 FlowUtils.initFlowBuilder(new FlowBuilder(), flowId, table);
885 Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
886 assertNotNull("Could not find flow in config: " + flowBuilder.build() + "--" + nodeBuilder.build(), flow);
887 flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
888 assertNotNull("Could not find flow in operational: " + flowBuilder.build() + "--" + nodeBuilder.build(),
892 private void verifyFlow(long datapathId, String flowId, Service service) throws InterruptedException {
893 verifyFlow(datapathId, flowId, pipelineOrchestrator.getTable(service));
896 private void readwait() {
898 LOG.warn("Waiting, kill with ps -ef | grep java, kill xxx... ");
901 } catch (IOException e) {
907 private List<NotifyingDataChangeListener> waitList = new ArrayList<>();
909 private void closeWaitFors() {
910 for (Iterator<NotifyingDataChangeListener> iterator = waitList.iterator(); iterator.hasNext();) {
911 NotifyingDataChangeListener listener = iterator.next();
915 } catch (Exception ex) {
916 LOG.warn("Failed to close registration {}", listener, ex);
919 LOG.info("waitList size {}", waitList.size());