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