Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1 | """ |
| 2 | Description: This test is to determine if ONOS can handle |
| 3 | a minority of it's nodes restarting |
| 4 | |
| 5 | List of test cases: |
| 6 | CASE1: Compile ONOS and push it to the test machines |
| 7 | CASE2: Assign devices to controllers |
| 8 | CASE21: Assign mastership to controllers |
| 9 | CASE3: Assign intents |
| 10 | CASE4: Ping across added host intents |
| 11 | CASE5: Reading state of ONOS |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 12 | CASE61: The Failure inducing case. |
| 13 | CASE62: The Failure recovery case. |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 14 | CASE7: Check state after control plane failure |
| 15 | CASE8: Compare topo |
| 16 | CASE9: Link s3-s28 down |
| 17 | CASE10: Link s3-s28 up |
| 18 | CASE11: Switch down |
| 19 | CASE12: Switch up |
| 20 | CASE13: Clean up |
| 21 | CASE14: start election app on all onos nodes |
| 22 | CASE15: Check that Leadership Election is still functional |
| 23 | CASE16: Install Distributed Primitives app |
| 24 | CASE17: Check for basic functionality with distributed primitives |
| 25 | """ |
| 26 | |
| 27 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 28 | class HAstopNodes: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 29 | |
| 30 | def __init__( self ): |
| 31 | self.default = '' |
| 32 | |
| 33 | def CASE1( self, main ): |
| 34 | """ |
| 35 | CASE1 is to compile ONOS and push it to the test machines |
| 36 | |
| 37 | Startup sequence: |
| 38 | cell <name> |
| 39 | onos-verify-cell |
| 40 | NOTE: temporary - onos-remove-raft-logs |
| 41 | onos-uninstall |
| 42 | start mininet |
| 43 | git pull |
| 44 | mvn clean install |
| 45 | onos-package |
| 46 | onos-install -f |
| 47 | onos-wait-for-start |
| 48 | start cli sessions |
| 49 | start tcpdump |
| 50 | """ |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 51 | import imp |
Jon Hall | 3b489db | 2015-10-05 14:38:37 -0700 | [diff] [blame] | 52 | import pexpect |
Jon Hall | f3d16e7 | 2015-12-16 17:45:08 -0800 | [diff] [blame] | 53 | import time |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 54 | import json |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 55 | main.log.info( "ONOS HA test: Stop a minority of ONOS nodes - " + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 56 | "initialization" ) |
| 57 | main.case( "Setting up test environment" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 58 | main.caseExplanation = "Setup the test environment including " +\ |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 59 | "installing ONOS, starting Mininet and ONOS" +\ |
| 60 | "cli sessions." |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 61 | |
| 62 | # load some variables from the params file |
| 63 | PULLCODE = False |
| 64 | if main.params[ 'Git' ] == 'True': |
| 65 | PULLCODE = True |
| 66 | gitBranch = main.params[ 'branch' ] |
| 67 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
| 68 | |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 69 | main.numCtrls = int( main.params[ 'num_controllers' ] ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 70 | if main.ONOSbench.maxNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 71 | if main.ONOSbench.maxNodes < main.numCtrls: |
| 72 | main.numCtrls = int( main.ONOSbench.maxNodes ) |
| 73 | # set global variables |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 74 | global ONOS1Port |
| 75 | global ONOS2Port |
| 76 | global ONOS3Port |
| 77 | global ONOS4Port |
| 78 | global ONOS5Port |
| 79 | global ONOS6Port |
| 80 | global ONOS7Port |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 81 | # These are for csv plotting in jenkins |
| 82 | global labels |
| 83 | global data |
| 84 | labels = [] |
| 85 | data = [] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 86 | |
| 87 | # FIXME: just get controller port from params? |
| 88 | # TODO: do we really need all these? |
| 89 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
| 90 | ONOS2Port = main.params[ 'CTRL' ][ 'port2' ] |
| 91 | ONOS3Port = main.params[ 'CTRL' ][ 'port3' ] |
| 92 | ONOS4Port = main.params[ 'CTRL' ][ 'port4' ] |
| 93 | ONOS5Port = main.params[ 'CTRL' ][ 'port5' ] |
| 94 | ONOS6Port = main.params[ 'CTRL' ][ 'port6' ] |
| 95 | ONOS7Port = main.params[ 'CTRL' ][ 'port7' ] |
| 96 | |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 97 | try: |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 98 | from tests.HAsanity.dependencies.HA import HA |
| 99 | main.HA = HA() |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 100 | except Exception as e: |
| 101 | main.log.exception( e ) |
| 102 | main.cleanup() |
| 103 | main.exit() |
| 104 | |
| 105 | main.CLIs = [] |
| 106 | main.nodes = [] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 107 | ipList = [] |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 108 | for i in range( 1, main.numCtrls + 1 ): |
| 109 | try: |
| 110 | main.CLIs.append( getattr( main, 'ONOScli' + str( i ) ) ) |
| 111 | main.nodes.append( getattr( main, 'ONOS' + str( i ) ) ) |
| 112 | ipList.append( main.nodes[ -1 ].ip_address ) |
| 113 | except AttributeError: |
| 114 | break |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 115 | |
| 116 | main.step( "Create cell file" ) |
| 117 | cellAppString = main.params[ 'ENV' ][ 'appString' ] |
| 118 | main.ONOSbench.createCellFile( main.ONOSbench.ip_address, cellName, |
| 119 | main.Mininet1.ip_address, |
| 120 | cellAppString, ipList ) |
| 121 | main.step( "Applying cell variable to environment" ) |
| 122 | cellResult = main.ONOSbench.setCell( cellName ) |
| 123 | verifyResult = main.ONOSbench.verifyCell() |
| 124 | |
| 125 | # FIXME:this is short term fix |
| 126 | main.log.info( "Removing raft logs" ) |
| 127 | main.ONOSbench.onosRemoveRaftLogs() |
| 128 | |
| 129 | main.log.info( "Uninstalling ONOS" ) |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 130 | for node in main.nodes: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 131 | main.ONOSbench.onosUninstall( node.ip_address ) |
| 132 | |
| 133 | # Make sure ONOS is DEAD |
| 134 | main.log.info( "Killing any ONOS processes" ) |
| 135 | killResults = main.TRUE |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 136 | for node in main.nodes: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 137 | killed = main.ONOSbench.onosKill( node.ip_address ) |
| 138 | killResults = killResults and killed |
| 139 | |
| 140 | cleanInstallResult = main.TRUE |
| 141 | gitPullResult = main.TRUE |
| 142 | |
| 143 | main.step( "Starting Mininet" ) |
| 144 | # scp topo file to mininet |
| 145 | # TODO: move to params? |
| 146 | topoName = "obelisk.py" |
| 147 | filePath = main.ONOSbench.home + "/tools/test/topos/" |
kelvin-onlab | d9e23de | 2015-08-06 10:34:44 -0700 | [diff] [blame] | 148 | main.ONOSbench.scp( main.Mininet1, |
| 149 | filePath + topoName, |
| 150 | main.Mininet1.home, |
| 151 | direction="to" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 152 | mnResult = main.Mininet1.startNet( ) |
| 153 | utilities.assert_equals( expect=main.TRUE, actual=mnResult, |
| 154 | onpass="Mininet Started", |
| 155 | onfail="Error starting Mininet" ) |
| 156 | |
| 157 | main.step( "Git checkout and pull " + gitBranch ) |
| 158 | if PULLCODE: |
| 159 | main.ONOSbench.gitCheckout( gitBranch ) |
| 160 | gitPullResult = main.ONOSbench.gitPull() |
| 161 | # values of 1 or 3 are good |
| 162 | utilities.assert_lesser( expect=0, actual=gitPullResult, |
| 163 | onpass="Git pull successful", |
| 164 | onfail="Git pull failed" ) |
| 165 | main.ONOSbench.getVersion( report=True ) |
| 166 | |
| 167 | main.step( "Using mvn clean install" ) |
| 168 | cleanInstallResult = main.TRUE |
| 169 | if PULLCODE and gitPullResult == main.TRUE: |
| 170 | cleanInstallResult = main.ONOSbench.cleanInstall() |
| 171 | else: |
| 172 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 173 | "clean install" ) |
| 174 | utilities.assert_equals( expect=main.TRUE, |
| 175 | actual=cleanInstallResult, |
| 176 | onpass="MCI successful", |
| 177 | onfail="MCI failed" ) |
| 178 | # GRAPHS |
| 179 | # NOTE: important params here: |
| 180 | # job = name of Jenkins job |
| 181 | # Plot Name = Plot-HA, only can be used if multiple plots |
| 182 | # index = The number of the graph under plot name |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 183 | job = "HAstopNodes" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 184 | plotName = "Plot-HA" |
Jon Hall | 843f8bc | 2016-03-18 14:28:13 -0700 | [diff] [blame] | 185 | index = "2" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 186 | graphs = '<ac:structured-macro ac:name="html">\n' |
| 187 | graphs += '<ac:plain-text-body><![CDATA[\n' |
| 188 | graphs += '<iframe src="https://onos-jenkins.onlab.us/job/' + job +\ |
Jon Hall | a9845df | 2016-01-15 14:55:58 -0800 | [diff] [blame] | 189 | '/plot/' + plotName + '/getPlot?index=' + index +\ |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 190 | '&width=500&height=300"' +\ |
| 191 | 'noborder="0" width="500" height="300" scrolling="yes" ' +\ |
| 192 | 'seamless="seamless"></iframe>\n' |
| 193 | graphs += ']]></ac:plain-text-body>\n' |
| 194 | graphs += '</ac:structured-macro>\n' |
| 195 | main.log.wiki(graphs) |
| 196 | |
| 197 | main.step( "Creating ONOS package" ) |
Jon Hall | 3b489db | 2015-10-05 14:38:37 -0700 | [diff] [blame] | 198 | # copy gen-partions file to ONOS |
| 199 | # NOTE: this assumes TestON and ONOS are on the same machine |
| 200 | srcFile = main.testDir + "/" + main.TEST + "/dependencies/onos-gen-partitions" |
| 201 | dstDir = main.ONOSbench.home + "/tools/test/bin/onos-gen-partitions" |
| 202 | cpResult = main.ONOSbench.secureCopy( main.ONOSbench.user_name, |
| 203 | main.ONOSbench.ip_address, |
| 204 | srcFile, |
| 205 | dstDir, |
| 206 | pwd=main.ONOSbench.pwd, |
| 207 | direction="from" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 208 | packageResult = main.ONOSbench.onosPackage() |
| 209 | utilities.assert_equals( expect=main.TRUE, actual=packageResult, |
| 210 | onpass="ONOS package successful", |
| 211 | onfail="ONOS package failed" ) |
| 212 | |
| 213 | main.step( "Installing ONOS package" ) |
| 214 | onosInstallResult = main.TRUE |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 215 | for node in main.nodes: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 216 | tmpResult = main.ONOSbench.onosInstall( options="-f", |
| 217 | node=node.ip_address ) |
| 218 | onosInstallResult = onosInstallResult and tmpResult |
| 219 | utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult, |
| 220 | onpass="ONOS install successful", |
| 221 | onfail="ONOS install failed" ) |
Jon Hall | 3b489db | 2015-10-05 14:38:37 -0700 | [diff] [blame] | 222 | # clean up gen-partitions file |
| 223 | try: |
| 224 | main.ONOSbench.handle.sendline( "cd " + main.ONOSbench.home ) |
| 225 | main.ONOSbench.handle.expect( main.ONOSbench.home + "\$" ) |
| 226 | main.ONOSbench.handle.sendline( "git checkout -- tools/test/bin/onos-gen-partitions" ) |
| 227 | main.ONOSbench.handle.expect( main.ONOSbench.home + "\$" ) |
| 228 | main.log.info( " Cleaning custom gen partitions file, response was: \n" + |
| 229 | str( main.ONOSbench.handle.before ) ) |
| 230 | except ( pexpect.TIMEOUT, pexpect.EOF ): |
| 231 | main.log.exception( "ONOSbench: pexpect exception found:" + |
| 232 | main.ONOSbench.handle.before ) |
| 233 | main.cleanup() |
| 234 | main.exit() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 235 | |
| 236 | main.step( "Checking if ONOS is up yet" ) |
| 237 | for i in range( 2 ): |
| 238 | onosIsupResult = main.TRUE |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 239 | for node in main.nodes: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 240 | started = main.ONOSbench.isup( node.ip_address ) |
| 241 | if not started: |
Jon Hall | c679355 | 2016-01-19 14:18:37 -0800 | [diff] [blame] | 242 | main.log.error( node.name + " hasn't started" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 243 | onosIsupResult = onosIsupResult and started |
| 244 | if onosIsupResult == main.TRUE: |
| 245 | break |
| 246 | utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult, |
| 247 | onpass="ONOS startup successful", |
| 248 | onfail="ONOS startup failed" ) |
| 249 | |
| 250 | main.log.step( "Starting ONOS CLI sessions" ) |
| 251 | cliResults = main.TRUE |
| 252 | threads = [] |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 253 | for i in range( main.numCtrls ): |
| 254 | t = main.Thread( target=main.CLIs[i].startOnosCli, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 255 | name="startOnosCli-" + str( i ), |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 256 | args=[main.nodes[i].ip_address] ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 257 | threads.append( t ) |
| 258 | t.start() |
| 259 | |
| 260 | for t in threads: |
| 261 | t.join() |
| 262 | cliResults = cliResults and t.result |
| 263 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 264 | onpass="ONOS cli startup successful", |
| 265 | onfail="ONOS cli startup failed" ) |
| 266 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 267 | # Create a list of active nodes for use when some nodes are stopped |
| 268 | main.activeNodes = [ i for i in range( 0, len( main.CLIs ) ) ] |
| 269 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 270 | if main.params[ 'tcpdump' ].lower() == "true": |
| 271 | main.step( "Start Packet Capture MN" ) |
| 272 | main.Mininet2.startTcpdump( |
| 273 | str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST ) |
| 274 | + "-MN.pcap", |
| 275 | intf=main.params[ 'MNtcpdump' ][ 'intf' ], |
| 276 | port=main.params[ 'MNtcpdump' ][ 'port' ] ) |
| 277 | |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 278 | main.step( "Checking ONOS nodes" ) |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 279 | nodeResults = utilities.retry( main.HA.nodesCheck, |
| 280 | False, |
| 281 | args=[main.activeNodes], |
| 282 | attempts=5 ) |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 283 | |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 284 | utilities.assert_equals( expect=True, actual=nodeResults, |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 285 | onpass="Nodes check successful", |
| 286 | onfail="Nodes check NOT successful" ) |
| 287 | |
| 288 | if not nodeResults: |
| 289 | for cli in main.CLIs: |
| 290 | main.log.debug( "{} components not ACTIVE: \n{}".format( |
| 291 | cli.name, |
| 292 | cli.sendline( "scr:list | grep -v ACTIVE" ) ) ) |
| 293 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 294 | if cliResults == main.FALSE: |
| 295 | main.log.error( "Failed to start ONOS, stopping test" ) |
| 296 | main.cleanup() |
| 297 | main.exit() |
| 298 | |
Jon Hall | 172b7ba | 2016-04-07 18:12:20 -0700 | [diff] [blame] | 299 | main.step( "Activate apps defined in the params file" ) |
| 300 | # get data from the params |
| 301 | apps = main.params.get( 'apps' ) |
| 302 | if apps: |
| 303 | apps = apps.split(',') |
| 304 | main.log.warn( apps ) |
| 305 | activateResult = True |
| 306 | for app in apps: |
| 307 | main.CLIs[ 0 ].app( app, "Activate" ) |
| 308 | # TODO: check this worked |
| 309 | time.sleep( 10 ) # wait for apps to activate |
| 310 | for app in apps: |
| 311 | state = main.CLIs[ 0 ].appStatus( app ) |
| 312 | if state == "ACTIVE": |
| 313 | activateResult = activeResult and True |
| 314 | else: |
| 315 | main.log.error( "{} is in {} state".format( app, state ) ) |
| 316 | activeResult = False |
| 317 | utilities.assert_equals( expect=True, |
| 318 | actual=activateResult, |
| 319 | onpass="Successfully activated apps", |
| 320 | onfail="Failed to activate apps" ) |
| 321 | else: |
| 322 | main.log.warn( "No apps were specified to be loaded after startup" ) |
| 323 | |
| 324 | main.step( "Set ONOS configurations" ) |
| 325 | config = main.params.get( 'ONOS_Configuration' ) |
| 326 | if config: |
| 327 | main.log.debug( config ) |
| 328 | checkResult = main.TRUE |
| 329 | for component in config: |
| 330 | for setting in config[component]: |
| 331 | value = config[component][setting] |
| 332 | check = main.CLIs[ 0 ].setCfg( component, setting, value ) |
| 333 | main.log.info( "Value was changed? {}".format( main.TRUE == check ) ) |
| 334 | checkResult = check and checkResult |
| 335 | utilities.assert_equals( expect=main.TRUE, |
| 336 | actual=checkResult, |
| 337 | onpass="Successfully set config", |
| 338 | onfail="Failed to set config" ) |
| 339 | else: |
| 340 | main.log.warn( "No configurations were specified to be changed after startup" ) |
| 341 | |
Jon Hall | 9d2dcad | 2016-04-08 10:15:20 -0700 | [diff] [blame] | 342 | main.step( "App Ids check" ) |
| 343 | appCheck = main.TRUE |
| 344 | threads = [] |
| 345 | for i in main.activeNodes: |
| 346 | t = main.Thread( target=main.CLIs[i].appToIDCheck, |
| 347 | name="appToIDCheck-" + str( i ), |
| 348 | args=[] ) |
| 349 | threads.append( t ) |
| 350 | t.start() |
| 351 | |
| 352 | for t in threads: |
| 353 | t.join() |
| 354 | appCheck = appCheck and t.result |
| 355 | if appCheck != main.TRUE: |
| 356 | node = main.activeNodes[0] |
| 357 | main.log.warn( main.CLIs[node].apps() ) |
| 358 | main.log.warn( main.CLIs[node].appIDs() ) |
| 359 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 360 | onpass="App Ids seem to be correct", |
| 361 | onfail="Something is wrong with app Ids" ) |
| 362 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 363 | def CASE2( self, main ): |
| 364 | """ |
| 365 | Assign devices to controllers |
| 366 | """ |
| 367 | import re |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 368 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 369 | assert main, "main not defined" |
| 370 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 371 | assert main.CLIs, "main.CLIs not defined" |
| 372 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 373 | assert ONOS1Port, "ONOS1Port not defined" |
| 374 | assert ONOS2Port, "ONOS2Port not defined" |
| 375 | assert ONOS3Port, "ONOS3Port not defined" |
| 376 | assert ONOS4Port, "ONOS4Port not defined" |
| 377 | assert ONOS5Port, "ONOS5Port not defined" |
| 378 | assert ONOS6Port, "ONOS6Port not defined" |
| 379 | assert ONOS7Port, "ONOS7Port not defined" |
| 380 | |
| 381 | main.case( "Assigning devices to controllers" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 382 | main.caseExplanation = "Assign switches to ONOS using 'ovs-vsctl' " +\ |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 383 | "and check that an ONOS node becomes the " +\ |
| 384 | "master of the device." |
| 385 | main.step( "Assign switches to controllers" ) |
| 386 | |
| 387 | ipList = [] |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 388 | for i in range( main.numCtrls ): |
| 389 | ipList.append( main.nodes[ i ].ip_address ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 390 | swList = [] |
| 391 | for i in range( 1, 29 ): |
| 392 | swList.append( "s" + str( i ) ) |
| 393 | main.Mininet1.assignSwController( sw=swList, ip=ipList ) |
| 394 | |
| 395 | mastershipCheck = main.TRUE |
| 396 | for i in range( 1, 29 ): |
| 397 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
| 398 | try: |
| 399 | main.log.info( str( response ) ) |
| 400 | except Exception: |
| 401 | main.log.info( repr( response ) ) |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 402 | for node in main.nodes: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 403 | if re.search( "tcp:" + node.ip_address, response ): |
| 404 | mastershipCheck = mastershipCheck and main.TRUE |
| 405 | else: |
| 406 | main.log.error( "Error, node " + node.ip_address + " is " + |
| 407 | "not in the list of controllers s" + |
| 408 | str( i ) + " is connecting to." ) |
| 409 | mastershipCheck = main.FALSE |
| 410 | utilities.assert_equals( |
| 411 | expect=main.TRUE, |
| 412 | actual=mastershipCheck, |
| 413 | onpass="Switch mastership assigned correctly", |
| 414 | onfail="Switches not assigned correctly to controllers" ) |
| 415 | |
| 416 | def CASE21( self, main ): |
| 417 | """ |
| 418 | Assign mastership to controllers |
| 419 | """ |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 420 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 421 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 422 | assert main, "main not defined" |
| 423 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 424 | assert main.CLIs, "main.CLIs not defined" |
| 425 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 426 | assert ONOS1Port, "ONOS1Port not defined" |
| 427 | assert ONOS2Port, "ONOS2Port not defined" |
| 428 | assert ONOS3Port, "ONOS3Port not defined" |
| 429 | assert ONOS4Port, "ONOS4Port not defined" |
| 430 | assert ONOS5Port, "ONOS5Port not defined" |
| 431 | assert ONOS6Port, "ONOS6Port not defined" |
| 432 | assert ONOS7Port, "ONOS7Port not defined" |
| 433 | |
| 434 | main.case( "Assigning Controller roles for switches" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 435 | main.caseExplanation = "Check that ONOS is connected to each " +\ |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 436 | "device. Then manually assign" +\ |
| 437 | " mastership to specific ONOS nodes using" +\ |
| 438 | " 'device-role'" |
| 439 | main.step( "Assign mastership of switches to specific controllers" ) |
| 440 | # Manually assign mastership to the controller we want |
| 441 | roleCall = main.TRUE |
| 442 | |
| 443 | ipList = [ ] |
| 444 | deviceList = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 445 | onosCli = main.CLIs[ main.activeNodes[0] ] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 446 | try: |
| 447 | # Assign mastership to specific controllers. This assignment was |
| 448 | # determined for a 7 node cluser, but will work with any sized |
| 449 | # cluster |
| 450 | for i in range( 1, 29 ): # switches 1 through 28 |
| 451 | # set up correct variables: |
| 452 | if i == 1: |
| 453 | c = 0 |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 454 | ip = main.nodes[ c ].ip_address # ONOS1 |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 455 | deviceId = onosCli.getDevice( "1000" ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 456 | elif i == 2: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 457 | c = 1 % main.numCtrls |
| 458 | ip = main.nodes[ c ].ip_address # ONOS2 |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 459 | deviceId = onosCli.getDevice( "2000" ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 460 | elif i == 3: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 461 | c = 1 % main.numCtrls |
| 462 | ip = main.nodes[ c ].ip_address # ONOS2 |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 463 | deviceId = onosCli.getDevice( "3000" ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 464 | elif i == 4: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 465 | c = 3 % main.numCtrls |
| 466 | ip = main.nodes[ c ].ip_address # ONOS4 |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 467 | deviceId = onosCli.getDevice( "3004" ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 468 | elif i == 5: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 469 | c = 2 % main.numCtrls |
| 470 | ip = main.nodes[ c ].ip_address # ONOS3 |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 471 | deviceId = onosCli.getDevice( "5000" ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 472 | elif i == 6: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 473 | c = 2 % main.numCtrls |
| 474 | ip = main.nodes[ c ].ip_address # ONOS3 |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 475 | deviceId = onosCli.getDevice( "6000" ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 476 | elif i == 7: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 477 | c = 5 % main.numCtrls |
| 478 | ip = main.nodes[ c ].ip_address # ONOS6 |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 479 | deviceId = onosCli.getDevice( "6007" ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 480 | elif i >= 8 and i <= 17: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 481 | c = 4 % main.numCtrls |
| 482 | ip = main.nodes[ c ].ip_address # ONOS5 |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 483 | dpid = '3' + str( i ).zfill( 3 ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 484 | deviceId = onosCli.getDevice( dpid ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 485 | elif i >= 18 and i <= 27: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 486 | c = 6 % main.numCtrls |
| 487 | ip = main.nodes[ c ].ip_address # ONOS7 |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 488 | dpid = '6' + str( i ).zfill( 3 ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 489 | deviceId = onosCli.getDevice( dpid ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 490 | elif i == 28: |
| 491 | c = 0 |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 492 | ip = main.nodes[ c ].ip_address # ONOS1 |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 493 | deviceId = onosCli.getDevice( "2800" ).get( 'id' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 494 | else: |
| 495 | main.log.error( "You didn't write an else statement for " + |
| 496 | "switch s" + str( i ) ) |
| 497 | roleCall = main.FALSE |
| 498 | # Assign switch |
| 499 | assert deviceId, "No device id for s" + str( i ) + " in ONOS" |
| 500 | # TODO: make this controller dynamic |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 501 | roleCall = roleCall and onosCli.deviceRole( deviceId, ip ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 502 | ipList.append( ip ) |
| 503 | deviceList.append( deviceId ) |
| 504 | except ( AttributeError, AssertionError ): |
| 505 | main.log.exception( "Something is wrong with ONOS device view" ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 506 | main.log.info( onosCli.devices() ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 507 | utilities.assert_equals( |
| 508 | expect=main.TRUE, |
| 509 | actual=roleCall, |
| 510 | onpass="Re-assigned switch mastership to designated controller", |
| 511 | onfail="Something wrong with deviceRole calls" ) |
| 512 | |
| 513 | main.step( "Check mastership was correctly assigned" ) |
| 514 | roleCheck = main.TRUE |
| 515 | # NOTE: This is due to the fact that device mastership change is not |
| 516 | # atomic and is actually a multi step process |
| 517 | time.sleep( 5 ) |
| 518 | for i in range( len( ipList ) ): |
| 519 | ip = ipList[i] |
| 520 | deviceId = deviceList[i] |
| 521 | # Check assignment |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 522 | master = onosCli.getRole( deviceId ).get( 'master' ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 523 | if ip in master: |
| 524 | roleCheck = roleCheck and main.TRUE |
| 525 | else: |
| 526 | roleCheck = roleCheck and main.FALSE |
| 527 | main.log.error( "Error, controller " + ip + " is not" + |
| 528 | " master " + "of device " + |
| 529 | str( deviceId ) + ". Master is " + |
| 530 | repr( master ) + "." ) |
| 531 | utilities.assert_equals( |
| 532 | expect=main.TRUE, |
| 533 | actual=roleCheck, |
| 534 | onpass="Switches were successfully reassigned to designated " + |
| 535 | "controller", |
| 536 | onfail="Switches were not successfully reassigned" ) |
| 537 | |
| 538 | def CASE3( self, main ): |
| 539 | """ |
| 540 | Assign intents |
| 541 | """ |
| 542 | import time |
| 543 | import json |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 544 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 545 | assert main, "main not defined" |
| 546 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 547 | assert main.CLIs, "main.CLIs not defined" |
| 548 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 549 | main.case( "Adding host Intents" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 550 | main.caseExplanation = "Discover hosts by using pingall then " +\ |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 551 | "assign predetermined host-to-host intents." +\ |
| 552 | " After installation, check that the intent" +\ |
| 553 | " is distributed to all nodes and the state" +\ |
| 554 | " is INSTALLED" |
| 555 | |
| 556 | # install onos-app-fwd |
| 557 | main.step( "Install reactive forwarding app" ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 558 | onosCli = main.CLIs[ main.activeNodes[0] ] |
| 559 | installResults = onosCli.activateApp( "org.onosproject.fwd" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 560 | utilities.assert_equals( expect=main.TRUE, actual=installResults, |
| 561 | onpass="Install fwd successful", |
| 562 | onfail="Install fwd failed" ) |
| 563 | |
| 564 | main.step( "Check app ids" ) |
| 565 | appCheck = main.TRUE |
| 566 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 567 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 568 | t = main.Thread( target=main.CLIs[i].appToIDCheck, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 569 | name="appToIDCheck-" + str( i ), |
| 570 | args=[] ) |
| 571 | threads.append( t ) |
| 572 | t.start() |
| 573 | |
| 574 | for t in threads: |
| 575 | t.join() |
| 576 | appCheck = appCheck and t.result |
| 577 | if appCheck != main.TRUE: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 578 | main.log.warn( onosCli.apps() ) |
| 579 | main.log.warn( onosCli.appIDs() ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 580 | utilities.assert_equals( expect=main.TRUE, actual=appCheck, |
| 581 | onpass="App Ids seem to be correct", |
| 582 | onfail="Something is wrong with app Ids" ) |
| 583 | |
| 584 | main.step( "Discovering Hosts( Via pingall for now )" ) |
| 585 | # FIXME: Once we have a host discovery mechanism, use that instead |
| 586 | # REACTIVE FWD test |
| 587 | pingResult = main.FALSE |
Jon Hall | 96091e6 | 2015-09-21 17:34:17 -0700 | [diff] [blame] | 588 | passMsg = "Reactive Pingall test passed" |
| 589 | time1 = time.time() |
| 590 | pingResult = main.Mininet1.pingall() |
| 591 | time2 = time.time() |
| 592 | if not pingResult: |
| 593 | main.log.warn("First pingall failed. Trying again...") |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 594 | pingResult = main.Mininet1.pingall() |
Jon Hall | 96091e6 | 2015-09-21 17:34:17 -0700 | [diff] [blame] | 595 | passMsg += " on the second try" |
| 596 | utilities.assert_equals( |
| 597 | expect=main.TRUE, |
| 598 | actual=pingResult, |
| 599 | onpass= passMsg, |
| 600 | onfail="Reactive Pingall failed, " + |
| 601 | "one or more ping pairs failed" ) |
| 602 | main.log.info( "Time for pingall: %2f seconds" % |
| 603 | ( time2 - time1 ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 604 | # timeout for fwd flows |
| 605 | time.sleep( 11 ) |
| 606 | # uninstall onos-app-fwd |
| 607 | main.step( "Uninstall reactive forwarding app" ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 608 | node = main.activeNodes[0] |
| 609 | uninstallResult = main.CLIs[node].deactivateApp( "org.onosproject.fwd" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 610 | utilities.assert_equals( expect=main.TRUE, actual=uninstallResult, |
| 611 | onpass="Uninstall fwd successful", |
| 612 | onfail="Uninstall fwd failed" ) |
| 613 | |
| 614 | main.step( "Check app ids" ) |
| 615 | threads = [] |
| 616 | appCheck2 = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 617 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 618 | t = main.Thread( target=main.CLIs[i].appToIDCheck, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 619 | name="appToIDCheck-" + str( i ), |
| 620 | args=[] ) |
| 621 | threads.append( t ) |
| 622 | t.start() |
| 623 | |
| 624 | for t in threads: |
| 625 | t.join() |
| 626 | appCheck2 = appCheck2 and t.result |
| 627 | if appCheck2 != main.TRUE: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 628 | node = main.activeNodes[0] |
| 629 | main.log.warn( main.CLIs[node].apps() ) |
| 630 | main.log.warn( main.CLIs[node].appIDs() ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 631 | utilities.assert_equals( expect=main.TRUE, actual=appCheck2, |
| 632 | onpass="App Ids seem to be correct", |
| 633 | onfail="Something is wrong with app Ids" ) |
| 634 | |
| 635 | main.step( "Add host intents via cli" ) |
| 636 | intentIds = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 637 | # TODO: move the host numbers to params |
| 638 | # Maybe look at all the paths we ping? |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 639 | intentAddResult = True |
| 640 | hostResult = main.TRUE |
| 641 | for i in range( 8, 18 ): |
| 642 | main.log.info( "Adding host intent between h" + str( i ) + |
| 643 | " and h" + str( i + 10 ) ) |
| 644 | host1 = "00:00:00:00:00:" + \ |
| 645 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 646 | host2 = "00:00:00:00:00:" + \ |
| 647 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
| 648 | # NOTE: getHost can return None |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 649 | host1Dict = onosCli.getHost( host1 ) |
| 650 | host2Dict = onosCli.getHost( host2 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 651 | host1Id = None |
| 652 | host2Id = None |
| 653 | if host1Dict and host2Dict: |
| 654 | host1Id = host1Dict.get( 'id', None ) |
| 655 | host2Id = host2Dict.get( 'id', None ) |
| 656 | if host1Id and host2Id: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 657 | nodeNum = ( i % len( main.activeNodes ) ) |
| 658 | node = main.activeNodes[nodeNum] |
| 659 | tmpId = main.CLIs[node].addHostIntent( host1Id, host2Id ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 660 | if tmpId: |
| 661 | main.log.info( "Added intent with id: " + tmpId ) |
| 662 | intentIds.append( tmpId ) |
| 663 | else: |
| 664 | main.log.error( "addHostIntent returned: " + |
| 665 | repr( tmpId ) ) |
| 666 | else: |
| 667 | main.log.error( "Error, getHost() failed for h" + str( i ) + |
| 668 | " and/or h" + str( i + 10 ) ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 669 | node = main.activeNodes[0] |
| 670 | hosts = main.CLIs[node].hosts() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 671 | main.log.warn( "Hosts output: " ) |
| 672 | try: |
| 673 | main.log.warn( json.dumps( json.loads( hosts ), |
| 674 | sort_keys=True, |
| 675 | indent=4, |
| 676 | separators=( ',', ': ' ) ) ) |
| 677 | except ( ValueError, TypeError ): |
| 678 | main.log.warn( repr( hosts ) ) |
| 679 | hostResult = main.FALSE |
| 680 | utilities.assert_equals( expect=main.TRUE, actual=hostResult, |
| 681 | onpass="Found a host id for each host", |
| 682 | onfail="Error looking up host ids" ) |
| 683 | |
| 684 | intentStart = time.time() |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 685 | onosIds = onosCli.getAllIntentsId() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 686 | main.log.info( "Submitted intents: " + str( intentIds ) ) |
| 687 | main.log.info( "Intents in ONOS: " + str( onosIds ) ) |
| 688 | for intent in intentIds: |
| 689 | if intent in onosIds: |
| 690 | pass # intent submitted is in onos |
| 691 | else: |
| 692 | intentAddResult = False |
| 693 | if intentAddResult: |
| 694 | intentStop = time.time() |
| 695 | else: |
| 696 | intentStop = None |
| 697 | # Print the intent states |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 698 | intents = onosCli.intents() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 699 | intentStates = [] |
| 700 | installedCheck = True |
| 701 | main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) ) |
| 702 | count = 0 |
| 703 | try: |
| 704 | for intent in json.loads( intents ): |
| 705 | state = intent.get( 'state', None ) |
| 706 | if "INSTALLED" not in state: |
| 707 | installedCheck = False |
| 708 | intentId = intent.get( 'id', None ) |
| 709 | intentStates.append( ( intentId, state ) ) |
| 710 | except ( ValueError, TypeError ): |
| 711 | main.log.exception( "Error parsing intents" ) |
| 712 | # add submitted intents not in the store |
| 713 | tmplist = [ i for i, s in intentStates ] |
| 714 | missingIntents = False |
| 715 | for i in intentIds: |
| 716 | if i not in tmplist: |
| 717 | intentStates.append( ( i, " - " ) ) |
| 718 | missingIntents = True |
| 719 | intentStates.sort() |
| 720 | for i, s in intentStates: |
| 721 | count += 1 |
| 722 | main.log.info( "%-6s%-15s%-15s" % |
| 723 | ( str( count ), str( i ), str( s ) ) ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 724 | leaders = onosCli.leaders() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 725 | try: |
| 726 | missing = False |
| 727 | if leaders: |
| 728 | parsedLeaders = json.loads( leaders ) |
| 729 | main.log.warn( json.dumps( parsedLeaders, |
| 730 | sort_keys=True, |
| 731 | indent=4, |
| 732 | separators=( ',', ': ' ) ) ) |
| 733 | # check for all intent partitions |
| 734 | topics = [] |
| 735 | for i in range( 14 ): |
| 736 | topics.append( "intent-partition-" + str( i ) ) |
| 737 | main.log.debug( topics ) |
| 738 | ONOStopics = [ j['topic'] for j in parsedLeaders ] |
| 739 | for topic in topics: |
| 740 | if topic not in ONOStopics: |
| 741 | main.log.error( "Error: " + topic + |
| 742 | " not in leaders" ) |
| 743 | missing = True |
| 744 | else: |
| 745 | main.log.error( "leaders() returned None" ) |
| 746 | except ( ValueError, TypeError ): |
| 747 | main.log.exception( "Error parsing leaders" ) |
| 748 | main.log.error( repr( leaders ) ) |
| 749 | # Check all nodes |
| 750 | if missing: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 751 | for i in main.activeNodes: |
| 752 | response = main.CLIs[i].leaders( jsonFormat=False) |
| 753 | main.log.warn( str( main.CLIs[i].name ) + " leaders output: \n" + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 754 | str( response ) ) |
| 755 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 756 | partitions = onosCli.partitions() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 757 | try: |
| 758 | if partitions : |
| 759 | parsedPartitions = json.loads( partitions ) |
| 760 | main.log.warn( json.dumps( parsedPartitions, |
| 761 | sort_keys=True, |
| 762 | indent=4, |
| 763 | separators=( ',', ': ' ) ) ) |
| 764 | # TODO check for a leader in all paritions |
| 765 | # TODO check for consistency among nodes |
| 766 | else: |
| 767 | main.log.error( "partitions() returned None" ) |
| 768 | except ( ValueError, TypeError ): |
| 769 | main.log.exception( "Error parsing partitions" ) |
| 770 | main.log.error( repr( partitions ) ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 771 | pendingMap = onosCli.pendingMap() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 772 | try: |
| 773 | if pendingMap : |
| 774 | parsedPending = json.loads( pendingMap ) |
| 775 | main.log.warn( json.dumps( parsedPending, |
| 776 | sort_keys=True, |
| 777 | indent=4, |
| 778 | separators=( ',', ': ' ) ) ) |
| 779 | # TODO check something here? |
| 780 | else: |
| 781 | main.log.error( "pendingMap() returned None" ) |
| 782 | except ( ValueError, TypeError ): |
| 783 | main.log.exception( "Error parsing pending map" ) |
| 784 | main.log.error( repr( pendingMap ) ) |
| 785 | |
| 786 | intentAddResult = bool( intentAddResult and not missingIntents and |
| 787 | installedCheck ) |
| 788 | if not intentAddResult: |
| 789 | main.log.error( "Error in pushing host intents to ONOS" ) |
| 790 | |
| 791 | main.step( "Intent Anti-Entropy dispersion" ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 792 | for j in range(100): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 793 | correct = True |
| 794 | main.log.info( "Submitted intents: " + str( sorted( intentIds ) ) ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 795 | for i in main.activeNodes: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 796 | onosIds = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 797 | ids = main.CLIs[i].getAllIntentsId() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 798 | onosIds.append( ids ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 799 | main.log.debug( "Intents in " + main.CLIs[i].name + ": " + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 800 | str( sorted( onosIds ) ) ) |
| 801 | if sorted( ids ) != sorted( intentIds ): |
| 802 | main.log.warn( "Set of intent IDs doesn't match" ) |
| 803 | correct = False |
| 804 | break |
| 805 | else: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 806 | intents = json.loads( main.CLIs[i].intents() ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 807 | for intent in intents: |
| 808 | if intent[ 'state' ] != "INSTALLED": |
| 809 | main.log.warn( "Intent " + intent[ 'id' ] + |
| 810 | " is " + intent[ 'state' ] ) |
| 811 | correct = False |
| 812 | break |
| 813 | if correct: |
| 814 | break |
| 815 | else: |
| 816 | time.sleep(1) |
| 817 | if not intentStop: |
| 818 | intentStop = time.time() |
| 819 | global gossipTime |
| 820 | gossipTime = intentStop - intentStart |
| 821 | main.log.info( "It took about " + str( gossipTime ) + |
| 822 | " seconds for all intents to appear in each node" ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 823 | gossipPeriod = int( main.params['timers']['gossip'] ) |
| 824 | maxGossipTime = gossipPeriod * len( main.activeNodes ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 825 | utilities.assert_greater_equals( |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 826 | expect=maxGossipTime, actual=gossipTime, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 827 | onpass="ECM anti-entropy for intents worked within " + |
| 828 | "expected time", |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 829 | onfail="Intent ECM anti-entropy took too long. " + |
| 830 | "Expected time:{}, Actual time:{}".format( maxGossipTime, |
| 831 | gossipTime ) ) |
| 832 | if gossipTime <= maxGossipTime: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 833 | intentAddResult = True |
| 834 | |
| 835 | if not intentAddResult or "key" in pendingMap: |
| 836 | import time |
| 837 | installedCheck = True |
| 838 | main.log.info( "Sleeping 60 seconds to see if intents are found" ) |
| 839 | time.sleep( 60 ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 840 | onosIds = onosCli.getAllIntentsId() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 841 | main.log.info( "Submitted intents: " + str( intentIds ) ) |
| 842 | main.log.info( "Intents in ONOS: " + str( onosIds ) ) |
| 843 | # Print the intent states |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 844 | intents = onosCli.intents() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 845 | intentStates = [] |
| 846 | main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) ) |
| 847 | count = 0 |
| 848 | try: |
| 849 | for intent in json.loads( intents ): |
| 850 | # Iter through intents of a node |
| 851 | state = intent.get( 'state', None ) |
| 852 | if "INSTALLED" not in state: |
| 853 | installedCheck = False |
| 854 | intentId = intent.get( 'id', None ) |
| 855 | intentStates.append( ( intentId, state ) ) |
| 856 | except ( ValueError, TypeError ): |
| 857 | main.log.exception( "Error parsing intents" ) |
| 858 | # add submitted intents not in the store |
| 859 | tmplist = [ i for i, s in intentStates ] |
| 860 | for i in intentIds: |
| 861 | if i not in tmplist: |
| 862 | intentStates.append( ( i, " - " ) ) |
| 863 | intentStates.sort() |
| 864 | for i, s in intentStates: |
| 865 | count += 1 |
| 866 | main.log.info( "%-6s%-15s%-15s" % |
| 867 | ( str( count ), str( i ), str( s ) ) ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 868 | leaders = onosCli.leaders() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 869 | try: |
| 870 | missing = False |
| 871 | if leaders: |
| 872 | parsedLeaders = json.loads( leaders ) |
| 873 | main.log.warn( json.dumps( parsedLeaders, |
| 874 | sort_keys=True, |
| 875 | indent=4, |
| 876 | separators=( ',', ': ' ) ) ) |
| 877 | # check for all intent partitions |
| 878 | # check for election |
| 879 | topics = [] |
| 880 | for i in range( 14 ): |
| 881 | topics.append( "intent-partition-" + str( i ) ) |
| 882 | # FIXME: this should only be after we start the app |
| 883 | topics.append( "org.onosproject.election" ) |
| 884 | main.log.debug( topics ) |
| 885 | ONOStopics = [ j['topic'] for j in parsedLeaders ] |
| 886 | for topic in topics: |
| 887 | if topic not in ONOStopics: |
| 888 | main.log.error( "Error: " + topic + |
| 889 | " not in leaders" ) |
| 890 | missing = True |
| 891 | else: |
| 892 | main.log.error( "leaders() returned None" ) |
| 893 | except ( ValueError, TypeError ): |
| 894 | main.log.exception( "Error parsing leaders" ) |
| 895 | main.log.error( repr( leaders ) ) |
| 896 | # Check all nodes |
| 897 | if missing: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 898 | for i in main.activeNodes: |
| 899 | node = main.CLIs[i] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 900 | response = node.leaders( jsonFormat=False) |
| 901 | main.log.warn( str( node.name ) + " leaders output: \n" + |
| 902 | str( response ) ) |
| 903 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 904 | partitions = onosCli.partitions() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 905 | try: |
| 906 | if partitions : |
| 907 | parsedPartitions = json.loads( partitions ) |
| 908 | main.log.warn( json.dumps( parsedPartitions, |
| 909 | sort_keys=True, |
| 910 | indent=4, |
| 911 | separators=( ',', ': ' ) ) ) |
| 912 | # TODO check for a leader in all paritions |
| 913 | # TODO check for consistency among nodes |
| 914 | else: |
| 915 | main.log.error( "partitions() returned None" ) |
| 916 | except ( ValueError, TypeError ): |
| 917 | main.log.exception( "Error parsing partitions" ) |
| 918 | main.log.error( repr( partitions ) ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 919 | pendingMap = onosCli.pendingMap() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 920 | try: |
| 921 | if pendingMap : |
| 922 | parsedPending = json.loads( pendingMap ) |
| 923 | main.log.warn( json.dumps( parsedPending, |
| 924 | sort_keys=True, |
| 925 | indent=4, |
| 926 | separators=( ',', ': ' ) ) ) |
| 927 | # TODO check something here? |
| 928 | else: |
| 929 | main.log.error( "pendingMap() returned None" ) |
| 930 | except ( ValueError, TypeError ): |
| 931 | main.log.exception( "Error parsing pending map" ) |
| 932 | main.log.error( repr( pendingMap ) ) |
| 933 | |
| 934 | def CASE4( self, main ): |
| 935 | """ |
| 936 | Ping across added host intents |
| 937 | """ |
| 938 | import json |
| 939 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 940 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 941 | assert main, "main not defined" |
| 942 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 943 | assert main.CLIs, "main.CLIs not defined" |
| 944 | assert main.nodes, "main.nodes not defined" |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 945 | main.case( "Verify connectivity by sending traffic across Intents" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 946 | main.caseExplanation = "Ping across added host intents to check " +\ |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 947 | "functionality and check the state of " +\ |
| 948 | "the intent" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 949 | |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 950 | onosCli = main.CLIs[ main.activeNodes[0] ] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 951 | main.step( "Check Intent state" ) |
| 952 | installedCheck = False |
| 953 | loopCount = 0 |
| 954 | while not installedCheck and loopCount < 40: |
| 955 | installedCheck = True |
| 956 | # Print the intent states |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 957 | intents = onosCli.intents() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 958 | intentStates = [] |
| 959 | main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) ) |
| 960 | count = 0 |
| 961 | # Iter through intents of a node |
| 962 | try: |
| 963 | for intent in json.loads( intents ): |
| 964 | state = intent.get( 'state', None ) |
| 965 | if "INSTALLED" not in state: |
| 966 | installedCheck = False |
| 967 | intentId = intent.get( 'id', None ) |
| 968 | intentStates.append( ( intentId, state ) ) |
| 969 | except ( ValueError, TypeError ): |
| 970 | main.log.exception( "Error parsing intents." ) |
| 971 | # Print states |
| 972 | intentStates.sort() |
| 973 | for i, s in intentStates: |
| 974 | count += 1 |
| 975 | main.log.info( "%-6s%-15s%-15s" % |
| 976 | ( str( count ), str( i ), str( s ) ) ) |
| 977 | if not installedCheck: |
| 978 | time.sleep( 1 ) |
| 979 | loopCount += 1 |
| 980 | utilities.assert_equals( expect=True, actual=installedCheck, |
| 981 | onpass="Intents are all INSTALLED", |
| 982 | onfail="Intents are not all in " + |
| 983 | "INSTALLED state" ) |
| 984 | |
Jon Hall | 9d2dcad | 2016-04-08 10:15:20 -0700 | [diff] [blame] | 985 | main.step( "Ping across added host intents" ) |
Jon Hall | 9d2dcad | 2016-04-08 10:15:20 -0700 | [diff] [blame] | 986 | PingResult = main.TRUE |
| 987 | for i in range( 8, 18 ): |
| 988 | ping = main.Mininet1.pingHost( src="h" + str( i ), |
| 989 | target="h" + str( i + 10 ) ) |
| 990 | PingResult = PingResult and ping |
| 991 | if ping == main.FALSE: |
| 992 | main.log.warn( "Ping failed between h" + str( i ) + |
| 993 | " and h" + str( i + 10 ) ) |
| 994 | elif ping == main.TRUE: |
| 995 | main.log.info( "Ping test passed!" ) |
| 996 | # Don't set PingResult or you'd override failures |
| 997 | if PingResult == main.FALSE: |
| 998 | main.log.error( |
| 999 | "Intents have not been installed correctly, pings failed." ) |
| 1000 | # TODO: pretty print |
| 1001 | main.log.warn( "ONOS1 intents: " ) |
| 1002 | try: |
| 1003 | tmpIntents = onosCli.intents() |
| 1004 | main.log.warn( json.dumps( json.loads( tmpIntents ), |
| 1005 | sort_keys=True, |
| 1006 | indent=4, |
| 1007 | separators=( ',', ': ' ) ) ) |
| 1008 | except ( ValueError, TypeError ): |
| 1009 | main.log.warn( repr( tmpIntents ) ) |
| 1010 | utilities.assert_equals( |
| 1011 | expect=main.TRUE, |
| 1012 | actual=PingResult, |
| 1013 | onpass="Intents have been installed correctly and pings work", |
| 1014 | onfail="Intents have not been installed correctly, pings failed." ) |
| 1015 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1016 | main.step( "Check leadership of topics" ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1017 | leaders = onosCli.leaders() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1018 | topicCheck = main.TRUE |
| 1019 | try: |
| 1020 | if leaders: |
| 1021 | parsedLeaders = json.loads( leaders ) |
| 1022 | main.log.warn( json.dumps( parsedLeaders, |
| 1023 | sort_keys=True, |
| 1024 | indent=4, |
| 1025 | separators=( ',', ': ' ) ) ) |
| 1026 | # check for all intent partitions |
| 1027 | # check for election |
| 1028 | # TODO: Look at Devices as topics now that it uses this system |
| 1029 | topics = [] |
| 1030 | for i in range( 14 ): |
| 1031 | topics.append( "intent-partition-" + str( i ) ) |
| 1032 | # FIXME: this should only be after we start the app |
| 1033 | # FIXME: topics.append( "org.onosproject.election" ) |
| 1034 | # Print leaders output |
| 1035 | main.log.debug( topics ) |
| 1036 | ONOStopics = [ j['topic'] for j in parsedLeaders ] |
| 1037 | for topic in topics: |
| 1038 | if topic not in ONOStopics: |
| 1039 | main.log.error( "Error: " + topic + |
| 1040 | " not in leaders" ) |
| 1041 | topicCheck = main.FALSE |
| 1042 | else: |
| 1043 | main.log.error( "leaders() returned None" ) |
| 1044 | topicCheck = main.FALSE |
| 1045 | except ( ValueError, TypeError ): |
| 1046 | topicCheck = main.FALSE |
| 1047 | main.log.exception( "Error parsing leaders" ) |
| 1048 | main.log.error( repr( leaders ) ) |
| 1049 | # TODO: Check for a leader of these topics |
| 1050 | # Check all nodes |
| 1051 | if topicCheck: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1052 | for i in main.activeNodes: |
| 1053 | node = main.CLIs[i] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1054 | response = node.leaders( jsonFormat=False) |
| 1055 | main.log.warn( str( node.name ) + " leaders output: \n" + |
| 1056 | str( response ) ) |
| 1057 | |
| 1058 | utilities.assert_equals( expect=main.TRUE, actual=topicCheck, |
| 1059 | onpass="intent Partitions is in leaders", |
| 1060 | onfail="Some topics were lost " ) |
| 1061 | # Print partitions |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1062 | partitions = onosCli.partitions() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1063 | try: |
| 1064 | if partitions : |
| 1065 | parsedPartitions = json.loads( partitions ) |
| 1066 | main.log.warn( json.dumps( parsedPartitions, |
| 1067 | sort_keys=True, |
| 1068 | indent=4, |
| 1069 | separators=( ',', ': ' ) ) ) |
| 1070 | # TODO check for a leader in all paritions |
| 1071 | # TODO check for consistency among nodes |
| 1072 | else: |
| 1073 | main.log.error( "partitions() returned None" ) |
| 1074 | except ( ValueError, TypeError ): |
| 1075 | main.log.exception( "Error parsing partitions" ) |
| 1076 | main.log.error( repr( partitions ) ) |
| 1077 | # Print Pending Map |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1078 | pendingMap = onosCli.pendingMap() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1079 | try: |
| 1080 | if pendingMap : |
| 1081 | parsedPending = json.loads( pendingMap ) |
| 1082 | main.log.warn( json.dumps( parsedPending, |
| 1083 | sort_keys=True, |
| 1084 | indent=4, |
| 1085 | separators=( ',', ': ' ) ) ) |
| 1086 | # TODO check something here? |
| 1087 | else: |
| 1088 | main.log.error( "pendingMap() returned None" ) |
| 1089 | except ( ValueError, TypeError ): |
| 1090 | main.log.exception( "Error parsing pending map" ) |
| 1091 | main.log.error( repr( pendingMap ) ) |
| 1092 | |
| 1093 | if not installedCheck: |
| 1094 | main.log.info( "Waiting 60 seconds to see if the state of " + |
| 1095 | "intents change" ) |
| 1096 | time.sleep( 60 ) |
| 1097 | # Print the intent states |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1098 | intents = onosCli.intents() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1099 | intentStates = [] |
| 1100 | main.log.info( "%-6s%-15s%-15s" % ( 'Count', 'ID', 'State' ) ) |
| 1101 | count = 0 |
| 1102 | # Iter through intents of a node |
| 1103 | try: |
| 1104 | for intent in json.loads( intents ): |
| 1105 | state = intent.get( 'state', None ) |
| 1106 | if "INSTALLED" not in state: |
| 1107 | installedCheck = False |
| 1108 | intentId = intent.get( 'id', None ) |
| 1109 | intentStates.append( ( intentId, state ) ) |
| 1110 | except ( ValueError, TypeError ): |
| 1111 | main.log.exception( "Error parsing intents." ) |
| 1112 | intentStates.sort() |
| 1113 | for i, s in intentStates: |
| 1114 | count += 1 |
| 1115 | main.log.info( "%-6s%-15s%-15s" % |
| 1116 | ( str( count ), str( i ), str( s ) ) ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1117 | leaders = onosCli.leaders() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1118 | try: |
| 1119 | missing = False |
| 1120 | if leaders: |
| 1121 | parsedLeaders = json.loads( leaders ) |
| 1122 | main.log.warn( json.dumps( parsedLeaders, |
| 1123 | sort_keys=True, |
| 1124 | indent=4, |
| 1125 | separators=( ',', ': ' ) ) ) |
| 1126 | # check for all intent partitions |
| 1127 | # check for election |
| 1128 | topics = [] |
| 1129 | for i in range( 14 ): |
| 1130 | topics.append( "intent-partition-" + str( i ) ) |
| 1131 | # FIXME: this should only be after we start the app |
| 1132 | topics.append( "org.onosproject.election" ) |
| 1133 | main.log.debug( topics ) |
| 1134 | ONOStopics = [ j['topic'] for j in parsedLeaders ] |
| 1135 | for topic in topics: |
| 1136 | if topic not in ONOStopics: |
| 1137 | main.log.error( "Error: " + topic + |
| 1138 | " not in leaders" ) |
| 1139 | missing = True |
| 1140 | else: |
| 1141 | main.log.error( "leaders() returned None" ) |
| 1142 | except ( ValueError, TypeError ): |
| 1143 | main.log.exception( "Error parsing leaders" ) |
| 1144 | main.log.error( repr( leaders ) ) |
| 1145 | if missing: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1146 | for i in main.activeNodes: |
| 1147 | node = main.CLIs[i] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1148 | response = node.leaders( jsonFormat=False) |
| 1149 | main.log.warn( str( node.name ) + " leaders output: \n" + |
| 1150 | str( response ) ) |
| 1151 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1152 | partitions = onosCli.partitions() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1153 | try: |
| 1154 | if partitions : |
| 1155 | parsedPartitions = json.loads( partitions ) |
| 1156 | main.log.warn( json.dumps( parsedPartitions, |
| 1157 | sort_keys=True, |
| 1158 | indent=4, |
| 1159 | separators=( ',', ': ' ) ) ) |
| 1160 | # TODO check for a leader in all paritions |
| 1161 | # TODO check for consistency among nodes |
| 1162 | else: |
| 1163 | main.log.error( "partitions() returned None" ) |
| 1164 | except ( ValueError, TypeError ): |
| 1165 | main.log.exception( "Error parsing partitions" ) |
| 1166 | main.log.error( repr( partitions ) ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1167 | pendingMap = onosCli.pendingMap() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1168 | try: |
| 1169 | if pendingMap : |
| 1170 | parsedPending = json.loads( pendingMap ) |
| 1171 | main.log.warn( json.dumps( parsedPending, |
| 1172 | sort_keys=True, |
| 1173 | indent=4, |
| 1174 | separators=( ',', ': ' ) ) ) |
| 1175 | # TODO check something here? |
| 1176 | else: |
| 1177 | main.log.error( "pendingMap() returned None" ) |
| 1178 | except ( ValueError, TypeError ): |
| 1179 | main.log.exception( "Error parsing pending map" ) |
| 1180 | main.log.error( repr( pendingMap ) ) |
| 1181 | # Print flowrules |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 1182 | main.log.debug( onosCli.flows( jsonFormat=False ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1183 | main.step( "Wait a minute then ping again" ) |
| 1184 | # the wait is above |
| 1185 | PingResult = main.TRUE |
| 1186 | for i in range( 8, 18 ): |
| 1187 | ping = main.Mininet1.pingHost( src="h" + str( i ), |
| 1188 | target="h" + str( i + 10 ) ) |
| 1189 | PingResult = PingResult and ping |
| 1190 | if ping == main.FALSE: |
| 1191 | main.log.warn( "Ping failed between h" + str( i ) + |
| 1192 | " and h" + str( i + 10 ) ) |
| 1193 | elif ping == main.TRUE: |
| 1194 | main.log.info( "Ping test passed!" ) |
| 1195 | # Don't set PingResult or you'd override failures |
| 1196 | if PingResult == main.FALSE: |
| 1197 | main.log.error( |
| 1198 | "Intents have not been installed correctly, pings failed." ) |
| 1199 | # TODO: pretty print |
| 1200 | main.log.warn( "ONOS1 intents: " ) |
| 1201 | try: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1202 | tmpIntents = onosCli.intents() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1203 | main.log.warn( json.dumps( json.loads( tmpIntents ), |
| 1204 | sort_keys=True, |
| 1205 | indent=4, |
| 1206 | separators=( ',', ': ' ) ) ) |
| 1207 | except ( ValueError, TypeError ): |
| 1208 | main.log.warn( repr( tmpIntents ) ) |
| 1209 | utilities.assert_equals( |
| 1210 | expect=main.TRUE, |
| 1211 | actual=PingResult, |
| 1212 | onpass="Intents have been installed correctly and pings work", |
| 1213 | onfail="Intents have not been installed correctly, pings failed." ) |
| 1214 | |
| 1215 | def CASE5( self, main ): |
| 1216 | """ |
| 1217 | Reading state of ONOS |
| 1218 | """ |
| 1219 | import json |
| 1220 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1221 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1222 | assert main, "main not defined" |
| 1223 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1224 | assert main.CLIs, "main.CLIs not defined" |
| 1225 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1226 | |
| 1227 | main.case( "Setting up and gathering data for current state" ) |
| 1228 | # The general idea for this test case is to pull the state of |
| 1229 | # ( intents,flows, topology,... ) from each ONOS node |
| 1230 | # We can then compare them with each other and also with past states |
| 1231 | |
| 1232 | main.step( "Check that each switch has a master" ) |
| 1233 | global mastershipState |
| 1234 | mastershipState = '[]' |
| 1235 | |
| 1236 | # Assert that each device has a master |
| 1237 | rolesNotNull = main.TRUE |
| 1238 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1239 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1240 | t = main.Thread( target=main.CLIs[i].rolesNotNull, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1241 | name="rolesNotNull-" + str( i ), |
| 1242 | args=[] ) |
| 1243 | threads.append( t ) |
| 1244 | t.start() |
| 1245 | |
| 1246 | for t in threads: |
| 1247 | t.join() |
| 1248 | rolesNotNull = rolesNotNull and t.result |
| 1249 | utilities.assert_equals( |
| 1250 | expect=main.TRUE, |
| 1251 | actual=rolesNotNull, |
| 1252 | onpass="Each device has a master", |
| 1253 | onfail="Some devices don't have a master assigned" ) |
| 1254 | |
| 1255 | main.step( "Get the Mastership of each switch from each controller" ) |
| 1256 | ONOSMastership = [] |
| 1257 | mastershipCheck = main.FALSE |
| 1258 | consistentMastership = True |
| 1259 | rolesResults = True |
| 1260 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1261 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1262 | t = main.Thread( target=main.CLIs[i].roles, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1263 | name="roles-" + str( i ), |
| 1264 | args=[] ) |
| 1265 | threads.append( t ) |
| 1266 | t.start() |
| 1267 | |
| 1268 | for t in threads: |
| 1269 | t.join() |
| 1270 | ONOSMastership.append( t.result ) |
| 1271 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1272 | for i in range( len( ONOSMastership ) ): |
| 1273 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1274 | if not ONOSMastership[i] or "Error" in ONOSMastership[i]: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1275 | main.log.error( "Error in getting ONOS" + node + " roles" ) |
| 1276 | main.log.warn( "ONOS" + node + " mastership response: " + |
| 1277 | repr( ONOSMastership[i] ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1278 | rolesResults = False |
| 1279 | utilities.assert_equals( |
| 1280 | expect=True, |
| 1281 | actual=rolesResults, |
| 1282 | onpass="No error in reading roles output", |
| 1283 | onfail="Error in reading roles from ONOS" ) |
| 1284 | |
| 1285 | main.step( "Check for consistency in roles from each controller" ) |
| 1286 | if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ): |
| 1287 | main.log.info( |
| 1288 | "Switch roles are consistent across all ONOS nodes" ) |
| 1289 | else: |
| 1290 | consistentMastership = False |
| 1291 | utilities.assert_equals( |
| 1292 | expect=True, |
| 1293 | actual=consistentMastership, |
| 1294 | onpass="Switch roles are consistent across all ONOS nodes", |
| 1295 | onfail="ONOS nodes have different views of switch roles" ) |
| 1296 | |
| 1297 | if rolesResults and not consistentMastership: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1298 | for i in range( len( main.activeNodes ) ): |
| 1299 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1300 | try: |
| 1301 | main.log.warn( |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1302 | "ONOS" + node + " roles: ", |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1303 | json.dumps( |
| 1304 | json.loads( ONOSMastership[ i ] ), |
| 1305 | sort_keys=True, |
| 1306 | indent=4, |
| 1307 | separators=( ',', ': ' ) ) ) |
| 1308 | except ( ValueError, TypeError ): |
| 1309 | main.log.warn( repr( ONOSMastership[ i ] ) ) |
| 1310 | elif rolesResults and consistentMastership: |
| 1311 | mastershipCheck = main.TRUE |
| 1312 | mastershipState = ONOSMastership[ 0 ] |
| 1313 | |
| 1314 | main.step( "Get the intents from each controller" ) |
| 1315 | global intentState |
| 1316 | intentState = [] |
| 1317 | ONOSIntents = [] |
| 1318 | intentCheck = main.FALSE |
| 1319 | consistentIntents = True |
| 1320 | intentsResults = True |
| 1321 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1322 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1323 | t = main.Thread( target=main.CLIs[i].intents, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1324 | name="intents-" + str( i ), |
| 1325 | args=[], |
| 1326 | kwargs={ 'jsonFormat': True } ) |
| 1327 | threads.append( t ) |
| 1328 | t.start() |
| 1329 | |
| 1330 | for t in threads: |
| 1331 | t.join() |
| 1332 | ONOSIntents.append( t.result ) |
| 1333 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1334 | for i in range( len( ONOSIntents ) ): |
| 1335 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1336 | if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1337 | main.log.error( "Error in getting ONOS" + node + " intents" ) |
| 1338 | main.log.warn( "ONOS" + node + " intents response: " + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1339 | repr( ONOSIntents[ i ] ) ) |
| 1340 | intentsResults = False |
| 1341 | utilities.assert_equals( |
| 1342 | expect=True, |
| 1343 | actual=intentsResults, |
| 1344 | onpass="No error in reading intents output", |
| 1345 | onfail="Error in reading intents from ONOS" ) |
| 1346 | |
| 1347 | main.step( "Check for consistency in Intents from each controller" ) |
| 1348 | if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ): |
| 1349 | main.log.info( "Intents are consistent across all ONOS " + |
| 1350 | "nodes" ) |
| 1351 | else: |
| 1352 | consistentIntents = False |
| 1353 | main.log.error( "Intents not consistent" ) |
| 1354 | utilities.assert_equals( |
| 1355 | expect=True, |
| 1356 | actual=consistentIntents, |
| 1357 | onpass="Intents are consistent across all ONOS nodes", |
| 1358 | onfail="ONOS nodes have different views of intents" ) |
| 1359 | |
| 1360 | if intentsResults: |
| 1361 | # Try to make it easy to figure out what is happening |
| 1362 | # |
| 1363 | # Intent ONOS1 ONOS2 ... |
| 1364 | # 0x01 INSTALLED INSTALLING |
| 1365 | # ... ... ... |
| 1366 | # ... ... ... |
| 1367 | title = " Id" |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1368 | for n in main.activeNodes: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1369 | title += " " * 10 + "ONOS" + str( n + 1 ) |
| 1370 | main.log.warn( title ) |
| 1371 | # get all intent keys in the cluster |
| 1372 | keys = [] |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 1373 | try: |
| 1374 | # Get the set of all intent keys |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1375 | for nodeStr in ONOSIntents: |
| 1376 | node = json.loads( nodeStr ) |
| 1377 | for intent in node: |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 1378 | keys.append( intent.get( 'id' ) ) |
| 1379 | keys = set( keys ) |
| 1380 | # For each intent key, print the state on each node |
| 1381 | for key in keys: |
| 1382 | row = "%-13s" % key |
| 1383 | for nodeStr in ONOSIntents: |
| 1384 | node = json.loads( nodeStr ) |
| 1385 | for intent in node: |
| 1386 | if intent.get( 'id', "Error" ) == key: |
| 1387 | row += "%-15s" % intent.get( 'state' ) |
| 1388 | main.log.warn( row ) |
| 1389 | # End of intent state table |
| 1390 | except ValueError as e: |
| 1391 | main.log.exception( e ) |
| 1392 | main.log.debug( "nodeStr was: " + repr( nodeStr ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1393 | |
| 1394 | if intentsResults and not consistentIntents: |
| 1395 | # print the json objects |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1396 | n = str( main.activeNodes[-1] + 1 ) |
| 1397 | main.log.debug( "ONOS" + n + " intents: " ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1398 | main.log.debug( json.dumps( json.loads( ONOSIntents[ -1 ] ), |
| 1399 | sort_keys=True, |
| 1400 | indent=4, |
| 1401 | separators=( ',', ': ' ) ) ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1402 | for i in range( len( ONOSIntents ) ): |
| 1403 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1404 | if ONOSIntents[ i ] != ONOSIntents[ -1 ]: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1405 | main.log.debug( "ONOS" + node + " intents: " ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1406 | main.log.debug( json.dumps( json.loads( ONOSIntents[i] ), |
| 1407 | sort_keys=True, |
| 1408 | indent=4, |
| 1409 | separators=( ',', ': ' ) ) ) |
| 1410 | else: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1411 | main.log.debug( "ONOS" + node + " intents match ONOS" + |
| 1412 | n + " intents" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1413 | elif intentsResults and consistentIntents: |
| 1414 | intentCheck = main.TRUE |
| 1415 | intentState = ONOSIntents[ 0 ] |
| 1416 | |
| 1417 | main.step( "Get the flows from each controller" ) |
| 1418 | global flowState |
| 1419 | flowState = [] |
| 1420 | ONOSFlows = [] |
| 1421 | ONOSFlowsJson = [] |
| 1422 | flowCheck = main.FALSE |
| 1423 | consistentFlows = True |
| 1424 | flowsResults = True |
| 1425 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1426 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1427 | t = main.Thread( target=main.CLIs[i].flows, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1428 | name="flows-" + str( i ), |
| 1429 | args=[], |
| 1430 | kwargs={ 'jsonFormat': True } ) |
| 1431 | threads.append( t ) |
| 1432 | t.start() |
| 1433 | |
| 1434 | # NOTE: Flows command can take some time to run |
| 1435 | time.sleep(30) |
| 1436 | for t in threads: |
| 1437 | t.join() |
| 1438 | result = t.result |
| 1439 | ONOSFlows.append( result ) |
| 1440 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1441 | for i in range( len( ONOSFlows ) ): |
| 1442 | num = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1443 | if not ONOSFlows[ i ] or "Error" in ONOSFlows[ i ]: |
| 1444 | main.log.error( "Error in getting ONOS" + num + " flows" ) |
| 1445 | main.log.warn( "ONOS" + num + " flows response: " + |
| 1446 | repr( ONOSFlows[ i ] ) ) |
| 1447 | flowsResults = False |
| 1448 | ONOSFlowsJson.append( None ) |
| 1449 | else: |
| 1450 | try: |
| 1451 | ONOSFlowsJson.append( json.loads( ONOSFlows[ i ] ) ) |
| 1452 | except ( ValueError, TypeError ): |
| 1453 | # FIXME: change this to log.error? |
| 1454 | main.log.exception( "Error in parsing ONOS" + num + |
| 1455 | " response as json." ) |
| 1456 | main.log.error( repr( ONOSFlows[ i ] ) ) |
| 1457 | ONOSFlowsJson.append( None ) |
| 1458 | flowsResults = False |
| 1459 | utilities.assert_equals( |
| 1460 | expect=True, |
| 1461 | actual=flowsResults, |
| 1462 | onpass="No error in reading flows output", |
| 1463 | onfail="Error in reading flows from ONOS" ) |
| 1464 | |
| 1465 | main.step( "Check for consistency in Flows from each controller" ) |
| 1466 | tmp = [ len( i ) == len( ONOSFlowsJson[ 0 ] ) for i in ONOSFlowsJson ] |
| 1467 | if all( tmp ): |
| 1468 | main.log.info( "Flow count is consistent across all ONOS nodes" ) |
| 1469 | else: |
| 1470 | consistentFlows = False |
| 1471 | utilities.assert_equals( |
| 1472 | expect=True, |
| 1473 | actual=consistentFlows, |
| 1474 | onpass="The flow count is consistent across all ONOS nodes", |
| 1475 | onfail="ONOS nodes have different flow counts" ) |
| 1476 | |
| 1477 | if flowsResults and not consistentFlows: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1478 | for i in range( len( ONOSFlows ) ): |
| 1479 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1480 | try: |
| 1481 | main.log.warn( |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1482 | "ONOS" + node + " flows: " + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1483 | json.dumps( json.loads( ONOSFlows[i] ), sort_keys=True, |
| 1484 | indent=4, separators=( ',', ': ' ) ) ) |
| 1485 | except ( ValueError, TypeError ): |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1486 | main.log.warn( "ONOS" + node + " flows: " + |
| 1487 | repr( ONOSFlows[ i ] ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1488 | elif flowsResults and consistentFlows: |
| 1489 | flowCheck = main.TRUE |
| 1490 | flowState = ONOSFlows[ 0 ] |
| 1491 | |
| 1492 | main.step( "Get the OF Table entries" ) |
| 1493 | global flows |
| 1494 | flows = [] |
| 1495 | for i in range( 1, 29 ): |
GlennRC | 68467eb | 2015-11-16 18:01:01 -0800 | [diff] [blame] | 1496 | flows.append( main.Mininet1.getFlowTable( "s" + str( i ), version="1.3", debug=False ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1497 | if flowCheck == main.FALSE: |
| 1498 | for table in flows: |
| 1499 | main.log.warn( table ) |
| 1500 | # TODO: Compare switch flow tables with ONOS flow tables |
| 1501 | |
| 1502 | main.step( "Start continuous pings" ) |
| 1503 | main.Mininet2.pingLong( |
| 1504 | src=main.params[ 'PING' ][ 'source1' ], |
| 1505 | target=main.params[ 'PING' ][ 'target1' ], |
| 1506 | pingTime=500 ) |
| 1507 | main.Mininet2.pingLong( |
| 1508 | src=main.params[ 'PING' ][ 'source2' ], |
| 1509 | target=main.params[ 'PING' ][ 'target2' ], |
| 1510 | pingTime=500 ) |
| 1511 | main.Mininet2.pingLong( |
| 1512 | src=main.params[ 'PING' ][ 'source3' ], |
| 1513 | target=main.params[ 'PING' ][ 'target3' ], |
| 1514 | pingTime=500 ) |
| 1515 | main.Mininet2.pingLong( |
| 1516 | src=main.params[ 'PING' ][ 'source4' ], |
| 1517 | target=main.params[ 'PING' ][ 'target4' ], |
| 1518 | pingTime=500 ) |
| 1519 | main.Mininet2.pingLong( |
| 1520 | src=main.params[ 'PING' ][ 'source5' ], |
| 1521 | target=main.params[ 'PING' ][ 'target5' ], |
| 1522 | pingTime=500 ) |
| 1523 | main.Mininet2.pingLong( |
| 1524 | src=main.params[ 'PING' ][ 'source6' ], |
| 1525 | target=main.params[ 'PING' ][ 'target6' ], |
| 1526 | pingTime=500 ) |
| 1527 | main.Mininet2.pingLong( |
| 1528 | src=main.params[ 'PING' ][ 'source7' ], |
| 1529 | target=main.params[ 'PING' ][ 'target7' ], |
| 1530 | pingTime=500 ) |
| 1531 | main.Mininet2.pingLong( |
| 1532 | src=main.params[ 'PING' ][ 'source8' ], |
| 1533 | target=main.params[ 'PING' ][ 'target8' ], |
| 1534 | pingTime=500 ) |
| 1535 | main.Mininet2.pingLong( |
| 1536 | src=main.params[ 'PING' ][ 'source9' ], |
| 1537 | target=main.params[ 'PING' ][ 'target9' ], |
| 1538 | pingTime=500 ) |
| 1539 | main.Mininet2.pingLong( |
| 1540 | src=main.params[ 'PING' ][ 'source10' ], |
| 1541 | target=main.params[ 'PING' ][ 'target10' ], |
| 1542 | pingTime=500 ) |
| 1543 | |
| 1544 | main.step( "Collecting topology information from ONOS" ) |
| 1545 | devices = [] |
| 1546 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1547 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1548 | t = main.Thread( target=main.CLIs[i].devices, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1549 | name="devices-" + str( i ), |
| 1550 | args=[ ] ) |
| 1551 | threads.append( t ) |
| 1552 | t.start() |
| 1553 | |
| 1554 | for t in threads: |
| 1555 | t.join() |
| 1556 | devices.append( t.result ) |
| 1557 | hosts = [] |
| 1558 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1559 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1560 | t = main.Thread( target=main.CLIs[i].hosts, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1561 | name="hosts-" + str( i ), |
| 1562 | args=[ ] ) |
| 1563 | threads.append( t ) |
| 1564 | t.start() |
| 1565 | |
| 1566 | for t in threads: |
| 1567 | t.join() |
| 1568 | try: |
| 1569 | hosts.append( json.loads( t.result ) ) |
| 1570 | except ( ValueError, TypeError ): |
| 1571 | # FIXME: better handling of this, print which node |
| 1572 | # Maybe use thread name? |
| 1573 | main.log.exception( "Error parsing json output of hosts" ) |
Jon Hall | f3d16e7 | 2015-12-16 17:45:08 -0800 | [diff] [blame] | 1574 | main.log.warn( repr( t.result ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1575 | hosts.append( None ) |
| 1576 | |
| 1577 | ports = [] |
| 1578 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1579 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1580 | t = main.Thread( target=main.CLIs[i].ports, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1581 | name="ports-" + str( i ), |
| 1582 | args=[ ] ) |
| 1583 | threads.append( t ) |
| 1584 | t.start() |
| 1585 | |
| 1586 | for t in threads: |
| 1587 | t.join() |
| 1588 | ports.append( t.result ) |
| 1589 | links = [] |
| 1590 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1591 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1592 | t = main.Thread( target=main.CLIs[i].links, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1593 | name="links-" + str( i ), |
| 1594 | args=[ ] ) |
| 1595 | threads.append( t ) |
| 1596 | t.start() |
| 1597 | |
| 1598 | for t in threads: |
| 1599 | t.join() |
| 1600 | links.append( t.result ) |
| 1601 | clusters = [] |
| 1602 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1603 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1604 | t = main.Thread( target=main.CLIs[i].clusters, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1605 | name="clusters-" + str( i ), |
| 1606 | args=[ ] ) |
| 1607 | threads.append( t ) |
| 1608 | t.start() |
| 1609 | |
| 1610 | for t in threads: |
| 1611 | t.join() |
| 1612 | clusters.append( t.result ) |
| 1613 | # Compare json objects for hosts and dataplane clusters |
| 1614 | |
| 1615 | # hosts |
| 1616 | main.step( "Host view is consistent across ONOS nodes" ) |
| 1617 | consistentHostsResult = main.TRUE |
| 1618 | for controller in range( len( hosts ) ): |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1619 | controllerStr = str( main.activeNodes[controller] + 1 ) |
Jon Hall | f3d16e7 | 2015-12-16 17:45:08 -0800 | [diff] [blame] | 1620 | if hosts[ controller ] and "Error" not in hosts[ controller ]: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1621 | if hosts[ controller ] == hosts[ 0 ]: |
| 1622 | continue |
| 1623 | else: # hosts not consistent |
| 1624 | main.log.error( "hosts from ONOS" + |
| 1625 | controllerStr + |
| 1626 | " is inconsistent with ONOS1" ) |
| 1627 | main.log.warn( repr( hosts[ controller ] ) ) |
| 1628 | consistentHostsResult = main.FALSE |
| 1629 | |
| 1630 | else: |
| 1631 | main.log.error( "Error in getting ONOS hosts from ONOS" + |
| 1632 | controllerStr ) |
| 1633 | consistentHostsResult = main.FALSE |
| 1634 | main.log.warn( "ONOS" + controllerStr + |
| 1635 | " hosts response: " + |
| 1636 | repr( hosts[ controller ] ) ) |
| 1637 | utilities.assert_equals( |
| 1638 | expect=main.TRUE, |
| 1639 | actual=consistentHostsResult, |
| 1640 | onpass="Hosts view is consistent across all ONOS nodes", |
| 1641 | onfail="ONOS nodes have different views of hosts" ) |
| 1642 | |
| 1643 | main.step( "Each host has an IP address" ) |
| 1644 | ipResult = main.TRUE |
| 1645 | for controller in range( 0, len( hosts ) ): |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1646 | controllerStr = str( main.activeNodes[controller] + 1 ) |
Jon Hall | f3d16e7 | 2015-12-16 17:45:08 -0800 | [diff] [blame] | 1647 | if hosts[ controller ]: |
| 1648 | for host in hosts[ controller ]: |
| 1649 | if not host.get( 'ipAddresses', [ ] ): |
| 1650 | main.log.error( "Error with host ips on controller" + |
| 1651 | controllerStr + ": " + str( host ) ) |
| 1652 | ipResult = main.FALSE |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1653 | utilities.assert_equals( |
| 1654 | expect=main.TRUE, |
| 1655 | actual=ipResult, |
| 1656 | onpass="The ips of the hosts aren't empty", |
| 1657 | onfail="The ip of at least one host is missing" ) |
| 1658 | |
| 1659 | # Strongly connected clusters of devices |
| 1660 | main.step( "Cluster view is consistent across ONOS nodes" ) |
| 1661 | consistentClustersResult = main.TRUE |
| 1662 | for controller in range( len( clusters ) ): |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1663 | controllerStr = str( main.activeNodes[controller] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1664 | if "Error" not in clusters[ controller ]: |
| 1665 | if clusters[ controller ] == clusters[ 0 ]: |
| 1666 | continue |
| 1667 | else: # clusters not consistent |
| 1668 | main.log.error( "clusters from ONOS" + controllerStr + |
| 1669 | " is inconsistent with ONOS1" ) |
| 1670 | consistentClustersResult = main.FALSE |
| 1671 | |
| 1672 | else: |
| 1673 | main.log.error( "Error in getting dataplane clusters " + |
| 1674 | "from ONOS" + controllerStr ) |
| 1675 | consistentClustersResult = main.FALSE |
| 1676 | main.log.warn( "ONOS" + controllerStr + |
| 1677 | " clusters response: " + |
| 1678 | repr( clusters[ controller ] ) ) |
| 1679 | utilities.assert_equals( |
| 1680 | expect=main.TRUE, |
| 1681 | actual=consistentClustersResult, |
| 1682 | onpass="Clusters view is consistent across all ONOS nodes", |
| 1683 | onfail="ONOS nodes have different views of clusters" ) |
Jon Hall | 172b7ba | 2016-04-07 18:12:20 -0700 | [diff] [blame] | 1684 | if consistentClustersResult != main.TRUE: |
| 1685 | main.log.debug( clusters ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1686 | # there should always only be one cluster |
| 1687 | main.step( "Cluster view correct across ONOS nodes" ) |
| 1688 | try: |
| 1689 | numClusters = len( json.loads( clusters[ 0 ] ) ) |
| 1690 | except ( ValueError, TypeError ): |
| 1691 | main.log.exception( "Error parsing clusters[0]: " + |
| 1692 | repr( clusters[ 0 ] ) ) |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 1693 | numClusters = "ERROR" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1694 | clusterResults = main.FALSE |
| 1695 | if numClusters == 1: |
| 1696 | clusterResults = main.TRUE |
| 1697 | utilities.assert_equals( |
| 1698 | expect=1, |
| 1699 | actual=numClusters, |
| 1700 | onpass="ONOS shows 1 SCC", |
| 1701 | onfail="ONOS shows " + str( numClusters ) + " SCCs" ) |
| 1702 | |
| 1703 | main.step( "Comparing ONOS topology to MN" ) |
| 1704 | devicesResults = main.TRUE |
| 1705 | linksResults = main.TRUE |
| 1706 | hostsResults = main.TRUE |
| 1707 | mnSwitches = main.Mininet1.getSwitches() |
| 1708 | mnLinks = main.Mininet1.getLinks() |
| 1709 | mnHosts = main.Mininet1.getHosts() |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1710 | for controller in main.activeNodes: |
| 1711 | controllerStr = str( main.activeNodes[controller] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1712 | if devices[ controller ] and ports[ controller ] and\ |
| 1713 | "Error" not in devices[ controller ] and\ |
| 1714 | "Error" not in ports[ controller ]: |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 1715 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 1716 | mnSwitches, |
| 1717 | json.loads( devices[ controller ] ), |
| 1718 | json.loads( ports[ controller ] ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1719 | else: |
| 1720 | currentDevicesResult = main.FALSE |
| 1721 | utilities.assert_equals( expect=main.TRUE, |
| 1722 | actual=currentDevicesResult, |
| 1723 | onpass="ONOS" + controllerStr + |
| 1724 | " Switches view is correct", |
| 1725 | onfail="ONOS" + controllerStr + |
| 1726 | " Switches view is incorrect" ) |
| 1727 | if links[ controller ] and "Error" not in links[ controller ]: |
| 1728 | currentLinksResult = main.Mininet1.compareLinks( |
| 1729 | mnSwitches, mnLinks, |
| 1730 | json.loads( links[ controller ] ) ) |
| 1731 | else: |
| 1732 | currentLinksResult = main.FALSE |
| 1733 | utilities.assert_equals( expect=main.TRUE, |
| 1734 | actual=currentLinksResult, |
| 1735 | onpass="ONOS" + controllerStr + |
| 1736 | " links view is correct", |
| 1737 | onfail="ONOS" + controllerStr + |
| 1738 | " links view is incorrect" ) |
| 1739 | |
Jon Hall | 657cdf6 | 2015-12-17 14:40:51 -0800 | [diff] [blame] | 1740 | if hosts[ controller ] and "Error" not in hosts[ controller ]: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1741 | currentHostsResult = main.Mininet1.compareHosts( |
| 1742 | mnHosts, |
| 1743 | hosts[ controller ] ) |
| 1744 | else: |
| 1745 | currentHostsResult = main.FALSE |
| 1746 | utilities.assert_equals( expect=main.TRUE, |
| 1747 | actual=currentHostsResult, |
| 1748 | onpass="ONOS" + controllerStr + |
| 1749 | " hosts exist in Mininet", |
| 1750 | onfail="ONOS" + controllerStr + |
| 1751 | " hosts don't match Mininet" ) |
| 1752 | |
| 1753 | devicesResults = devicesResults and currentDevicesResult |
| 1754 | linksResults = linksResults and currentLinksResult |
| 1755 | hostsResults = hostsResults and currentHostsResult |
| 1756 | |
| 1757 | main.step( "Device information is correct" ) |
| 1758 | utilities.assert_equals( |
| 1759 | expect=main.TRUE, |
| 1760 | actual=devicesResults, |
| 1761 | onpass="Device information is correct", |
| 1762 | onfail="Device information is incorrect" ) |
| 1763 | |
| 1764 | main.step( "Links are correct" ) |
| 1765 | utilities.assert_equals( |
| 1766 | expect=main.TRUE, |
| 1767 | actual=linksResults, |
| 1768 | onpass="Link are correct", |
| 1769 | onfail="Links are incorrect" ) |
| 1770 | |
| 1771 | main.step( "Hosts are correct" ) |
| 1772 | utilities.assert_equals( |
| 1773 | expect=main.TRUE, |
| 1774 | actual=hostsResults, |
| 1775 | onpass="Hosts are correct", |
| 1776 | onfail="Hosts are incorrect" ) |
| 1777 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1778 | def CASE61( self, main ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1779 | """ |
| 1780 | The Failure case. |
| 1781 | """ |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1782 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1783 | assert main, "main not defined" |
| 1784 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1785 | assert main.CLIs, "main.CLIs not defined" |
| 1786 | assert main.nodes, "main.nodes not defined" |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1787 | main.case( "Stop minority of ONOS nodes" ) |
Jon Hall | 96091e6 | 2015-09-21 17:34:17 -0700 | [diff] [blame] | 1788 | |
| 1789 | main.step( "Checking ONOS Logs for errors" ) |
| 1790 | for node in main.nodes: |
| 1791 | main.log.debug( "Checking logs for errors on " + node.name + ":" ) |
| 1792 | main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) ) |
| 1793 | |
Jon Hall | 3b489db | 2015-10-05 14:38:37 -0700 | [diff] [blame] | 1794 | n = len( main.nodes ) # Number of nodes |
| 1795 | p = ( ( n + 1 ) / 2 ) + 1 # Number of partitions |
| 1796 | main.kill = [ 0 ] # ONOS node to kill, listed by index in main.nodes |
| 1797 | if n > 3: |
| 1798 | main.kill.append( p - 1 ) |
| 1799 | # NOTE: This only works for cluster sizes of 3,5, or 7. |
| 1800 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1801 | main.step( "Stopping " + str( len( main.kill ) ) + " ONOS nodes" ) |
Jon Hall | 3b489db | 2015-10-05 14:38:37 -0700 | [diff] [blame] | 1802 | killResults = main.TRUE |
| 1803 | for i in main.kill: |
| 1804 | killResults = killResults and\ |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1805 | main.ONOSbench.onosStop( main.nodes[i].ip_address ) |
| 1806 | main.activeNodes.remove( i ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1807 | utilities.assert_equals( expect=main.TRUE, actual=killResults, |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1808 | onpass="ONOS nodes stopped successfully", |
| 1809 | onfail="ONOS nodes NOT successfully stopped" ) |
| 1810 | |
| 1811 | def CASE62( self, main ): |
| 1812 | """ |
| 1813 | The bring up stopped nodes |
| 1814 | """ |
| 1815 | import time |
| 1816 | assert main.numCtrls, "main.numCtrls not defined" |
| 1817 | assert main, "main not defined" |
| 1818 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
| 1819 | assert main.CLIs, "main.CLIs not defined" |
| 1820 | assert main.nodes, "main.nodes not defined" |
| 1821 | assert main.kill, "main.kill not defined" |
| 1822 | main.case( "Restart minority of ONOS nodes" ) |
| 1823 | |
| 1824 | main.step( "Restarting " + str( len( main.kill ) ) + " ONOS nodes" ) |
| 1825 | startResults = main.TRUE |
| 1826 | restartTime = time.time() |
| 1827 | for i in main.kill: |
| 1828 | startResults = startResults and\ |
| 1829 | main.ONOSbench.onosStart( main.nodes[i].ip_address ) |
| 1830 | utilities.assert_equals( expect=main.TRUE, actual=startResults, |
| 1831 | onpass="ONOS nodes started successfully", |
| 1832 | onfail="ONOS nodes NOT successfully started" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1833 | |
| 1834 | main.step( "Checking if ONOS is up yet" ) |
| 1835 | count = 0 |
| 1836 | onosIsupResult = main.FALSE |
| 1837 | while onosIsupResult == main.FALSE and count < 10: |
Jon Hall | 3b489db | 2015-10-05 14:38:37 -0700 | [diff] [blame] | 1838 | onosIsupResult = main.TRUE |
| 1839 | for i in main.kill: |
| 1840 | onosIsupResult = onosIsupResult and\ |
| 1841 | main.ONOSbench.isup( main.nodes[i].ip_address ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1842 | count = count + 1 |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1843 | utilities.assert_equals( expect=main.TRUE, actual=onosIsupResult, |
| 1844 | onpass="ONOS restarted successfully", |
| 1845 | onfail="ONOS restart NOT successful" ) |
| 1846 | |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1847 | main.step( "Restarting ONOS main.CLIs" ) |
Jon Hall | 3b489db | 2015-10-05 14:38:37 -0700 | [diff] [blame] | 1848 | cliResults = main.TRUE |
| 1849 | for i in main.kill: |
| 1850 | cliResults = cliResults and\ |
| 1851 | main.CLIs[i].startOnosCli( main.nodes[i].ip_address ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1852 | main.activeNodes.append( i ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1853 | utilities.assert_equals( expect=main.TRUE, actual=cliResults, |
| 1854 | onpass="ONOS cli restarted", |
| 1855 | onfail="ONOS cli did not restart" ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1856 | main.activeNodes.sort() |
| 1857 | try: |
| 1858 | assert list( set( main.activeNodes ) ) == main.activeNodes,\ |
| 1859 | "List of active nodes has duplicates, this likely indicates something was run out of order" |
| 1860 | except AssertionError: |
| 1861 | main.log.exception( "" ) |
| 1862 | main.cleanup() |
| 1863 | main.exit() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1864 | |
| 1865 | # Grab the time of restart so we chan check how long the gossip |
| 1866 | # protocol has had time to work |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1867 | main.restartTime = time.time() - restartTime |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1868 | main.log.debug( "Restart time: " + str( main.restartTime ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1869 | # TODO: MAke this configurable. Also, we are breaking the above timer |
| 1870 | time.sleep( 60 ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1871 | node = main.activeNodes[0] |
| 1872 | main.log.debug( main.CLIs[node].nodes( jsonFormat=False ) ) |
| 1873 | main.log.debug( main.CLIs[node].leaders( jsonFormat=False ) ) |
| 1874 | main.log.debug( main.CLIs[node].partitions( jsonFormat=False ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1875 | |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 1876 | main.step( "Rerun for election on the node(s) that were killed" ) |
| 1877 | runResults = main.TRUE |
| 1878 | for i in main.kill: |
| 1879 | runResults = runResults and\ |
| 1880 | main.CLIs[i].electionTestRun() |
| 1881 | utilities.assert_equals( expect=main.TRUE, actual=runResults, |
| 1882 | onpass="ONOS nodes reran for election topic", |
| 1883 | onfail="Errror rerunning for election" ) |
| 1884 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1885 | def CASE7( self, main ): |
| 1886 | """ |
| 1887 | Check state after ONOS failure |
| 1888 | """ |
| 1889 | import json |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1890 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1891 | assert main, "main not defined" |
| 1892 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1893 | assert main.CLIs, "main.CLIs not defined" |
| 1894 | assert main.nodes, "main.nodes not defined" |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1895 | try: |
| 1896 | main.kill |
| 1897 | except AttributeError: |
| 1898 | main.kill = [] |
| 1899 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1900 | main.case( "Running ONOS Constant State Tests" ) |
| 1901 | |
| 1902 | main.step( "Check that each switch has a master" ) |
| 1903 | # Assert that each device has a master |
| 1904 | rolesNotNull = main.TRUE |
| 1905 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1906 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1907 | t = main.Thread( target=main.CLIs[i].rolesNotNull, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1908 | name="rolesNotNull-" + str( i ), |
| 1909 | args=[ ] ) |
| 1910 | threads.append( t ) |
| 1911 | t.start() |
| 1912 | |
| 1913 | for t in threads: |
| 1914 | t.join() |
| 1915 | rolesNotNull = rolesNotNull and t.result |
| 1916 | utilities.assert_equals( |
| 1917 | expect=main.TRUE, |
| 1918 | actual=rolesNotNull, |
| 1919 | onpass="Each device has a master", |
| 1920 | onfail="Some devices don't have a master assigned" ) |
| 1921 | |
| 1922 | main.step( "Read device roles from ONOS" ) |
| 1923 | ONOSMastership = [] |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 1924 | mastershipCheck = main.FALSE |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1925 | consistentMastership = True |
| 1926 | rolesResults = True |
| 1927 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1928 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1929 | t = main.Thread( target=main.CLIs[i].roles, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1930 | name="roles-" + str( i ), |
| 1931 | args=[] ) |
| 1932 | threads.append( t ) |
| 1933 | t.start() |
| 1934 | |
| 1935 | for t in threads: |
| 1936 | t.join() |
| 1937 | ONOSMastership.append( t.result ) |
| 1938 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1939 | for i in range( len( ONOSMastership ) ): |
| 1940 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1941 | if not ONOSMastership[i] or "Error" in ONOSMastership[i]: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1942 | main.log.error( "Error in getting ONOS" + node + " roles" ) |
| 1943 | main.log.warn( "ONOS" + node + " mastership response: " + |
| 1944 | repr( ONOSMastership[i] ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1945 | rolesResults = False |
| 1946 | utilities.assert_equals( |
| 1947 | expect=True, |
| 1948 | actual=rolesResults, |
| 1949 | onpass="No error in reading roles output", |
| 1950 | onfail="Error in reading roles from ONOS" ) |
| 1951 | |
| 1952 | main.step( "Check for consistency in roles from each controller" ) |
| 1953 | if all([ i == ONOSMastership[ 0 ] for i in ONOSMastership ] ): |
| 1954 | main.log.info( |
| 1955 | "Switch roles are consistent across all ONOS nodes" ) |
| 1956 | else: |
| 1957 | consistentMastership = False |
| 1958 | utilities.assert_equals( |
| 1959 | expect=True, |
| 1960 | actual=consistentMastership, |
| 1961 | onpass="Switch roles are consistent across all ONOS nodes", |
| 1962 | onfail="ONOS nodes have different views of switch roles" ) |
| 1963 | |
| 1964 | if rolesResults and not consistentMastership: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1965 | for i in range( len( ONOSMastership ) ): |
| 1966 | node = str( main.activeNodes[i] + 1 ) |
| 1967 | main.log.warn( "ONOS" + node + " roles: ", |
| 1968 | json.dumps( json.loads( ONOSMastership[ i ] ), |
| 1969 | sort_keys=True, |
| 1970 | indent=4, |
| 1971 | separators=( ',', ': ' ) ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1972 | |
| 1973 | # NOTE: we expect mastership to change on controller failure |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1974 | |
| 1975 | main.step( "Get the intents and compare across all nodes" ) |
| 1976 | ONOSIntents = [] |
| 1977 | intentCheck = main.FALSE |
| 1978 | consistentIntents = True |
| 1979 | intentsResults = True |
| 1980 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1981 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 1982 | t = main.Thread( target=main.CLIs[i].intents, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1983 | name="intents-" + str( i ), |
| 1984 | args=[], |
| 1985 | kwargs={ 'jsonFormat': True } ) |
| 1986 | threads.append( t ) |
| 1987 | t.start() |
| 1988 | |
| 1989 | for t in threads: |
| 1990 | t.join() |
| 1991 | ONOSIntents.append( t.result ) |
| 1992 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1993 | for i in range( len( ONOSIntents) ): |
| 1994 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1995 | if not ONOSIntents[ i ] or "Error" in ONOSIntents[ i ]: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 1996 | main.log.error( "Error in getting ONOS" + node + " intents" ) |
| 1997 | main.log.warn( "ONOS" + node + " intents response: " + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 1998 | repr( ONOSIntents[ i ] ) ) |
| 1999 | intentsResults = False |
| 2000 | utilities.assert_equals( |
| 2001 | expect=True, |
| 2002 | actual=intentsResults, |
| 2003 | onpass="No error in reading intents output", |
| 2004 | onfail="Error in reading intents from ONOS" ) |
| 2005 | |
| 2006 | main.step( "Check for consistency in Intents from each controller" ) |
| 2007 | if all([ sorted( i ) == sorted( ONOSIntents[ 0 ] ) for i in ONOSIntents ] ): |
| 2008 | main.log.info( "Intents are consistent across all ONOS " + |
| 2009 | "nodes" ) |
| 2010 | else: |
| 2011 | consistentIntents = False |
| 2012 | |
| 2013 | # Try to make it easy to figure out what is happening |
| 2014 | # |
| 2015 | # Intent ONOS1 ONOS2 ... |
| 2016 | # 0x01 INSTALLED INSTALLING |
| 2017 | # ... ... ... |
| 2018 | # ... ... ... |
| 2019 | title = " ID" |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2020 | for n in main.activeNodes: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2021 | title += " " * 10 + "ONOS" + str( n + 1 ) |
| 2022 | main.log.warn( title ) |
| 2023 | # get all intent keys in the cluster |
| 2024 | keys = [] |
| 2025 | for nodeStr in ONOSIntents: |
| 2026 | node = json.loads( nodeStr ) |
| 2027 | for intent in node: |
| 2028 | keys.append( intent.get( 'id' ) ) |
| 2029 | keys = set( keys ) |
| 2030 | for key in keys: |
| 2031 | row = "%-13s" % key |
| 2032 | for nodeStr in ONOSIntents: |
| 2033 | node = json.loads( nodeStr ) |
| 2034 | for intent in node: |
| 2035 | if intent.get( 'id' ) == key: |
| 2036 | row += "%-15s" % intent.get( 'state' ) |
| 2037 | main.log.warn( row ) |
| 2038 | # End table view |
| 2039 | |
| 2040 | utilities.assert_equals( |
| 2041 | expect=True, |
| 2042 | actual=consistentIntents, |
| 2043 | onpass="Intents are consistent across all ONOS nodes", |
| 2044 | onfail="ONOS nodes have different views of intents" ) |
| 2045 | intentStates = [] |
| 2046 | for node in ONOSIntents: # Iter through ONOS nodes |
| 2047 | nodeStates = [] |
| 2048 | # Iter through intents of a node |
| 2049 | try: |
| 2050 | for intent in json.loads( node ): |
| 2051 | nodeStates.append( intent[ 'state' ] ) |
| 2052 | except ( ValueError, TypeError ): |
| 2053 | main.log.exception( "Error in parsing intents" ) |
| 2054 | main.log.error( repr( node ) ) |
| 2055 | intentStates.append( nodeStates ) |
| 2056 | out = [ (i, nodeStates.count( i ) ) for i in set( nodeStates ) ] |
| 2057 | main.log.info( dict( out ) ) |
| 2058 | |
| 2059 | if intentsResults and not consistentIntents: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2060 | for i in range( len( main.activeNodes ) ): |
| 2061 | node = str( main.activeNodes[i] + 1 ) |
| 2062 | main.log.warn( "ONOS" + node + " intents: " ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2063 | main.log.warn( json.dumps( |
| 2064 | json.loads( ONOSIntents[ i ] ), |
| 2065 | sort_keys=True, |
| 2066 | indent=4, |
| 2067 | separators=( ',', ': ' ) ) ) |
| 2068 | elif intentsResults and consistentIntents: |
| 2069 | intentCheck = main.TRUE |
| 2070 | |
| 2071 | # NOTE: Store has no durability, so intents are lost across system |
| 2072 | # restarts |
| 2073 | main.step( "Compare current intents with intents before the failure" ) |
| 2074 | # NOTE: this requires case 5 to pass for intentState to be set. |
| 2075 | # maybe we should stop the test if that fails? |
| 2076 | sameIntents = main.FALSE |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2077 | try: |
| 2078 | intentState |
| 2079 | except NameError: |
| 2080 | main.log.warn( "No previous intent state was saved" ) |
| 2081 | else: |
| 2082 | if intentState and intentState == ONOSIntents[ 0 ]: |
| 2083 | sameIntents = main.TRUE |
| 2084 | main.log.info( "Intents are consistent with before failure" ) |
| 2085 | # TODO: possibly the states have changed? we may need to figure out |
| 2086 | # what the acceptable states are |
| 2087 | elif len( intentState ) == len( ONOSIntents[ 0 ] ): |
| 2088 | sameIntents = main.TRUE |
| 2089 | try: |
| 2090 | before = json.loads( intentState ) |
| 2091 | after = json.loads( ONOSIntents[ 0 ] ) |
| 2092 | for intent in before: |
| 2093 | if intent not in after: |
| 2094 | sameIntents = main.FALSE |
| 2095 | main.log.debug( "Intent is not currently in ONOS " + |
| 2096 | "(at least in the same form):" ) |
| 2097 | main.log.debug( json.dumps( intent ) ) |
| 2098 | except ( ValueError, TypeError ): |
| 2099 | main.log.exception( "Exception printing intents" ) |
| 2100 | main.log.debug( repr( ONOSIntents[0] ) ) |
| 2101 | main.log.debug( repr( intentState ) ) |
| 2102 | if sameIntents == main.FALSE: |
| 2103 | try: |
| 2104 | main.log.debug( "ONOS intents before: " ) |
| 2105 | main.log.debug( json.dumps( json.loads( intentState ), |
| 2106 | sort_keys=True, indent=4, |
| 2107 | separators=( ',', ': ' ) ) ) |
| 2108 | main.log.debug( "Current ONOS intents: " ) |
| 2109 | main.log.debug( json.dumps( json.loads( ONOSIntents[ 0 ] ), |
| 2110 | sort_keys=True, indent=4, |
| 2111 | separators=( ',', ': ' ) ) ) |
| 2112 | except ( ValueError, TypeError ): |
| 2113 | main.log.exception( "Exception printing intents" ) |
| 2114 | main.log.debug( repr( ONOSIntents[0] ) ) |
| 2115 | main.log.debug( repr( intentState ) ) |
| 2116 | utilities.assert_equals( |
| 2117 | expect=main.TRUE, |
| 2118 | actual=sameIntents, |
| 2119 | onpass="Intents are consistent with before failure", |
| 2120 | onfail="The Intents changed during failure" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2121 | intentCheck = intentCheck and sameIntents |
| 2122 | |
| 2123 | main.step( "Get the OF Table entries and compare to before " + |
| 2124 | "component failure" ) |
| 2125 | FlowTables = main.TRUE |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2126 | for i in range( 28 ): |
| 2127 | main.log.info( "Checking flow table on s" + str( i + 1 ) ) |
GlennRC | 68467eb | 2015-11-16 18:01:01 -0800 | [diff] [blame] | 2128 | tmpFlows = main.Mininet1.getFlowTable( "s" + str( i + 1 ), version="1.3", debug=False ) |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 2129 | curSwitch = main.Mininet1.flowTableComp( flows[i], tmpFlows ) |
| 2130 | FlowTables = FlowTables and curSwitch |
| 2131 | if curSwitch == main.FALSE: |
GlennRC | 68467eb | 2015-11-16 18:01:01 -0800 | [diff] [blame] | 2132 | main.log.warn( "Differences in flow table for switch: s{}".format( i + 1 ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2133 | utilities.assert_equals( |
| 2134 | expect=main.TRUE, |
| 2135 | actual=FlowTables, |
| 2136 | onpass="No changes were found in the flow tables", |
| 2137 | onfail="Changes were found in the flow tables" ) |
| 2138 | |
| 2139 | main.Mininet2.pingLongKill() |
| 2140 | ''' |
| 2141 | main.step( "Check the continuous pings to ensure that no packets " + |
| 2142 | "were dropped during component failure" ) |
| 2143 | main.Mininet2.pingKill( main.params[ 'TESTONUSER' ], |
| 2144 | main.params[ 'TESTONIP' ] ) |
| 2145 | LossInPings = main.FALSE |
| 2146 | # NOTE: checkForLoss returns main.FALSE with 0% packet loss |
| 2147 | for i in range( 8, 18 ): |
| 2148 | main.log.info( |
| 2149 | "Checking for a loss in pings along flow from s" + |
| 2150 | str( i ) ) |
| 2151 | LossInPings = main.Mininet2.checkForLoss( |
| 2152 | "/tmp/ping.h" + |
| 2153 | str( i ) ) or LossInPings |
| 2154 | if LossInPings == main.TRUE: |
| 2155 | main.log.info( "Loss in ping detected" ) |
| 2156 | elif LossInPings == main.ERROR: |
| 2157 | main.log.info( "There are multiple mininet process running" ) |
| 2158 | elif LossInPings == main.FALSE: |
| 2159 | main.log.info( "No Loss in the pings" ) |
| 2160 | main.log.info( "No loss of dataplane connectivity" ) |
| 2161 | utilities.assert_equals( |
| 2162 | expect=main.FALSE, |
| 2163 | actual=LossInPings, |
| 2164 | onpass="No Loss of connectivity", |
| 2165 | onfail="Loss of dataplane connectivity detected" ) |
| 2166 | ''' |
| 2167 | |
| 2168 | main.step( "Leadership Election is still functional" ) |
| 2169 | # Test of LeadershipElection |
| 2170 | leaderList = [] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2171 | |
Jon Hall | 3b489db | 2015-10-05 14:38:37 -0700 | [diff] [blame] | 2172 | restarted = [] |
| 2173 | for i in main.kill: |
| 2174 | restarted.append( main.nodes[i].ip_address ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2175 | leaderResult = main.TRUE |
Jon Hall | 3b489db | 2015-10-05 14:38:37 -0700 | [diff] [blame] | 2176 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2177 | for i in main.activeNodes: |
| 2178 | cli = main.CLIs[i] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2179 | leaderN = cli.electionTestLeader() |
| 2180 | leaderList.append( leaderN ) |
| 2181 | if leaderN == main.FALSE: |
| 2182 | # error in response |
| 2183 | main.log.error( "Something is wrong with " + |
| 2184 | "electionTestLeader function, check the" + |
| 2185 | " error logs" ) |
| 2186 | leaderResult = main.FALSE |
| 2187 | elif leaderN is None: |
| 2188 | main.log.error( cli.name + |
| 2189 | " shows no leader for the election-app was" + |
| 2190 | " elected after the old one died" ) |
| 2191 | leaderResult = main.FALSE |
| 2192 | elif leaderN in restarted: |
| 2193 | main.log.error( cli.name + " shows " + str( leaderN ) + |
| 2194 | " as leader for the election-app, but it " + |
| 2195 | "was restarted" ) |
| 2196 | leaderResult = main.FALSE |
| 2197 | if len( set( leaderList ) ) != 1: |
| 2198 | leaderResult = main.FALSE |
| 2199 | main.log.error( |
| 2200 | "Inconsistent view of leader for the election test app" ) |
| 2201 | # TODO: print the list |
| 2202 | utilities.assert_equals( |
| 2203 | expect=main.TRUE, |
| 2204 | actual=leaderResult, |
| 2205 | onpass="Leadership election passed", |
| 2206 | onfail="Something went wrong with Leadership election" ) |
| 2207 | |
| 2208 | def CASE8( self, main ): |
| 2209 | """ |
| 2210 | Compare topo |
| 2211 | """ |
| 2212 | import json |
| 2213 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2214 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2215 | assert main, "main not defined" |
| 2216 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2217 | assert main.CLIs, "main.CLIs not defined" |
| 2218 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2219 | |
| 2220 | main.case( "Compare ONOS Topology view to Mininet topology" ) |
Jon Hall | 783bbf9 | 2015-07-23 14:33:19 -0700 | [diff] [blame] | 2221 | main.caseExplanation = "Compare topology objects between Mininet" +\ |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2222 | " and ONOS" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2223 | topoResult = main.FALSE |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2224 | topoFailMsg = "ONOS topology don't match Mininet" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2225 | elapsed = 0 |
| 2226 | count = 0 |
Jon Hall | e9b1fa3 | 2015-12-08 15:32:21 -0800 | [diff] [blame] | 2227 | main.step( "Comparing ONOS topology to MN topology" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2228 | startTime = time.time() |
| 2229 | # Give time for Gossip to work |
Jon Hall | e9b1fa3 | 2015-12-08 15:32:21 -0800 | [diff] [blame] | 2230 | while topoResult == main.FALSE and ( elapsed < 60 or count < 3 ): |
Jon Hall | 96091e6 | 2015-09-21 17:34:17 -0700 | [diff] [blame] | 2231 | devicesResults = main.TRUE |
| 2232 | linksResults = main.TRUE |
| 2233 | hostsResults = main.TRUE |
| 2234 | hostAttachmentResults = True |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2235 | count += 1 |
| 2236 | cliStart = time.time() |
| 2237 | devices = [] |
| 2238 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2239 | for i in main.activeNodes: |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2240 | t = main.Thread( target=utilities.retry, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2241 | name="devices-" + str( i ), |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2242 | args=[ main.CLIs[i].devices, [ None ] ], |
| 2243 | kwargs= { 'sleep': 5, 'attempts': 5, |
| 2244 | 'randomTime': True } ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2245 | threads.append( t ) |
| 2246 | t.start() |
| 2247 | |
| 2248 | for t in threads: |
| 2249 | t.join() |
| 2250 | devices.append( t.result ) |
| 2251 | hosts = [] |
| 2252 | ipResult = main.TRUE |
| 2253 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2254 | for i in main.activeNodes: |
Jon Hall | d8f6de8 | 2015-12-17 17:04:34 -0800 | [diff] [blame] | 2255 | t = main.Thread( target=utilities.retry, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2256 | name="hosts-" + str( i ), |
Jon Hall | d8f6de8 | 2015-12-17 17:04:34 -0800 | [diff] [blame] | 2257 | args=[ main.CLIs[i].hosts, [ None ] ], |
| 2258 | kwargs= { 'sleep': 5, 'attempts': 5, |
| 2259 | 'randomTime': True } ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2260 | threads.append( t ) |
| 2261 | t.start() |
| 2262 | |
| 2263 | for t in threads: |
| 2264 | t.join() |
| 2265 | try: |
| 2266 | hosts.append( json.loads( t.result ) ) |
| 2267 | except ( ValueError, TypeError ): |
| 2268 | main.log.exception( "Error parsing hosts results" ) |
| 2269 | main.log.error( repr( t.result ) ) |
Jon Hall | f3d16e7 | 2015-12-16 17:45:08 -0800 | [diff] [blame] | 2270 | hosts.append( None ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2271 | for controller in range( 0, len( hosts ) ): |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2272 | controllerStr = str( main.activeNodes[controller] + 1 ) |
Jon Hall | acd1b18 | 2015-12-17 11:43:20 -0800 | [diff] [blame] | 2273 | if hosts[ controller ]: |
| 2274 | for host in hosts[ controller ]: |
| 2275 | if host is None or host.get( 'ipAddresses', [] ) == []: |
| 2276 | main.log.error( |
| 2277 | "Error with host ipAddresses on controller" + |
| 2278 | controllerStr + ": " + str( host ) ) |
| 2279 | ipResult = main.FALSE |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2280 | ports = [] |
| 2281 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2282 | for i in main.activeNodes: |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2283 | t = main.Thread( target=utilities.retry, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2284 | name="ports-" + str( i ), |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2285 | args=[ main.CLIs[i].ports, [ None ] ], |
| 2286 | kwargs= { 'sleep': 5, 'attempts': 5, |
| 2287 | 'randomTime': True } ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2288 | threads.append( t ) |
| 2289 | t.start() |
| 2290 | |
| 2291 | for t in threads: |
| 2292 | t.join() |
| 2293 | ports.append( t.result ) |
| 2294 | links = [] |
| 2295 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2296 | for i in main.activeNodes: |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2297 | t = main.Thread( target=utilities.retry, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2298 | name="links-" + str( i ), |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2299 | args=[ main.CLIs[i].links, [ None ] ], |
| 2300 | kwargs= { 'sleep': 5, 'attempts': 5, |
| 2301 | 'randomTime': True } ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2302 | threads.append( t ) |
| 2303 | t.start() |
| 2304 | |
| 2305 | for t in threads: |
| 2306 | t.join() |
| 2307 | links.append( t.result ) |
| 2308 | clusters = [] |
| 2309 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2310 | for i in main.activeNodes: |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2311 | t = main.Thread( target=utilities.retry, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2312 | name="clusters-" + str( i ), |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2313 | args=[ main.CLIs[i].clusters, [ None ] ], |
| 2314 | kwargs= { 'sleep': 5, 'attempts': 5, |
| 2315 | 'randomTime': True } ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2316 | threads.append( t ) |
| 2317 | t.start() |
| 2318 | |
| 2319 | for t in threads: |
| 2320 | t.join() |
| 2321 | clusters.append( t.result ) |
| 2322 | |
| 2323 | elapsed = time.time() - startTime |
| 2324 | cliTime = time.time() - cliStart |
| 2325 | print "Elapsed time: " + str( elapsed ) |
| 2326 | print "CLI time: " + str( cliTime ) |
| 2327 | |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2328 | if all( e is None for e in devices ) and\ |
| 2329 | all( e is None for e in hosts ) and\ |
| 2330 | all( e is None for e in ports ) and\ |
| 2331 | all( e is None for e in links ) and\ |
| 2332 | all( e is None for e in clusters ): |
| 2333 | topoFailMsg = "Could not get topology from ONOS" |
| 2334 | main.log.error( topoFailMsg ) |
| 2335 | continue # Try again, No use trying to compare |
| 2336 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2337 | mnSwitches = main.Mininet1.getSwitches() |
| 2338 | mnLinks = main.Mininet1.getLinks() |
| 2339 | mnHosts = main.Mininet1.getHosts() |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2340 | for controller in range( len( main.activeNodes ) ): |
| 2341 | controllerStr = str( main.activeNodes[controller] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2342 | if devices[ controller ] and ports[ controller ] and\ |
| 2343 | "Error" not in devices[ controller ] and\ |
| 2344 | "Error" not in ports[ controller ]: |
| 2345 | |
Jon Hall | c679355 | 2016-01-19 14:18:37 -0800 | [diff] [blame] | 2346 | try: |
| 2347 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 2348 | mnSwitches, |
| 2349 | json.loads( devices[ controller ] ), |
| 2350 | json.loads( ports[ controller ] ) ) |
| 2351 | except ( TypeError, ValueError ) as e: |
| 2352 | main.log.exception( "Object not as expected; devices={!r}\nports={!r}".format( |
| 2353 | devices[ controller ], ports[ controller ] ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2354 | else: |
| 2355 | currentDevicesResult = main.FALSE |
| 2356 | utilities.assert_equals( expect=main.TRUE, |
| 2357 | actual=currentDevicesResult, |
| 2358 | onpass="ONOS" + controllerStr + |
| 2359 | " Switches view is correct", |
| 2360 | onfail="ONOS" + controllerStr + |
| 2361 | " Switches view is incorrect" ) |
| 2362 | |
| 2363 | if links[ controller ] and "Error" not in links[ controller ]: |
| 2364 | currentLinksResult = main.Mininet1.compareLinks( |
| 2365 | mnSwitches, mnLinks, |
| 2366 | json.loads( links[ controller ] ) ) |
| 2367 | else: |
| 2368 | currentLinksResult = main.FALSE |
| 2369 | utilities.assert_equals( expect=main.TRUE, |
| 2370 | actual=currentLinksResult, |
| 2371 | onpass="ONOS" + controllerStr + |
| 2372 | " links view is correct", |
| 2373 | onfail="ONOS" + controllerStr + |
| 2374 | " links view is incorrect" ) |
Jon Hall | 657cdf6 | 2015-12-17 14:40:51 -0800 | [diff] [blame] | 2375 | if hosts[ controller ] and "Error" not in hosts[ controller ]: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2376 | currentHostsResult = main.Mininet1.compareHosts( |
| 2377 | mnHosts, |
| 2378 | hosts[ controller ] ) |
Jon Hall | 13b446e | 2016-01-05 12:17:01 -0800 | [diff] [blame] | 2379 | elif hosts[ controller ] == []: |
| 2380 | currentHostsResult = main.TRUE |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2381 | else: |
| 2382 | currentHostsResult = main.FALSE |
| 2383 | utilities.assert_equals( expect=main.TRUE, |
| 2384 | actual=currentHostsResult, |
| 2385 | onpass="ONOS" + controllerStr + |
| 2386 | " hosts exist in Mininet", |
| 2387 | onfail="ONOS" + controllerStr + |
| 2388 | " hosts don't match Mininet" ) |
| 2389 | # CHECKING HOST ATTACHMENT POINTS |
| 2390 | hostAttachment = True |
| 2391 | zeroHosts = False |
| 2392 | # FIXME: topo-HA/obelisk specific mappings: |
| 2393 | # key is mac and value is dpid |
| 2394 | mappings = {} |
| 2395 | for i in range( 1, 29 ): # hosts 1 through 28 |
| 2396 | # set up correct variables: |
| 2397 | macId = "00:" * 5 + hex( i ).split( "0x" )[1].upper().zfill(2) |
| 2398 | if i == 1: |
| 2399 | deviceId = "1000".zfill(16) |
| 2400 | elif i == 2: |
| 2401 | deviceId = "2000".zfill(16) |
| 2402 | elif i == 3: |
| 2403 | deviceId = "3000".zfill(16) |
| 2404 | elif i == 4: |
| 2405 | deviceId = "3004".zfill(16) |
| 2406 | elif i == 5: |
| 2407 | deviceId = "5000".zfill(16) |
| 2408 | elif i == 6: |
| 2409 | deviceId = "6000".zfill(16) |
| 2410 | elif i == 7: |
| 2411 | deviceId = "6007".zfill(16) |
| 2412 | elif i >= 8 and i <= 17: |
| 2413 | dpid = '3' + str( i ).zfill( 3 ) |
| 2414 | deviceId = dpid.zfill(16) |
| 2415 | elif i >= 18 and i <= 27: |
| 2416 | dpid = '6' + str( i ).zfill( 3 ) |
| 2417 | deviceId = dpid.zfill(16) |
| 2418 | elif i == 28: |
| 2419 | deviceId = "2800".zfill(16) |
| 2420 | mappings[ macId ] = deviceId |
Jon Hall | d8f6de8 | 2015-12-17 17:04:34 -0800 | [diff] [blame] | 2421 | if hosts[ controller ] is not None and "Error" not in hosts[ controller ]: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2422 | if hosts[ controller ] == []: |
| 2423 | main.log.warn( "There are no hosts discovered" ) |
| 2424 | zeroHosts = True |
| 2425 | else: |
| 2426 | for host in hosts[ controller ]: |
| 2427 | mac = None |
| 2428 | location = None |
| 2429 | device = None |
| 2430 | port = None |
| 2431 | try: |
| 2432 | mac = host.get( 'mac' ) |
| 2433 | assert mac, "mac field could not be found for this host object" |
| 2434 | |
| 2435 | location = host.get( 'location' ) |
| 2436 | assert location, "location field could not be found for this host object" |
| 2437 | |
| 2438 | # Trim the protocol identifier off deviceId |
| 2439 | device = str( location.get( 'elementId' ) ).split(':')[1] |
| 2440 | assert device, "elementId field could not be found for this host location object" |
| 2441 | |
| 2442 | port = location.get( 'port' ) |
| 2443 | assert port, "port field could not be found for this host location object" |
| 2444 | |
| 2445 | # Now check if this matches where they should be |
| 2446 | if mac and device and port: |
| 2447 | if str( port ) != "1": |
| 2448 | main.log.error( "The attachment port is incorrect for " + |
| 2449 | "host " + str( mac ) + |
| 2450 | ". Expected: 1 Actual: " + str( port) ) |
| 2451 | hostAttachment = False |
| 2452 | if device != mappings[ str( mac ) ]: |
| 2453 | main.log.error( "The attachment device is incorrect for " + |
| 2454 | "host " + str( mac ) + |
| 2455 | ". Expected: " + mappings[ str( mac ) ] + |
| 2456 | " Actual: " + device ) |
| 2457 | hostAttachment = False |
| 2458 | else: |
| 2459 | hostAttachment = False |
| 2460 | except AssertionError: |
| 2461 | main.log.exception( "Json object not as expected" ) |
| 2462 | main.log.error( repr( host ) ) |
| 2463 | hostAttachment = False |
| 2464 | else: |
| 2465 | main.log.error( "No hosts json output or \"Error\"" + |
| 2466 | " in output. hosts = " + |
| 2467 | repr( hosts[ controller ] ) ) |
| 2468 | if zeroHosts is False: |
| 2469 | hostAttachment = True |
| 2470 | |
| 2471 | # END CHECKING HOST ATTACHMENT POINTS |
| 2472 | devicesResults = devicesResults and currentDevicesResult |
| 2473 | linksResults = linksResults and currentLinksResult |
| 2474 | hostsResults = hostsResults and currentHostsResult |
| 2475 | hostAttachmentResults = hostAttachmentResults and\ |
| 2476 | hostAttachment |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2477 | topoResult = ( devicesResults and linksResults |
| 2478 | and hostsResults and ipResult and |
| 2479 | hostAttachmentResults ) |
Jon Hall | e9b1fa3 | 2015-12-08 15:32:21 -0800 | [diff] [blame] | 2480 | utilities.assert_equals( expect=True, |
| 2481 | actual=topoResult, |
| 2482 | onpass="ONOS topology matches Mininet", |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2483 | onfail=topoFailMsg ) |
Jon Hall | e9b1fa3 | 2015-12-08 15:32:21 -0800 | [diff] [blame] | 2484 | # End of While loop to pull ONOS state |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2485 | |
| 2486 | # Compare json objects for hosts and dataplane clusters |
| 2487 | |
| 2488 | # hosts |
| 2489 | main.step( "Hosts view is consistent across all ONOS nodes" ) |
| 2490 | consistentHostsResult = main.TRUE |
| 2491 | for controller in range( len( hosts ) ): |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2492 | controllerStr = str( main.activeNodes[controller] + 1 ) |
Jon Hall | 13b446e | 2016-01-05 12:17:01 -0800 | [diff] [blame] | 2493 | if hosts[ controller ] is not None and "Error" not in hosts[ controller ]: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2494 | if hosts[ controller ] == hosts[ 0 ]: |
| 2495 | continue |
| 2496 | else: # hosts not consistent |
| 2497 | main.log.error( "hosts from ONOS" + controllerStr + |
| 2498 | " is inconsistent with ONOS1" ) |
| 2499 | main.log.warn( repr( hosts[ controller ] ) ) |
| 2500 | consistentHostsResult = main.FALSE |
| 2501 | |
| 2502 | else: |
| 2503 | main.log.error( "Error in getting ONOS hosts from ONOS" + |
| 2504 | controllerStr ) |
| 2505 | consistentHostsResult = main.FALSE |
| 2506 | main.log.warn( "ONOS" + controllerStr + |
| 2507 | " hosts response: " + |
| 2508 | repr( hosts[ controller ] ) ) |
| 2509 | utilities.assert_equals( |
| 2510 | expect=main.TRUE, |
| 2511 | actual=consistentHostsResult, |
| 2512 | onpass="Hosts view is consistent across all ONOS nodes", |
| 2513 | onfail="ONOS nodes have different views of hosts" ) |
| 2514 | |
| 2515 | main.step( "Hosts information is correct" ) |
| 2516 | hostsResults = hostsResults and ipResult |
| 2517 | utilities.assert_equals( |
| 2518 | expect=main.TRUE, |
| 2519 | actual=hostsResults, |
| 2520 | onpass="Host information is correct", |
| 2521 | onfail="Host information is incorrect" ) |
| 2522 | |
| 2523 | main.step( "Host attachment points to the network" ) |
| 2524 | utilities.assert_equals( |
| 2525 | expect=True, |
| 2526 | actual=hostAttachmentResults, |
| 2527 | onpass="Hosts are correctly attached to the network", |
| 2528 | onfail="ONOS did not correctly attach hosts to the network" ) |
| 2529 | |
| 2530 | # Strongly connected clusters of devices |
| 2531 | main.step( "Clusters view is consistent across all ONOS nodes" ) |
| 2532 | consistentClustersResult = main.TRUE |
| 2533 | for controller in range( len( clusters ) ): |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2534 | controllerStr = str( main.activeNodes[controller] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2535 | if "Error" not in clusters[ controller ]: |
| 2536 | if clusters[ controller ] == clusters[ 0 ]: |
| 2537 | continue |
| 2538 | else: # clusters not consistent |
| 2539 | main.log.error( "clusters from ONOS" + |
| 2540 | controllerStr + |
| 2541 | " is inconsistent with ONOS1" ) |
| 2542 | consistentClustersResult = main.FALSE |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2543 | else: |
| 2544 | main.log.error( "Error in getting dataplane clusters " + |
| 2545 | "from ONOS" + controllerStr ) |
| 2546 | consistentClustersResult = main.FALSE |
| 2547 | main.log.warn( "ONOS" + controllerStr + |
| 2548 | " clusters response: " + |
| 2549 | repr( clusters[ controller ] ) ) |
| 2550 | utilities.assert_equals( |
| 2551 | expect=main.TRUE, |
| 2552 | actual=consistentClustersResult, |
| 2553 | onpass="Clusters view is consistent across all ONOS nodes", |
| 2554 | onfail="ONOS nodes have different views of clusters" ) |
| 2555 | |
| 2556 | main.step( "There is only one SCC" ) |
| 2557 | # there should always only be one cluster |
| 2558 | try: |
| 2559 | numClusters = len( json.loads( clusters[ 0 ] ) ) |
| 2560 | except ( ValueError, TypeError ): |
| 2561 | main.log.exception( "Error parsing clusters[0]: " + |
| 2562 | repr( clusters[0] ) ) |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2563 | numClusters = "ERROR" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2564 | clusterResults = main.FALSE |
| 2565 | if numClusters == 1: |
| 2566 | clusterResults = main.TRUE |
| 2567 | utilities.assert_equals( |
| 2568 | expect=1, |
| 2569 | actual=numClusters, |
| 2570 | onpass="ONOS shows 1 SCC", |
| 2571 | onfail="ONOS shows " + str( numClusters ) + " SCCs" ) |
| 2572 | |
| 2573 | topoResult = ( devicesResults and linksResults |
| 2574 | and hostsResults and consistentHostsResult |
| 2575 | and consistentClustersResult and clusterResults |
| 2576 | and ipResult and hostAttachmentResults ) |
| 2577 | |
| 2578 | topoResult = topoResult and int( count <= 2 ) |
| 2579 | note = "note it takes about " + str( int( cliTime ) ) + \ |
| 2580 | " seconds for the test to make all the cli calls to fetch " +\ |
| 2581 | "the topology from each ONOS instance" |
| 2582 | main.log.info( |
| 2583 | "Very crass estimate for topology discovery/convergence( " + |
| 2584 | str( note ) + " ): " + str( elapsed ) + " seconds, " + |
| 2585 | str( count ) + " tries" ) |
| 2586 | |
| 2587 | main.step( "Device information is correct" ) |
| 2588 | utilities.assert_equals( |
| 2589 | expect=main.TRUE, |
| 2590 | actual=devicesResults, |
| 2591 | onpass="Device information is correct", |
| 2592 | onfail="Device information is incorrect" ) |
| 2593 | |
| 2594 | main.step( "Links are correct" ) |
| 2595 | utilities.assert_equals( |
| 2596 | expect=main.TRUE, |
| 2597 | actual=linksResults, |
| 2598 | onpass="Link are correct", |
| 2599 | onfail="Links are incorrect" ) |
| 2600 | |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2601 | main.step( "Hosts are correct" ) |
| 2602 | utilities.assert_equals( |
| 2603 | expect=main.TRUE, |
| 2604 | actual=hostsResults, |
| 2605 | onpass="Hosts are correct", |
| 2606 | onfail="Hosts are incorrect" ) |
| 2607 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2608 | # FIXME: move this to an ONOS state case |
| 2609 | main.step( "Checking ONOS nodes" ) |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 2610 | nodeResults = utilities.retry( main.HA.nodesCheck, |
| 2611 | False, |
| 2612 | args=[main.activeNodes], |
| 2613 | attempts=5 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2614 | |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 2615 | utilities.assert_equals( expect=True, actual=nodeResults, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2616 | onpass="Nodes check successful", |
| 2617 | onfail="Nodes check NOT successful" ) |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2618 | if not nodeResults: |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 2619 | for i in main.activeNodes: |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2620 | main.log.debug( "{} components not ACTIVE: \n{}".format( |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 2621 | main.CLIs[i].name, |
| 2622 | main.CLIs[i].sendline( "scr:list | grep -v ACTIVE" ) ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2623 | |
| 2624 | def CASE9( self, main ): |
| 2625 | """ |
| 2626 | Link s3-s28 down |
| 2627 | """ |
| 2628 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2629 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2630 | assert main, "main not defined" |
| 2631 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2632 | assert main.CLIs, "main.CLIs not defined" |
| 2633 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2634 | # NOTE: You should probably run a topology check after this |
| 2635 | |
| 2636 | linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 2637 | |
| 2638 | description = "Turn off a link to ensure that Link Discovery " +\ |
| 2639 | "is working properly" |
| 2640 | main.case( description ) |
| 2641 | |
| 2642 | main.step( "Kill Link between s3 and s28" ) |
| 2643 | LinkDown = main.Mininet1.link( END1="s3", END2="s28", OPTION="down" ) |
| 2644 | main.log.info( "Waiting " + str( linkSleep ) + |
| 2645 | " seconds for link down to be discovered" ) |
| 2646 | time.sleep( linkSleep ) |
| 2647 | utilities.assert_equals( expect=main.TRUE, actual=LinkDown, |
| 2648 | onpass="Link down successful", |
| 2649 | onfail="Failed to bring link down" ) |
| 2650 | # TODO do some sort of check here |
| 2651 | |
| 2652 | def CASE10( self, main ): |
| 2653 | """ |
| 2654 | Link s3-s28 up |
| 2655 | """ |
| 2656 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2657 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2658 | assert main, "main not defined" |
| 2659 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2660 | assert main.CLIs, "main.CLIs not defined" |
| 2661 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2662 | # NOTE: You should probably run a topology check after this |
| 2663 | |
| 2664 | linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
| 2665 | |
| 2666 | description = "Restore a link to ensure that Link Discovery is " + \ |
| 2667 | "working properly" |
| 2668 | main.case( description ) |
| 2669 | |
| 2670 | main.step( "Bring link between s3 and s28 back up" ) |
| 2671 | LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" ) |
| 2672 | main.log.info( "Waiting " + str( linkSleep ) + |
| 2673 | " seconds for link up to be discovered" ) |
| 2674 | time.sleep( linkSleep ) |
| 2675 | utilities.assert_equals( expect=main.TRUE, actual=LinkUp, |
| 2676 | onpass="Link up successful", |
| 2677 | onfail="Failed to bring link up" ) |
| 2678 | # TODO do some sort of check here |
| 2679 | |
| 2680 | def CASE11( self, main ): |
| 2681 | """ |
| 2682 | Switch Down |
| 2683 | """ |
| 2684 | # NOTE: You should probably run a topology check after this |
| 2685 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2686 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2687 | assert main, "main not defined" |
| 2688 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2689 | assert main.CLIs, "main.CLIs not defined" |
| 2690 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2691 | |
| 2692 | switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
| 2693 | |
| 2694 | description = "Killing a switch to ensure it is discovered correctly" |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2695 | onosCli = main.CLIs[ main.activeNodes[0] ] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2696 | main.case( description ) |
| 2697 | switch = main.params[ 'kill' ][ 'switch' ] |
| 2698 | switchDPID = main.params[ 'kill' ][ 'dpid' ] |
| 2699 | |
| 2700 | # TODO: Make this switch parameterizable |
| 2701 | main.step( "Kill " + switch ) |
| 2702 | main.log.info( "Deleting " + switch ) |
| 2703 | main.Mininet1.delSwitch( switch ) |
| 2704 | main.log.info( "Waiting " + str( switchSleep ) + |
| 2705 | " seconds for switch down to be discovered" ) |
| 2706 | time.sleep( switchSleep ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2707 | device = onosCli.getDevice( dpid=switchDPID ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2708 | # Peek at the deleted switch |
| 2709 | main.log.warn( str( device ) ) |
| 2710 | result = main.FALSE |
| 2711 | if device and device[ 'available' ] is False: |
| 2712 | result = main.TRUE |
| 2713 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 2714 | onpass="Kill switch successful", |
| 2715 | onfail="Failed to kill switch?" ) |
| 2716 | |
| 2717 | def CASE12( self, main ): |
| 2718 | """ |
| 2719 | Switch Up |
| 2720 | """ |
| 2721 | # NOTE: You should probably run a topology check after this |
| 2722 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2723 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2724 | assert main, "main not defined" |
| 2725 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2726 | assert main.CLIs, "main.CLIs not defined" |
| 2727 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2728 | assert ONOS1Port, "ONOS1Port not defined" |
| 2729 | assert ONOS2Port, "ONOS2Port not defined" |
| 2730 | assert ONOS3Port, "ONOS3Port not defined" |
| 2731 | assert ONOS4Port, "ONOS4Port not defined" |
| 2732 | assert ONOS5Port, "ONOS5Port not defined" |
| 2733 | assert ONOS6Port, "ONOS6Port not defined" |
| 2734 | assert ONOS7Port, "ONOS7Port not defined" |
| 2735 | |
| 2736 | switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
| 2737 | switch = main.params[ 'kill' ][ 'switch' ] |
| 2738 | switchDPID = main.params[ 'kill' ][ 'dpid' ] |
| 2739 | links = main.params[ 'kill' ][ 'links' ].split() |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2740 | onosCli = main.CLIs[ main.activeNodes[0] ] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2741 | description = "Adding a switch to ensure it is discovered correctly" |
| 2742 | main.case( description ) |
| 2743 | |
| 2744 | main.step( "Add back " + switch ) |
| 2745 | main.Mininet1.addSwitch( switch, dpid=switchDPID ) |
| 2746 | for peer in links: |
| 2747 | main.Mininet1.addLink( switch, peer ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2748 | ipList = [ node.ip_address for node in main.nodes ] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2749 | main.Mininet1.assignSwController( sw=switch, ip=ipList ) |
| 2750 | main.log.info( "Waiting " + str( switchSleep ) + |
| 2751 | " seconds for switch up to be discovered" ) |
| 2752 | time.sleep( switchSleep ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2753 | device = onosCli.getDevice( dpid=switchDPID ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2754 | # Peek at the deleted switch |
| 2755 | main.log.warn( str( device ) ) |
| 2756 | result = main.FALSE |
| 2757 | if device and device[ 'available' ]: |
| 2758 | result = main.TRUE |
| 2759 | utilities.assert_equals( expect=main.TRUE, actual=result, |
| 2760 | onpass="add switch successful", |
| 2761 | onfail="Failed to add switch?" ) |
| 2762 | |
| 2763 | def CASE13( self, main ): |
| 2764 | """ |
| 2765 | Clean up |
| 2766 | """ |
| 2767 | import os |
| 2768 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2769 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2770 | assert main, "main not defined" |
| 2771 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2772 | assert main.CLIs, "main.CLIs not defined" |
| 2773 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2774 | |
| 2775 | # printing colors to terminal |
| 2776 | colors = { 'cyan': '\033[96m', 'purple': '\033[95m', |
| 2777 | 'blue': '\033[94m', 'green': '\033[92m', |
| 2778 | 'yellow': '\033[93m', 'red': '\033[91m', 'end': '\033[0m' } |
| 2779 | main.case( "Test Cleanup" ) |
| 2780 | main.step( "Killing tcpdumps" ) |
| 2781 | main.Mininet2.stopTcpdump() |
| 2782 | |
| 2783 | testname = main.TEST |
Jon Hall | 96091e6 | 2015-09-21 17:34:17 -0700 | [diff] [blame] | 2784 | if main.params[ 'BACKUP' ][ 'ENABLED' ] == "True": |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2785 | main.step( "Copying MN pcap and ONOS log files to test station" ) |
| 2786 | teststationUser = main.params[ 'BACKUP' ][ 'TESTONUSER' ] |
| 2787 | teststationIP = main.params[ 'BACKUP' ][ 'TESTONIP' ] |
Jon Hall | 96091e6 | 2015-09-21 17:34:17 -0700 | [diff] [blame] | 2788 | # NOTE: MN Pcap file is being saved to logdir. |
| 2789 | # We scp this file as MN and TestON aren't necessarily the same vm |
| 2790 | |
| 2791 | # FIXME: To be replaced with a Jenkin's post script |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2792 | # TODO: Load these from params |
| 2793 | # NOTE: must end in / |
| 2794 | logFolder = "/opt/onos/log/" |
| 2795 | logFiles = [ "karaf.log", "karaf.log.1" ] |
| 2796 | # NOTE: must end in / |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2797 | for f in logFiles: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2798 | for node in main.nodes: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2799 | dstName = main.logdir + "/" + node.name + "-" + f |
Jon Hall | 96091e6 | 2015-09-21 17:34:17 -0700 | [diff] [blame] | 2800 | main.ONOSbench.secureCopy( node.user_name, node.ip_address, |
| 2801 | logFolder + f, dstName ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2802 | # std*.log's |
| 2803 | # NOTE: must end in / |
| 2804 | logFolder = "/opt/onos/var/" |
| 2805 | logFiles = [ "stderr.log", "stdout.log" ] |
| 2806 | # NOTE: must end in / |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2807 | for f in logFiles: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2808 | for node in main.nodes: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2809 | dstName = main.logdir + "/" + node.name + "-" + f |
Jon Hall | 96091e6 | 2015-09-21 17:34:17 -0700 | [diff] [blame] | 2810 | main.ONOSbench.secureCopy( node.user_name, node.ip_address, |
| 2811 | logFolder + f, dstName ) |
| 2812 | else: |
| 2813 | main.log.debug( "skipping saving log files" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2814 | |
| 2815 | main.step( "Stopping Mininet" ) |
| 2816 | mnResult = main.Mininet1.stopNet() |
| 2817 | utilities.assert_equals( expect=main.TRUE, actual=mnResult, |
| 2818 | onpass="Mininet stopped", |
| 2819 | onfail="MN cleanup NOT successful" ) |
| 2820 | |
| 2821 | main.step( "Checking ONOS Logs for errors" ) |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2822 | for node in main.nodes: |
Jon Hall | 96091e6 | 2015-09-21 17:34:17 -0700 | [diff] [blame] | 2823 | main.log.debug( "Checking logs for errors on " + node.name + ":" ) |
| 2824 | main.log.warn( main.ONOSbench.checkLogs( node.ip_address ) ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2825 | |
| 2826 | try: |
| 2827 | timerLog = open( main.logdir + "/Timers.csv", 'w') |
| 2828 | # Overwrite with empty line and close |
| 2829 | labels = "Gossip Intents, Restart" |
| 2830 | data = str( gossipTime ) + ", " + str( main.restartTime ) |
| 2831 | timerLog.write( labels + "\n" + data ) |
| 2832 | timerLog.close() |
| 2833 | except NameError, e: |
| 2834 | main.log.exception(e) |
| 2835 | |
| 2836 | def CASE14( self, main ): |
| 2837 | """ |
| 2838 | start election app on all onos nodes |
| 2839 | """ |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2840 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2841 | assert main, "main not defined" |
| 2842 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2843 | assert main.CLIs, "main.CLIs not defined" |
| 2844 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2845 | |
| 2846 | main.case("Start Leadership Election app") |
| 2847 | main.step( "Install leadership election app" ) |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2848 | onosCli = main.CLIs[ main.activeNodes[0] ] |
| 2849 | appResult = onosCli.activateApp( "org.onosproject.election" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2850 | utilities.assert_equals( |
| 2851 | expect=main.TRUE, |
| 2852 | actual=appResult, |
| 2853 | onpass="Election app installed", |
| 2854 | onfail="Something went wrong with installing Leadership election" ) |
| 2855 | |
| 2856 | main.step( "Run for election on each node" ) |
| 2857 | leaderResult = main.TRUE |
| 2858 | leaders = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2859 | for i in main.activeNodes: |
| 2860 | main.CLIs[i].electionTestRun() |
| 2861 | for i in main.activeNodes: |
| 2862 | cli = main.CLIs[i] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2863 | leader = cli.electionTestLeader() |
| 2864 | if leader is None or leader == main.FALSE: |
| 2865 | main.log.error( cli.name + ": Leader for the election app " + |
| 2866 | "should be an ONOS node, instead got '" + |
| 2867 | str( leader ) + "'" ) |
| 2868 | leaderResult = main.FALSE |
| 2869 | leaders.append( leader ) |
| 2870 | utilities.assert_equals( |
| 2871 | expect=main.TRUE, |
| 2872 | actual=leaderResult, |
| 2873 | onpass="Successfully ran for leadership", |
| 2874 | onfail="Failed to run for leadership" ) |
| 2875 | |
| 2876 | main.step( "Check that each node shows the same leader" ) |
| 2877 | sameLeader = main.TRUE |
| 2878 | if len( set( leaders ) ) != 1: |
| 2879 | sameLeader = main.FALSE |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2880 | main.log.error( "Results of electionTestLeader is order of main.CLIs:" + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2881 | str( leaders ) ) |
| 2882 | utilities.assert_equals( |
| 2883 | expect=main.TRUE, |
| 2884 | actual=sameLeader, |
| 2885 | onpass="Leadership is consistent for the election topic", |
| 2886 | onfail="Nodes have different leaders" ) |
| 2887 | |
| 2888 | def CASE15( self, main ): |
| 2889 | """ |
| 2890 | Check that Leadership Election is still functional |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2891 | 15.1 Run election on each node |
| 2892 | 15.2 Check that each node has the same leaders and candidates |
| 2893 | 15.3 Find current leader and withdraw |
| 2894 | 15.4 Check that a new node was elected leader |
| 2895 | 15.5 Check that that new leader was the candidate of old leader |
| 2896 | 15.6 Run for election on old leader |
| 2897 | 15.7 Check that oldLeader is a candidate, and leader if only 1 node |
| 2898 | 15.8 Make sure that the old leader was added to the candidate list |
| 2899 | |
| 2900 | old and new variable prefixes refer to data from before vs after |
| 2901 | withdrawl and later before withdrawl vs after re-election |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2902 | """ |
| 2903 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2904 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2905 | assert main, "main not defined" |
| 2906 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 2907 | assert main.CLIs, "main.CLIs not defined" |
| 2908 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2909 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2910 | description = "Check that Leadership Election is still functional" |
| 2911 | main.case( description ) |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2912 | # NOTE: Need to re-run after restarts since being a canidate is not persistant |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2913 | |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2914 | oldLeaders = [] # list of lists of each nodes' candidates before |
| 2915 | newLeaders = [] # list of lists of each nodes' candidates after |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2916 | oldLeader = '' # the old leader from oldLeaders, None if not same |
| 2917 | newLeader = '' # the new leaders fron newLoeaders, None if not same |
| 2918 | oldLeaderCLI = None # the CLI of the old leader used for re-electing |
| 2919 | expectNoLeader = False # True when there is only one leader |
| 2920 | if main.numCtrls == 1: |
| 2921 | expectNoLeader = True |
| 2922 | |
| 2923 | main.step( "Run for election on each node" ) |
| 2924 | electionResult = main.TRUE |
| 2925 | |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2926 | for i in main.activeNodes: # run test election on each node |
| 2927 | if main.CLIs[i].electionTestRun() == main.FALSE: |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2928 | electionResult = main.FALSE |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2929 | utilities.assert_equals( |
| 2930 | expect=main.TRUE, |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2931 | actual=electionResult, |
| 2932 | onpass="All nodes successfully ran for leadership", |
| 2933 | onfail="At least one node failed to run for leadership" ) |
| 2934 | |
acsmars | 3a72bde | 2015-09-02 14:16:22 -0700 | [diff] [blame] | 2935 | if electionResult == main.FALSE: |
| 2936 | main.log.error( |
| 2937 | "Skipping Test Case because Election Test App isn't loaded" ) |
| 2938 | main.skipCase() |
| 2939 | |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2940 | main.step( "Check that each node shows the same leader and candidates" ) |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2941 | failMessage = "Nodes have different leaderboards" |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2942 | activeCLIs = [ main.CLIs[i] for i in main.activeNodes ] |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 2943 | sameResult, oldLeaders = main.HA.consistentLeaderboards( activeCLIs ) |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2944 | if sameResult: |
| 2945 | oldLeader = oldLeaders[ 0 ][ 0 ] |
| 2946 | main.log.warn( oldLeader ) |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2947 | else: |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2948 | oldLeader = None |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2949 | utilities.assert_equals( |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2950 | expect=True, |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2951 | actual=sameResult, |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2952 | onpass="Leaderboards are consistent for the election topic", |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2953 | onfail=failMessage ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2954 | |
| 2955 | main.step( "Find current leader and withdraw" ) |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2956 | withdrawResult = main.TRUE |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2957 | # do some sanity checking on leader before using it |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2958 | if oldLeader is None: |
| 2959 | main.log.error( "Leadership isn't consistent." ) |
| 2960 | withdrawResult = main.FALSE |
| 2961 | # Get the CLI of the oldLeader |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 2962 | for i in main.activeNodes: |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2963 | if oldLeader == main.nodes[ i ].ip_address: |
| 2964 | oldLeaderCLI = main.CLIs[ i ] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2965 | break |
| 2966 | else: # FOR/ELSE statement |
| 2967 | main.log.error( "Leader election, could not find current leader" ) |
| 2968 | if oldLeader: |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2969 | withdrawResult = oldLeaderCLI.electionTestWithdraw() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2970 | utilities.assert_equals( |
| 2971 | expect=main.TRUE, |
| 2972 | actual=withdrawResult, |
| 2973 | onpass="Node was withdrawn from election", |
| 2974 | onfail="Node was not withdrawn from election" ) |
| 2975 | |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2976 | main.step( "Check that a new node was elected leader" ) |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2977 | failMessage = "Nodes have different leaders" |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2978 | # Get new leaders and candidates |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 2979 | newLeaderResult, newLeaders = main.HA.consistentLeaderboards( activeCLIs ) |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2980 | if newLeaders[ 0 ][ 0 ] == 'none': |
| 2981 | main.log.error( "No leader was elected on at least 1 node" ) |
| 2982 | if not expectNoLeader: |
| 2983 | newLeaderResult = False |
| 2984 | if newLeaderResult: |
| 2985 | newLeader = newLeaders[ 0 ][ 0 ] |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2986 | else: |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2987 | newLeader = None |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2988 | |
| 2989 | # Check that the new leader is not the older leader, which was withdrawn |
| 2990 | if newLeader == oldLeader: |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2991 | newLeaderResult = False |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 2992 | main.log.error( "All nodes still see old leader: " + str( oldLeader ) + |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2993 | " as the current leader" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2994 | utilities.assert_equals( |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 2995 | expect=True, |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 2996 | actual=newLeaderResult, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 2997 | onpass="Leadership election passed", |
| 2998 | onfail="Something went wrong with Leadership election" ) |
| 2999 | |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 3000 | main.step( "Check that that new leader was the candidate of old leader" ) |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 3001 | # candidates[ 2 ] should become the top candidate after withdrawl |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 3002 | correctCandidateResult = main.TRUE |
| 3003 | if expectNoLeader: |
| 3004 | if newLeader == 'none': |
| 3005 | main.log.info( "No leader expected. None found. Pass" ) |
| 3006 | correctCandidateResult = main.TRUE |
| 3007 | else: |
| 3008 | main.log.info( "Expected no leader, got: " + str( newLeader ) ) |
| 3009 | correctCandidateResult = main.FALSE |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 3010 | elif len( oldLeaders[0] ) >= 3: |
| 3011 | if newLeader == oldLeaders[ 0 ][ 2 ]: |
| 3012 | # correct leader was elected |
| 3013 | correctCandidateResult = main.TRUE |
| 3014 | else: |
| 3015 | correctCandidateResult = main.FALSE |
| 3016 | main.log.error( "Candidate {} was elected. {} should have had priority.".format( |
| 3017 | newLeader, oldLeaders[ 0 ][ 2 ] ) ) |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 3018 | else: |
| 3019 | main.log.warn( "Could not determine who should be the correct leader" ) |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 3020 | main.log.debug( oldLeaders[ 0 ] ) |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 3021 | correctCandidateResult = main.FALSE |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 3022 | utilities.assert_equals( |
| 3023 | expect=main.TRUE, |
| 3024 | actual=correctCandidateResult, |
| 3025 | onpass="Correct Candidate Elected", |
| 3026 | onfail="Incorrect Candidate Elected" ) |
| 3027 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3028 | main.step( "Run for election on old leader( just so everyone " + |
| 3029 | "is in the hat )" ) |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 3030 | if oldLeaderCLI is not None: |
| 3031 | runResult = oldLeaderCLI.electionTestRun() |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3032 | else: |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 3033 | main.log.error( "No old leader to re-elect" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3034 | runResult = main.FALSE |
| 3035 | utilities.assert_equals( |
| 3036 | expect=main.TRUE, |
| 3037 | actual=runResult, |
| 3038 | onpass="App re-ran for election", |
| 3039 | onfail="App failed to run for election" ) |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 3040 | |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 3041 | main.step( |
| 3042 | "Check that oldLeader is a candidate, and leader if only 1 node" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3043 | # verify leader didn't just change |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 3044 | # Get new leaders and candidates |
| 3045 | reRunLeaders = [] |
| 3046 | time.sleep( 5 ) # Paremterize |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 3047 | positionResult, reRunLeaders = main.HA.consistentLeaderboards( activeCLIs ) |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 3048 | |
| 3049 | # Check that the re-elected node is last on the candidate List |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 3050 | if oldLeader != reRunLeaders[ 0 ][ -1 ]: |
| 3051 | main.log.error( "Old Leader ({}) not in the proper position: {} ".format( str( oldLeader), |
| 3052 | str( reRunLeaders[ 0 ] ) ) ) |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 3053 | positionResult = main.FALSE |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3054 | |
| 3055 | utilities.assert_equals( |
Jon Hall | a440e87 | 2016-03-31 15:15:50 -0700 | [diff] [blame] | 3056 | expect=True, |
acsmars | 71adceb | 2015-08-31 15:09:26 -0700 | [diff] [blame] | 3057 | actual=positionResult, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3058 | onpass="Old leader successfully re-ran for election", |
| 3059 | onfail="Something went wrong with Leadership election after " + |
| 3060 | "the old leader re-ran for election" ) |
| 3061 | |
| 3062 | def CASE16( self, main ): |
| 3063 | """ |
| 3064 | Install Distributed Primitives app |
| 3065 | """ |
| 3066 | import time |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3067 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3068 | assert main, "main not defined" |
| 3069 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3070 | assert main.CLIs, "main.CLIs not defined" |
| 3071 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3072 | |
| 3073 | # Variables for the distributed primitives tests |
| 3074 | global pCounterName |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3075 | global pCounterValue |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3076 | global onosSet |
| 3077 | global onosSetName |
| 3078 | pCounterName = "TestON-Partitions" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3079 | pCounterValue = 0 |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3080 | onosSet = set([]) |
| 3081 | onosSetName = "TestON-set" |
| 3082 | |
| 3083 | description = "Install Primitives app" |
| 3084 | main.case( description ) |
| 3085 | main.step( "Install Primitives app" ) |
| 3086 | appName = "org.onosproject.distributedprimitives" |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3087 | node = main.activeNodes[0] |
| 3088 | appResults = main.CLIs[node].activateApp( appName ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3089 | utilities.assert_equals( expect=main.TRUE, |
| 3090 | actual=appResults, |
| 3091 | onpass="Primitives app activated", |
| 3092 | onfail="Primitives app not activated" ) |
| 3093 | time.sleep( 5 ) # To allow all nodes to activate |
| 3094 | |
| 3095 | def CASE17( self, main ): |
| 3096 | """ |
| 3097 | Check for basic functionality with distributed primitives |
| 3098 | """ |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3099 | # Make sure variables are defined/set |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3100 | assert main.numCtrls, "main.numCtrls not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3101 | assert main, "main not defined" |
| 3102 | assert utilities.assert_equals, "utilities.assert_equals not defined" |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3103 | assert main.CLIs, "main.CLIs not defined" |
| 3104 | assert main.nodes, "main.nodes not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3105 | assert pCounterName, "pCounterName not defined" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3106 | assert onosSetName, "onosSetName not defined" |
| 3107 | # NOTE: assert fails if value is 0/None/Empty/False |
| 3108 | try: |
| 3109 | pCounterValue |
| 3110 | except NameError: |
| 3111 | main.log.error( "pCounterValue not defined, setting to 0" ) |
| 3112 | pCounterValue = 0 |
| 3113 | try: |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3114 | onosSet |
| 3115 | except NameError: |
| 3116 | main.log.error( "onosSet not defined, setting to empty Set" ) |
| 3117 | onosSet = set([]) |
| 3118 | # Variables for the distributed primitives tests. These are local only |
| 3119 | addValue = "a" |
| 3120 | addAllValue = "a b c d e f" |
| 3121 | retainValue = "c d e f" |
| 3122 | |
| 3123 | description = "Check for basic functionality with distributed " +\ |
| 3124 | "primitives" |
| 3125 | main.case( description ) |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3126 | main.caseExplanation = "Test the methods of the distributed " +\ |
| 3127 | "primitives (counters and sets) throught the cli" |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3128 | # DISTRIBUTED ATOMIC COUNTERS |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3129 | # Partitioned counters |
| 3130 | main.step( "Increment then get a default counter on each node" ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3131 | pCounters = [] |
| 3132 | threads = [] |
| 3133 | addedPValues = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3134 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3135 | t = main.Thread( target=main.CLIs[i].counterTestAddAndGet, |
| 3136 | name="counterAddAndGet-" + str( i ), |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3137 | args=[ pCounterName ] ) |
| 3138 | pCounterValue += 1 |
| 3139 | addedPValues.append( pCounterValue ) |
| 3140 | threads.append( t ) |
| 3141 | t.start() |
| 3142 | |
| 3143 | for t in threads: |
| 3144 | t.join() |
| 3145 | pCounters.append( t.result ) |
| 3146 | # Check that counter incremented numController times |
| 3147 | pCounterResults = True |
| 3148 | for i in addedPValues: |
| 3149 | tmpResult = i in pCounters |
| 3150 | pCounterResults = pCounterResults and tmpResult |
| 3151 | if not tmpResult: |
| 3152 | main.log.error( str( i ) + " is not in partitioned " |
| 3153 | "counter incremented results" ) |
| 3154 | utilities.assert_equals( expect=True, |
| 3155 | actual=pCounterResults, |
| 3156 | onpass="Default counter incremented", |
| 3157 | onfail="Error incrementing default" + |
| 3158 | " counter" ) |
| 3159 | |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3160 | main.step( "Get then Increment a default counter on each node" ) |
| 3161 | pCounters = [] |
| 3162 | threads = [] |
| 3163 | addedPValues = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3164 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3165 | t = main.Thread( target=main.CLIs[i].counterTestGetAndAdd, |
| 3166 | name="counterGetAndAdd-" + str( i ), |
| 3167 | args=[ pCounterName ] ) |
| 3168 | addedPValues.append( pCounterValue ) |
| 3169 | pCounterValue += 1 |
| 3170 | threads.append( t ) |
| 3171 | t.start() |
| 3172 | |
| 3173 | for t in threads: |
| 3174 | t.join() |
| 3175 | pCounters.append( t.result ) |
| 3176 | # Check that counter incremented numController times |
| 3177 | pCounterResults = True |
| 3178 | for i in addedPValues: |
| 3179 | tmpResult = i in pCounters |
| 3180 | pCounterResults = pCounterResults and tmpResult |
| 3181 | if not tmpResult: |
| 3182 | main.log.error( str( i ) + " is not in partitioned " |
| 3183 | "counter incremented results" ) |
| 3184 | utilities.assert_equals( expect=True, |
| 3185 | actual=pCounterResults, |
| 3186 | onpass="Default counter incremented", |
| 3187 | onfail="Error incrementing default" + |
| 3188 | " counter" ) |
| 3189 | |
| 3190 | main.step( "Counters we added have the correct values" ) |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 3191 | incrementCheck = main.HA.counterCheck( pCounterName, pCounterValue ) |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3192 | utilities.assert_equals( expect=main.TRUE, |
| 3193 | actual=incrementCheck, |
| 3194 | onpass="Added counters are correct", |
| 3195 | onfail="Added counters are incorrect" ) |
| 3196 | |
| 3197 | main.step( "Add -8 to then get a default counter on each node" ) |
| 3198 | pCounters = [] |
| 3199 | threads = [] |
| 3200 | addedPValues = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3201 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3202 | t = main.Thread( target=main.CLIs[i].counterTestAddAndGet, |
| 3203 | name="counterIncrement-" + str( i ), |
| 3204 | args=[ pCounterName ], |
| 3205 | kwargs={ "delta": -8 } ) |
| 3206 | pCounterValue += -8 |
| 3207 | addedPValues.append( pCounterValue ) |
| 3208 | threads.append( t ) |
| 3209 | t.start() |
| 3210 | |
| 3211 | for t in threads: |
| 3212 | t.join() |
| 3213 | pCounters.append( t.result ) |
| 3214 | # Check that counter incremented numController times |
| 3215 | pCounterResults = True |
| 3216 | for i in addedPValues: |
| 3217 | tmpResult = i in pCounters |
| 3218 | pCounterResults = pCounterResults and tmpResult |
| 3219 | if not tmpResult: |
| 3220 | main.log.error( str( i ) + " is not in partitioned " |
| 3221 | "counter incremented results" ) |
| 3222 | utilities.assert_equals( expect=True, |
| 3223 | actual=pCounterResults, |
| 3224 | onpass="Default counter incremented", |
| 3225 | onfail="Error incrementing default" + |
| 3226 | " counter" ) |
| 3227 | |
| 3228 | main.step( "Add 5 to then get a default counter on each node" ) |
| 3229 | pCounters = [] |
| 3230 | threads = [] |
| 3231 | addedPValues = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3232 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3233 | t = main.Thread( target=main.CLIs[i].counterTestAddAndGet, |
| 3234 | name="counterIncrement-" + str( i ), |
| 3235 | args=[ pCounterName ], |
| 3236 | kwargs={ "delta": 5 } ) |
| 3237 | pCounterValue += 5 |
| 3238 | addedPValues.append( pCounterValue ) |
| 3239 | threads.append( t ) |
| 3240 | t.start() |
| 3241 | |
| 3242 | for t in threads: |
| 3243 | t.join() |
| 3244 | pCounters.append( t.result ) |
| 3245 | # Check that counter incremented numController times |
| 3246 | pCounterResults = True |
| 3247 | for i in addedPValues: |
| 3248 | tmpResult = i in pCounters |
| 3249 | pCounterResults = pCounterResults and tmpResult |
| 3250 | if not tmpResult: |
| 3251 | main.log.error( str( i ) + " is not in partitioned " |
| 3252 | "counter incremented results" ) |
| 3253 | utilities.assert_equals( expect=True, |
| 3254 | actual=pCounterResults, |
| 3255 | onpass="Default counter incremented", |
| 3256 | onfail="Error incrementing default" + |
| 3257 | " counter" ) |
| 3258 | |
| 3259 | main.step( "Get then add 5 to a default counter on each node" ) |
| 3260 | pCounters = [] |
| 3261 | threads = [] |
| 3262 | addedPValues = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3263 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3264 | t = main.Thread( target=main.CLIs[i].counterTestGetAndAdd, |
| 3265 | name="counterIncrement-" + str( i ), |
| 3266 | args=[ pCounterName ], |
| 3267 | kwargs={ "delta": 5 } ) |
| 3268 | addedPValues.append( pCounterValue ) |
| 3269 | pCounterValue += 5 |
| 3270 | threads.append( t ) |
| 3271 | t.start() |
| 3272 | |
| 3273 | for t in threads: |
| 3274 | t.join() |
| 3275 | pCounters.append( t.result ) |
| 3276 | # Check that counter incremented numController times |
| 3277 | pCounterResults = True |
| 3278 | for i in addedPValues: |
| 3279 | tmpResult = i in pCounters |
| 3280 | pCounterResults = pCounterResults and tmpResult |
| 3281 | if not tmpResult: |
| 3282 | main.log.error( str( i ) + " is not in partitioned " |
| 3283 | "counter incremented results" ) |
| 3284 | utilities.assert_equals( expect=True, |
| 3285 | actual=pCounterResults, |
| 3286 | onpass="Default counter incremented", |
| 3287 | onfail="Error incrementing default" + |
| 3288 | " counter" ) |
| 3289 | |
| 3290 | main.step( "Counters we added have the correct values" ) |
Jon Hall | 41d39f1 | 2016-04-11 22:54:35 -0700 | [diff] [blame] | 3291 | incrementCheck = main.HA.counterCheck( pCounterName, pCounterValue ) |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3292 | utilities.assert_equals( expect=main.TRUE, |
| 3293 | actual=incrementCheck, |
| 3294 | onpass="Added counters are correct", |
| 3295 | onfail="Added counters are incorrect" ) |
| 3296 | |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3297 | # DISTRIBUTED SETS |
| 3298 | main.step( "Distributed Set get" ) |
| 3299 | size = len( onosSet ) |
| 3300 | getResponses = [] |
| 3301 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3302 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3303 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3304 | name="setTestGet-" + str( i ), |
| 3305 | args=[ onosSetName ] ) |
| 3306 | threads.append( t ) |
| 3307 | t.start() |
| 3308 | for t in threads: |
| 3309 | t.join() |
| 3310 | getResponses.append( t.result ) |
| 3311 | |
| 3312 | getResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3313 | for i in range( len( main.activeNodes ) ): |
| 3314 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3315 | if isinstance( getResponses[ i ], list): |
| 3316 | current = set( getResponses[ i ] ) |
| 3317 | if len( current ) == len( getResponses[ i ] ): |
| 3318 | # no repeats |
| 3319 | if onosSet != current: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3320 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3321 | " has incorrect view" + |
| 3322 | " of set " + onosSetName + ":\n" + |
| 3323 | str( getResponses[ i ] ) ) |
| 3324 | main.log.debug( "Expected: " + str( onosSet ) ) |
| 3325 | main.log.debug( "Actual: " + str( current ) ) |
| 3326 | getResults = main.FALSE |
| 3327 | else: |
| 3328 | # error, set is not a set |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3329 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3330 | " has repeat elements in" + |
| 3331 | " set " + onosSetName + ":\n" + |
| 3332 | str( getResponses[ i ] ) ) |
| 3333 | getResults = main.FALSE |
| 3334 | elif getResponses[ i ] == main.ERROR: |
| 3335 | getResults = main.FALSE |
| 3336 | utilities.assert_equals( expect=main.TRUE, |
| 3337 | actual=getResults, |
| 3338 | onpass="Set elements are correct", |
| 3339 | onfail="Set elements are incorrect" ) |
| 3340 | |
| 3341 | main.step( "Distributed Set size" ) |
| 3342 | sizeResponses = [] |
| 3343 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3344 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3345 | t = main.Thread( target=main.CLIs[i].setTestSize, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3346 | name="setTestSize-" + str( i ), |
| 3347 | args=[ onosSetName ] ) |
| 3348 | threads.append( t ) |
| 3349 | t.start() |
| 3350 | for t in threads: |
| 3351 | t.join() |
| 3352 | sizeResponses.append( t.result ) |
| 3353 | |
| 3354 | sizeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3355 | for i in range( len( main.activeNodes ) ): |
| 3356 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3357 | if size != sizeResponses[ i ]: |
| 3358 | sizeResults = main.FALSE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3359 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3360 | " expected a size of " + str( size ) + |
| 3361 | " for set " + onosSetName + |
| 3362 | " but got " + str( sizeResponses[ i ] ) ) |
| 3363 | utilities.assert_equals( expect=main.TRUE, |
| 3364 | actual=sizeResults, |
| 3365 | onpass="Set sizes are correct", |
| 3366 | onfail="Set sizes are incorrect" ) |
| 3367 | |
| 3368 | main.step( "Distributed Set add()" ) |
| 3369 | onosSet.add( addValue ) |
| 3370 | addResponses = [] |
| 3371 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3372 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3373 | t = main.Thread( target=main.CLIs[i].setTestAdd, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3374 | name="setTestAdd-" + str( i ), |
| 3375 | args=[ onosSetName, addValue ] ) |
| 3376 | threads.append( t ) |
| 3377 | t.start() |
| 3378 | for t in threads: |
| 3379 | t.join() |
| 3380 | addResponses.append( t.result ) |
| 3381 | |
| 3382 | # main.TRUE = successfully changed the set |
| 3383 | # main.FALSE = action resulted in no change in set |
| 3384 | # main.ERROR - Some error in executing the function |
| 3385 | addResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3386 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3387 | if addResponses[ i ] == main.TRUE: |
| 3388 | # All is well |
| 3389 | pass |
| 3390 | elif addResponses[ i ] == main.FALSE: |
| 3391 | # Already in set, probably fine |
| 3392 | pass |
| 3393 | elif addResponses[ i ] == main.ERROR: |
| 3394 | # Error in execution |
| 3395 | addResults = main.FALSE |
| 3396 | else: |
| 3397 | # unexpected result |
| 3398 | addResults = main.FALSE |
| 3399 | if addResults != main.TRUE: |
| 3400 | main.log.error( "Error executing set add" ) |
| 3401 | |
| 3402 | # Check if set is still correct |
| 3403 | size = len( onosSet ) |
| 3404 | getResponses = [] |
| 3405 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3406 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3407 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3408 | name="setTestGet-" + str( i ), |
| 3409 | args=[ onosSetName ] ) |
| 3410 | threads.append( t ) |
| 3411 | t.start() |
| 3412 | for t in threads: |
| 3413 | t.join() |
| 3414 | getResponses.append( t.result ) |
| 3415 | getResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3416 | for i in range( len( main.activeNodes ) ): |
| 3417 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3418 | if isinstance( getResponses[ i ], list): |
| 3419 | current = set( getResponses[ i ] ) |
| 3420 | if len( current ) == len( getResponses[ i ] ): |
| 3421 | # no repeats |
| 3422 | if onosSet != current: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3423 | main.log.error( "ONOS" + node + " has incorrect view" + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3424 | " of set " + onosSetName + ":\n" + |
| 3425 | str( getResponses[ i ] ) ) |
| 3426 | main.log.debug( "Expected: " + str( onosSet ) ) |
| 3427 | main.log.debug( "Actual: " + str( current ) ) |
| 3428 | getResults = main.FALSE |
| 3429 | else: |
| 3430 | # error, set is not a set |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3431 | main.log.error( "ONOS" + node + " has repeat elements in" + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3432 | " set " + onosSetName + ":\n" + |
| 3433 | str( getResponses[ i ] ) ) |
| 3434 | getResults = main.FALSE |
| 3435 | elif getResponses[ i ] == main.ERROR: |
| 3436 | getResults = main.FALSE |
| 3437 | sizeResponses = [] |
| 3438 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3439 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3440 | t = main.Thread( target=main.CLIs[i].setTestSize, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3441 | name="setTestSize-" + str( i ), |
| 3442 | args=[ onosSetName ] ) |
| 3443 | threads.append( t ) |
| 3444 | t.start() |
| 3445 | for t in threads: |
| 3446 | t.join() |
| 3447 | sizeResponses.append( t.result ) |
| 3448 | sizeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3449 | for i in range( len( main.activeNodes ) ): |
| 3450 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3451 | if size != sizeResponses[ i ]: |
| 3452 | sizeResults = main.FALSE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3453 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3454 | " expected a size of " + str( size ) + |
| 3455 | " for set " + onosSetName + |
| 3456 | " but got " + str( sizeResponses[ i ] ) ) |
| 3457 | addResults = addResults and getResults and sizeResults |
| 3458 | utilities.assert_equals( expect=main.TRUE, |
| 3459 | actual=addResults, |
| 3460 | onpass="Set add correct", |
| 3461 | onfail="Set add was incorrect" ) |
| 3462 | |
| 3463 | main.step( "Distributed Set addAll()" ) |
| 3464 | onosSet.update( addAllValue.split() ) |
| 3465 | addResponses = [] |
| 3466 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3467 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3468 | t = main.Thread( target=main.CLIs[i].setTestAdd, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3469 | name="setTestAddAll-" + str( i ), |
| 3470 | args=[ onosSetName, addAllValue ] ) |
| 3471 | threads.append( t ) |
| 3472 | t.start() |
| 3473 | for t in threads: |
| 3474 | t.join() |
| 3475 | addResponses.append( t.result ) |
| 3476 | |
| 3477 | # main.TRUE = successfully changed the set |
| 3478 | # main.FALSE = action resulted in no change in set |
| 3479 | # main.ERROR - Some error in executing the function |
| 3480 | addAllResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3481 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3482 | if addResponses[ i ] == main.TRUE: |
| 3483 | # All is well |
| 3484 | pass |
| 3485 | elif addResponses[ i ] == main.FALSE: |
| 3486 | # Already in set, probably fine |
| 3487 | pass |
| 3488 | elif addResponses[ i ] == main.ERROR: |
| 3489 | # Error in execution |
| 3490 | addAllResults = main.FALSE |
| 3491 | else: |
| 3492 | # unexpected result |
| 3493 | addAllResults = main.FALSE |
| 3494 | if addAllResults != main.TRUE: |
| 3495 | main.log.error( "Error executing set addAll" ) |
| 3496 | |
| 3497 | # Check if set is still correct |
| 3498 | size = len( onosSet ) |
| 3499 | getResponses = [] |
| 3500 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3501 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3502 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3503 | name="setTestGet-" + str( i ), |
| 3504 | args=[ onosSetName ] ) |
| 3505 | threads.append( t ) |
| 3506 | t.start() |
| 3507 | for t in threads: |
| 3508 | t.join() |
| 3509 | getResponses.append( t.result ) |
| 3510 | getResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3511 | for i in range( len( main.activeNodes ) ): |
| 3512 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3513 | if isinstance( getResponses[ i ], list): |
| 3514 | current = set( getResponses[ i ] ) |
| 3515 | if len( current ) == len( getResponses[ i ] ): |
| 3516 | # no repeats |
| 3517 | if onosSet != current: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3518 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3519 | " has incorrect view" + |
| 3520 | " of set " + onosSetName + ":\n" + |
| 3521 | str( getResponses[ i ] ) ) |
| 3522 | main.log.debug( "Expected: " + str( onosSet ) ) |
| 3523 | main.log.debug( "Actual: " + str( current ) ) |
| 3524 | getResults = main.FALSE |
| 3525 | else: |
| 3526 | # error, set is not a set |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3527 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3528 | " has repeat elements in" + |
| 3529 | " set " + onosSetName + ":\n" + |
| 3530 | str( getResponses[ i ] ) ) |
| 3531 | getResults = main.FALSE |
| 3532 | elif getResponses[ i ] == main.ERROR: |
| 3533 | getResults = main.FALSE |
| 3534 | sizeResponses = [] |
| 3535 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3536 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3537 | t = main.Thread( target=main.CLIs[i].setTestSize, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3538 | name="setTestSize-" + str( i ), |
| 3539 | args=[ onosSetName ] ) |
| 3540 | threads.append( t ) |
| 3541 | t.start() |
| 3542 | for t in threads: |
| 3543 | t.join() |
| 3544 | sizeResponses.append( t.result ) |
| 3545 | sizeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3546 | for i in range( len( main.activeNodes ) ): |
| 3547 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3548 | if size != sizeResponses[ i ]: |
| 3549 | sizeResults = main.FALSE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3550 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3551 | " expected a size of " + str( size ) + |
| 3552 | " for set " + onosSetName + |
| 3553 | " but got " + str( sizeResponses[ i ] ) ) |
| 3554 | addAllResults = addAllResults and getResults and sizeResults |
| 3555 | utilities.assert_equals( expect=main.TRUE, |
| 3556 | actual=addAllResults, |
| 3557 | onpass="Set addAll correct", |
| 3558 | onfail="Set addAll was incorrect" ) |
| 3559 | |
| 3560 | main.step( "Distributed Set contains()" ) |
| 3561 | containsResponses = [] |
| 3562 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3563 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3564 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3565 | name="setContains-" + str( i ), |
| 3566 | args=[ onosSetName ], |
| 3567 | kwargs={ "values": addValue } ) |
| 3568 | threads.append( t ) |
| 3569 | t.start() |
| 3570 | for t in threads: |
| 3571 | t.join() |
| 3572 | # NOTE: This is the tuple |
| 3573 | containsResponses.append( t.result ) |
| 3574 | |
| 3575 | containsResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3576 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3577 | if containsResponses[ i ] == main.ERROR: |
| 3578 | containsResults = main.FALSE |
| 3579 | else: |
| 3580 | containsResults = containsResults and\ |
| 3581 | containsResponses[ i ][ 1 ] |
| 3582 | utilities.assert_equals( expect=main.TRUE, |
| 3583 | actual=containsResults, |
| 3584 | onpass="Set contains is functional", |
| 3585 | onfail="Set contains failed" ) |
| 3586 | |
| 3587 | main.step( "Distributed Set containsAll()" ) |
| 3588 | containsAllResponses = [] |
| 3589 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3590 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3591 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3592 | name="setContainsAll-" + str( i ), |
| 3593 | args=[ onosSetName ], |
| 3594 | kwargs={ "values": addAllValue } ) |
| 3595 | threads.append( t ) |
| 3596 | t.start() |
| 3597 | for t in threads: |
| 3598 | t.join() |
| 3599 | # NOTE: This is the tuple |
| 3600 | containsAllResponses.append( t.result ) |
| 3601 | |
| 3602 | containsAllResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3603 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3604 | if containsResponses[ i ] == main.ERROR: |
| 3605 | containsResults = main.FALSE |
| 3606 | else: |
| 3607 | containsResults = containsResults and\ |
| 3608 | containsResponses[ i ][ 1 ] |
| 3609 | utilities.assert_equals( expect=main.TRUE, |
| 3610 | actual=containsAllResults, |
| 3611 | onpass="Set containsAll is functional", |
| 3612 | onfail="Set containsAll failed" ) |
| 3613 | |
| 3614 | main.step( "Distributed Set remove()" ) |
| 3615 | onosSet.remove( addValue ) |
| 3616 | removeResponses = [] |
| 3617 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3618 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3619 | t = main.Thread( target=main.CLIs[i].setTestRemove, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3620 | name="setTestRemove-" + str( i ), |
| 3621 | args=[ onosSetName, addValue ] ) |
| 3622 | threads.append( t ) |
| 3623 | t.start() |
| 3624 | for t in threads: |
| 3625 | t.join() |
| 3626 | removeResponses.append( t.result ) |
| 3627 | |
| 3628 | # main.TRUE = successfully changed the set |
| 3629 | # main.FALSE = action resulted in no change in set |
| 3630 | # main.ERROR - Some error in executing the function |
| 3631 | removeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3632 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3633 | if removeResponses[ i ] == main.TRUE: |
| 3634 | # All is well |
| 3635 | pass |
| 3636 | elif removeResponses[ i ] == main.FALSE: |
| 3637 | # not in set, probably fine |
| 3638 | pass |
| 3639 | elif removeResponses[ i ] == main.ERROR: |
| 3640 | # Error in execution |
| 3641 | removeResults = main.FALSE |
| 3642 | else: |
| 3643 | # unexpected result |
| 3644 | removeResults = main.FALSE |
| 3645 | if removeResults != main.TRUE: |
| 3646 | main.log.error( "Error executing set remove" ) |
| 3647 | |
| 3648 | # Check if set is still correct |
| 3649 | size = len( onosSet ) |
| 3650 | getResponses = [] |
| 3651 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3652 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3653 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3654 | name="setTestGet-" + str( i ), |
| 3655 | args=[ onosSetName ] ) |
| 3656 | threads.append( t ) |
| 3657 | t.start() |
| 3658 | for t in threads: |
| 3659 | t.join() |
| 3660 | getResponses.append( t.result ) |
| 3661 | getResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3662 | for i in range( len( main.activeNodes ) ): |
| 3663 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3664 | if isinstance( getResponses[ i ], list): |
| 3665 | current = set( getResponses[ i ] ) |
| 3666 | if len( current ) == len( getResponses[ i ] ): |
| 3667 | # no repeats |
| 3668 | if onosSet != current: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3669 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3670 | " has incorrect view" + |
| 3671 | " of set " + onosSetName + ":\n" + |
| 3672 | str( getResponses[ i ] ) ) |
| 3673 | main.log.debug( "Expected: " + str( onosSet ) ) |
| 3674 | main.log.debug( "Actual: " + str( current ) ) |
| 3675 | getResults = main.FALSE |
| 3676 | else: |
| 3677 | # error, set is not a set |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3678 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3679 | " has repeat elements in" + |
| 3680 | " set " + onosSetName + ":\n" + |
| 3681 | str( getResponses[ i ] ) ) |
| 3682 | getResults = main.FALSE |
| 3683 | elif getResponses[ i ] == main.ERROR: |
| 3684 | getResults = main.FALSE |
| 3685 | sizeResponses = [] |
| 3686 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3687 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3688 | t = main.Thread( target=main.CLIs[i].setTestSize, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3689 | name="setTestSize-" + str( i ), |
| 3690 | args=[ onosSetName ] ) |
| 3691 | threads.append( t ) |
| 3692 | t.start() |
| 3693 | for t in threads: |
| 3694 | t.join() |
| 3695 | sizeResponses.append( t.result ) |
| 3696 | sizeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3697 | for i in range( len( main.activeNodes ) ): |
| 3698 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3699 | if size != sizeResponses[ i ]: |
| 3700 | sizeResults = main.FALSE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3701 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3702 | " expected a size of " + str( size ) + |
| 3703 | " for set " + onosSetName + |
| 3704 | " but got " + str( sizeResponses[ i ] ) ) |
| 3705 | removeResults = removeResults and getResults and sizeResults |
| 3706 | utilities.assert_equals( expect=main.TRUE, |
| 3707 | actual=removeResults, |
| 3708 | onpass="Set remove correct", |
| 3709 | onfail="Set remove was incorrect" ) |
| 3710 | |
| 3711 | main.step( "Distributed Set removeAll()" ) |
| 3712 | onosSet.difference_update( addAllValue.split() ) |
| 3713 | removeAllResponses = [] |
| 3714 | threads = [] |
| 3715 | try: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3716 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3717 | t = main.Thread( target=main.CLIs[i].setTestRemove, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3718 | name="setTestRemoveAll-" + str( i ), |
| 3719 | args=[ onosSetName, addAllValue ] ) |
| 3720 | threads.append( t ) |
| 3721 | t.start() |
| 3722 | for t in threads: |
| 3723 | t.join() |
| 3724 | removeAllResponses.append( t.result ) |
| 3725 | except Exception, e: |
| 3726 | main.log.exception(e) |
| 3727 | |
| 3728 | # main.TRUE = successfully changed the set |
| 3729 | # main.FALSE = action resulted in no change in set |
| 3730 | # main.ERROR - Some error in executing the function |
| 3731 | removeAllResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3732 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3733 | if removeAllResponses[ i ] == main.TRUE: |
| 3734 | # All is well |
| 3735 | pass |
| 3736 | elif removeAllResponses[ i ] == main.FALSE: |
| 3737 | # not in set, probably fine |
| 3738 | pass |
| 3739 | elif removeAllResponses[ i ] == main.ERROR: |
| 3740 | # Error in execution |
| 3741 | removeAllResults = main.FALSE |
| 3742 | else: |
| 3743 | # unexpected result |
| 3744 | removeAllResults = main.FALSE |
| 3745 | if removeAllResults != main.TRUE: |
| 3746 | main.log.error( "Error executing set removeAll" ) |
| 3747 | |
| 3748 | # Check if set is still correct |
| 3749 | size = len( onosSet ) |
| 3750 | getResponses = [] |
| 3751 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3752 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3753 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3754 | name="setTestGet-" + str( i ), |
| 3755 | args=[ onosSetName ] ) |
| 3756 | threads.append( t ) |
| 3757 | t.start() |
| 3758 | for t in threads: |
| 3759 | t.join() |
| 3760 | getResponses.append( t.result ) |
| 3761 | getResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3762 | for i in range( len( main.activeNodes ) ): |
| 3763 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3764 | if isinstance( getResponses[ i ], list): |
| 3765 | current = set( getResponses[ i ] ) |
| 3766 | if len( current ) == len( getResponses[ i ] ): |
| 3767 | # no repeats |
| 3768 | if onosSet != current: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3769 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3770 | " has incorrect view" + |
| 3771 | " of set " + onosSetName + ":\n" + |
| 3772 | str( getResponses[ i ] ) ) |
| 3773 | main.log.debug( "Expected: " + str( onosSet ) ) |
| 3774 | main.log.debug( "Actual: " + str( current ) ) |
| 3775 | getResults = main.FALSE |
| 3776 | else: |
| 3777 | # error, set is not a set |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3778 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3779 | " has repeat elements in" + |
| 3780 | " set " + onosSetName + ":\n" + |
| 3781 | str( getResponses[ i ] ) ) |
| 3782 | getResults = main.FALSE |
| 3783 | elif getResponses[ i ] == main.ERROR: |
| 3784 | getResults = main.FALSE |
| 3785 | sizeResponses = [] |
| 3786 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3787 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3788 | t = main.Thread( target=main.CLIs[i].setTestSize, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3789 | name="setTestSize-" + str( i ), |
| 3790 | args=[ onosSetName ] ) |
| 3791 | threads.append( t ) |
| 3792 | t.start() |
| 3793 | for t in threads: |
| 3794 | t.join() |
| 3795 | sizeResponses.append( t.result ) |
| 3796 | sizeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3797 | for i in range( len( main.activeNodes ) ): |
| 3798 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3799 | if size != sizeResponses[ i ]: |
| 3800 | sizeResults = main.FALSE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3801 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3802 | " expected a size of " + str( size ) + |
| 3803 | " for set " + onosSetName + |
| 3804 | " but got " + str( sizeResponses[ i ] ) ) |
| 3805 | removeAllResults = removeAllResults and getResults and sizeResults |
| 3806 | utilities.assert_equals( expect=main.TRUE, |
| 3807 | actual=removeAllResults, |
| 3808 | onpass="Set removeAll correct", |
| 3809 | onfail="Set removeAll was incorrect" ) |
| 3810 | |
| 3811 | main.step( "Distributed Set addAll()" ) |
| 3812 | onosSet.update( addAllValue.split() ) |
| 3813 | addResponses = [] |
| 3814 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3815 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3816 | t = main.Thread( target=main.CLIs[i].setTestAdd, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3817 | name="setTestAddAll-" + str( i ), |
| 3818 | args=[ onosSetName, addAllValue ] ) |
| 3819 | threads.append( t ) |
| 3820 | t.start() |
| 3821 | for t in threads: |
| 3822 | t.join() |
| 3823 | addResponses.append( t.result ) |
| 3824 | |
| 3825 | # main.TRUE = successfully changed the set |
| 3826 | # main.FALSE = action resulted in no change in set |
| 3827 | # main.ERROR - Some error in executing the function |
| 3828 | addAllResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3829 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3830 | if addResponses[ i ] == main.TRUE: |
| 3831 | # All is well |
| 3832 | pass |
| 3833 | elif addResponses[ i ] == main.FALSE: |
| 3834 | # Already in set, probably fine |
| 3835 | pass |
| 3836 | elif addResponses[ i ] == main.ERROR: |
| 3837 | # Error in execution |
| 3838 | addAllResults = main.FALSE |
| 3839 | else: |
| 3840 | # unexpected result |
| 3841 | addAllResults = main.FALSE |
| 3842 | if addAllResults != main.TRUE: |
| 3843 | main.log.error( "Error executing set addAll" ) |
| 3844 | |
| 3845 | # Check if set is still correct |
| 3846 | size = len( onosSet ) |
| 3847 | getResponses = [] |
| 3848 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3849 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3850 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3851 | name="setTestGet-" + str( i ), |
| 3852 | args=[ onosSetName ] ) |
| 3853 | threads.append( t ) |
| 3854 | t.start() |
| 3855 | for t in threads: |
| 3856 | t.join() |
| 3857 | getResponses.append( t.result ) |
| 3858 | getResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3859 | for i in range( len( main.activeNodes ) ): |
| 3860 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3861 | if isinstance( getResponses[ i ], list): |
| 3862 | current = set( getResponses[ i ] ) |
| 3863 | if len( current ) == len( getResponses[ i ] ): |
| 3864 | # no repeats |
| 3865 | if onosSet != current: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3866 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3867 | " has incorrect view" + |
| 3868 | " of set " + onosSetName + ":\n" + |
| 3869 | str( getResponses[ i ] ) ) |
| 3870 | main.log.debug( "Expected: " + str( onosSet ) ) |
| 3871 | main.log.debug( "Actual: " + str( current ) ) |
| 3872 | getResults = main.FALSE |
| 3873 | else: |
| 3874 | # error, set is not a set |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3875 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3876 | " has repeat elements in" + |
| 3877 | " set " + onosSetName + ":\n" + |
| 3878 | str( getResponses[ i ] ) ) |
| 3879 | getResults = main.FALSE |
| 3880 | elif getResponses[ i ] == main.ERROR: |
| 3881 | getResults = main.FALSE |
| 3882 | sizeResponses = [] |
| 3883 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3884 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3885 | t = main.Thread( target=main.CLIs[i].setTestSize, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3886 | name="setTestSize-" + str( i ), |
| 3887 | args=[ onosSetName ] ) |
| 3888 | threads.append( t ) |
| 3889 | t.start() |
| 3890 | for t in threads: |
| 3891 | t.join() |
| 3892 | sizeResponses.append( t.result ) |
| 3893 | sizeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3894 | for i in range( len( main.activeNodes ) ): |
| 3895 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3896 | if size != sizeResponses[ i ]: |
| 3897 | sizeResults = main.FALSE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3898 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3899 | " expected a size of " + str( size ) + |
| 3900 | " for set " + onosSetName + |
| 3901 | " but got " + str( sizeResponses[ i ] ) ) |
| 3902 | addAllResults = addAllResults and getResults and sizeResults |
| 3903 | utilities.assert_equals( expect=main.TRUE, |
| 3904 | actual=addAllResults, |
| 3905 | onpass="Set addAll correct", |
| 3906 | onfail="Set addAll was incorrect" ) |
| 3907 | |
| 3908 | main.step( "Distributed Set clear()" ) |
| 3909 | onosSet.clear() |
| 3910 | clearResponses = [] |
| 3911 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3912 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3913 | t = main.Thread( target=main.CLIs[i].setTestRemove, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3914 | name="setTestClear-" + str( i ), |
| 3915 | args=[ onosSetName, " "], # Values doesn't matter |
| 3916 | kwargs={ "clear": True } ) |
| 3917 | threads.append( t ) |
| 3918 | t.start() |
| 3919 | for t in threads: |
| 3920 | t.join() |
| 3921 | clearResponses.append( t.result ) |
| 3922 | |
| 3923 | # main.TRUE = successfully changed the set |
| 3924 | # main.FALSE = action resulted in no change in set |
| 3925 | # main.ERROR - Some error in executing the function |
| 3926 | clearResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3927 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3928 | if clearResponses[ i ] == main.TRUE: |
| 3929 | # All is well |
| 3930 | pass |
| 3931 | elif clearResponses[ i ] == main.FALSE: |
| 3932 | # Nothing set, probably fine |
| 3933 | pass |
| 3934 | elif clearResponses[ i ] == main.ERROR: |
| 3935 | # Error in execution |
| 3936 | clearResults = main.FALSE |
| 3937 | else: |
| 3938 | # unexpected result |
| 3939 | clearResults = main.FALSE |
| 3940 | if clearResults != main.TRUE: |
| 3941 | main.log.error( "Error executing set clear" ) |
| 3942 | |
| 3943 | # Check if set is still correct |
| 3944 | size = len( onosSet ) |
| 3945 | getResponses = [] |
| 3946 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3947 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3948 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3949 | name="setTestGet-" + str( i ), |
| 3950 | args=[ onosSetName ] ) |
| 3951 | threads.append( t ) |
| 3952 | t.start() |
| 3953 | for t in threads: |
| 3954 | t.join() |
| 3955 | getResponses.append( t.result ) |
| 3956 | getResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3957 | for i in range( len( main.activeNodes ) ): |
| 3958 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3959 | if isinstance( getResponses[ i ], list): |
| 3960 | current = set( getResponses[ i ] ) |
| 3961 | if len( current ) == len( getResponses[ i ] ): |
| 3962 | # no repeats |
| 3963 | if onosSet != current: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3964 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3965 | " has incorrect view" + |
| 3966 | " of set " + onosSetName + ":\n" + |
| 3967 | str( getResponses[ i ] ) ) |
| 3968 | main.log.debug( "Expected: " + str( onosSet ) ) |
| 3969 | main.log.debug( "Actual: " + str( current ) ) |
| 3970 | getResults = main.FALSE |
| 3971 | else: |
| 3972 | # error, set is not a set |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3973 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3974 | " has repeat elements in" + |
| 3975 | " set " + onosSetName + ":\n" + |
| 3976 | str( getResponses[ i ] ) ) |
| 3977 | getResults = main.FALSE |
| 3978 | elif getResponses[ i ] == main.ERROR: |
| 3979 | getResults = main.FALSE |
| 3980 | sizeResponses = [] |
| 3981 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3982 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 3983 | t = main.Thread( target=main.CLIs[i].setTestSize, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3984 | name="setTestSize-" + str( i ), |
| 3985 | args=[ onosSetName ] ) |
| 3986 | threads.append( t ) |
| 3987 | t.start() |
| 3988 | for t in threads: |
| 3989 | t.join() |
| 3990 | sizeResponses.append( t.result ) |
| 3991 | sizeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3992 | for i in range( len( main.activeNodes ) ): |
| 3993 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3994 | if size != sizeResponses[ i ]: |
| 3995 | sizeResults = main.FALSE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 3996 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 3997 | " expected a size of " + str( size ) + |
| 3998 | " for set " + onosSetName + |
| 3999 | " but got " + str( sizeResponses[ i ] ) ) |
| 4000 | clearResults = clearResults and getResults and sizeResults |
| 4001 | utilities.assert_equals( expect=main.TRUE, |
| 4002 | actual=clearResults, |
| 4003 | onpass="Set clear correct", |
| 4004 | onfail="Set clear was incorrect" ) |
| 4005 | |
| 4006 | main.step( "Distributed Set addAll()" ) |
| 4007 | onosSet.update( addAllValue.split() ) |
| 4008 | addResponses = [] |
| 4009 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4010 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 4011 | t = main.Thread( target=main.CLIs[i].setTestAdd, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4012 | name="setTestAddAll-" + str( i ), |
| 4013 | args=[ onosSetName, addAllValue ] ) |
| 4014 | threads.append( t ) |
| 4015 | t.start() |
| 4016 | for t in threads: |
| 4017 | t.join() |
| 4018 | addResponses.append( t.result ) |
| 4019 | |
| 4020 | # main.TRUE = successfully changed the set |
| 4021 | # main.FALSE = action resulted in no change in set |
| 4022 | # main.ERROR - Some error in executing the function |
| 4023 | addAllResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4024 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4025 | if addResponses[ i ] == main.TRUE: |
| 4026 | # All is well |
| 4027 | pass |
| 4028 | elif addResponses[ i ] == main.FALSE: |
| 4029 | # Already in set, probably fine |
| 4030 | pass |
| 4031 | elif addResponses[ i ] == main.ERROR: |
| 4032 | # Error in execution |
| 4033 | addAllResults = main.FALSE |
| 4034 | else: |
| 4035 | # unexpected result |
| 4036 | addAllResults = main.FALSE |
| 4037 | if addAllResults != main.TRUE: |
| 4038 | main.log.error( "Error executing set addAll" ) |
| 4039 | |
| 4040 | # Check if set is still correct |
| 4041 | size = len( onosSet ) |
| 4042 | getResponses = [] |
| 4043 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4044 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 4045 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4046 | name="setTestGet-" + str( i ), |
| 4047 | args=[ onosSetName ] ) |
| 4048 | threads.append( t ) |
| 4049 | t.start() |
| 4050 | for t in threads: |
| 4051 | t.join() |
| 4052 | getResponses.append( t.result ) |
| 4053 | getResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4054 | for i in range( len( main.activeNodes ) ): |
| 4055 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4056 | if isinstance( getResponses[ i ], list): |
| 4057 | current = set( getResponses[ i ] ) |
| 4058 | if len( current ) == len( getResponses[ i ] ): |
| 4059 | # no repeats |
| 4060 | if onosSet != current: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4061 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4062 | " has incorrect view" + |
| 4063 | " of set " + onosSetName + ":\n" + |
| 4064 | str( getResponses[ i ] ) ) |
| 4065 | main.log.debug( "Expected: " + str( onosSet ) ) |
| 4066 | main.log.debug( "Actual: " + str( current ) ) |
| 4067 | getResults = main.FALSE |
| 4068 | else: |
| 4069 | # error, set is not a set |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4070 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4071 | " has repeat elements in" + |
| 4072 | " set " + onosSetName + ":\n" + |
| 4073 | str( getResponses[ i ] ) ) |
| 4074 | getResults = main.FALSE |
| 4075 | elif getResponses[ i ] == main.ERROR: |
| 4076 | getResults = main.FALSE |
| 4077 | sizeResponses = [] |
| 4078 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4079 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 4080 | t = main.Thread( target=main.CLIs[i].setTestSize, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4081 | name="setTestSize-" + str( i ), |
| 4082 | args=[ onosSetName ] ) |
| 4083 | threads.append( t ) |
| 4084 | t.start() |
| 4085 | for t in threads: |
| 4086 | t.join() |
| 4087 | sizeResponses.append( t.result ) |
| 4088 | sizeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4089 | for i in range( len( main.activeNodes ) ): |
| 4090 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4091 | if size != sizeResponses[ i ]: |
| 4092 | sizeResults = main.FALSE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4093 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4094 | " expected a size of " + str( size ) + |
| 4095 | " for set " + onosSetName + |
| 4096 | " but got " + str( sizeResponses[ i ] ) ) |
| 4097 | addAllResults = addAllResults and getResults and sizeResults |
| 4098 | utilities.assert_equals( expect=main.TRUE, |
| 4099 | actual=addAllResults, |
| 4100 | onpass="Set addAll correct", |
| 4101 | onfail="Set addAll was incorrect" ) |
| 4102 | |
| 4103 | main.step( "Distributed Set retain()" ) |
| 4104 | onosSet.intersection_update( retainValue.split() ) |
| 4105 | retainResponses = [] |
| 4106 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4107 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 4108 | t = main.Thread( target=main.CLIs[i].setTestRemove, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4109 | name="setTestRetain-" + str( i ), |
| 4110 | args=[ onosSetName, retainValue ], |
| 4111 | kwargs={ "retain": True } ) |
| 4112 | threads.append( t ) |
| 4113 | t.start() |
| 4114 | for t in threads: |
| 4115 | t.join() |
| 4116 | retainResponses.append( t.result ) |
| 4117 | |
| 4118 | # main.TRUE = successfully changed the set |
| 4119 | # main.FALSE = action resulted in no change in set |
| 4120 | # main.ERROR - Some error in executing the function |
| 4121 | retainResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4122 | for i in range( len( main.activeNodes ) ): |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4123 | if retainResponses[ i ] == main.TRUE: |
| 4124 | # All is well |
| 4125 | pass |
| 4126 | elif retainResponses[ i ] == main.FALSE: |
| 4127 | # Already in set, probably fine |
| 4128 | pass |
| 4129 | elif retainResponses[ i ] == main.ERROR: |
| 4130 | # Error in execution |
| 4131 | retainResults = main.FALSE |
| 4132 | else: |
| 4133 | # unexpected result |
| 4134 | retainResults = main.FALSE |
| 4135 | if retainResults != main.TRUE: |
| 4136 | main.log.error( "Error executing set retain" ) |
| 4137 | |
| 4138 | # Check if set is still correct |
| 4139 | size = len( onosSet ) |
| 4140 | getResponses = [] |
| 4141 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4142 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 4143 | t = main.Thread( target=main.CLIs[i].setTestGet, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4144 | name="setTestGet-" + str( i ), |
| 4145 | args=[ onosSetName ] ) |
| 4146 | threads.append( t ) |
| 4147 | t.start() |
| 4148 | for t in threads: |
| 4149 | t.join() |
| 4150 | getResponses.append( t.result ) |
| 4151 | getResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4152 | for i in range( len( main.activeNodes ) ): |
| 4153 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4154 | if isinstance( getResponses[ i ], list): |
| 4155 | current = set( getResponses[ i ] ) |
| 4156 | if len( current ) == len( getResponses[ i ] ): |
| 4157 | # no repeats |
| 4158 | if onosSet != current: |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4159 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4160 | " has incorrect view" + |
| 4161 | " of set " + onosSetName + ":\n" + |
| 4162 | str( getResponses[ i ] ) ) |
| 4163 | main.log.debug( "Expected: " + str( onosSet ) ) |
| 4164 | main.log.debug( "Actual: " + str( current ) ) |
| 4165 | getResults = main.FALSE |
| 4166 | else: |
| 4167 | # error, set is not a set |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4168 | main.log.error( "ONOS" + node + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4169 | " has repeat elements in" + |
| 4170 | " set " + onosSetName + ":\n" + |
| 4171 | str( getResponses[ i ] ) ) |
| 4172 | getResults = main.FALSE |
| 4173 | elif getResponses[ i ] == main.ERROR: |
| 4174 | getResults = main.FALSE |
| 4175 | sizeResponses = [] |
| 4176 | threads = [] |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4177 | for i in main.activeNodes: |
Jon Hall | e1a3b75 | 2015-07-22 13:02:46 -0700 | [diff] [blame] | 4178 | t = main.Thread( target=main.CLIs[i].setTestSize, |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4179 | name="setTestSize-" + str( i ), |
| 4180 | args=[ onosSetName ] ) |
| 4181 | threads.append( t ) |
| 4182 | t.start() |
| 4183 | for t in threads: |
| 4184 | t.join() |
| 4185 | sizeResponses.append( t.result ) |
| 4186 | sizeResults = main.TRUE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4187 | for i in range( len( main.activeNodes ) ): |
| 4188 | node = str( main.activeNodes[i] + 1 ) |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4189 | if size != sizeResponses[ i ]: |
| 4190 | sizeResults = main.FALSE |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4191 | main.log.error( "ONOS" + node + " expected a size of " + |
Jon Hall | 5cf14d5 | 2015-07-16 12:15:19 -0700 | [diff] [blame] | 4192 | str( size ) + " for set " + onosSetName + |
| 4193 | " but got " + str( sizeResponses[ i ] ) ) |
| 4194 | retainResults = retainResults and getResults and sizeResults |
| 4195 | utilities.assert_equals( expect=main.TRUE, |
| 4196 | actual=retainResults, |
| 4197 | onpass="Set retain correct", |
| 4198 | onfail="Set retain was incorrect" ) |
| 4199 | |
Jon Hall | 2a5002c | 2015-08-21 16:49:11 -0700 | [diff] [blame] | 4200 | # Transactional maps |
| 4201 | main.step( "Partitioned Transactional maps put" ) |
| 4202 | tMapValue = "Testing" |
| 4203 | numKeys = 100 |
| 4204 | putResult = True |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4205 | node = main.activeNodes[0] |
| 4206 | putResponses = main.CLIs[node].transactionalMapPut( numKeys, tMapValue ) |
Jon Hall | 6e70975 | 2016-02-01 13:38:46 -0800 | [diff] [blame] | 4207 | if putResponses and len( putResponses ) == 100: |
Jon Hall | 2a5002c | 2015-08-21 16:49:11 -0700 | [diff] [blame] | 4208 | for i in putResponses: |
| 4209 | if putResponses[ i ][ 'value' ] != tMapValue: |
| 4210 | putResult = False |
| 4211 | else: |
| 4212 | putResult = False |
| 4213 | if not putResult: |
| 4214 | main.log.debug( "Put response values: " + str( putResponses ) ) |
| 4215 | utilities.assert_equals( expect=True, |
| 4216 | actual=putResult, |
| 4217 | onpass="Partitioned Transactional Map put successful", |
| 4218 | onfail="Partitioned Transactional Map put values are incorrect" ) |
| 4219 | |
| 4220 | main.step( "Partitioned Transactional maps get" ) |
| 4221 | getCheck = True |
| 4222 | for n in range( 1, numKeys + 1 ): |
| 4223 | getResponses = [] |
| 4224 | threads = [] |
| 4225 | valueCheck = True |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4226 | for i in main.activeNodes: |
Jon Hall | 2a5002c | 2015-08-21 16:49:11 -0700 | [diff] [blame] | 4227 | t = main.Thread( target=main.CLIs[i].transactionalMapGet, |
| 4228 | name="TMap-get-" + str( i ), |
Jon Hall | b3ed8ed | 2015-10-28 16:43:55 -0700 | [diff] [blame] | 4229 | args=[ "Key" + str( n ) ] ) |
Jon Hall | 2a5002c | 2015-08-21 16:49:11 -0700 | [diff] [blame] | 4230 | threads.append( t ) |
| 4231 | t.start() |
| 4232 | for t in threads: |
| 4233 | t.join() |
| 4234 | getResponses.append( t.result ) |
| 4235 | for node in getResponses: |
| 4236 | if node != tMapValue: |
| 4237 | valueCheck = False |
| 4238 | if not valueCheck: |
| 4239 | main.log.warn( "Values for key 'Key" + str( n ) + "' do not match:" ) |
| 4240 | main.log.warn( getResponses ) |
| 4241 | getCheck = getCheck and valueCheck |
| 4242 | utilities.assert_equals( expect=True, |
| 4243 | actual=getCheck, |
| 4244 | onpass="Partitioned Transactional Map get values were correct", |
| 4245 | onfail="Partitioned Transactional Map values incorrect" ) |