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