kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 1 | |
| 2 | # Testing the basic functionality of ONOS Next |
| 3 | # For sanity and driver functionality excercises only. |
| 4 | |
| 5 | import time |
| 6 | import json |
| 7 | |
| 8 | time.sleep( 1 ) |
| 9 | |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 10 | class FuncIntent: |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 11 | |
| 12 | def __init__( self ): |
| 13 | self.default = '' |
| 14 | |
| 15 | def CASE10( self, main ): |
| 16 | import time |
| 17 | import os |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 18 | import imp |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 19 | """ |
| 20 | Startup sequence: |
| 21 | cell <name> |
| 22 | onos-verify-cell |
| 23 | onos-remove-raft-log |
| 24 | git pull |
| 25 | mvn clean install |
| 26 | onos-package |
| 27 | onos-install -f |
| 28 | onos-wait-for-start |
| 29 | """ |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 30 | global init |
| 31 | try: |
| 32 | if type(init) is not bool: |
| 33 | init = False |
| 34 | except NameError: |
| 35 | init = False |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 36 | #Local variables |
| 37 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 38 | apps = main.params[ 'ENV' ][ 'cellApps' ] |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 39 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 40 | benchIp = main.params[ 'BENCH' ][ 'ip1' ] |
| 41 | benchUser = main.params[ 'BENCH' ][ 'user' ] |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 42 | topology = main.params[ 'MININET' ][ 'topo' ] |
| 43 | maxNodes = int( main.params[ 'availableNodes' ] ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 44 | main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] ) |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 45 | main.numLinks = int( main.params[ 'MININET' ][ 'links' ] ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 46 | main.numCtrls = main.params[ 'CTRL' ][ 'num' ] |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 47 | main.wrapper = imp.load_source( 'FuncIntentFunction', |
| 48 | '/home/admin/ONLabTest/TestON/tests/' + |
| 49 | 'FuncIntent/Dependency/' + |
| 50 | 'FuncIntentFunction.py' ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 51 | PULLCODE = False |
| 52 | if main.params[ 'GIT' ][ 'pull' ] == 'True': |
| 53 | PULLCODE = True |
| 54 | main.case( "Setting up test environment" ) |
kelvin-onlab | 2ccad6e | 2015-05-18 10:36:54 -0700 | [diff] [blame^] | 55 | main.hostsData = {} |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 56 | main.CLIs = [] |
| 57 | for i in range( 1, int( main.numCtrls ) + 1 ): |
| 58 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 59 | |
| 60 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 61 | if init == False: |
| 62 | init = True |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 63 | main.MNisUp = main.FALSE |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 64 | |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 65 | main.ONOSip = [] |
| 66 | main.ONOSport = [] |
| 67 | main.scale = ( main.params[ 'SCALE' ] ).split( "," ) |
| 68 | main.numCtrls = int( main.scale[ 0 ] ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 69 | |
| 70 | if PULLCODE: |
| 71 | main.step( "Git checkout and pull " + gitBranch ) |
| 72 | main.ONOSbench.gitCheckout( gitBranch ) |
| 73 | gitPullResult = main.ONOSbench.gitPull() |
| 74 | if gitPullResult == main.ERROR: |
| 75 | main.log.error( "Error pulling git branch" ) |
| 76 | main.step( "Using mvn clean & install" ) |
| 77 | cleanInstallResult = main.ONOSbench.cleanInstall() |
| 78 | stepResult = cleanInstallResult |
| 79 | utilities.assert_equals( expect=main.TRUE, |
| 80 | actual=stepResult, |
| 81 | onpass="Successfully compiled " + |
| 82 | "latest ONOS", |
| 83 | onfail="Failed to compile " + |
| 84 | "latest ONOS" ) |
| 85 | else: |
| 86 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 87 | "clean install" ) |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 88 | # Populate main.ONOSip with ips from params |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 89 | for i in range( 1, maxNodes + 1): |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 90 | main.ONOSip.append( main.params[ 'CTRL' ][ 'ip' + str( i ) ] ) |
| 91 | main.ONOSport.append( main.params[ 'CTRL' ][ 'port' + |
| 92 | str( i ) ]) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 93 | |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 94 | main.numCtrls = int( main.scale[ 0 ] ) |
| 95 | main.scale.remove( main.scale[ 0 ] ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 96 | #kill off all onos processes |
| 97 | main.log.info( "Safety check, killing all ONOS processes" + |
| 98 | " before initiating enviornment setup" ) |
| 99 | for i in range( maxNodes ): |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 100 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 101 | """main.step( "Removing raft logs" ) |
| 102 | removeRaftResult = main.ONOSbench.onosRemoveRaftLogs() |
| 103 | stepResult = removeRaftResult |
| 104 | utilities.assert_equals( expect=main.TRUE, |
| 105 | actual=stepResult, |
| 106 | onpass="Successfully removed raft logs", |
| 107 | onfail="Failed to remove raft logs" ) |
| 108 | """ |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 109 | print "NODE COUNT = ", main.numCtrls |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 110 | main.log.info( "Creating cell file" ) |
| 111 | cellIp = [] |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 112 | for i in range( main.numCtrls ): |
| 113 | cellIp.append( str( main.ONOSip[ i ] ) ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 114 | print cellIp |
| 115 | main.ONOSbench.createCellFile( benchIp, cellName, "", |
| 116 | str( apps ), *cellIp ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 117 | |
| 118 | main.step( "Apply cell to environment" ) |
| 119 | cellResult = main.ONOSbench.setCell( cellName ) |
| 120 | verifyResult = main.ONOSbench.verifyCell() |
| 121 | stepResult = cellResult and verifyResult |
| 122 | utilities.assert_equals( expect=main.TRUE, |
| 123 | actual=stepResult, |
| 124 | onpass="Successfully applied cell to " + \ |
| 125 | "environment", |
| 126 | onfail="Failed to apply cell to environment " ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 127 | |
| 128 | main.step( "Creating ONOS package" ) |
| 129 | packageResult = main.ONOSbench.onosPackage() |
| 130 | stepResult = packageResult |
| 131 | utilities.assert_equals( expect=main.TRUE, |
| 132 | actual=stepResult, |
| 133 | onpass="Successfully created ONOS package", |
| 134 | onfail="Failed to create ONOS package" ) |
| 135 | |
| 136 | main.step( "Uninstalling ONOS package" ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 137 | onosUninstallResult = main.TRUE |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 138 | for i in range( main.numCtrls): |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 139 | onosUninstallResult = onosUninstallResult and \ |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 140 | main.ONOSbench.onosUninstall( nodeIp=main.ONOSip[ i ] ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 141 | stepResult = onosUninstallResult |
| 142 | utilities.assert_equals( expect=main.TRUE, |
| 143 | actual=stepResult, |
| 144 | onpass="Successfully uninstalled ONOS package", |
| 145 | onfail="Failed to uninstall ONOS package" ) |
| 146 | time.sleep( 5 ) |
| 147 | main.step( "Installing ONOS package" ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 148 | onosInstallResult = main.TRUE |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 149 | for i in range( main.numCtrls): |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 150 | onosInstallResult = onosInstallResult and \ |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 151 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 152 | stepResult = onosInstallResult |
| 153 | utilities.assert_equals( expect=main.TRUE, |
| 154 | actual=stepResult, |
| 155 | onpass="Successfully installed ONOS package", |
| 156 | onfail="Failed to install ONOS package" ) |
| 157 | |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 158 | time.sleep( 5 ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 159 | main.step( "Starting ONOS service" ) |
| 160 | stopResult = main.TRUE |
| 161 | startResult = main.TRUE |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 162 | onosIsUp = main.TRUE |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 163 | for i in range( main.numCtrls ): |
| 164 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 165 | if onosIsUp == main.TRUE: |
| 166 | main.log.report( "ONOS instance is up and ready" ) |
| 167 | else: |
| 168 | main.log.report( "ONOS instance may not be up, stop and " + |
| 169 | "start ONOS again " ) |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 170 | for i in range( main.numCtrls ): |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 171 | stopResult = stopResult and \ |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 172 | main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 173 | for i in range( main.numCtrls ): |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 174 | startResult = startResult and \ |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 175 | main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 176 | stepResult = onosIsUp and stopResult and startResult |
| 177 | utilities.assert_equals( expect=main.TRUE, |
| 178 | actual=stepResult, |
| 179 | onpass="ONOS service is ready", |
| 180 | onfail="ONOS service did not start properly" ) |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 181 | |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 182 | main.step( "Start ONOS cli" ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 183 | cliResult = main.TRUE |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 184 | for i in range( main.numCtrls ): |
| 185 | cliResult = cliResult and \ |
| 186 | main.CLIs[i].startOnosCli( main.ONOSip[ i ] ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 187 | stepResult = cliResult |
| 188 | utilities.assert_equals( expect=main.TRUE, |
| 189 | actual=stepResult, |
| 190 | onpass="Successfully start ONOS cli", |
| 191 | onfail="Failed to start ONOS cli" ) |
| 192 | |
| 193 | def CASE11( self, main ): |
| 194 | """ |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 195 | Start mininet |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 196 | """ |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 197 | import time |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 198 | main.log.report( "Start Mininet topology" ) |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 199 | main.case( "Start Mininet topology" ) |
| 200 | if not main.MNisUp: |
| 201 | main.MNisUp = main.TRUE |
| 202 | else: |
| 203 | main.Mininet1.stopNet() |
| 204 | time.sleep( 30 ) |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 205 | main.step( "Starting Mininet Topology" ) |
| 206 | topoResult = main.Mininet1.startNet( topoFile=topology ) |
| 207 | stepResult = topoResult |
| 208 | utilities.assert_equals( expect=main.TRUE, |
| 209 | actual=stepResult, |
| 210 | onpass="Successfully loaded topology", |
| 211 | onfail="Failed to load topology" ) |
| 212 | # Exit if topology did not load properly |
| 213 | if not topoResult: |
| 214 | main.cleanup() |
| 215 | main.exit() |
| 216 | |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 217 | def CASE12( self, main ): |
| 218 | """ |
| 219 | Assign mastership to controllers |
| 220 | """ |
| 221 | import re |
| 222 | |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 223 | main.case( "Assign switches to controllers" ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 224 | main.step( "Assigning switches to controllers" ) |
| 225 | assignResult = main.TRUE |
kelvin-onlab | 5cbf999 | 2015-05-05 14:34:07 -0700 | [diff] [blame] | 226 | for i in range( 1, ( main.numSwitch + 1 ) ): |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 227 | main.Mininet1.assignSwController( sw=str( i ), |
| 228 | count=1, |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 229 | ip1=main.ONOSip[ 0 ], |
| 230 | port1=main.ONOSport[ 0 ] ) |
kelvin-onlab | 5cbf999 | 2015-05-05 14:34:07 -0700 | [diff] [blame] | 231 | for i in range( 1, ( main.numSwitch + 1 ) ): |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 232 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 233 | print( "Response is " + str( response ) ) |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 234 | if re.search( "tcp:" + main.ONOSip[ 0 ], response ): |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 235 | assignResult = assignResult and main.TRUE |
| 236 | else: |
| 237 | assignResult = main.FALSE |
| 238 | stepResult = assignResult |
| 239 | utilities.assert_equals( expect=main.TRUE, |
| 240 | actual=stepResult, |
| 241 | onpass="Successfully assigned switches" + |
| 242 | "to controller", |
| 243 | onfail="Failed to assign switches to " + |
| 244 | "controller" ) |
kelvin-onlab | 2ccad6e | 2015-05-18 10:36:54 -0700 | [diff] [blame^] | 245 | def CASE13( self, main ): |
| 246 | """ |
| 247 | Discover all hosts and store its data to a dictionary |
| 248 | """ |
| 249 | main.case( "Discover all hosts" ) |
| 250 | |
| 251 | stepResult = main.TRUE |
| 252 | main.step( "IPV4: Add host intents between h1 and h9" ) |
| 253 | stepResult = main.wrapper.getHostsData( main ) |
| 254 | utilities.assert_equals( expect=main.FALSE, |
| 255 | actual=stepResult, |
| 256 | onpass="Successfully discovered hosts", |
| 257 | onfail="Failed to discover hosts" ) |
kelvin-onlab | 4ff9cc1 | 2015-05-05 11:14:42 -0700 | [diff] [blame] | 258 | |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 259 | def CASE1001( self, main ): |
kelvin-onlab | 7c577e8 | 2015-05-07 10:45:16 -0700 | [diff] [blame] | 260 | """ |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 261 | Add host intents between 2 host: |
| 262 | - Discover hosts |
| 263 | - Add host intents |
| 264 | - Check intents |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 265 | - Verify flows |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 266 | - Ping hosts |
| 267 | - Reroute |
| 268 | - Link down |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 269 | - Verify flows |
| 270 | - Check topology |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 271 | - Ping hosts |
| 272 | - Link up |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 273 | - Verify flows |
| 274 | - Check topology |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 275 | - Ping hosts |
| 276 | - Remove intents |
kelvin-onlab | 7c577e8 | 2015-05-07 10:45:16 -0700 | [diff] [blame] | 277 | """ |
| 278 | import time |
| 279 | import json |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 280 | import re |
| 281 | """ |
| 282 | Create your item(s) here |
| 283 | item = { 'name': '', 'host1': |
| 284 | { 'name': '', 'MAC': '00:00:00:00:00:0X', |
| 285 | 'id':'00:00:00:00:00:0X/-X' } , 'host2': |
| 286 | { 'name': '', 'MAC': '00:00:00:00:00:0X', |
| 287 | 'id':'00:00:00:00:00:0X/-X'}, 'link': { 'switch1': '', |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 288 | 'switch2': '', 'expect':'' } } |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 289 | """ |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 290 | |
| 291 | # Assert variables - These variable's name|format must be followed |
| 292 | # if you want to use the wrapper function |
| 293 | assert main, "There is no main" |
| 294 | assert main.CLIs, "There is no main.CLIs" |
| 295 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 296 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 297 | main.numSwitch" |
| 298 | |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 299 | main.case( "Add host intents between 2 host" ) |
kelvin-onlab | 05cf773 | 2015-05-08 14:25:46 -0700 | [diff] [blame] | 300 | |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 301 | stepResult = main.TRUE |
kelvin-onlab | 2ccad6e | 2015-05-18 10:36:54 -0700 | [diff] [blame^] | 302 | main.step( "IPV4: Add host intents between h1 and h9" ) |
| 303 | stepResult = main.wrapper.hostIntent( main, |
| 304 | name='IPV4', |
| 305 | host1='h1', |
| 306 | host2='h9', |
| 307 | host1Id='00:00:00:00:00:01/-1', |
| 308 | host2Id='00:00:00:00:00:09/-1', |
| 309 | sw1='s5', |
| 310 | sw2='s2', |
| 311 | expectedLink=18 ) |
kelvin-onlab | 7c577e8 | 2015-05-07 10:45:16 -0700 | [diff] [blame] | 312 | |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 313 | utilities.assert_equals( expect=main.TRUE, |
| 314 | actual=stepResult, |
kelvin-onlab | 2ccad6e | 2015-05-18 10:36:54 -0700 | [diff] [blame^] | 315 | onpass="IPV4: Add host intent successful", |
| 316 | onfail="IPV4: Add host intent failed" ) |
| 317 | stepResult = main.TRUE |
| 318 | |
| 319 | main.step( "DUALSTACK: Add host intents between h3 and h11" ) |
| 320 | stepResult = main.wrapper.hostIntent( main, |
| 321 | name='DUALSTACK', |
| 322 | host1='h3', |
| 323 | host2='h11', |
| 324 | host1Id='00:00:00:00:00:03/-1', |
| 325 | host2Id='00:00:00:00:00:011/-1', |
| 326 | sw1='s5', |
| 327 | sw2='s2', |
| 328 | expectedLink=18 ) |
| 329 | |
| 330 | utilities.assert_equals( expect=main.TRUE, |
| 331 | actual=stepResult, |
| 332 | onpass="DUALSTACK: Add host intent successful", |
| 333 | onfail="DUALSTACK: Add host intent failed" ) |
kelvin-onlab | 7c577e8 | 2015-05-07 10:45:16 -0700 | [diff] [blame] | 334 | |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 335 | def CASE1002( self, main ): |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 336 | """ |
| 337 | Add point intents between 2 hosts: |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 338 | - Get device ids | ports |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 339 | - Add point intents |
| 340 | - Check intents |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 341 | - Verify flows |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 342 | - Ping hosts |
| 343 | - Reroute |
| 344 | - Link down |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 345 | - Verify flows |
| 346 | - Check topology |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 347 | - Ping hosts |
| 348 | - Link up |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 349 | - Verify flows |
| 350 | - Check topology |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 351 | - Ping hosts |
| 352 | - Remove intents |
| 353 | """ |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 354 | import time |
| 355 | import json |
| 356 | import re |
| 357 | """ |
| 358 | Create your item(s) here |
kelvin-onlab | b223560 | 2015-05-13 17:51:06 -0700 | [diff] [blame] | 359 | item = { 'name':'', 'host1': { 'name': '' }, |
| 360 | 'host2': { 'name': '' }, |
| 361 | 'ingressDevice':'' , 'egressDevice':'', |
| 362 | 'ingressPort':'', 'egressPort':'', |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 363 | 'option':{ 'ethType':'', 'ethSrc':'', 'ethDst':'' } , |
| 364 | 'link': { 'switch1': '', 'switch2':'', 'expect':'' } } |
| 365 | |
| 366 | """ |
| 367 | |
| 368 | # Assert variables - These variable's name|format must be followed |
| 369 | # if you want to use the wrapper function |
| 370 | assert main, "There is no main" |
| 371 | assert main.CLIs, "There is no main.CLIs" |
| 372 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 373 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 374 | main.numSwitch" |
| 375 | |
kelvin-onlab | b223560 | 2015-05-13 17:51:06 -0700 | [diff] [blame] | 376 | ipv4 = { 'name':'IPV4', 'ingressDevice':'of:0000000000000005/1' , |
| 377 | 'host1': { 'name': 'h1' }, 'host2': { 'name': 'h9' }, |
| 378 | 'egressDevice':'of:0000000000000006/1', 'option': |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 379 | { 'ethType':'IPV4', 'ethSrc':'00:00:00:00:00:01', |
| 380 | 'ethDst':'00:00:00:00:00:09' }, 'link': { 'switch1':'s5', |
kelvin-onlab | 2ccad6e | 2015-05-18 10:36:54 -0700 | [diff] [blame^] | 381 | 'switch2':'s2', 'expect':'18' } } |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 382 | |
kelvin-onlab | b223560 | 2015-05-13 17:51:06 -0700 | [diff] [blame] | 383 | """ |
| 384 | ipv4 = { 'name':'IPV4', 'ingressDevice':'of:0000000000000005/1' , |
| 385 | 'host1': { 'name': 'h1' }, 'host2': { 'name': 'h9' }, |
| 386 | 'egressDevice':'of:0000000000000006/1', 'option': |
| 387 | { 'ethType':'IPV4', 'ethSrc':'00:00:00:00:00:01' }, |
| 388 | 'link': { 'switch1':'s5', 'switch2':'s2', 'expect':'18' } } |
kelvin-onlab | 2ccad6e | 2015-05-18 10:36:54 -0700 | [diff] [blame^] | 389 | """ |
kelvin-onlab | b223560 | 2015-05-13 17:51:06 -0700 | [diff] [blame] | 390 | dualStack1 = { 'name':'IPV4', 'ingressDevice':'0000000000000005/3' , |
| 391 | 'host1': { 'name': 'h3' }, 'host2': { 'name': 'h11' }, |
| 392 | 'egressDevice':'0000000000000006/3', 'option': |
| 393 | { 'ethType':'IPV4', 'ethSrc':'00:00:00:00:00:03', |
| 394 | 'ethDst':'00:00:00:00:00:0B' }, 'link': { 'switch1':'s5', |
| 395 | 'switch2':'s2', 'expect':'18' } } |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 396 | |
kelvin-onlab | b223560 | 2015-05-13 17:51:06 -0700 | [diff] [blame] | 397 | main.case( "Add point intents between 2 devices" ) |
| 398 | |
| 399 | stepResult = main.TRUE |
kelvin-onlab | 2ccad6e | 2015-05-18 10:36:54 -0700 | [diff] [blame^] | 400 | main.step( "IPV4: Add point intents between h1 and h9" ) |
| 401 | stepResult = main.wrapper.pointIntent( |
| 402 | main, |
| 403 | name="IPV4", |
| 404 | host1="h1", |
| 405 | host2="h9", |
| 406 | deviceId1="of:0000000000000005/1", |
| 407 | deviceId2="of:0000000000000006/1", |
| 408 | port1="", |
| 409 | port2="", |
| 410 | ethType="IPV4", |
| 411 | mac1="00:00:00:00:00:01", |
| 412 | mac2="00:00:00:00:00:09", |
| 413 | bandwidth="", |
| 414 | lambdaAlloc=False, |
| 415 | ipProto="", |
| 416 | ip1="", |
| 417 | ip2="", |
| 418 | tcp1="", |
| 419 | tcp2="", |
| 420 | sw1="s5", |
| 421 | sw2="s2", |
| 422 | expectedLink=18 ) |
| 423 | |
kelvin-onlab | b223560 | 2015-05-13 17:51:06 -0700 | [diff] [blame] | 424 | utilities.assert_equals( expect=main.TRUE, |
| 425 | actual=stepResult, |
kelvin-onlab | 2ccad6e | 2015-05-18 10:36:54 -0700 | [diff] [blame^] | 426 | onpass="IPV4: Add point intent successful", |
| 427 | onfail="IPV4: Add point intent failed" ) |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 428 | |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 429 | def CASE1003( self, main ): |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 430 | """ |
| 431 | Add single point to multi point intents |
| 432 | - Get device ids |
| 433 | - Add single point to multi point intents |
| 434 | - Check intents |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 435 | - Verify flows |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 436 | - Ping hosts |
| 437 | - Reroute |
| 438 | - Link down |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 439 | - Verify flows |
| 440 | - Check topology |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 441 | - Ping hosts |
| 442 | - Link up |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 443 | - Verify flows |
| 444 | - Check topology |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 445 | - Ping hosts |
| 446 | - Remove intents |
| 447 | """ |
| 448 | |
kelvin-onlab | f70fd54 | 2015-05-07 18:41:40 -0700 | [diff] [blame] | 449 | def CASE1004( self, main ): |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 450 | """ |
| 451 | Add multi point to single point intents |
| 452 | - Get device ids |
| 453 | - Add multi point to single point intents |
| 454 | - Check intents |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 455 | - Verify flows |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 456 | - Ping hosts |
| 457 | - Reroute |
| 458 | - Link down |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 459 | - Verify flows |
| 460 | - Check topology |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 461 | - Ping hosts |
| 462 | - Link up |
kelvin-onlab | e5239e5 | 2015-05-13 14:46:45 -0700 | [diff] [blame] | 463 | - Verify flows |
| 464 | - Check topology |
kelvin-onlab | 65782a8 | 2015-05-07 14:12:13 -0700 | [diff] [blame] | 465 | - Ping hosts |
| 466 | - Remove intents |
| 467 | """ |