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