kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1 | |
| 2 | # Testing the basic intent functionality of ONOS |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 3 | # TODO: Replace the CLI calls with REST API equivalents as they become available. |
| 4 | # - May need to write functions in the onosrestdriver.py file to do this |
| 5 | # TODO: Complete implementation of case 3000, 4000, and 6000 as REST API allows |
| 6 | # -Currently there is no support in the REST API for Multi to Single and Single to Multi point intents |
| 7 | # As such, these cases are incomplete and should not be enabled in the .params file |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 8 | |
| 9 | import time |
| 10 | import json |
| 11 | |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 12 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 13 | class FUNCintentRest: |
| 14 | |
| 15 | def __init__( self ): |
| 16 | self.default = '' |
| 17 | |
| 18 | def CASE1( self, main ): |
| 19 | import time |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 20 | import imp |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 21 | import re |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 22 | |
| 23 | """ |
| 24 | - Construct tests variables |
| 25 | - GIT ( optional ) |
| 26 | - Checkout ONOS master branch |
| 27 | - Pull latest ONOS code |
| 28 | - Building ONOS ( optional ) |
| 29 | - Install ONOS package |
| 30 | - Build ONOS package |
| 31 | """ |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 32 | main.case( "Constructing test variables and building ONOS package" ) |
| 33 | main.step( "Constructing test variables" ) |
| 34 | main.caseExplanation = "This test case is mainly for loading " +\ |
| 35 | "from params file, and pull and build the " +\ |
| 36 | " latest ONOS package" |
| 37 | stepResult = main.FALSE |
| 38 | |
| 39 | # Test variables |
| 40 | try: |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 41 | main.testOnDirectory = re.sub( "(/tests)$", "", main.testDir ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 42 | main.apps = main.params[ 'ENV' ][ 'cellApps' ] |
| 43 | gitBranch = main.params[ 'GIT' ][ 'branch' ] |
| 44 | main.dependencyPath = main.testOnDirectory + \ |
| 45 | main.params[ 'DEPENDENCY' ][ 'path' ] |
| 46 | main.topology = main.params[ 'DEPENDENCY' ][ 'topology' ] |
| 47 | main.scale = ( main.params[ 'SCALE' ][ 'size' ] ).split( "," ) |
| 48 | if main.ONOSbench.maxNodes: |
| 49 | main.maxNodes = int( main.ONOSbench.maxNodes ) |
| 50 | else: |
| 51 | main.maxNodes = 0 |
| 52 | wrapperFile1 = main.params[ 'DEPENDENCY' ][ 'wrapper1' ] |
| 53 | wrapperFile2 = main.params[ 'DEPENDENCY' ][ 'wrapper2' ] |
| 54 | wrapperFile3 = main.params[ 'DEPENDENCY' ][ 'wrapper3' ] |
| 55 | main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 56 | main.checkIntentSleep = int( main.params[ 'SLEEP' ][ 'checkintent' ] ) |
| 57 | main.removeIntentsleeo = int( main.params[ 'SLEEP' ][ 'removeintent' ] ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 58 | main.rerouteSleep = int( main.params[ 'SLEEP' ][ 'reroute' ] ) |
| 59 | main.fwdSleep = int( main.params[ 'SLEEP' ][ 'fwd' ] ) |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 60 | main.addIntentSleep = int( main.params[ 'SLEEP' ][ 'addIntent' ] ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 61 | main.checkTopoAttempts = int( main.params[ 'SLEEP' ][ 'topoAttempts' ] ) |
Jeremy Songster | 306ed7a | 2016-07-19 10:59:07 -0700 | [diff] [blame] | 62 | main.flowDurationSleep = int( main.params[ 'SLEEP' ][ 'flowDuration' ] ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 63 | gitPull = main.params[ 'GIT' ][ 'pull' ] |
| 64 | main.numSwitch = int( main.params[ 'MININET' ][ 'switch' ] ) |
| 65 | main.numLinks = int( main.params[ 'MININET' ][ 'links' ] ) |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 66 | main.cellData = {} # for creating cell file |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 67 | main.hostsData = {} |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 68 | main.RESTs = [] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 69 | main.CLIs = [] |
| 70 | main.ONOSip = [] |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 71 | main.scapyHostNames = main.params[ 'SCAPY' ][ 'HOSTNAMES' ].split( ',' ) |
| 72 | main.scapyHosts = [] # List of scapy hosts for iterating |
| 73 | main.assertReturnString = '' # Assembled assert return string |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 74 | main.cycle = 0 # How many times FUNCintent has run through its tests |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 75 | |
| 76 | main.ONOSip = main.ONOSbench.getOnosIps() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 77 | print main.ONOSip |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 78 | |
| 79 | # Assigning ONOS cli handles to a list |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 80 | try: |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 81 | for i in range( 1, main.maxNodes + 1 ): |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 82 | main.RESTs.append( getattr( main, 'ONOSrest' + str( i ) ) ) |
| 83 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 84 | except AttributeError: |
| 85 | main.log.warn( "A " + str( main.maxNodes ) + " node cluster " + |
| 86 | "was defined in env variables, but only " + |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 87 | str( len( main.RESTs ) ) + |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 88 | " nodes were defined in the .topo file. " + |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 89 | "Using " + str( len( main.RESTs ) ) + |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 90 | " nodes for the test." ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 91 | |
| 92 | # -- INIT SECTION, ONLY RUNS ONCE -- # |
| 93 | main.startUp = imp.load_source( wrapperFile1, |
| 94 | main.dependencyPath + |
| 95 | wrapperFile1 + |
| 96 | ".py" ) |
| 97 | |
| 98 | main.intentFunction = imp.load_source( wrapperFile2, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 99 | main.dependencyPath + |
| 100 | wrapperFile2 + |
| 101 | ".py" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 102 | |
| 103 | main.topo = imp.load_source( wrapperFile3, |
| 104 | main.dependencyPath + |
| 105 | wrapperFile3 + |
| 106 | ".py" ) |
| 107 | |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 108 | copyResult1 = main.ONOSbench.scp( main.Mininet1, |
| 109 | main.dependencyPath + |
| 110 | main.topology, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 111 | main.Mininet1.home + "custom/", |
Jon Hall | f723488 | 2015-08-28 13:16:31 -0700 | [diff] [blame] | 112 | direction="to" ) |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 113 | if main.RESTs and main.CLIs: |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 114 | stepResult = main.TRUE |
| 115 | else: |
| 116 | main.log.error( "Did not properly created list of ONOS CLI handle" ) |
| 117 | stepResult = main.FALSE |
| 118 | except Exception as e: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 119 | main.log.exception( e ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 120 | main.cleanup() |
| 121 | main.exit() |
| 122 | |
| 123 | utilities.assert_equals( expect=main.TRUE, |
| 124 | actual=stepResult, |
| 125 | onpass="Successfully construct " + |
| 126 | "test variables ", |
| 127 | onfail="Failed to construct test variables" ) |
| 128 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 129 | main.ONOSbench.getVersion( report=True ) |
| 130 | |
| 131 | def CASE2( self, main ): |
| 132 | """ |
| 133 | - Set up cell |
| 134 | - Create cell file |
| 135 | - Set cell file |
| 136 | - Verify cell file |
| 137 | - Kill ONOS process |
| 138 | - Uninstall ONOS cluster |
| 139 | - Verify ONOS start up |
| 140 | - Install ONOS cluster |
| 141 | - Connect to cli |
| 142 | """ |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 143 | main.cycle += 1 |
| 144 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 145 | # main.scale[ 0 ] determines the current number of ONOS controller |
| 146 | main.numCtrls = int( main.scale[ 0 ] ) |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 147 | main.flowCompiler = "Flow Rules" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 148 | main.initialized = main.TRUE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 149 | |
| 150 | main.case( "Starting up " + str( main.numCtrls ) + |
| 151 | " node(s) ONOS cluster" ) |
| 152 | main.caseExplanation = "Set up ONOS with " + str( main.numCtrls ) +\ |
| 153 | " node(s) ONOS cluster" |
| 154 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 155 | #kill off all onos processes |
| 156 | main.log.info( "Safety check, killing all ONOS processes" + |
Jon Hall | 70b2ff4 | 2015-11-17 15:49:44 -0800 | [diff] [blame] | 157 | " before initiating environment setup" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 158 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 159 | time.sleep( main.startUpSleep ) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 160 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 161 | main.step( "Uninstalling ONOS package" ) |
| 162 | onosUninstallResult = main.TRUE |
| 163 | for ip in main.ONOSip: |
| 164 | onosUninstallResult = onosUninstallResult and \ |
| 165 | main.ONOSbench.onosUninstall( nodeIp=ip ) |
| 166 | stepResult = onosUninstallResult |
| 167 | utilities.assert_equals( expect=main.TRUE, |
| 168 | actual=stepResult, |
| 169 | onpass="Successfully uninstalled ONOS package", |
| 170 | onfail="Failed to uninstall ONOS package" ) |
| 171 | |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 172 | time.sleep( main.startUpSleep ) |
| 173 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 174 | for i in range( main.maxNodes ): |
| 175 | main.ONOSbench.onosDie( main.ONOSip[ i ] ) |
| 176 | |
| 177 | print "NODE COUNT = ", main.numCtrls |
| 178 | |
| 179 | tempOnosIp = [] |
| 180 | for i in range( main.numCtrls ): |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 181 | tempOnosIp.append( main.ONOSip[ i ] ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 182 | |
| 183 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, |
| 184 | "temp", main.Mininet1.ip_address, |
Devin Lim | 461f087 | 2017-06-05 16:49:33 -0700 | [diff] [blame] | 185 | main.apps, tempOnosIp, main.ONOScli1.user_name ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 186 | |
| 187 | main.step( "Apply cell to environment" ) |
| 188 | cellResult = main.ONOSbench.setCell( "temp" ) |
| 189 | verifyResult = main.ONOSbench.verifyCell() |
| 190 | stepResult = cellResult and verifyResult |
| 191 | utilities.assert_equals( expect=main.TRUE, |
| 192 | actual=stepResult, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 193 | onpass="Successfully applied cell to " + |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 194 | "environment", |
| 195 | onfail="Failed to apply cell to environment " ) |
| 196 | |
| 197 | main.step( "Creating ONOS package" ) |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 198 | packageResult = main.ONOSbench.buckBuild() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 199 | stepResult = packageResult |
| 200 | utilities.assert_equals( expect=main.TRUE, |
| 201 | actual=stepResult, |
| 202 | onpass="Successfully created ONOS package", |
| 203 | onfail="Failed to create ONOS package" ) |
| 204 | |
| 205 | time.sleep( main.startUpSleep ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 206 | main.step( "Installing ONOS package" ) |
| 207 | onosInstallResult = main.TRUE |
| 208 | for i in range( main.numCtrls ): |
| 209 | onosInstallResult = onosInstallResult and \ |
| 210 | main.ONOSbench.onosInstall( node=main.ONOSip[ i ] ) |
| 211 | stepResult = onosInstallResult |
| 212 | utilities.assert_equals( expect=main.TRUE, |
| 213 | actual=stepResult, |
| 214 | onpass="Successfully installed ONOS package", |
| 215 | onfail="Failed to install ONOS package" ) |
| 216 | |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 217 | main.step( "Set up ONOS secure SSH" ) |
| 218 | secureSshResult = main.TRUE |
| 219 | for i in range( int( main.numCtrls ) ): |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 220 | secureSshResult = secureSshResult and main.ONOSbench.onosSecureSSH( node=main.ONOSip[ i ] ) |
You Wang | f5de25b | 2017-01-06 15:13:01 -0800 | [diff] [blame] | 221 | utilities.assert_equals( expect=main.TRUE, actual=secureSshResult, |
| 222 | onpass="Test step PASS", |
| 223 | onfail="Test step FAIL" ) |
| 224 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 225 | time.sleep( main.startUpSleep ) |
| 226 | main.step( "Starting ONOS service" ) |
| 227 | stopResult = main.TRUE |
| 228 | startResult = main.TRUE |
| 229 | onosIsUp = main.TRUE |
| 230 | |
| 231 | for i in range( main.numCtrls ): |
| 232 | onosIsUp = onosIsUp and main.ONOSbench.isup( main.ONOSip[ i ] ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 233 | if onosIsUp == main.TRUE: |
| 234 | main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) ) |
| 235 | else: |
| 236 | main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) + |
| 237 | "start ONOS again " ) |
| 238 | stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] ) |
| 239 | startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] ) |
| 240 | if not startResult or stopResult: |
| 241 | main.log.report( "ONOS instance {0} did not start correctly.".format( i + 1 ) ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 242 | stepResult = onosIsUp and stopResult and startResult |
| 243 | utilities.assert_equals( expect=main.TRUE, |
| 244 | actual=stepResult, |
| 245 | onpass="ONOS service is ready", |
| 246 | onfail="ONOS service did not start properly" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 247 | if not stepResult: |
| 248 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 249 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 250 | # Start an ONOS cli to provide functionality that is not currently |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 251 | # supported by the Rest API remove this when Leader Checking is supported |
| 252 | # by the REST API |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 253 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 254 | main.step( "Start ONOS cli" ) |
| 255 | cliResult = main.TRUE |
| 256 | for i in range( main.numCtrls ): |
| 257 | cliResult = cliResult and \ |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 258 | main.CLIs[ i ].startOnosCli( main.ONOSip[ i ] ) |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 259 | stepResult = cliResult |
| 260 | utilities.assert_equals( expect=main.TRUE, |
| 261 | actual=stepResult, |
| 262 | onpass="Successfully start ONOS cli", |
| 263 | onfail="Failed to start ONOS cli" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 264 | if not stepResult: |
| 265 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 266 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 267 | # Remove the first element in main.scale list |
| 268 | main.scale.remove( main.scale[ 0 ] ) |
| 269 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 270 | main.intentFunction.report( main ) |
| 271 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 272 | def CASE8( self, main ): |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 273 | # OLD FUNCintentRest CASE 8 |
| 274 | # This remains here for archiving and reference purposes and will be |
| 275 | # removed when the new FUNCintentRest is verified to work. |
| 276 | # """ |
| 277 | # Compare Topo |
| 278 | # """ |
| 279 | # import json |
| 280 | |
| 281 | # main.case( "Compare ONOS Topology view to Mininet topology" ) |
| 282 | # main.caseExplanation = "Compare topology elements between Mininet" +\ |
| 283 | # " and ONOS" |
| 284 | |
| 285 | # main.step( "Gathering topology information" ) |
| 286 | # # TODO: add a paramaterized sleep here |
| 287 | # devicesResults = main.TRUE # Overall Boolean for device correctness |
| 288 | # linksResults = main.TRUE # Overall Boolean for link correctness |
| 289 | # hostsResults = main.TRUE # Overall Boolean for host correctness |
| 290 | # devices = main.topo.getAllDevices( main ) |
| 291 | # hosts = main.topo.getAllHosts( main ) |
| 292 | # ports = main.topo.getAllPorts( main ) |
| 293 | # links = main.topo.getAllLinks( main ) |
| 294 | # clusters = main.topo.getAllClusters( main ) |
| 295 | |
| 296 | # mnSwitches = main.Mininet1.getSwitches() |
| 297 | # mnLinks = main.Mininet1.getLinks() |
| 298 | # mnHosts = main.Mininet1.getHosts() |
| 299 | |
| 300 | # main.step( "Comparing MN topology to ONOS topology" ) |
| 301 | # for controller in range( main.numCtrls ): |
| 302 | # controllerStr = str( controller + 1 ) |
| 303 | # if devices[ controller ] and ports[ controller ] and\ |
| 304 | # "Error" not in devices[ controller ] and\ |
| 305 | # "Error" not in ports[ controller ]: |
| 306 | |
| 307 | # currentDevicesResult = main.Mininet1.compareSwitches( |
| 308 | # mnSwitches, |
| 309 | # json.loads( devices[ controller ] ), |
| 310 | # json.loads( ports[ controller ] ) ) |
| 311 | # else: |
| 312 | # currentDevicesResult = main.FALSE |
| 313 | # utilities.assert_equals( expect=main.TRUE, |
| 314 | # actual=currentDevicesResult, |
| 315 | # onpass="ONOS" + controllerStr + |
| 316 | # " Switches view is correct", |
| 317 | # onfail="ONOS" + controllerStr + |
| 318 | # " Switches view is incorrect" ) |
| 319 | |
| 320 | # if links[ controller ] and "Error" not in links[ controller ]: |
| 321 | # currentLinksResult = main.Mininet1.compareLinks( |
| 322 | # mnSwitches, mnLinks, |
| 323 | # json.loads( links[ controller ] ) ) |
| 324 | # else: |
| 325 | # currentLinksResult = main.FALSE |
| 326 | # utilities.assert_equals( expect=main.TRUE, |
| 327 | # actual=currentLinksResult, |
| 328 | # onpass="ONOS" + controllerStr + |
| 329 | # " links view is correct", |
| 330 | # onfail="ONOS" + controllerStr + |
| 331 | # " links view is incorrect" ) |
| 332 | |
| 333 | # if hosts[ controller ] or "Error" not in hosts[ controller ]: |
| 334 | # currentHostsResult = main.Mininet1.compareHosts( |
| 335 | # mnHosts, |
| 336 | # json.loads( hosts[ controller ] ) ) |
| 337 | # else: |
| 338 | # currentHostsResult = main.FALSE |
| 339 | # utilities.assert_equals( expect=main.TRUE, |
| 340 | # actual=currentHostsResult, |
| 341 | # onpass="ONOS" + controllerStr + |
| 342 | # " hosts exist in Mininet", |
| 343 | # onfail="ONOS" + controllerStr + |
| 344 | # " hosts don't match Mininet" ) |
| 345 | |
| 346 | # NEW FUNCintentRest Case 8 as based off of the CASE 8 from FUNCintent |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 347 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 348 | Compare ONOS Topology to Mininet Topology |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 349 | """ |
| 350 | import json |
| 351 | |
| 352 | main.case( "Compare ONOS Topology view to Mininet topology" ) |
| 353 | main.caseExplanation = "Compare topology elements between Mininet" +\ |
| 354 | " and ONOS" |
| 355 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 356 | main.log.info( "Gathering topology information from Mininet" ) |
| 357 | devicesResults = main.FALSE # Overall Boolean for device correctness |
| 358 | linksResults = main.FALSE # Overall Boolean for link correctness |
| 359 | hostsResults = main.FALSE # Overall Boolean for host correctness |
| 360 | deviceFails = [] # Nodes where devices are incorrect |
| 361 | linkFails = [] # Nodes where links are incorrect |
| 362 | hostFails = [] # Nodes where hosts are incorrect |
| 363 | attempts = main.checkTopoAttempts # Remaining Attempts |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 364 | |
| 365 | mnSwitches = main.Mininet1.getSwitches() |
| 366 | mnLinks = main.Mininet1.getLinks() |
| 367 | mnHosts = main.Mininet1.getHosts() |
| 368 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 369 | main.step( "Comparing Mininet topology to ONOS topology" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 370 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 371 | while ( attempts >= 0 ) and\ |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 372 | ( not devicesResults or not linksResults or not hostsResults ): |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 373 | time.sleep( 2 ) |
| 374 | if not devicesResults: |
| 375 | devices = main.topo.getAllDevices( main ) |
| 376 | ports = main.topo.getAllPorts( main ) |
| 377 | devicesResults = main.TRUE |
| 378 | deviceFails = [] # Reset for each failed attempt |
| 379 | if not linksResults: |
| 380 | links = main.topo.getAllLinks( main ) |
| 381 | linksResults = main.TRUE |
| 382 | linkFails = [] # Reset for each failed attempt |
| 383 | if not hostsResults: |
| 384 | hosts = main.topo.getAllHosts( main ) |
| 385 | hostsResults = main.TRUE |
| 386 | hostFails = [] # Reset for each failed attempt |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 387 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 388 | # Check for matching topology on each node |
| 389 | for controller in range( main.numCtrls ): |
| 390 | controllerStr = str( controller + 1 ) # ONOS node number |
| 391 | # Compare Devices |
| 392 | if devices[ controller ] and ports[ controller ] and\ |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 393 | "Error" not in devices[ controller ] and\ |
| 394 | "Error" not in ports[ controller ]: |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 395 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 396 | try: |
| 397 | deviceData = json.loads( devices[ controller ] ) |
| 398 | portData = json.loads( ports[ controller ] ) |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 399 | except ( TypeError, ValueError ): |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 400 | main.log.error( "Could not load json: {0} or {1}".format( str( devices[ controller ] ), |
| 401 | str( ports[ controller ] ) ) ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 402 | currentDevicesResult = main.FALSE |
| 403 | else: |
| 404 | currentDevicesResult = main.Mininet1.compareSwitches( |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 405 | mnSwitches, deviceData, portData ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 406 | else: |
| 407 | currentDevicesResult = main.FALSE |
| 408 | if not currentDevicesResult: |
| 409 | deviceFails.append( controllerStr ) |
| 410 | devicesResults = devicesResults and currentDevicesResult |
| 411 | # Compare Links |
| 412 | if links[ controller ] and "Error" not in links[ controller ]: |
| 413 | try: |
| 414 | linkData = json.loads( links[ controller ] ) |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 415 | except ( TypeError, ValueError ): |
| 416 | main.log.error( "Could not load json:" + str( links[ controller ] ) ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 417 | currentLinksResult = main.FALSE |
| 418 | else: |
| 419 | currentLinksResult = main.Mininet1.compareLinks( |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 420 | mnSwitches, mnLinks, linkData ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 421 | else: |
| 422 | currentLinksResult = main.FALSE |
| 423 | if not currentLinksResult: |
| 424 | linkFails.append( controllerStr ) |
| 425 | linksResults = linksResults and currentLinksResult |
| 426 | # Compare Hosts |
| 427 | if hosts[ controller ] and "Error" not in hosts[ controller ]: |
| 428 | try: |
| 429 | hostData = json.loads( hosts[ controller ] ) |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 430 | except ( TypeError, ValueError ): |
| 431 | main.log.error( "Could not load json:" + str( hosts[ controller ] ) ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 432 | currentHostsResult = main.FALSE |
| 433 | else: |
| 434 | currentHostsResult = main.Mininet1.compareHosts( |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 435 | mnHosts, hostData ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 436 | else: |
| 437 | currentHostsResult = main.FALSE |
| 438 | if not currentHostsResult: |
| 439 | hostFails.append( controllerStr ) |
| 440 | hostsResults = hostsResults and currentHostsResult |
| 441 | # Decrement Attempts Remaining |
| 442 | attempts -= 1 |
| 443 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 444 | utilities.assert_equals( expect=[], |
| 445 | actual=deviceFails, |
| 446 | onpass="ONOS correctly discovered all devices", |
| 447 | onfail="ONOS incorrectly discovered devices on nodes: " + |
| 448 | str( deviceFails ) ) |
| 449 | utilities.assert_equals( expect=[], |
| 450 | actual=linkFails, |
| 451 | onpass="ONOS correctly discovered all links", |
| 452 | onfail="ONOS incorrectly discovered links on nodes: " + |
| 453 | str( linkFails ) ) |
| 454 | utilities.assert_equals( expect=[], |
| 455 | actual=hostFails, |
| 456 | onpass="ONOS correctly discovered all hosts", |
| 457 | onfail="ONOS incorrectly discovered hosts on nodes: " + |
| 458 | str( hostFails ) ) |
| 459 | topoResults = hostsResults and linksResults and devicesResults |
| 460 | utilities.assert_equals( expect=main.TRUE, |
| 461 | actual=topoResults, |
| 462 | onpass="ONOS correctly discovered the topology", |
| 463 | onfail="ONOS incorrectly discovered the topology" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 464 | |
| 465 | def CASE9( self, main ): |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 466 | """ |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 467 | Report errors/warnings/exceptions |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 468 | """ |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 469 | main.log.info( "Error report: \n" ) |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 470 | main.ONOSbench.logReport( globalONOSip[ 0 ], |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 471 | [ "INFO", "FOLLOWER", "WARN", "flow", "ERROR", "Except" ], |
| 472 | "s" ) |
| 473 | #main.ONOSbench.logReport( globalONOSip[ 1 ], [ "INFO" ], "d" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 474 | |
| 475 | def CASE10( self, main ): |
| 476 | """ |
| 477 | Start Mininet topology with OF 1.0 switches |
| 478 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 479 | if main.initialized == main.FALSE: |
| 480 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 481 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 482 | main.OFProtocol = "1.0" |
| 483 | main.log.report( "Start Mininet topology with OF 1.0 switches" ) |
| 484 | main.case( "Start Mininet topology with OF 1.0 switches" ) |
| 485 | main.caseExplanation = "Start mininet topology with OF 1.0 " +\ |
| 486 | "switches to test intents, exits out if " +\ |
| 487 | "topology did not start correctly" |
| 488 | |
| 489 | main.step( "Starting Mininet topology with OF 1.0 switches" ) |
| 490 | args = "--switch ovs,protocols=OpenFlow10" |
| 491 | topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + |
| 492 | main.topology, |
| 493 | args=args ) |
| 494 | stepResult = topoResult |
| 495 | utilities.assert_equals( expect=main.TRUE, |
| 496 | actual=stepResult, |
| 497 | onpass="Successfully loaded topology", |
| 498 | onfail="Failed to load topology" ) |
| 499 | # Exit if topology did not load properly |
| 500 | if not topoResult: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 501 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 502 | |
| 503 | def CASE11( self, main ): |
| 504 | """ |
| 505 | Start Mininet topology with OF 1.3 switches |
| 506 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 507 | if main.initialized == main.FALSE: |
| 508 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 509 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 510 | main.OFProtocol = "1.3" |
| 511 | main.log.report( "Start Mininet topology with OF 1.3 switches" ) |
| 512 | main.case( "Start Mininet topology with OF 1.3 switches" ) |
| 513 | main.caseExplanation = "Start mininet topology with OF 1.3 " +\ |
| 514 | "switches to test intents, exits out if " +\ |
| 515 | "topology did not start correctly" |
| 516 | |
| 517 | main.step( "Starting Mininet topology with OF 1.3 switches" ) |
| 518 | args = "--switch ovs,protocols=OpenFlow13" |
| 519 | topoResult = main.Mininet1.startNet( topoFile=main.dependencyPath + |
| 520 | main.topology, |
| 521 | args=args ) |
| 522 | stepResult = topoResult |
| 523 | utilities.assert_equals( expect=main.TRUE, |
| 524 | actual=stepResult, |
| 525 | onpass="Successfully loaded topology", |
| 526 | onfail="Failed to load topology" ) |
| 527 | # Exit if topology did not load properly |
| 528 | if not topoResult: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 529 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 530 | |
| 531 | def CASE12( self, main ): |
| 532 | """ |
| 533 | Assign mastership to controllers |
| 534 | """ |
| 535 | import re |
| 536 | |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 537 | if main.initialized == main.FALSE: |
| 538 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 539 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 540 | main.case( "Assign switches to controllers" ) |
| 541 | main.step( "Assigning switches to controllers" ) |
| 542 | main.caseExplanation = "Assign OF " + main.OFProtocol +\ |
| 543 | " switches to ONOS nodes" |
| 544 | |
| 545 | assignResult = main.TRUE |
| 546 | switchList = [] |
| 547 | |
| 548 | # Creates a list switch name, use getSwitch() function later... |
| 549 | for i in range( 1, ( main.numSwitch + 1 ) ): |
| 550 | switchList.append( 's' + str( i ) ) |
| 551 | |
| 552 | tempONOSip = [] |
| 553 | for i in range( main.numCtrls ): |
| 554 | tempONOSip.append( main.ONOSip[ i ] ) |
| 555 | |
| 556 | assignResult = main.Mininet1.assignSwController( sw=switchList, |
| 557 | ip=tempONOSip, |
Charles Chan | 029be65 | 2015-08-24 01:46:10 +0800 | [diff] [blame] | 558 | port='6653' ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 559 | if not assignResult: |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 560 | main.log.error( "Problem assigning mastership of switches, skipping further test cases" ) |
| 561 | main.initialized = main.FALSE |
| 562 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 563 | |
| 564 | for i in range( 1, ( main.numSwitch + 1 ) ): |
| 565 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 566 | print( "Response is " + str( response ) ) |
| 567 | if re.search( "tcp:" + main.ONOSip[ 0 ], response ): |
| 568 | assignResult = assignResult and main.TRUE |
| 569 | else: |
| 570 | assignResult = main.FALSE |
| 571 | stepResult = assignResult |
| 572 | utilities.assert_equals( expect=main.TRUE, |
| 573 | actual=stepResult, |
| 574 | onpass="Successfully assigned switches" + |
| 575 | "to controller", |
| 576 | onfail="Failed to assign switches to " + |
| 577 | "controller" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 578 | if not stepResult: |
| 579 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 580 | |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 581 | def CASE13( self, main ): |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 582 | """ |
| 583 | Create Scapy components |
| 584 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 585 | if main.initialized == main.FALSE: |
| 586 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 587 | main.skipCase() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 588 | main.case( "Create scapy components" ) |
| 589 | main.step( "Create scapy components" ) |
| 590 | import json |
| 591 | scapyResult = main.TRUE |
| 592 | for hostName in main.scapyHostNames: |
| 593 | main.Scapy1.createHostComponent( hostName ) |
| 594 | main.scapyHosts.append( getattr( main, hostName ) ) |
| 595 | |
| 596 | main.step( "Start scapy components" ) |
| 597 | for host in main.scapyHosts: |
| 598 | host.startHostCli() |
| 599 | host.startScapy() |
| 600 | host.updateSelf() |
| 601 | main.log.debug( host.name ) |
| 602 | main.log.debug( host.hostIp ) |
| 603 | main.log.debug( host.hostMac ) |
| 604 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 605 | utilities.assert_equals( expect=main.TRUE, |
| 606 | actual=scapyResult, |
| 607 | onpass="Successfully created Scapy Components", |
| 608 | onfail="Failed to discover Scapy Components" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 609 | if not scapyResult: |
| 610 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 611 | |
| 612 | def CASE14( self, main ): |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 613 | """ |
| 614 | Discover all hosts and store its data to a dictionary |
| 615 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 616 | if main.initialized == main.FALSE: |
| 617 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 618 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 619 | main.case( "Discover all hosts" ) |
| 620 | |
| 621 | stepResult = main.TRUE |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 622 | main.step( "Discover all ipv4 host hosts " ) |
| 623 | hostList = [] |
| 624 | # List of host with default vlan |
| 625 | defaultHosts = [ "h1", "h3", "h8", "h9", "h11", "h16", "h17", "h19", "h24" ] |
| 626 | # Lists of host with unique vlan |
| 627 | vlanHosts1 = [ "h4", "h12", "h20" ] |
| 628 | vlanHosts2 = [ "h5", "h13", "h21" ] |
| 629 | vlanHosts3 = [ "h6", "h14", "h22" ] |
| 630 | vlanHosts4 = [ "h7", "h15", "h23" ] |
| 631 | hostList.append( defaultHosts ) |
| 632 | hostList.append( vlanHosts1 ) |
| 633 | hostList.append( vlanHosts2 ) |
| 634 | hostList.append( vlanHosts3 ) |
| 635 | hostList.append( vlanHosts4 ) |
| 636 | |
| 637 | stepResult = main.intentFunction.getHostsData( main, hostList ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 638 | utilities.assert_equals( expect=main.TRUE, |
| 639 | actual=stepResult, |
| 640 | onpass="Successfully discovered hosts", |
| 641 | onfail="Failed to discover hosts" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 642 | if not stepResult: |
| 643 | main.initialized = main.FALSE |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 644 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 645 | def CASE15( self, main ): |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 646 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 647 | Discover all hosts with scapy arp packets and store its data to a dictionary |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 648 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 649 | if main.initialized == main.FALSE: |
| 650 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 651 | main.skipCase() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 652 | main.case( "Discover all hosts using scapy" ) |
| 653 | main.step( "Send packets from each host to the first host and confirm onos discovery" ) |
| 654 | |
| 655 | import collections |
| 656 | if len( main.scapyHosts ) < 1: |
| 657 | main.log.error( "No scapy hosts have been created" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 658 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 659 | main.skipCase() |
| 660 | |
| 661 | # Send ARP packets from each scapy host component |
| 662 | main.intentFunction.sendDiscoveryArp( main, main.scapyHosts ) |
| 663 | |
| 664 | stepResult = utilities.retry( f=main.intentFunction.confirmHostDiscovery, |
| 665 | retValue=main.FALSE, args=[ main ], |
| 666 | attempts=main.checkTopoAttempts, sleep=2 ) |
| 667 | |
| 668 | utilities.assert_equals( expect=main.TRUE, |
| 669 | actual=stepResult, |
| 670 | onpass="ONOS correctly discovered all hosts", |
| 671 | onfail="ONOS incorrectly discovered hosts" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 672 | if not stepResult: |
| 673 | main.initialized = main.FALSE |
| 674 | main.skipCase() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 675 | |
| 676 | main.step( "Populate hostsData" ) |
| 677 | stepResult = main.intentFunction.populateHostData( main ) |
| 678 | utilities.assert_equals( expect=main.TRUE, |
| 679 | actual=stepResult, |
| 680 | onpass="Successfully populated hostsData", |
| 681 | onfail="Failed to populate hostsData" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 682 | if not stepResult: |
| 683 | main.initialized = main.FALSE |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 684 | |
| 685 | def CASE16( self, main ): |
| 686 | """ |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 687 | Balance Masters |
| 688 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 689 | if main.initialized == main.FALSE: |
| 690 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 691 | main.skipCase() |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 692 | main.case( "Balance mastership of switches" ) |
| 693 | main.step( "Balancing mastership of switches" ) |
| 694 | |
| 695 | balanceResult = main.FALSE |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 696 | balanceResult = utilities.retry( f=main.CLIs[ 0 ].balanceMasters, retValue=main.FALSE, args=[] ) |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 697 | |
| 698 | utilities.assert_equals( expect=main.TRUE, |
| 699 | actual=stepResult, |
| 700 | onpass="Successfully balanced mastership of switches", |
| 701 | onfail="Failed to balance mastership of switches" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 702 | if not stepResult: |
| 703 | main.initialized = main.FALSE |
Jeremy | 42df2e7 | 2016-02-23 16:37:46 -0800 | [diff] [blame] | 704 | |
| 705 | def CASE17( self, main ): |
| 706 | """ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 707 | Use Flow Objectives |
| 708 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 709 | if main.initialized == main.FALSE: |
| 710 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 711 | main.skipCase() |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 712 | main.case( "Enable intent compilation using Flow Objectives" ) |
| 713 | main.step( "Enabling Flow Objectives" ) |
| 714 | |
| 715 | main.flowCompiler = "Flow Objectives" |
| 716 | |
| 717 | cmd = "org.onosproject.net.intent.impl.compiler.IntentConfigurableRegistrator" |
| 718 | |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 719 | stepResult = main.CLIs[ 0 ].setCfg( component=cmd, |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 720 | propName="useFlowObjectives", value="true" ) |
You Wang | 106d0fa | 2017-05-15 17:22:15 -0700 | [diff] [blame] | 721 | stepResult &= main.CLIs[ 0 ].setCfg( component=cmd, |
| 722 | propName="defaultFlowObjectiveCompiler", |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 723 | value='org.onosproject.net.intent.impl.compiler.LinkCollectionIntentObjectiveCompiler' ) |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 724 | |
| 725 | utilities.assert_equals( expect=main.TRUE, |
| 726 | actual=stepResult, |
| 727 | onpass="Successfully activated Flow Objectives", |
| 728 | onfail="Failed to activate Flow Objectives" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 729 | if not stepResult: |
| 730 | main.initialized = main.FALSE |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 731 | |
| 732 | def CASE18( self, main ): |
| 733 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 734 | Stop mininet and remove scapy hosts |
| 735 | """ |
| 736 | main.log.report( "Stop Mininet and Scapy" ) |
| 737 | main.case( "Stop Mininet and Scapy" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 738 | main.caseExplanation = "Stopping the current mininet topology " +\ |
| 739 | "to start up fresh" |
| 740 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 741 | main.step( "Stopping and Removing Scapy Host Components" ) |
| 742 | scapyResult = main.TRUE |
| 743 | for host in main.scapyHosts: |
| 744 | scapyResult = scapyResult and host.stopScapy() |
| 745 | main.log.info( "Stopped Scapy Host: {0}".format( host.name ) ) |
| 746 | |
| 747 | for host in main.scapyHosts: |
| 748 | scapyResult = scapyResult and main.Scapy1.removeHostComponent( host.name ) |
| 749 | main.log.info( "Removed Scapy Host Component: {0}".format( host.name ) ) |
| 750 | |
| 751 | main.scapyHosts = [] |
| 752 | main.scapyHostIPs = [] |
| 753 | |
| 754 | utilities.assert_equals( expect=main.TRUE, |
| 755 | actual=scapyResult, |
| 756 | onpass="Successfully stopped scapy and removed host components", |
| 757 | onfail="Failed to stop mininet and scapy" ) |
| 758 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 759 | main.step( "Stopping Mininet Topology" ) |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 760 | mininetResult = main.Mininet1.stopNet() |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 761 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 762 | utilities.assert_equals( expect=main.TRUE, |
| 763 | actual=stepResult, |
| 764 | onpass="Successfully stop mininet", |
| 765 | onfail="Failed to stop mininet" ) |
| 766 | # Exit if topology did not load properly |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 767 | if not ( mininetResult and scapyResult ): |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 768 | main.cleanup() |
| 769 | main.exit() |
| 770 | |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 771 | def CASE19( self, main ): |
| 772 | """ |
| 773 | Copy the karaf.log files after each testcase cycle |
| 774 | """ |
| 775 | main.log.report( "Copy karaf logs" ) |
| 776 | main.case( "Copy karaf logs" ) |
| 777 | main.caseExplanation = "Copying the karaf logs to preserve them through" +\ |
| 778 | "reinstalling ONOS" |
| 779 | main.step( "Copying karaf logs" ) |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 780 | stepResult = main.TRUE |
| 781 | scpResult = main.TRUE |
| 782 | copyResult = main.TRUE |
Jeremy Songster | cc5414b | 2016-07-11 10:59:53 -0700 | [diff] [blame] | 783 | for i in range( main.numCtrls ): |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 784 | main.node = main.CLIs[ i ] |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 785 | ip = main.ONOSip[ i ] |
| 786 | main.node.ip_address = ip |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 787 | scpResult = scpResult and main.ONOSbench.scp( main.node, |
| 788 | "/opt/onos/log/karaf.log", |
| 789 | "/tmp/karaf.log", |
| 790 | direction="from" ) |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 791 | copyResult = copyResult and main.ONOSbench.cpLogsToDir( "/tmp/karaf.log", main.logdir, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 792 | copyFileName=( "karaf.log.node{0}.cycle{1}".format( |
| 793 | str( i + 1 ), str( main.cycle ) ) ) ) |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 794 | if scpResult and copyResult: |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 795 | stepResult = main.TRUE and stepResult |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 796 | else: |
| 797 | stepResult = main.FALSE and stepResult |
Jeremy Songster | 31aad31 | 2016-06-13 16:32:11 -0700 | [diff] [blame] | 798 | utilities.assert_equals( expect=main.TRUE, |
| 799 | actual=stepResult, |
| 800 | onpass="Successfully copied remote ONOS logs", |
| 801 | onfail="Failed to copy remote ONOS logs" ) |
Jeremy Songster | 17147f2 | 2016-05-31 18:30:52 -0700 | [diff] [blame] | 802 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 803 | def CASE1000( self, main ): |
| 804 | """ |
| 805 | Add host intents between 2 host: |
| 806 | - Discover hosts |
| 807 | - Add host intents |
| 808 | - Check intents |
| 809 | - Verify flows |
| 810 | - Ping hosts |
| 811 | - Reroute |
| 812 | - Link down |
| 813 | - Verify flows |
| 814 | - Check topology |
| 815 | - Ping hosts |
| 816 | - Link up |
| 817 | - Verify flows |
| 818 | - Check topology |
| 819 | - Ping hosts |
| 820 | - Remove intents |
| 821 | """ |
| 822 | import time |
| 823 | import json |
| 824 | import re |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 825 | if main.initialized == main.FALSE: |
| 826 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 827 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 828 | # Assert variables - These variable's name|format must be followed |
| 829 | # if you want to use the wrapper function |
| 830 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 831 | try: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 832 | assert main.RESTs |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 833 | except AssertionError: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 834 | main.log.error( "There is no main.RESTs, skipping test cases" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 835 | main.initialized = main.FALSE |
| 836 | main.skipCase() |
| 837 | try: |
| 838 | assert main.Mininet1 |
| 839 | except AssertionError: |
| 840 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 841 | main.initialized = main.FALSE |
| 842 | main.skipCase() |
| 843 | try: |
| 844 | assert main.numSwitch |
| 845 | except AssertionError: |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 846 | main.log.error( "Place the total number of switch topology in " + |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 847 | main.numSwitch ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 848 | main.initialized = main.FALSE |
| 849 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 850 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 851 | # Save leader candidates |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 852 | intentLeadersOld = main.CLIs[ 0 ].leaderCandidates() |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 853 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 854 | main.case( "Host Intents Test - " + str( main.numCtrls ) + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 855 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 856 | main.caseExplanation = "This test case tests Host intents using " +\ |
| 857 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 858 | "Different type of hosts will be tested in " +\ |
| 859 | "each step such as IPV4, Dual stack, VLAN " +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 860 | "etc;\nThe test will use OF " + main.OFProtocol +\ |
| 861 | " OVS running in Mininet and compile intents" +\ |
| 862 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 863 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 864 | main.step( "IPV4: Add and test host intents between h1 and h9" ) |
| 865 | main.assertReturnString = "Assertion result for IPV4 host intent with mac addresses\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 866 | host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" } |
| 867 | host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 868 | testResult = main.FALSE |
| 869 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 870 | name='IPV4', |
| 871 | onosNode='0', |
| 872 | host1=host1, |
| 873 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 874 | |
| 875 | if installResult: |
| 876 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 877 | name='IPV4', |
| 878 | intentId=installResult, |
| 879 | onosNode='0', |
| 880 | host1=host1, |
| 881 | host2=host2, |
| 882 | sw1='s5', |
| 883 | sw2='s2', |
| 884 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 885 | |
| 886 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 887 | actual=testResult, |
| 888 | onpass=main.assertReturnString, |
| 889 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 890 | |
| 891 | main.step( "DUALSTACK1: Add host intents between h3 and h11" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 892 | main.assertReturnString = "Assertion Result for dualstack IPV4 with MAC addresses\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 893 | host1 = { "name": "h3", "id": "00:00:00:00:00:03/-1" } |
| 894 | host2 = { "name": "h11", "id": "00:00:00:00:00:0B/-1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 895 | testResult = main.FALSE |
| 896 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 897 | name='DUALSTACK1', |
| 898 | onosNode='0', |
| 899 | host1=host1, |
| 900 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 901 | |
| 902 | if installResult: |
| 903 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 904 | name='DUALSTACK1', |
| 905 | intentId=installResult, |
| 906 | onosNode='0', |
| 907 | host1=host1, |
| 908 | host2=host2, |
| 909 | sw1='s5', |
| 910 | sw2='s2', |
| 911 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 912 | |
| 913 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 914 | actual=testResult, |
| 915 | onpass=main.assertReturnString, |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 916 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 917 | |
| 918 | main.step( "DUALSTACK2: Add host intents between h1 and h11" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 919 | main.assertReturnString = "Assertion Result for dualstack2 host intent\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 920 | host1 = { "name": "h1" } |
| 921 | host2 = { "name": "h11" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 922 | testResult = main.FALSE |
| 923 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 924 | name='DUALSTACK2', |
| 925 | onosNode='0', |
| 926 | host1=host1, |
| 927 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 928 | |
| 929 | if installResult: |
| 930 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 931 | name='DUALSTACK2', |
| 932 | intentId=installResult, |
| 933 | onosNode='0', |
| 934 | host1=host1, |
| 935 | host2=host2, |
| 936 | sw1='s5', |
| 937 | sw2='s2', |
| 938 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 939 | |
| 940 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 941 | actual=testResult, |
| 942 | onpass=main.assertReturnString, |
| 943 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 944 | |
| 945 | main.step( "1HOP: Add host intents between h1 and h3" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 946 | main.assertReturnString = "Assertion Result for 1HOP for IPV4 same switch\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 947 | host1 = { "name": "h1" } |
| 948 | host2 = { "name": "h3" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 949 | testResult = main.FALSE |
| 950 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 951 | name='1HOP', |
| 952 | onosNode='0', |
| 953 | host1=host1, |
| 954 | host2=host2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 955 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 956 | if installResult: |
| 957 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 958 | name='1HOP', |
| 959 | intentId=installResult, |
| 960 | onosNode='0', |
| 961 | host1=host1, |
| 962 | host2=host2, |
| 963 | sw1='s5', |
| 964 | sw2='s2', |
| 965 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 966 | |
| 967 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 968 | actual=testResult, |
| 969 | onpass=main.assertReturnString, |
| 970 | onfail=main.assertReturnString ) |
| 971 | |
| 972 | main.step( "VLAN1: Add vlan host intents between h4 and h12" ) |
| 973 | main.assertReturnString = "Assertion Result vlan IPV4\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 974 | host1 = { "name": "h4", "id": "00:00:00:00:00:04/100", "vlanId": "100" } |
| 975 | host2 = { "name": "h12", "id": "00:00:00:00:00:0C/100", "vlanId": "100" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 976 | testResult = main.FALSE |
| 977 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 978 | name='VLAN1', |
| 979 | onosNode='0', |
| 980 | host1=host1, |
| 981 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 982 | |
| 983 | if installResult: |
| 984 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 985 | name='VLAN1', |
| 986 | intentId=installResult, |
| 987 | onosNode='0', |
| 988 | host1=host1, |
| 989 | host2=host2, |
| 990 | sw1='s5', |
| 991 | sw2='s2', |
| 992 | expectedLink=18 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 993 | |
| 994 | utilities.assert_equals( expect=main.TRUE, |
| 995 | actual=testResult, |
| 996 | onpass=main.assertReturnString, |
| 997 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 998 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 999 | # This step isn't currently possible to perform in the REST API |
| 1000 | # main.step( "VLAN2: Add inter vlan host intents between h13 and h20" ) |
| 1001 | # main.assertReturnString = "Assertion Result different VLAN negative test\n" |
| 1002 | # host1 = { "name":"h13" } |
| 1003 | # host2 = { "name":"h20" } |
| 1004 | # testResult = main.FALSE |
| 1005 | # installResult = main.intentFunction.installHostIntent( main, |
| 1006 | # name='VLAN2', |
| 1007 | # onosNode='0', |
| 1008 | # host1=host1, |
| 1009 | # host2=host2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1010 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1011 | # if installResult: |
| 1012 | # testResult = main.intentFunction.testHostIntent( main, |
| 1013 | # name='VLAN2', |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1014 | # intentId=installResult, |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1015 | # onosNode='0', |
| 1016 | # host1=host1, |
| 1017 | # host2=host2, |
| 1018 | # sw1='s5', |
| 1019 | # sw2='s2', |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1020 | # expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1021 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1022 | # utilities.assert_equals( expect=main.TRUE, |
| 1023 | # actual=testResult, |
| 1024 | # onpass=main.assertReturnString, |
| 1025 | # onfail=main.assertReturnString ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1026 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 1027 | # Change the following to use the REST API when leader checking is |
| 1028 | # supported by it |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1029 | |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1030 | main.step( "Confirm that ONOS leadership is unchanged" ) |
| 1031 | intentLeadersNew = main.CLIs[ 0 ].leaderCandidates() |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 1032 | main.intentFunction.checkLeaderChange( intentLeadersOld, |
| 1033 | intentLeadersNew ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1034 | |
Jeremy | e1ea060 | 2016-02-08 16:35:05 -0800 | [diff] [blame] | 1035 | utilities.assert_equals( expect=main.TRUE, |
| 1036 | actual=testResult, |
| 1037 | onpass="ONOS Leaders Unchanged", |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1038 | onfail="ONOS Leader Mismatch" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1039 | |
| 1040 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1041 | |
| 1042 | def CASE2000( self, main ): |
| 1043 | """ |
| 1044 | Add point intents between 2 hosts: |
| 1045 | - Get device ids | ports |
| 1046 | - Add point intents |
| 1047 | - Check intents |
| 1048 | - Verify flows |
| 1049 | - Ping hosts |
| 1050 | - Reroute |
| 1051 | - Link down |
| 1052 | - Verify flows |
| 1053 | - Check topology |
| 1054 | - Ping hosts |
| 1055 | - Link up |
| 1056 | - Verify flows |
| 1057 | - Check topology |
| 1058 | - Ping hosts |
| 1059 | - Remove intents |
| 1060 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1061 | if main.initialized == main.FALSE: |
| 1062 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1063 | main.skipCase() |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1064 | # Assert variables - These variable's name|format must be followed |
| 1065 | # if you want to use the wrapper function |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1066 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1067 | try: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1068 | assert main.RESTs |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1069 | except AssertionError: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1070 | main.log.error( "There is no main.RESTs, skipping test cases" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1071 | main.initialized = main.FALSE |
| 1072 | main.skipCase() |
| 1073 | try: |
| 1074 | assert main.Mininet1 |
| 1075 | except AssertionError: |
| 1076 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1077 | main.initialized = main.FALSE |
| 1078 | main.skipCase() |
| 1079 | try: |
| 1080 | assert main.numSwitch |
| 1081 | except AssertionError: |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1082 | main.log.error( "Place the total number of switch topology in " + |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1083 | main.numSwitch ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1084 | main.initialized = main.FALSE |
| 1085 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1086 | |
| 1087 | main.case( "Point Intents Test - " + str( main.numCtrls ) + |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1088 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1089 | main.caseExplanation = "This test case will test point to point" + \ |
| 1090 | " intents using " + str( main.numCtrls ) + \ |
| 1091 | " node(s) cluster;\n" + \ |
| 1092 | "Different type of hosts will be tested in " + \ |
| 1093 | "each step such as IPV4, Dual stack, VLAN etc" + \ |
| 1094 | ";\nThe test will use OF " + main.OFProtocol + \ |
| 1095 | " OVS running in Mininet and compile intents" + \ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1096 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1097 | |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1098 | # No option point intent |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1099 | main.step( "NOOPTION: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1100 | main.assertReturnString = "Assertion Result for NOOPTION point intent\n" |
| 1101 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1102 | { "name": "h1", "device": "of:0000000000000005/1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1103 | ] |
| 1104 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1105 | { "name": "h9", "device": "of:0000000000000006/1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1106 | ] |
| 1107 | testResult = main.FALSE |
| 1108 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1109 | main, |
| 1110 | name="NOOPTION", |
| 1111 | senders=senders, |
| 1112 | recipients=recipients ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1113 | |
| 1114 | if installResult: |
| 1115 | testResult = main.intentFunction.testPointIntent( |
| 1116 | main, |
| 1117 | intentId=installResult, |
| 1118 | name="NOOPTION", |
| 1119 | senders=senders, |
| 1120 | recipients=recipients, |
| 1121 | sw1="s5", |
| 1122 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1123 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1124 | |
| 1125 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1126 | actual=testResult, |
| 1127 | onpass=main.assertReturnString, |
| 1128 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1129 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1130 | main.step( "IPV4: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1131 | main.assertReturnString = "Assertion Result for IPV4 point intent\n" |
| 1132 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1133 | { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1134 | ] |
| 1135 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1136 | { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1137 | ] |
| 1138 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1139 | main, |
| 1140 | name="IPV4", |
| 1141 | senders=senders, |
| 1142 | recipients=recipients, |
| 1143 | ethType="IPV4" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1144 | |
| 1145 | if installResult: |
| 1146 | testResult = main.intentFunction.testPointIntent( |
| 1147 | main, |
| 1148 | intentId=installResult, |
| 1149 | name="IPV4", |
| 1150 | senders=senders, |
| 1151 | recipients=recipients, |
| 1152 | sw1="s5", |
| 1153 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1154 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1155 | |
| 1156 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1157 | actual=testResult, |
| 1158 | onpass=main.assertReturnString, |
| 1159 | onfail=main.assertReturnString ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1160 | |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 1161 | # main.step( "Protected: Add point intents between h1 and h9" ) |
| 1162 | # main.assertReturnString = "Assertion Result for protected point intent\n" |
| 1163 | # senders = [ |
| 1164 | # { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" } |
| 1165 | # ] |
| 1166 | # recipients = [ |
| 1167 | # { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09" } |
| 1168 | # ] |
| 1169 | # testResult = main.FALSE |
| 1170 | # installResult = main.intentFunction.installPointIntent( |
| 1171 | # main, |
| 1172 | # name="Protected", |
| 1173 | # senders=senders, |
| 1174 | # recipients=recipients, |
| 1175 | # protected=True ) |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1176 | # |
alison | da15727 | 2016-12-22 01:13:21 -0800 | [diff] [blame] | 1177 | # if installResult: |
| 1178 | # testResult = main.intentFunction.testPointIntent( |
| 1179 | # main, |
| 1180 | # name="Protected", |
| 1181 | # intentId=installResult, |
| 1182 | # senders=senders, |
| 1183 | # recipients=recipients, |
| 1184 | # sw1="s5", |
| 1185 | # sw2="s2", |
| 1186 | # protected=True, |
| 1187 | # expectedLink=18 ) |
| 1188 | # |
| 1189 | # utilities.assert_equals( expect=main.TRUE, |
| 1190 | # actual=testResult, |
| 1191 | # onpass=main.assertReturnString, |
| 1192 | # onfail=main.assertReturnString ) |
| 1193 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1194 | main.step( "IPV4_2: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1195 | main.assertReturnString = "Assertion Result for IPV4 no mac address point intents\n" |
| 1196 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1197 | { "name": "h1", "device": "of:0000000000000005/1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1198 | ] |
| 1199 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1200 | { "name": "h9", "device": "of:0000000000000006/1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1201 | ] |
| 1202 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1203 | main, |
| 1204 | name="IPV4_2", |
| 1205 | senders=senders, |
| 1206 | recipients=recipients, |
| 1207 | ethType="IPV4" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1208 | |
| 1209 | if installResult: |
| 1210 | testResult = main.intentFunction.testPointIntent( |
| 1211 | main, |
| 1212 | intentId=installResult, |
| 1213 | name="IPV4_2", |
| 1214 | senders=senders, |
| 1215 | recipients=recipients, |
| 1216 | sw1="s5", |
| 1217 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1218 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1219 | |
| 1220 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1221 | actual=testResult, |
| 1222 | onpass=main.assertReturnString, |
| 1223 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1224 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1225 | main.step( "SDNIP-ICMP: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1226 | main.assertReturnString = "Assertion Result for SDNIP-ICMP IPV4 using TCP point intents\n" |
| 1227 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1228 | { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01", |
| 1229 | "ip": ( main.h1.hostIp + "/24" ) } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1230 | ] |
| 1231 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1232 | { "name": "h9", "device": "of:0000000000000006/1", "mac": "00:00:00:00:00:09", |
| 1233 | "ip": ( main.h9.hostIp + "/24" ) } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1234 | ] |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1235 | # ipProto = main.params[ 'SDNIP' ][ 'icmpProto' ] |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1236 | ipProto = main.params[ 'SDNIP' ][ 'ipPrototype' ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1237 | # Uneccessary, not including this in the selectors |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1238 | tcpSrc = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 1239 | tcpDst = main.params[ 'SDNIP' ][ 'dstPort' ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1240 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1241 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1242 | main, |
| 1243 | name="SDNIP-ICMP", |
| 1244 | senders=senders, |
| 1245 | recipients=recipients, |
| 1246 | ethType="IPV4", |
| 1247 | ipProto=ipProto, |
| 1248 | tcpSrc=tcpSrc, |
| 1249 | tcpDst=tcpDst ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1250 | |
| 1251 | if installResult: |
| 1252 | testResult = main.intentFunction.testPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1253 | main, |
| 1254 | intentId=installResult, |
| 1255 | name="SDNIP_ICMP", |
| 1256 | senders=senders, |
| 1257 | recipients=recipients, |
| 1258 | sw1="s5", |
| 1259 | sw2="s2", |
| 1260 | expectedLink=18, |
| 1261 | useTCP=True ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1262 | |
| 1263 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1264 | actual=testResult, |
| 1265 | onpass=main.assertReturnString, |
| 1266 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1267 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1268 | main.step( "SDNIP-TCP: Add point intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1269 | main.assertReturnString = "Assertion Result for SDNIP-TCP IPV4 using ICMP point intents\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1270 | mac1 = main.hostsData[ 'h1' ][ 'mac' ] |
| 1271 | mac2 = main.hostsData[ 'h9' ][ 'mac' ] |
| 1272 | ip1 = str( main.hostsData[ 'h1' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
| 1273 | ip2 = str( main.hostsData[ 'h9' ][ 'ipAddresses' ][ 0 ] ) + "/32" |
| 1274 | ipProto = main.params[ 'SDNIP' ][ 'tcpProto' ] |
| 1275 | tcp1 = main.params[ 'SDNIP' ][ 'srcPort' ] |
| 1276 | tcp2 = main.params[ 'SDNIP' ][ 'dstPort' ] |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1277 | |
kelvin-onlab | 0e68468 | 2015-08-11 18:51:41 -0700 | [diff] [blame] | 1278 | stepResult = main.intentFunction.pointIntentTcp( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1279 | main, |
| 1280 | name="SDNIP-TCP", |
| 1281 | host1="h1", |
| 1282 | host2="h9", |
| 1283 | deviceId1="of:0000000000000005/1", |
| 1284 | deviceId2="of:0000000000000006/1", |
| 1285 | mac1=mac1, |
| 1286 | mac2=mac2, |
| 1287 | ethType="IPV4", |
| 1288 | ipProto=ipProto, |
| 1289 | ip1=ip1, |
| 1290 | ip2=ip2, |
| 1291 | tcp1=tcp1, |
| 1292 | tcp2=tcp2 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1293 | |
| 1294 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1295 | actual=stepResult, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1296 | onpass=main.assertReturnString, |
| 1297 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1298 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1299 | main.step( "DUALSTACK1: Add point intents between h3 and h11" ) |
| 1300 | main.assertReturnString = "Assertion Result for Dualstack1 IPV4 with mac address point intents\n" |
| 1301 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1302 | { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1303 | ] |
| 1304 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1305 | { "name": "h11", "device": "of:0000000000000006/3", "mac": "00:00:00:00:00:0B" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1306 | ] |
| 1307 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1308 | main, |
| 1309 | name="DUALSTACK1", |
| 1310 | senders=senders, |
| 1311 | recipients=recipients, |
| 1312 | ethType="IPV4" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1313 | |
| 1314 | if installResult: |
| 1315 | testResult = main.intentFunction.testPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1316 | main, |
| 1317 | intentId=installResult, |
| 1318 | name="DUALSTACK1", |
| 1319 | senders=senders, |
| 1320 | recipients=recipients, |
| 1321 | sw1="s5", |
| 1322 | sw2="s2", |
| 1323 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1324 | |
| 1325 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1326 | actual=testResult, |
| 1327 | onpass=main.assertReturnString, |
| 1328 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1329 | |
| 1330 | main.step( "VLAN: Add point intents between h5 and h21" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1331 | main.assertReturnString = "Assertion Result for VLAN IPV4 with mac address point intents\n" |
| 1332 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1333 | { "name": "h5", "device": "of:0000000000000005/5", "mac": "00:00:00:00:00:05", "vlanId": "200" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1334 | ] |
| 1335 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1336 | { "name": "h21", "device": "of:0000000000000007/5", "mac": "00:00:00:00:00:15", "vlanId": "200" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1337 | ] |
| 1338 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1339 | main, |
| 1340 | name="VLAN", |
| 1341 | senders=senders, |
| 1342 | recipients=recipients ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1343 | |
| 1344 | if installResult: |
| 1345 | testResult = main.intentFunction.testPointIntent( |
| 1346 | main, |
| 1347 | intentId=installResult, |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1348 | name="VLAN", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1349 | senders=senders, |
| 1350 | recipients=recipients, |
| 1351 | sw1="s5", |
| 1352 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1353 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1354 | |
| 1355 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1356 | actual=testResult, |
| 1357 | onpass=main.assertReturnString, |
| 1358 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1359 | |
Jeremy Songster | ae2dd45 | 2016-05-17 16:44:35 -0700 | [diff] [blame] | 1360 | # TODO: implement VLAN selector REST API intent test once supported |
| 1361 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1362 | main.step( "1HOP: Add point intents between h1 and h3" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1363 | main.assertReturnString = "Assertion Result for 1HOP IPV4 with no mac address point intents\n" |
| 1364 | senders = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1365 | { "name": "h1", "device": "of:0000000000000005/1", "mac": "00:00:00:00:00:01" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1366 | ] |
| 1367 | recipients = [ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1368 | { "name": "h3", "device": "of:0000000000000005/3", "mac": "00:00:00:00:00:03" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1369 | ] |
| 1370 | installResult = main.intentFunction.installPointIntent( |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1371 | main, |
| 1372 | name="1HOP IPV4", |
| 1373 | senders=senders, |
| 1374 | recipients=recipients, |
| 1375 | ethType="IPV4" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1376 | |
| 1377 | if installResult: |
| 1378 | testResult = main.intentFunction.testPointIntent( |
| 1379 | main, |
| 1380 | intentId=installResult, |
| 1381 | name="1HOP IPV4", |
| 1382 | senders=senders, |
| 1383 | recipients=recipients, |
| 1384 | sw1="s5", |
| 1385 | sw2="s2", |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1386 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1387 | |
| 1388 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1389 | actual=testResult, |
| 1390 | onpass=main.assertReturnString, |
| 1391 | onfail=main.assertReturnString ) |
| 1392 | |
| 1393 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1394 | |
| 1395 | def CASE3000( self, main ): |
| 1396 | """ |
| 1397 | Add single point to multi point intents |
| 1398 | - Get device ids |
| 1399 | - Add single point to multi point intents |
| 1400 | - Check intents |
| 1401 | - Verify flows |
| 1402 | - Ping hosts |
| 1403 | - Reroute |
| 1404 | - Link down |
| 1405 | - Verify flows |
| 1406 | - Check topology |
| 1407 | - Ping hosts |
| 1408 | - Link up |
| 1409 | - Verify flows |
| 1410 | - Check topology |
| 1411 | - Ping hosts |
| 1412 | - Remove intents |
| 1413 | """ |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1414 | if main.initialized == main.FALSE: |
| 1415 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1416 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1417 | assert main, "There is no main" |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1418 | |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1419 | try: |
| 1420 | assert main.CLIs, "There is no main.CLIs, skipping test cases" |
| 1421 | assert main.Mininet1, "Mininet handle should be named Mininet1, skipping test cases" |
| 1422 | assert main.numSwitch, "Place the total number of switch topology in main.numSwitch" |
| 1423 | except AssertionError: |
| 1424 | main.initialized = main.FALSE |
| 1425 | main.skipCase() |
| 1426 | |
| 1427 | main.testName = "Single to Multi Point Intents" |
| 1428 | main.case( main.testName + " Test - " + str( main.numCtrls ) + |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1429 | " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1430 | main.caseExplanation = "This test case will test single point to" + \ |
| 1431 | " multi point intents using " + \ |
| 1432 | str( main.numCtrls ) + " node(s) cluster;\n" + \ |
| 1433 | "Different type of hosts will be tested in " + \ |
| 1434 | "each step such as IPV4, Dual stack, VLAN etc" + \ |
| 1435 | ";\nThe test will use OF " + main.OFProtocol + \ |
| 1436 | " OVS running in Mininet and compile intents" + \ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1437 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1438 | |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1439 | main.step( "NOOPTION: Install and test single point to multi point intents" ) |
| 1440 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent with no options set\n" |
| 1441 | senders = [ |
| 1442 | { "name": "h8", "device": "of:0000000000000005/8" } |
| 1443 | ] |
| 1444 | recipients = [ |
| 1445 | { "name": "h16", "device": "of:0000000000000006/8" }, |
| 1446 | { "name": "h24", "device": "of:0000000000000007/8" } |
| 1447 | ] |
| 1448 | badSenders = [ { "name": "h9" } ] # Senders that are not in the intent |
| 1449 | badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent |
| 1450 | testResult = main.FALSE |
| 1451 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1452 | main, |
| 1453 | name="NOOPTION", |
| 1454 | senders=senders, |
| 1455 | recipients=recipients ) |
| 1456 | |
| 1457 | if installResult: |
| 1458 | testResult = main.intentFunction.testPointIntent( |
| 1459 | main, |
| 1460 | intentId=installResult, |
| 1461 | name="NOOPTION", |
| 1462 | senders=senders, |
| 1463 | recipients=recipients, |
| 1464 | badSenders=badSenders, |
| 1465 | badRecipients=badRecipients, |
| 1466 | sw1="s5", |
| 1467 | sw2="s2", |
| 1468 | expectedLink=18 ) |
| 1469 | else: |
| 1470 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1471 | |
| 1472 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1473 | actual=testResult, |
| 1474 | onpass=main.assertReturnString, |
| 1475 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1476 | |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1477 | main.step( "IPV4: Install and test single point to multi point intents" ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1478 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \ |
| 1479 | "with IPV4 type and MAC addresses\n" |
| 1480 | senders = [ |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1481 | { "name": "h8", "device": "of:0000000000000005/8", "mac": "00:00:00:00:00:08" } |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1482 | ] |
| 1483 | recipients = [ |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1484 | { "name": "h16", "device": "of:0000000000000006/8", "mac": "00:00:00:00:00:10" }, |
| 1485 | { "name": "h24", "device": "of:0000000000000007/8", "mac": "00:00:00:00:00:18" } |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1486 | ] |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1487 | badSenders = [ { "name": "h9" } ] # Senders that are not in the intent |
| 1488 | badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1489 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1490 | main, |
| 1491 | name="IPV4", |
| 1492 | senders=senders, |
| 1493 | recipients=recipients, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1494 | ethType="IPV4" ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1495 | |
| 1496 | if installResult: |
| 1497 | testResult = main.intentFunction.testPointIntent( |
| 1498 | main, |
| 1499 | intentId=installResult, |
| 1500 | name="IPV4", |
| 1501 | senders=senders, |
| 1502 | recipients=recipients, |
| 1503 | badSenders=badSenders, |
| 1504 | badRecipients=badRecipients, |
| 1505 | sw1="s5", |
| 1506 | sw2="s2", |
| 1507 | expectedLink=18 ) |
| 1508 | else: |
| 1509 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1510 | |
| 1511 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1512 | actual=testResult, |
| 1513 | onpass=main.assertReturnString, |
| 1514 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1515 | |
| 1516 | main.step( "IPV4_2: Add single point to multi point intents" ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1517 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent " \ |
| 1518 | "with IPV4 type and no MAC addresses\n" |
| 1519 | senders = [ |
| 1520 | { "name": "h8", "device": "of:0000000000000005/8" } |
| 1521 | ] |
| 1522 | recipients = [ |
| 1523 | { "name": "h16", "device": "of:0000000000000006/8" }, |
| 1524 | { "name": "h24", "device": "of:0000000000000007/8" } |
| 1525 | ] |
| 1526 | badSenders = [ { "name": "h9" } ] # Senders that are not in the intent |
| 1527 | badRecipients = [ { "name": "h17" } ] # Recipients that are not in the intent |
| 1528 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1529 | main, |
| 1530 | name="IPV4_2", |
| 1531 | senders=senders, |
| 1532 | recipients=recipients, |
| 1533 | ethType="IPV4" ) |
| 1534 | |
| 1535 | if installResult: |
| 1536 | testResult = main.intentFunction.testPointIntent( |
| 1537 | main, |
| 1538 | intentId=installResult, |
| 1539 | name="IPV4_2", |
| 1540 | senders=senders, |
| 1541 | recipients=recipients, |
| 1542 | badSenders=badSenders, |
| 1543 | badRecipients=badRecipients, |
| 1544 | sw1="s5", |
| 1545 | sw2="s2", |
| 1546 | expectedLink=18 ) |
| 1547 | else: |
| 1548 | main.CLIs[ 0 ].removeAllIntents( purge=True ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1549 | |
| 1550 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1551 | actual=testResult, |
| 1552 | onpass=main.assertReturnString, |
| 1553 | onfail=main.assertReturnString ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1554 | |
| 1555 | main.step( "VLAN: Add single point to multi point intents" ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1556 | main.assertReturnString = "Assertion results for IPV4 single to multi point intent with IPV4 type " \ |
| 1557 | "and MAC addresses in the same VLAN\n" |
| 1558 | senders = [ |
| 1559 | { "name": "h4", "device": "of:0000000000000005/4", "mac": "00:00:00:00:00:04", "vlan": "100" } |
| 1560 | ] |
| 1561 | recipients = [ |
| 1562 | { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" }, |
| 1563 | { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" } |
| 1564 | ] |
| 1565 | badSenders = [ { "name": "h13" } ] # Senders that are not in the intent |
| 1566 | badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent |
| 1567 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1568 | main, |
| 1569 | name="VLAN", |
| 1570 | senders=senders, |
| 1571 | recipients=recipients, |
| 1572 | sw1="s5", |
| 1573 | sw2="s2" ) |
| 1574 | |
| 1575 | if installResult: |
| 1576 | testResult = main.intentFunction.testPointIntent( |
| 1577 | main, |
| 1578 | intentId=installResult, |
| 1579 | name="VLAN", |
| 1580 | senders=senders, |
| 1581 | recipients=recipients, |
| 1582 | badSenders=badSenders, |
| 1583 | badRecipients=badRecipients, |
| 1584 | sw1="s5", |
| 1585 | sw2="s2", |
| 1586 | expectedLink=18 ) |
| 1587 | else: |
| 1588 | main.CLIs[ 0 ].removeAllIntents() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1589 | |
| 1590 | utilities.assert_equals( expect=main.TRUE, |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1591 | actual=testResult, |
| 1592 | onpass=main.assertReturnString, |
| 1593 | onfail=main.assertReturnString ) |
| 1594 | |
| 1595 | main.step( "VLAN: Add single point to multi point intents" ) |
| 1596 | main.assertReturnString = "Assertion results for single to multi point intent with VLAN treatment\n" |
| 1597 | senders = [ |
| 1598 | { "name": "h5", "vlan": "200" } |
| 1599 | ] |
| 1600 | recipients = [ |
| 1601 | { "name": "h12", "device": "of:0000000000000006/4", "mac": "00:00:00:00:00:0C", "vlan": "100" }, |
| 1602 | { "name": "h20", "device": "of:0000000000000007/4", "mac": "00:00:00:00:00:14", "vlan": "100" } |
| 1603 | ] |
| 1604 | badSenders = [ { "name": "h13" } ] # Senders that are not in the intent |
| 1605 | badRecipients = [ { "name": "h21" } ] # Recipients that are not in the intent |
| 1606 | testResult = main.FALSE |
| 1607 | installResult = main.intentFunction.installSingleToMultiIntent( |
| 1608 | main, |
| 1609 | name="VLAN2", |
| 1610 | senders=senders, |
| 1611 | recipients=recipients, |
| 1612 | sw1="s5", |
| 1613 | sw2="s2" ) |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1614 | #setVlan=100 ) |
Ming Yan Shu | ab2f7f5 | 2016-08-03 15:21:24 -0700 | [diff] [blame] | 1615 | |
| 1616 | if installResult: |
| 1617 | testResult = main.intentFunction.testPointIntent( |
| 1618 | main, |
| 1619 | intentId=installResult, |
| 1620 | name="VLAN2", |
| 1621 | senders=senders, |
| 1622 | recipients=recipients, |
| 1623 | badSenders=badSenders, |
| 1624 | badRecipients=badRecipients, |
| 1625 | sw1="s5", |
| 1626 | sw2="s2", |
| 1627 | expectedLink=18 ) |
| 1628 | else: |
| 1629 | main.CLIs[ 0 ].removeAllIntents() |
| 1630 | |
| 1631 | utilities.assert_equals( expect=main.TRUE, |
| 1632 | actual=testResult, |
| 1633 | onpass=main.assertReturnString, |
| 1634 | onfail=main.assertReturnString ) |
| 1635 | |
| 1636 | main.intentFunction.report( main ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1637 | |
| 1638 | def CASE4000( self, main ): |
| 1639 | """ |
| 1640 | Add multi point to single point intents |
| 1641 | - Get device ids |
| 1642 | - Add multi point to single point intents |
| 1643 | - Check intents |
| 1644 | - Verify flows |
| 1645 | - Ping hosts |
| 1646 | - Reroute |
| 1647 | - Link down |
| 1648 | - Verify flows |
| 1649 | - Check topology |
| 1650 | - Ping hosts |
| 1651 | - Link up |
| 1652 | - Verify flows |
| 1653 | - Check topology |
| 1654 | - Ping hosts |
| 1655 | - Remove intents |
| 1656 | """ |
| 1657 | assert main, "There is no main" |
| 1658 | assert main.CLIs, "There is no main.CLIs" |
| 1659 | assert main.Mininet1, "Mininet handle should be named Mininet1" |
| 1660 | assert main.numSwitch, "Placed the total number of switch topology in \ |
| 1661 | main.numSwitch" |
| 1662 | |
| 1663 | main.case( "Multi To Single Point Intents Test - " + |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1664 | str( main.numCtrls ) + " NODE(S) - OF " + main.OFProtocol + " - Using " + main.flowCompiler ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1665 | main.caseExplanation = "This test case will test single point to" +\ |
| 1666 | " multi point intents using " +\ |
| 1667 | str( main.numCtrls ) + " node(s) cluster;\n" +\ |
| 1668 | "Different type of hosts will be tested in " +\ |
| 1669 | "each step such as IPV4, Dual stack, VLAN etc" +\ |
| 1670 | ";\nThe test will use OF " + main.OFProtocol +\ |
Jeremy | eb51cb1 | 2016-03-28 17:53:35 -0700 | [diff] [blame] | 1671 | " OVS running in Mininet and compile intents" +\ |
| 1672 | " using " + main.flowCompiler |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1673 | |
| 1674 | main.step( "NOOPTION: Add multi point to single point intents" ) |
| 1675 | stepResult = main.TRUE |
| 1676 | hostNames = [ 'h8', 'h16', 'h24' ] |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1677 | devices = [ 'of:0000000000000005/8', 'of:0000000000000006/8', |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1678 | 'of:0000000000000007/8' ] |
| 1679 | macs = [ '00:00:00:00:00:08', '00:00:00:00:00:10', '00:00:00:00:00:18' ] |
| 1680 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1681 | main, |
| 1682 | name="NOOPTION", |
| 1683 | hostNames=hostNames, |
| 1684 | devices=devices, |
| 1685 | sw1="s5", |
| 1686 | sw2="s2", |
| 1687 | expectedLink=18 ) |
| 1688 | |
| 1689 | utilities.assert_equals( expect=main.TRUE, |
| 1690 | actual=stepResult, |
| 1691 | onpass="NOOPTION: Successfully added multi " |
| 1692 | + " point to single point intents" + |
| 1693 | " with no match action", |
| 1694 | onfail="NOOPTION: Failed to add multi point" + |
| 1695 | " to single point intents" + |
| 1696 | " with no match action" ) |
| 1697 | |
| 1698 | main.step( "IPV4: Add multi point to single point intents" ) |
| 1699 | stepResult = main.TRUE |
| 1700 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1701 | main, |
| 1702 | name="IPV4", |
| 1703 | hostNames=hostNames, |
| 1704 | devices=devices, |
| 1705 | ports=None, |
| 1706 | ethType="IPV4", |
| 1707 | macs=macs, |
| 1708 | bandwidth="", |
| 1709 | lambdaAlloc=False, |
| 1710 | ipProto="", |
| 1711 | ipAddresses="", |
| 1712 | tcp="", |
| 1713 | sw1="s5", |
| 1714 | sw2="s2", |
| 1715 | expectedLink=18 ) |
| 1716 | |
| 1717 | utilities.assert_equals( expect=main.TRUE, |
| 1718 | actual=stepResult, |
| 1719 | onpass="IPV4: Successfully added multi point" |
| 1720 | + " to single point intents" + |
| 1721 | " with IPV4 type and MAC addresses", |
| 1722 | onfail="IPV4: Failed to add multi point" + |
| 1723 | " to single point intents" + |
| 1724 | " with IPV4 type and MAC addresses" ) |
| 1725 | |
| 1726 | main.step( "IPV4_2: Add multi point to single point intents" ) |
| 1727 | stepResult = main.TRUE |
| 1728 | hostNames = [ 'h8', 'h16', 'h24' ] |
| 1729 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1730 | main, |
| 1731 | name="IPV4", |
| 1732 | hostNames=hostNames, |
| 1733 | ethType="IPV4", |
| 1734 | lambdaAlloc=False ) |
| 1735 | |
| 1736 | utilities.assert_equals( expect=main.TRUE, |
| 1737 | actual=stepResult, |
| 1738 | onpass="IPV4_2: Successfully added multi point" |
| 1739 | + " to single point intents" + |
| 1740 | " with IPV4 type and no MAC addresses", |
| 1741 | onfail="IPV4_2: Failed to add multi point" + |
| 1742 | " to single point intents" + |
| 1743 | " with IPV4 type and no MAC addresses" ) |
| 1744 | |
| 1745 | main.step( "VLAN: Add multi point to single point intents" ) |
| 1746 | stepResult = main.TRUE |
| 1747 | hostNames = [ 'h5', 'h13', 'h21' ] |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1748 | devices = [ 'of:0000000000000005/5', 'of:0000000000000006/5', |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1749 | 'of:0000000000000007/5' ] |
| 1750 | macs = [ '00:00:00:00:00:05', '00:00:00:00:00:0D', '00:00:00:00:00:15' ] |
| 1751 | stepResult = main.intentFunction.multiToSingleIntent( |
| 1752 | main, |
| 1753 | name="VLAN", |
| 1754 | hostNames=hostNames, |
| 1755 | devices=devices, |
| 1756 | ports=None, |
| 1757 | ethType="IPV4", |
| 1758 | macs=macs, |
| 1759 | bandwidth="", |
| 1760 | lambdaAlloc=False, |
| 1761 | ipProto="", |
| 1762 | ipAddresses="", |
| 1763 | tcp="", |
| 1764 | sw1="s5", |
| 1765 | sw2="s2", |
| 1766 | expectedLink=18 ) |
| 1767 | |
| 1768 | utilities.assert_equals( expect=main.TRUE, |
| 1769 | actual=stepResult, |
| 1770 | onpass="VLAN: Successfully added multi point" |
| 1771 | + " to single point intents" + |
| 1772 | " with IPV4 type and MAC addresses" + |
| 1773 | " in the same VLAN", |
| 1774 | onfail="VLAN: Failed to add multi point" + |
| 1775 | " to single point intents" ) |
| 1776 | |
| 1777 | def CASE5000( self, main ): |
| 1778 | """ |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1779 | Tests Host Mobility |
| 1780 | Modifies the topology location of h1 |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1781 | """ |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1782 | if main.initialized == main.FALSE: |
| 1783 | main.log.error( "Test components did not start correctly, skipping further tests" ) |
| 1784 | main.skipCase() |
| 1785 | # Assert variables - These variable's name|format must be followed |
| 1786 | # if you want to use the wrapper function |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1787 | assert main, "There is no main" |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1788 | try: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1789 | assert main.RESTs |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1790 | except AssertionError: |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1791 | main.log.error( "There is no main.RESTs, skipping test cases" ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1792 | main.initialized = main.FALSE |
| 1793 | main.skipCase() |
| 1794 | try: |
| 1795 | assert main.Mininet1 |
| 1796 | except AssertionError: |
| 1797 | main.log.error( "Mininet handle should be named Mininet1, skipping test cases" ) |
| 1798 | main.initialized = main.FALSE |
| 1799 | main.skipCase() |
| 1800 | try: |
| 1801 | assert main.numSwitch |
| 1802 | except AssertionError: |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1803 | main.log.error( "Place the total number of switch topology in " + |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1804 | main.numSwitch ) |
Jeremy | dd9bda6 | 2016-04-18 12:02:32 -0700 | [diff] [blame] | 1805 | main.initialized = main.FALSE |
| 1806 | main.skipCase() |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1807 | main.case( "Test host mobility with host intents " ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1808 | main.step( "Testing host mobility by moving h1 from s5 to s6" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1809 | h1PreMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1810 | |
Jeremy Songster | e7f3b34 | 2016-08-17 14:56:49 -0700 | [diff] [blame] | 1811 | main.log.info( "Moving h1 from s5 to s6" ) |
| 1812 | main.Mininet1.moveHost( "h1", "s5", "s6" ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1813 | |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1814 | # Send discovery ping from moved host |
| 1815 | # Moving the host brings down the default interfaces and creates a new one. |
| 1816 | # Scapy is restarted on this host to detect the new interface |
| 1817 | main.h1.stopScapy() |
| 1818 | main.h1.startScapy() |
| 1819 | |
| 1820 | # Discover new host location in ONOS and populate host data. |
| 1821 | # Host 1 IP and MAC should be unchanged |
| 1822 | main.intentFunction.sendDiscoveryArp( main, [ main.h1 ] ) |
| 1823 | main.intentFunction.populateHostData( main ) |
| 1824 | |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1825 | h1PostMove = main.hostsData[ "h1" ][ "location" ][ 0:19 ] |
| 1826 | |
| 1827 | utilities.assert_equals( expect="of:0000000000000006", |
| 1828 | actual=h1PostMove, |
| 1829 | onpass="Mobility: Successfully moved h1 to s6", |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1830 | onfail="Mobility: Failed to move h1 to s6" + |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1831 | " to single point intents" + |
| 1832 | " with IPV4 type and MAC addresses" + |
| 1833 | " in the same VLAN" ) |
| 1834 | |
| 1835 | main.step( "IPV4: Add host intents between h1 and h9" ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1836 | main.assertReturnString = "Assert result for IPV4 host intent between h1, moved, and h9\n" |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1837 | host1 = { "name": "h1", "id": "00:00:00:00:00:01/-1" } |
| 1838 | host2 = { "name": "h9", "id": "00:00:00:00:00:09/-1" } |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1839 | |
| 1840 | installResult = main.intentFunction.installHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1841 | name='IPV4 Mobility IPV4', |
| 1842 | onosNode='0', |
| 1843 | host1=host1, |
| 1844 | host2=host2 ) |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1845 | if installResult: |
| 1846 | testResult = main.intentFunction.testHostIntent( main, |
Jon Hall | 02758ac | 2017-05-24 16:20:28 -0700 | [diff] [blame] | 1847 | name='Host Mobility IPV4', |
| 1848 | intentId=installResult, |
| 1849 | onosNode='0', |
| 1850 | host1=host1, |
| 1851 | host2=host2, |
| 1852 | sw1="s6", |
| 1853 | sw2="s2", |
| 1854 | expectedLink=18 ) |
kelvin-onlab | 4414780 | 2015-07-27 17:57:31 -0700 | [diff] [blame] | 1855 | |
| 1856 | utilities.assert_equals( expect=main.TRUE, |
Jeremy | 2f190ca | 2016-01-29 15:23:57 -0800 | [diff] [blame] | 1857 | actual=testResult, |
| 1858 | onpass=main.assertReturnString, |
| 1859 | onfail=main.assertReturnString ) |
| 1860 | |
Jon Hall | bd60ea0 | 2016-08-23 10:03:59 -0700 | [diff] [blame] | 1861 | main.intentFunction.report( main ) |