Add Stratum-bmv2 to Trellis SRBridging
TODO:
- Refactor so that we can use with other SR Tests
- Add creating docker image
Change-Id: Ib44418579e6f0eb4a862c36077459ed4dd389f8e
(cherry picked from commit 9bc3fb67167255b8962f4c1e4dc05d7fac10656b)
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/README.md b/TestON/tests/USECASE/SegmentRouting/SRBridging/README.md
index 7409f58..5b86f4c 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/README.md
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/README.md
@@ -10,6 +10,12 @@
- Trellis leaf-spine fabric: please visit following URL to set up Trellis leaf-spine fabric
https://github.com/opennetworkinglab/routing/tree/master/trellis
- ONOS_APPS=drivers,openflow,segmentrouting,fpm,netcfghostprovider
+ - For the stratum bmv2 switch testing, the minient node requires docker. The docker image
+ can be built using dependencies/Dockerfile.
+ - The treliis mininet topology file requires the stratum.py file which can be found in the
+ stratum repo (github.com/stratum/stratum) at stratum/tools/mininet/stratum.py.
+ The stratum docker has this file already installed, but you may want to add this
+ to the mininet/custom folder as well.
<h3>Topologies</h3>
- 0x1 single ToR
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params
index 2d50ac0..97d83a1 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params
@@ -16,6 +16,8 @@
<useCommonConf>False</useCommonConf>
<useCommonTopo>True</useCommonTopo>
<useBmv2>False</useBmv2>
+ <bmv2SwitchType>bmv2</bmv2SwitchType>
+ <stratumRoot>~/stratum</stratumRoot>
<topology>trellis_fabric.py</topology>
<lib>routinglib.py,trellislib.py</lib>
<trellisOar>/home/sdn/segmentrouting-oar-3.0.0-SNAPSHOT.oar</trellisOar>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params.stratum b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params.stratum
new file mode 100644
index 0000000..e1e7395
--- /dev/null
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/SRBridging.params.stratum
@@ -0,0 +1,56 @@
+<PARAMS>
+ # Sample testcase for physical network: 7
+ <testcases>5,6,7,8,15,16,17,18,25,26,27,28,35,36,37,38,45,46,47,48,55,56,57,58,65,66,67,68,75,76,77,78</testcases>
+
+ <GRAPH>
+ <nodeCluster>Fabric</nodeCluster>
+ <builds>20</builds>
+ </GRAPH>
+
+ <SCALE>
+ <size>3</size>
+ <max>3</max>
+ </SCALE>
+
+ <DEPENDENCY>
+ <useCommonConf>False</useCommonConf>
+ <useCommonTopo>True</useCommonTopo>
+ <useBmv2>True</useBmv2>
+ <bmv2SwitchType>stratum</bmv2SwitchType>
+ <stratumRoot>~/stratum</stratumRoot>
+ <topology>trellis_fabric.py</topology>
+ <lib>routinglib.py,trellislib.py</lib>
+ </DEPENDENCY>
+
+ <MN_DOCKER>
+ <args>--privileged --net host --rm -v topo:/topo -v ~/mininet/custom:/root/mininet/custom -v /var/run/openvswitch/:/var/run/openvswitch/ -v /tmp/mn-stratum:/tmp --hostname mn-stratum -v /etc/network/interfaces:/etc/network/interfaces -it -d</args>
+ <name>trellis_mininet</name>
+ </MN_DOCKER>
+
+ <ENV>
+ <cellName>productionCell</cellName>
+ <cellApps>drivers,segmentrouting,openflow,fpm,netcfghostprovider,drivers.bmv2,pipelines.fabric</cellApps>
+ </ENV>
+
+ <GIT>
+ <pull>False</pull>
+ <branch>master</branch>
+ </GIT>
+
+ <CTRL>
+ <port>6653</port>
+ </CTRL>
+
+ <timers>
+ <LinkDiscovery>12</LinkDiscovery>
+ <SwitchDiscovery>12</SwitchDiscovery>
+ </timers>
+
+ <SLEEP>
+ <startup>10</startup>
+ </SLEEP>
+
+ <ALARM>
+ <minPassPercent>100</minPassPercent>
+ </ALARM>
+</PARAMS>
diff --git a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
index af2848f..3368950 100644
--- a/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
+++ b/TestON/tests/USECASE/SegmentRouting/SRBridging/dependencies/SRBridgingTest.py
@@ -62,6 +62,31 @@
run.loadJson( main )
run.loadChart( main )
if hasattr( main, 'Mininet1' ):
+ if 'MN_DOCKER' in main.params and main.params['MN_DOCKER']['args']:
+ main.log.info( "Creating Mininet Docker" )
+ main.Mininet1.dockerPrompt = '#'
+ # Start docker container
+ handle = main.Mininet1.handle
+ handle.sendline( "docker run %s %s" % ( main.params[ 'MN_DOCKER' ][ 'args' ], main.params[ 'MN_DOCKER' ][ 'name' ] ) )
+ handle.expect( main.Mininet1.bashPrompt )
+ output = handle.before + handle.after
+ main.log.debug( repr(output) )
+ startStr = main.params[ 'MN_DOCKER' ][ 'name' ]
+ endStr = main.Mininet1.user_name
+ start = output.find( startStr ) + len( startStr )
+ end = output.find( endStr )
+ containerId = output[start:end].strip()
+ main.log.debug( repr( containerId ) )
+
+ handle = main.Mininet1.handle
+ handle.sendline( "docker attach %s " % containerId ) # Strip?
+ handle.expect( main.Mininet1.dockerPrompt )
+ main.log.debug( handle.before + handle.after )
+ # We should be good to go
+ main.Mininet1.prompt = main.Mininet1.dockerPrompt
+ main.Mininet1.sudoRequired = False
+
+
# Run the test with Mininet
mininet_args = ' --spine=%d --leaf=%d' % ( self.topo[ topology ][ 0 ], self.topo[ topology ][ 1 ] )
if self.topo[ topology ][ 2 ]:
@@ -69,10 +94,24 @@
if len( vlan ) > 0 :
mininet_args += ' --vlan=%s' % ( ','.join( ['%d' % vlanId for vlanId in vlan ] ) )
if main.useBmv2:
- mininet_args += ' --switch bmv2'
- main.log.info( "Using BMv2 switch" )
+ switchType = main.params[ 'DEPENDENCY' ].get( 'bmv2SwitchType', 'stratum' )
+ mininet_args += ' --switch %s' % switchType
+ main.log.info( "Using %s switch" % switchType )
run.startMininet( main, 'trellis_fabric.py', args=mininet_args )
+
+ if main.useBmv2:
+ filename = "onos-netcfg.json"
+ for switch in main.Mininet1.getSwitches(switchRegex=r"(StratumBmv2Switch)|(Bmv2Switch)").keys():
+ path = "/tmp/mn-stratum/%s/" % switch
+ main.ONOSbench1.handle.sendline( "sudo sed -i 's/localhost/%s/g' %s%s" % ( main.Mininet1.ip_address, path, filename ) )
+ main.ONOSbench1.handle.expect( main.ONOSbench1.prompt )
+ main.log.debug( main.ONOSbench1.handle.before + main.ONOSbench1.handle.after )
+ main.ONOSbench1.handle.sendline( "sudo sed -i 's/device:%s/device:bmv2:%s/g' %s%s" % ( switch, switch, path, filename ) )
+ main.ONOSbench1.handle.expect( main.ONOSbench1.prompt )
+ main.log.debug( main.ONOSbench1.handle.before + main.ONOSbench1.handle.after )
+ main.ONOSbench1.onosNetCfg( main.ONOSserver1.ip_address, path, filename )
+
else:
# Run the test with physical devices
run.connectToPhysicalNetwork( main, self.switchNames[ topology ] )
@@ -87,3 +126,22 @@
run.pingAll( main )
run.cleanup( main )
+ if 'MN_DOCKER' in main.params and main.params['MN_DOCKER']['args']:
+ main.log.info( "Deleting Mininet Docker" )
+
+ # Detach from container
+ handle = main.Mininet1.handle
+ try:
+ handle.sendline( "exit" ) # ctrl-p ctrk-q to detach from container
+ import time
+ time.sleep(5)
+ handle.expect( main.Mininet1.dockerPrompt )
+ main.log.debug( handle.before + handle.after )
+ main.Mininet1.prompt = main.Mininet1.bashPrompt
+ handle.expect( main.Mininet1.prompt )
+ main.log.debug( handle.before + handle.after )
+ main.Mininet1.sudoRequired = True
+ except Exception as e:
+ main.log.error( e )
+
+ # We should be good to go