Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 2 | Description: This test is to determine if the HA test setup is |
| 3 | working correctly. There are no failures so this test should |
| 4 | have a 100% pass rate |
| 5 | |
| 6 | List of test cases: |
| 7 | CASE1: Compile ONOS and push it to the test machines |
| 8 | CASE2: Assign mastership to controllers |
| 9 | CASE3: Assign intents |
| 10 | CASE4: Ping across added host intents |
| 11 | CASE5: Reading state of ONOS |
| 12 | CASE6: The Failure case. Since this is the Sanity test, we do nothing. |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 13 | CASE7: Check state after control plane failure |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 14 | CASE8: Compare topo |
| 15 | CASE9: Link s3-s28 down |
| 16 | CASE10: Link s3-s28 up |
| 17 | CASE11: Switch down |
| 18 | CASE12: Switch up |
| 19 | CASE13: Clean up |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 20 | CASE14: start election app on all onos nodes |
| 21 | CASE15: Check that Leadership Election is still functional |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 22 | """ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 23 | |
| 24 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 25 | class HATestSanity: |
| 26 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 27 | def __init__( self ): |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 28 | self.default = '' |
| 29 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 30 | def CASE1( self, main ): |
| 31 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 32 | CASE1 is to compile ONOS and push it to the test machines |
| 33 | |
| 34 | Startup sequence: |
| 35 | git pull |
| 36 | mvn clean install |
| 37 | onos-package |
| 38 | cell <name> |
| 39 | onos-verify-cell |
| 40 | NOTE: temporary - onos-remove-raft-logs |
| 41 | onos-install -f |
| 42 | onos-wait-for-start |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 43 | """ |
| 44 | main.log.report( "ONOS HA Sanity test - initialization" ) |
| 45 | main.case( "Setting up test environment" ) |
| 46 | # TODO: save all the timers and output them for plotting |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 47 | |
| 48 | # load some vairables from the params file |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 49 | PULLCODE = False |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 50 | if main.params[ 'Git' ] == 'True': |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 51 | PULLCODE = True |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 52 | gitBranch = main.params[ 'branch' ] |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 53 | cellName = main.params[ 'ENV' ][ 'cellName' ] |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 54 | |
| 55 | # set global variables |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 56 | global ONOS1Ip |
| 57 | global ONOS1Port |
| 58 | global ONOS2Ip |
| 59 | global ONOS2Port |
| 60 | global ONOS3Ip |
| 61 | global ONOS3Port |
| 62 | global ONOS4Ip |
| 63 | global ONOS4Port |
| 64 | global ONOS5Ip |
| 65 | global ONOS5Port |
| 66 | global ONOS6Ip |
| 67 | global ONOS6Port |
| 68 | global ONOS7Ip |
| 69 | global ONOS7Port |
| 70 | global numControllers |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 71 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 72 | ONOS1Ip = main.params[ 'CTRL' ][ 'ip1' ] |
| 73 | ONOS1Port = main.params[ 'CTRL' ][ 'port1' ] |
| 74 | ONOS2Ip = main.params[ 'CTRL' ][ 'ip2' ] |
| 75 | ONOS2Port = main.params[ 'CTRL' ][ 'port2' ] |
| 76 | ONOS3Ip = main.params[ 'CTRL' ][ 'ip3' ] |
| 77 | ONOS3Port = main.params[ 'CTRL' ][ 'port3' ] |
| 78 | ONOS4Ip = main.params[ 'CTRL' ][ 'ip4' ] |
| 79 | ONOS4Port = main.params[ 'CTRL' ][ 'port4' ] |
| 80 | ONOS5Ip = main.params[ 'CTRL' ][ 'ip5' ] |
| 81 | ONOS5Port = main.params[ 'CTRL' ][ 'port5' ] |
| 82 | ONOS6Ip = main.params[ 'CTRL' ][ 'ip6' ] |
| 83 | ONOS6Port = main.params[ 'CTRL' ][ 'port6' ] |
| 84 | ONOS7Ip = main.params[ 'CTRL' ][ 'ip7' ] |
| 85 | ONOS7Port = main.params[ 'CTRL' ][ 'port7' ] |
| 86 | numControllers = int( main.params[ 'num_controllers' ] ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 87 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 88 | main.step( "Applying cell variable to environment" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 89 | cellResult = main.ONOSbench.setCell( cellName ) |
| 90 | verifyResult = main.ONOSbench.verifyCell() |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 91 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 92 | # FIXME:this is short term fix |
| 93 | main.log.report( "Removing raft logs" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 94 | main.ONOSbench.onosRemoveRaftLogs() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 95 | main.log.report( "Uninstalling ONOS" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 96 | main.ONOSbench.onosUninstall( ONOS1Ip ) |
| 97 | main.ONOSbench.onosUninstall( ONOS2Ip ) |
| 98 | main.ONOSbench.onosUninstall( ONOS3Ip ) |
| 99 | main.ONOSbench.onosUninstall( ONOS4Ip ) |
| 100 | main.ONOSbench.onosUninstall( ONOS5Ip ) |
| 101 | main.ONOSbench.onosUninstall( ONOS6Ip ) |
| 102 | main.ONOSbench.onosUninstall( ONOS7Ip ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 103 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 104 | cleanInstallResult = main.TRUE |
| 105 | gitPullResult = main.TRUE |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 106 | |
Jon Hall | 97f3175 | 2015-02-04 12:01:04 -0800 | [diff] [blame] | 107 | main.step( "Starting Mininet" ) |
| 108 | main.Mininet1.startNet( ) |
| 109 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 110 | main.step( "Compiling the latest version of ONOS" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 111 | if PULLCODE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 112 | # TODO Configure branch in params |
| 113 | main.step( "Git checkout and pull master" ) |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 114 | main.ONOSbench.gitCheckout( gitBranch ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 115 | gitPullResult = main.ONOSbench.gitPull() |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 116 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 117 | main.step( "Using mvn clean & install" ) |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 118 | cleanInstallResult = main.ONOSbench.cleanInstall() |
| 119 | else: |
| 120 | main.log.warn( "Did not pull new code so skipping mvn " + |
| 121 | "clean install" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 122 | main.ONOSbench.getVersion( report=True ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 123 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 124 | main.step( "Creating ONOS package" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 125 | packageResult = main.ONOSbench.onosPackage() |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 126 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 127 | main.step( "Installing ONOS package" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 128 | onos1InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 129 | node=ONOS1Ip ) |
| 130 | onos2InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 131 | node=ONOS2Ip ) |
| 132 | onos3InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 133 | node=ONOS3Ip ) |
| 134 | onos4InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 135 | node=ONOS4Ip ) |
| 136 | onos5InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 137 | node=ONOS5Ip ) |
| 138 | onos6InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 139 | node=ONOS6Ip ) |
| 140 | onos7InstallResult = main.ONOSbench.onosInstall( options="-f", |
| 141 | node=ONOS7Ip ) |
| 142 | onosInstallResult = onos1InstallResult and onos2InstallResult\ |
| 143 | and onos3InstallResult and onos4InstallResult\ |
| 144 | and onos5InstallResult and onos6InstallResult\ |
| 145 | and onos7InstallResult |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 146 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 147 | main.step( "Checking if ONOS is up yet" ) |
| 148 | # TODO check bundle:list? |
| 149 | for i in range( 2 ): |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 150 | onos1Isup = main.ONOSbench.isup( ONOS1Ip ) |
| 151 | if not onos1Isup: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 152 | main.log.report( "ONOS1 didn't start!" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 153 | onos2Isup = main.ONOSbench.isup( ONOS2Ip ) |
| 154 | if not onos2Isup: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 155 | main.log.report( "ONOS2 didn't start!" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 156 | onos3Isup = main.ONOSbench.isup( ONOS3Ip ) |
| 157 | if not onos3Isup: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 158 | main.log.report( "ONOS3 didn't start!" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 159 | onos4Isup = main.ONOSbench.isup( ONOS4Ip ) |
| 160 | if not onos4Isup: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 161 | main.log.report( "ONOS4 didn't start!" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 162 | onos5Isup = main.ONOSbench.isup( ONOS5Ip ) |
| 163 | if not onos5Isup: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 164 | main.log.report( "ONOS5 didn't start!" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 165 | onos6Isup = main.ONOSbench.isup( ONOS6Ip ) |
| 166 | if not onos6Isup: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 167 | main.log.report( "ONOS6 didn't start!" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 168 | onos7Isup = main.ONOSbench.isup( ONOS7Ip ) |
| 169 | if not onos7Isup: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 170 | main.log.report( "ONOS7 didn't start!" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 171 | onosIsupResult = onos1Isup and onos2Isup and onos3Isup\ |
| 172 | and onos4Isup and onos5Isup and onos6Isup and onos7Isup |
| 173 | if onosIsupResult == main.TRUE: |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 174 | break |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 175 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 176 | cliResult1 = main.ONOScli1.startOnosCli( ONOS1Ip ) |
| 177 | cliResult2 = main.ONOScli2.startOnosCli( ONOS2Ip ) |
| 178 | cliResult3 = main.ONOScli3.startOnosCli( ONOS3Ip ) |
| 179 | cliResult4 = main.ONOScli4.startOnosCli( ONOS4Ip ) |
| 180 | cliResult5 = main.ONOScli5.startOnosCli( ONOS5Ip ) |
| 181 | cliResult6 = main.ONOScli6.startOnosCli( ONOS6Ip ) |
| 182 | cliResult7 = main.ONOScli7.startOnosCli( ONOS7Ip ) |
| 183 | cliResults = cliResult1 and cliResult2 and cliResult3 and\ |
| 184 | cliResult4 and cliResult5 and cliResult6 and cliResult7 |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 185 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 186 | main.step( "Start Packet Capture MN" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 187 | main.Mininet2.startTcpdump( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 188 | str( main.params[ 'MNtcpdump' ][ 'folder' ] ) + str( main.TEST ) |
| 189 | + "-MN.pcap", |
| 190 | intf=main.params[ 'MNtcpdump' ][ 'intf' ], |
| 191 | port=main.params[ 'MNtcpdump' ][ 'port' ] ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 192 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 193 | case1Result = ( cleanInstallResult and packageResult and |
| 194 | cellResult and verifyResult and onosInstallResult |
| 195 | and onosIsupResult and cliResults ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 196 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 197 | utilities.assert_equals( expect=main.TRUE, actual=case1Result, |
| 198 | onpass="Test startup successful", |
| 199 | onfail="Test startup NOT successful" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 200 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 201 | if case1Result == main.FALSE: |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 202 | main.cleanup() |
| 203 | main.exit() |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 204 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 205 | def CASE2( self, main ): |
| 206 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 207 | Assign mastership to controllers |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 208 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 209 | import re |
| 210 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 211 | main.log.report( "Assigning switches to controllers" ) |
| 212 | main.case( "Assigning Controllers" ) |
| 213 | main.step( "Assign switches to controllers" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 214 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 215 | for i in range( 1, 29 ): |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 216 | main.Mininet1.assignSwController( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 217 | sw=str( i ), |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 218 | count=numControllers, |
| 219 | ip1=ONOS1Ip, port1=ONOS1Port, |
| 220 | ip2=ONOS2Ip, port2=ONOS2Port, |
| 221 | ip3=ONOS3Ip, port3=ONOS3Port, |
| 222 | ip4=ONOS4Ip, port4=ONOS4Port, |
| 223 | ip5=ONOS5Ip, port5=ONOS5Port, |
| 224 | ip6=ONOS6Ip, port6=ONOS6Port, |
| 225 | ip7=ONOS7Ip, port7=ONOS7Port ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 226 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 227 | mastershipCheck = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 228 | for i in range( 1, 29 ): |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 229 | response = main.Mininet1.getSwController( "s" + str( i ) ) |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 230 | try: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 231 | main.log.info( str( response ) ) |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 232 | except: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 233 | main.log.info( repr( response ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 234 | if re.search( "tcp:" + ONOS1Ip, response )\ |
| 235 | and re.search( "tcp:" + ONOS2Ip, response )\ |
| 236 | and re.search( "tcp:" + ONOS3Ip, response )\ |
| 237 | and re.search( "tcp:" + ONOS4Ip, response )\ |
| 238 | and re.search( "tcp:" + ONOS5Ip, response )\ |
| 239 | and re.search( "tcp:" + ONOS6Ip, response )\ |
| 240 | and re.search( "tcp:" + ONOS7Ip, response ): |
| 241 | mastershipCheck = mastershipCheck and main.TRUE |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 242 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 243 | mastershipCheck = main.FALSE |
| 244 | if mastershipCheck == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 245 | main.log.report( "Switch mastership assigned correctly" ) |
| 246 | utilities.assert_equals( |
| 247 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 248 | actual=mastershipCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 249 | onpass="Switch mastership assigned correctly", |
| 250 | onfail="Switches not assigned correctly to controllers" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 251 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 252 | # Manually assign mastership to the controller we want |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 253 | roleCall = main.TRUE |
| 254 | roleCheck = main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 255 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 256 | # Assign switch |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 257 | deviceId = main.ONOScli1.getDevice( "1000" ).get( 'id' ) |
| 258 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 259 | deviceId, |
| 260 | ONOS1Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 261 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 262 | if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 263 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 264 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 265 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 266 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 267 | # Assign switch |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 268 | deviceId = main.ONOScli1.getDevice( "2800" ).get( 'id' ) |
| 269 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 270 | deviceId, |
| 271 | ONOS1Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 272 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 273 | if ONOS1Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 274 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 275 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 276 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 277 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 278 | # Assign switch |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 279 | deviceId = main.ONOScli1.getDevice( "2000" ).get( 'id' ) |
| 280 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 281 | deviceId, |
| 282 | ONOS2Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 283 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 284 | if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 285 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 286 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 287 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 288 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 289 | # Assign switch |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 290 | deviceId = main.ONOScli1.getDevice( "3000" ).get( 'id' ) |
| 291 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 292 | deviceId, |
| 293 | ONOS2Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 294 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 295 | if ONOS2Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 296 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 297 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 298 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 299 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 300 | # Assign switch |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 301 | deviceId = main.ONOScli1.getDevice( "5000" ).get( 'id' ) |
| 302 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 303 | deviceId, |
| 304 | ONOS3Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 305 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 306 | if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 307 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 308 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 309 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 310 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 311 | # Assign switch |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 312 | deviceId = main.ONOScli1.getDevice( "6000" ).get( 'id' ) |
| 313 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 314 | deviceId, |
| 315 | ONOS3Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 316 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 317 | if ONOS3Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 318 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 319 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 320 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 321 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 322 | # Assign switch |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 323 | deviceId = main.ONOScli1.getDevice( "3004" ).get( 'id' ) |
| 324 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 325 | deviceId, |
| 326 | ONOS4Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 327 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 328 | if ONOS4Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 329 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 330 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 331 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 332 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 333 | for i in range( 8, 18 ): |
| 334 | dpid = '3' + str( i ).zfill( 3 ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 335 | deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' ) |
| 336 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 337 | deviceId, |
| 338 | ONOS5Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 339 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 340 | if ONOS5Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 341 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 342 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 343 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 344 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 345 | deviceId = main.ONOScli1.getDevice( "6007" ).get( 'id' ) |
| 346 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 347 | deviceId, |
| 348 | ONOS6Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 349 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 350 | if ONOS6Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 351 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 352 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 353 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 354 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 355 | for i in range( 18, 28 ): |
| 356 | dpid = '6' + str( i ).zfill( 3 ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 357 | deviceId = main.ONOScli1.getDevice( dpid ).get( 'id' ) |
| 358 | roleCall = roleCall and main.ONOScli1.deviceRole( |
| 359 | deviceId, |
| 360 | ONOS7Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 361 | # Check assignment |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 362 | if ONOS7Ip in main.ONOScli1.getRole( deviceId ).get( 'master' ): |
| 363 | roleCheck = roleCheck and main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 364 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 365 | roleCheck = roleCheck and main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 366 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 367 | utilities.assert_equals( |
| 368 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 369 | actual=roleCall, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 370 | onpass="Re-assigned switch mastership to designated controller", |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 371 | onfail="Something wrong with deviceRole calls" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 372 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 373 | utilities.assert_equals( |
| 374 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 375 | actual=roleCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 376 | onpass="Switches were successfully reassigned to designated " + |
| 377 | "controller", |
| 378 | onfail="Switches were not successfully reassigned" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 379 | mastershipCheck = mastershipCheck and roleCall and roleCheck |
| 380 | utilities.assert_equals( expect=main.TRUE, actual=mastershipCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 381 | onpass="Switch mastership correctly assigned", |
| 382 | onfail="Error in (re)assigning switch" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 383 | " mastership" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 384 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 385 | def CASE3( self, main ): |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 386 | """ |
| 387 | Assign intents |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 388 | """ |
| 389 | import time |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 390 | main.log.report( "Adding host intents" ) |
| 391 | main.case( "Adding host Intents" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 392 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 393 | main.step( "Discovering Hosts( Via pingall for now )" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 394 | # FIXME: Once we have a host discovery mechanism, use that instead |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 395 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 396 | # install onos-app-fwd |
| 397 | main.log.info( "Install reactive forwarding app" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 398 | main.ONOScli1.featureInstall( "onos-app-fwd" ) |
| 399 | main.ONOScli2.featureInstall( "onos-app-fwd" ) |
| 400 | main.ONOScli3.featureInstall( "onos-app-fwd" ) |
| 401 | main.ONOScli4.featureInstall( "onos-app-fwd" ) |
| 402 | main.ONOScli5.featureInstall( "onos-app-fwd" ) |
| 403 | main.ONOScli6.featureInstall( "onos-app-fwd" ) |
| 404 | main.ONOScli7.featureInstall( "onos-app-fwd" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 405 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 406 | # REACTIVE FWD test |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 407 | pingResult = main.FALSE |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 408 | time1 = time.time() |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 409 | pingResult = main.Mininet1.pingall() |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 410 | utilities.assert_equals( |
| 411 | expect=main.TRUE, |
| 412 | actual=pingResult, |
| 413 | onpass="Reactive Pingall test passed", |
| 414 | onfail="Reactive Pingall failed, one or more ping pairs failed" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 415 | time2 = time.time() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 416 | main.log.info( "Time for pingall: %2f seconds" % ( time2 - time1 ) ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 417 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 418 | # uninstall onos-app-fwd |
| 419 | main.log.info( "Uninstall reactive forwarding app" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 420 | main.ONOScli1.featureUninstall( "onos-app-fwd" ) |
| 421 | main.ONOScli2.featureUninstall( "onos-app-fwd" ) |
| 422 | main.ONOScli3.featureUninstall( "onos-app-fwd" ) |
| 423 | main.ONOScli4.featureUninstall( "onos-app-fwd" ) |
| 424 | main.ONOScli5.featureUninstall( "onos-app-fwd" ) |
| 425 | main.ONOScli6.featureUninstall( "onos-app-fwd" ) |
| 426 | main.ONOScli7.featureUninstall( "onos-app-fwd" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 427 | # timeout for fwd flows |
| 428 | time.sleep( 10 ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 429 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 430 | main.step( "Add host intents" ) |
| 431 | # TODO: move the host numbers to params |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 432 | intentAddResult = True |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 433 | for i in range( 8, 18 ): |
| 434 | main.log.info( "Adding host intent between h" + str( i ) + |
| 435 | " and h" + str( i + 10 ) ) |
| 436 | host1 = "00:00:00:00:00:" + \ |
| 437 | str( hex( i )[ 2: ] ).zfill( 2 ).upper() |
| 438 | host2 = "00:00:00:00:00:" + \ |
| 439 | str( hex( i + 10 )[ 2: ] ).zfill( 2 ).upper() |
Jon Hall | 1b8f54a | 2015-02-04 13:24:20 -0800 | [diff] [blame] | 440 | # NOTE: getHost can return None |
| 441 | host1Dict = main.ONOScli1.getHost( host1 ) |
| 442 | host2Dict = main.ONOScli1.getHost( host2 ) |
| 443 | host1Id = None |
| 444 | host2Id = None |
| 445 | if host1Dict and host2Dict: |
| 446 | host1Id = host1Dict.get( 'id', None ) |
| 447 | host2Id = host2Dict.get( 'id', None ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 448 | if host1Id and host2Id: |
| 449 | tmpResult = main.ONOScli1.addHostIntent( |
| 450 | host1Id, |
| 451 | host2Id ) |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 452 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 453 | main.log.error( "Error, getHost() failed" ) |
Jon Hall | 1b8f54a | 2015-02-04 13:24:20 -0800 | [diff] [blame] | 454 | main.log.warn( json.dumps( json.loads( main.ONOScli1.hosts() ), |
| 455 | sort_keys=True, |
| 456 | indent=4, |
| 457 | separators=( ',', ': ' ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 458 | tmpResult = main.FALSE |
| 459 | intentAddResult = bool( pingResult and intentAddResult |
| 460 | and tmpResult ) |
| 461 | # TODO Check that intents were added? |
Jon Hall | 1b8f54a | 2015-02-04 13:24:20 -0800 | [diff] [blame] | 462 | # Print the intent states |
| 463 | intents = main.ONOScli1.intents( ) |
| 464 | intentStates = [] |
| 465 | for intent in json.loads( intents ): # Iter through intents of a node |
| 466 | intentStates.append( intent.get( 'state', None ) ) |
| 467 | out = [ (i, intentStates.count( i ) ) for i in set( intentStates ) ] |
| 468 | main.log.info( dict( out ) ) |
| 469 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 470 | utilities.assert_equals( |
| 471 | expect=True, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 472 | actual=intentAddResult, |
| 473 | onpass="Pushed host intents to ONOS", |
| 474 | onfail="Error in pushing host intents to ONOS" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 475 | # TODO Check if intents all exist in datastore |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 476 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 477 | def CASE4( self, main ): |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 478 | """ |
| 479 | Ping across added host intents |
| 480 | """ |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 481 | description = " Ping across added host intents" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 482 | main.log.report( description ) |
| 483 | main.case( description ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 484 | PingResult = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 485 | for i in range( 8, 18 ): |
| 486 | ping = main.Mininet1.pingHost( |
| 487 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 488 | PingResult = PingResult and ping |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 489 | if ping == main.FALSE: |
| 490 | main.log.warn( "Ping failed between h" + str( i ) + |
| 491 | " and h" + str( i + 10 ) ) |
| 492 | elif ping == main.TRUE: |
| 493 | main.log.info( "Ping test passed!" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 494 | PingResult = main.TRUE |
| 495 | if PingResult == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 496 | main.log.report( |
| 497 | "Intents have not been installed correctly, pings failed." ) |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 498 | #TODO: pretty print |
| 499 | main.log.warn( "ONSO1 intents: " ) |
| 500 | main.log.warn( json.dumps( json.loads( main.ONOScli1.intents() ), |
| 501 | sort_keys=True, |
| 502 | indent=4, |
| 503 | separators=( ',', ': ' ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 504 | if PingResult == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 505 | main.log.report( |
| 506 | "Intents have been installed correctly and verified by pings" ) |
| 507 | utilities.assert_equals( |
| 508 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 509 | actual=PingResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 510 | onpass="Intents have been installed correctly and pings work", |
| 511 | onfail="Intents have not been installed correctly, pings failed." ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 512 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 513 | def CASE5( self, main ): |
| 514 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 515 | Reading state of ONOS |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 516 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 517 | import json |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 518 | # assumes that sts is already in you PYTHONPATH |
| 519 | from sts.topology.teston_topology import TestONTopology |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 520 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 521 | main.log.report( "Setting up and gathering data for current state" ) |
| 522 | main.case( "Setting up and gathering data for current state" ) |
| 523 | # The general idea for this test case is to pull the state of |
| 524 | # ( intents,flows, topology,... ) from each ONOS node |
| 525 | # We can then compare them with eachother and also with past states |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 526 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 527 | main.step( "Get the Mastership of each switch from each controller" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 528 | global mastershipState |
| 529 | mastershipState = [] |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 530 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 531 | # Assert that each device has a master |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 532 | ONOS1MasterNotNull = main.ONOScli1.rolesNotNull() |
| 533 | ONOS2MasterNotNull = main.ONOScli2.rolesNotNull() |
| 534 | ONOS3MasterNotNull = main.ONOScli3.rolesNotNull() |
| 535 | ONOS4MasterNotNull = main.ONOScli4.rolesNotNull() |
| 536 | ONOS5MasterNotNull = main.ONOScli5.rolesNotNull() |
| 537 | ONOS6MasterNotNull = main.ONOScli6.rolesNotNull() |
| 538 | ONOS7MasterNotNull = main.ONOScli7.rolesNotNull() |
| 539 | rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\ |
| 540 | ONOS3MasterNotNull and ONOS4MasterNotNull and\ |
| 541 | ONOS5MasterNotNull and ONOS6MasterNotNull and\ |
| 542 | ONOS7MasterNotNull |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 543 | utilities.assert_equals( |
| 544 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 545 | actual=rolesNotNull, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 546 | onpass="Each device has a master", |
| 547 | onfail="Some devices don't have a master assigned" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 548 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 549 | ONOS1Mastership = main.ONOScli1.roles() |
| 550 | ONOS2Mastership = main.ONOScli2.roles() |
| 551 | ONOS3Mastership = main.ONOScli3.roles() |
| 552 | ONOS4Mastership = main.ONOScli4.roles() |
| 553 | ONOS5Mastership = main.ONOScli5.roles() |
| 554 | ONOS6Mastership = main.ONOScli6.roles() |
| 555 | ONOS7Mastership = main.ONOScli7.roles() |
| 556 | # print json.dumps( json.loads( ONOS1Mastership ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 557 | # indent=4, separators=( ',', ': ' ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 558 | if "Error" in ONOS1Mastership or not ONOS1Mastership\ |
| 559 | or "Error" in ONOS2Mastership or not ONOS2Mastership\ |
| 560 | or "Error" in ONOS3Mastership or not ONOS3Mastership\ |
| 561 | or "Error" in ONOS4Mastership or not ONOS4Mastership\ |
| 562 | or "Error" in ONOS5Mastership or not ONOS5Mastership\ |
| 563 | or "Error" in ONOS6Mastership or not ONOS6Mastership\ |
| 564 | or "Error" in ONOS7Mastership or not ONOS7Mastership: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 565 | main.log.report( "Error in getting ONOS roles" ) |
| 566 | main.log.warn( |
| 567 | "ONOS1 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 568 | repr( ONOS1Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 569 | main.log.warn( |
| 570 | "ONOS2 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 571 | repr( ONOS2Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 572 | main.log.warn( |
| 573 | "ONOS3 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 574 | repr( ONOS3Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 575 | main.log.warn( |
| 576 | "ONOS4 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 577 | repr( ONOS4Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 578 | main.log.warn( |
| 579 | "ONOS5 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 580 | repr( ONOS5Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 581 | main.log.warn( |
| 582 | "ONOS6 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 583 | repr( ONOS6Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 584 | main.log.warn( |
| 585 | "ONOS7 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 586 | repr( ONOS7Mastership ) ) |
| 587 | consistentMastership = main.FALSE |
| 588 | elif ONOS1Mastership == ONOS2Mastership\ |
| 589 | and ONOS1Mastership == ONOS3Mastership\ |
| 590 | and ONOS1Mastership == ONOS4Mastership\ |
| 591 | and ONOS1Mastership == ONOS5Mastership\ |
| 592 | and ONOS1Mastership == ONOS6Mastership\ |
| 593 | and ONOS1Mastership == ONOS7Mastership: |
| 594 | mastershipState = ONOS1Mastership |
| 595 | consistentMastership = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 596 | main.log.report( |
| 597 | "Switch roles are consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 598 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 599 | main.log.warn( |
| 600 | "ONOS1 roles: ", |
| 601 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 602 | json.loads( ONOS1Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 603 | sort_keys=True, |
| 604 | indent=4, |
| 605 | separators=( |
| 606 | ',', |
| 607 | ': ' ) ) ) |
| 608 | main.log.warn( |
| 609 | "ONOS2 roles: ", |
| 610 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 611 | json.loads( ONOS2Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 612 | sort_keys=True, |
| 613 | indent=4, |
| 614 | separators=( |
| 615 | ',', |
| 616 | ': ' ) ) ) |
| 617 | main.log.warn( |
| 618 | "ONOS3 roles: ", |
| 619 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 620 | json.loads( ONOS3Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 621 | sort_keys=True, |
| 622 | indent=4, |
| 623 | separators=( |
| 624 | ',', |
| 625 | ': ' ) ) ) |
| 626 | main.log.warn( |
| 627 | "ONOS4 roles: ", |
| 628 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 629 | json.loads( ONOS4Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 630 | sort_keys=True, |
| 631 | indent=4, |
| 632 | separators=( |
| 633 | ',', |
| 634 | ': ' ) ) ) |
| 635 | main.log.warn( |
| 636 | "ONOS5 roles: ", |
| 637 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 638 | json.loads( ONOS5Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 639 | sort_keys=True, |
| 640 | indent=4, |
| 641 | separators=( |
| 642 | ',', |
| 643 | ': ' ) ) ) |
| 644 | main.log.warn( |
| 645 | "ONOS6 roles: ", |
| 646 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 647 | json.loads( ONOS6Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 648 | sort_keys=True, |
| 649 | indent=4, |
| 650 | separators=( |
| 651 | ',', |
| 652 | ': ' ) ) ) |
| 653 | main.log.warn( |
| 654 | "ONOS7 roles: ", |
| 655 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 656 | json.loads( ONOS7Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 657 | sort_keys=True, |
| 658 | indent=4, |
| 659 | separators=( |
| 660 | ',', |
| 661 | ': ' ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 662 | consistentMastership = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 663 | utilities.assert_equals( |
| 664 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 665 | actual=consistentMastership, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 666 | onpass="Switch roles are consistent across all ONOS nodes", |
| 667 | onfail="ONOS nodes have different views of switch roles" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 668 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 669 | main.step( "Get the intents from each controller" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 670 | global intentState |
| 671 | intentState = [] |
| 672 | ONOS1Intents = main.ONOScli1.intents( jsonFormat=True ) |
| 673 | ONOS2Intents = main.ONOScli2.intents( jsonFormat=True ) |
| 674 | ONOS3Intents = main.ONOScli3.intents( jsonFormat=True ) |
| 675 | ONOS4Intents = main.ONOScli4.intents( jsonFormat=True ) |
| 676 | ONOS5Intents = main.ONOScli5.intents( jsonFormat=True ) |
| 677 | ONOS6Intents = main.ONOScli6.intents( jsonFormat=True ) |
| 678 | ONOS7Intents = main.ONOScli7.intents( jsonFormat=True ) |
| 679 | intentCheck = main.FALSE |
| 680 | if "Error" in ONOS1Intents or not ONOS1Intents\ |
| 681 | or "Error" in ONOS2Intents or not ONOS2Intents\ |
| 682 | or "Error" in ONOS3Intents or not ONOS3Intents\ |
| 683 | or "Error" in ONOS4Intents or not ONOS4Intents\ |
| 684 | or "Error" in ONOS5Intents or not ONOS5Intents\ |
| 685 | or "Error" in ONOS6Intents or not ONOS6Intents\ |
| 686 | or "Error" in ONOS7Intents or not ONOS7Intents: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 687 | main.log.report( "Error in getting ONOS intents" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 688 | main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) ) |
| 689 | main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) ) |
| 690 | main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) ) |
| 691 | main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) ) |
| 692 | main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) ) |
| 693 | main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) ) |
| 694 | main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) ) |
| 695 | elif ONOS1Intents == ONOS2Intents\ |
| 696 | and ONOS1Intents == ONOS3Intents\ |
| 697 | and ONOS1Intents == ONOS4Intents\ |
| 698 | and ONOS1Intents == ONOS5Intents\ |
| 699 | and ONOS1Intents == ONOS6Intents\ |
| 700 | and ONOS1Intents == ONOS7Intents: |
| 701 | intentState = ONOS1Intents |
| 702 | intentCheck = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 703 | main.log.report( "Intents are consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 704 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 705 | main.log.warn( |
| 706 | "ONOS1 intents: ", |
| 707 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 708 | json.loads( ONOS1Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 709 | sort_keys=True, |
| 710 | indent=4, |
| 711 | separators=( |
| 712 | ',', |
| 713 | ': ' ) ) ) |
| 714 | main.log.warn( |
| 715 | "ONOS2 intents: ", |
| 716 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 717 | json.loads( ONOS2Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 718 | sort_keys=True, |
| 719 | indent=4, |
| 720 | separators=( |
| 721 | ',', |
| 722 | ': ' ) ) ) |
| 723 | main.log.warn( |
| 724 | "ONOS3 intents: ", |
| 725 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 726 | json.loads( ONOS3Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 727 | sort_keys=True, |
| 728 | indent=4, |
| 729 | separators=( |
| 730 | ',', |
| 731 | ': ' ) ) ) |
| 732 | main.log.warn( |
| 733 | "ONOS4 intents: ", |
| 734 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 735 | json.loads( ONOS4Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 736 | sort_keys=True, |
| 737 | indent=4, |
| 738 | separators=( |
| 739 | ',', |
| 740 | ': ' ) ) ) |
| 741 | main.log.warn( |
| 742 | "ONOS5 intents: ", |
| 743 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 744 | json.loads( ONOS5Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 745 | sort_keys=True, |
| 746 | indent=4, |
| 747 | separators=( |
| 748 | ',', |
| 749 | ': ' ) ) ) |
| 750 | main.log.warn( |
| 751 | "ONOS6 intents: ", |
| 752 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 753 | json.loads( ONOS6Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 754 | sort_keys=True, |
| 755 | indent=4, |
| 756 | separators=( |
| 757 | ',', |
| 758 | ': ' ) ) ) |
| 759 | main.log.warn( |
| 760 | "ONOS7 intents: ", |
| 761 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 762 | json.loads( ONOS7Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 763 | sort_keys=True, |
| 764 | indent=4, |
| 765 | separators=( |
| 766 | ',', |
| 767 | ': ' ) ) ) |
| 768 | utilities.assert_equals( |
| 769 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 770 | actual=intentCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 771 | onpass="Intents are consistent across all ONOS nodes", |
| 772 | onfail="ONOS nodes have different views of intents" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 773 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 774 | main.step( "Get the flows from each controller" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 775 | global flowState |
| 776 | flowState = [] |
| 777 | ONOS1Flows = main.ONOScli1.flows( jsonFormat=True ) |
| 778 | ONOS2Flows = main.ONOScli2.flows( jsonFormat=True ) |
| 779 | ONOS3Flows = main.ONOScli3.flows( jsonFormat=True ) |
| 780 | ONOS4Flows = main.ONOScli4.flows( jsonFormat=True ) |
| 781 | ONOS5Flows = main.ONOScli5.flows( jsonFormat=True ) |
| 782 | ONOS6Flows = main.ONOScli6.flows( jsonFormat=True ) |
| 783 | ONOS7Flows = main.ONOScli7.flows( jsonFormat=True ) |
| 784 | ONOS1FlowsJson = json.loads( ONOS1Flows ) |
| 785 | ONOS2FlowsJson = json.loads( ONOS2Flows ) |
| 786 | ONOS3FlowsJson = json.loads( ONOS3Flows ) |
| 787 | ONOS4FlowsJson = json.loads( ONOS4Flows ) |
| 788 | ONOS5FlowsJson = json.loads( ONOS5Flows ) |
| 789 | ONOS6FlowsJson = json.loads( ONOS6Flows ) |
| 790 | ONOS7FlowsJson = json.loads( ONOS7Flows ) |
| 791 | flowCheck = main.FALSE |
| 792 | if "Error" in ONOS1Flows or not ONOS1Flows\ |
| 793 | or "Error" in ONOS2Flows or not ONOS2Flows\ |
| 794 | or "Error" in ONOS3Flows or not ONOS3Flows\ |
| 795 | or "Error" in ONOS4Flows or not ONOS4Flows\ |
| 796 | or "Error" in ONOS5Flows or not ONOS5Flows\ |
| 797 | or "Error" in ONOS6Flows or not ONOS6Flows\ |
| 798 | or "Error" in ONOS7Flows or not ONOS7Flows: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 799 | main.log.report( "Error in getting ONOS intents" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 800 | main.log.warn( "ONOS1 flows repsponse: " + ONOS1Flows ) |
| 801 | main.log.warn( "ONOS2 flows repsponse: " + ONOS2Flows ) |
| 802 | main.log.warn( "ONOS3 flows repsponse: " + ONOS3Flows ) |
| 803 | main.log.warn( "ONOS4 flows repsponse: " + ONOS4Flows ) |
| 804 | main.log.warn( "ONOS5 flows repsponse: " + ONOS5Flows ) |
| 805 | main.log.warn( "ONOS6 flows repsponse: " + ONOS6Flows ) |
| 806 | main.log.warn( "ONOS7 flows repsponse: " + ONOS7Flows ) |
| 807 | elif len( ONOS1FlowsJson ) == len( ONOS2FlowsJson )\ |
| 808 | and len( ONOS1FlowsJson ) == len( ONOS3FlowsJson )\ |
| 809 | and len( ONOS1FlowsJson ) == len( ONOS4FlowsJson )\ |
| 810 | and len( ONOS1FlowsJson ) == len( ONOS5FlowsJson )\ |
| 811 | and len( ONOS1FlowsJson ) == len( ONOS6FlowsJson )\ |
| 812 | and len( ONOS1FlowsJson ) == len( ONOS7FlowsJson ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 813 | # TODO: Do a better check, maybe compare flows on switches? |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 814 | flowState = ONOS1Flows |
| 815 | flowCheck = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 816 | main.log.report( "Flow count is consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 817 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 818 | main.log.warn( "ONOS1 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 819 | json.dumps( ONOS1FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 820 | indent=4, separators=( ',', ': ' ) ) ) |
| 821 | main.log.warn( "ONOS2 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 822 | json.dumps( ONOS2FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 823 | indent=4, separators=( ',', ': ' ) ) ) |
| 824 | main.log.warn( "ONOS3 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 825 | json.dumps( ONOS3FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 826 | indent=4, separators=( ',', ': ' ) ) ) |
| 827 | main.log.warn( "ONOS4 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 828 | json.dumps( ONOS4FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 829 | indent=4, separators=( ',', ': ' ) ) ) |
| 830 | main.log.warn( "ONOS5 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 831 | json.dumps( ONOS5FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 832 | indent=4, separators=( ',', ': ' ) ) ) |
| 833 | main.log.warn( "ONOS6 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 834 | json.dumps( ONOS6FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 835 | indent=4, separators=( ',', ': ' ) ) ) |
| 836 | main.log.warn( "ONOS7 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 837 | json.dumps( ONOS7FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 838 | indent=4, separators=( ',', ': ' ) ) ) |
| 839 | utilities.assert_equals( |
| 840 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 841 | actual=flowCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 842 | onpass="The flow count is consistent across all ONOS nodes", |
| 843 | onfail="ONOS nodes have different flow counts" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 844 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 845 | main.step( "Get the OF Table entries" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 846 | global flows |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 847 | flows = [] |
| 848 | for i in range( 1, 29 ): |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 849 | flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 850 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 851 | # TODO: Compare switch flow tables with ONOS flow tables |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 852 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 853 | main.step( "Start continuous pings" ) |
| 854 | main.Mininet2.pingLong( |
| 855 | src=main.params[ 'PING' ][ 'source1' ], |
| 856 | target=main.params[ 'PING' ][ 'target1' ], |
| 857 | pingTime=500 ) |
| 858 | main.Mininet2.pingLong( |
| 859 | src=main.params[ 'PING' ][ 'source2' ], |
| 860 | target=main.params[ 'PING' ][ 'target2' ], |
| 861 | pingTime=500 ) |
| 862 | main.Mininet2.pingLong( |
| 863 | src=main.params[ 'PING' ][ 'source3' ], |
| 864 | target=main.params[ 'PING' ][ 'target3' ], |
| 865 | pingTime=500 ) |
| 866 | main.Mininet2.pingLong( |
| 867 | src=main.params[ 'PING' ][ 'source4' ], |
| 868 | target=main.params[ 'PING' ][ 'target4' ], |
| 869 | pingTime=500 ) |
| 870 | main.Mininet2.pingLong( |
| 871 | src=main.params[ 'PING' ][ 'source5' ], |
| 872 | target=main.params[ 'PING' ][ 'target5' ], |
| 873 | pingTime=500 ) |
| 874 | main.Mininet2.pingLong( |
| 875 | src=main.params[ 'PING' ][ 'source6' ], |
| 876 | target=main.params[ 'PING' ][ 'target6' ], |
| 877 | pingTime=500 ) |
| 878 | main.Mininet2.pingLong( |
| 879 | src=main.params[ 'PING' ][ 'source7' ], |
| 880 | target=main.params[ 'PING' ][ 'target7' ], |
| 881 | pingTime=500 ) |
| 882 | main.Mininet2.pingLong( |
| 883 | src=main.params[ 'PING' ][ 'source8' ], |
| 884 | target=main.params[ 'PING' ][ 'target8' ], |
| 885 | pingTime=500 ) |
| 886 | main.Mininet2.pingLong( |
| 887 | src=main.params[ 'PING' ][ 'source9' ], |
| 888 | target=main.params[ 'PING' ][ 'target9' ], |
| 889 | pingTime=500 ) |
| 890 | main.Mininet2.pingLong( |
| 891 | src=main.params[ 'PING' ][ 'source10' ], |
| 892 | target=main.params[ 'PING' ][ 'target10' ], |
| 893 | pingTime=500 ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 894 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 895 | main.step( "Create TestONTopology object" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 896 | ctrls = [] |
| 897 | count = 1 |
| 898 | while True: |
| 899 | temp = () |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 900 | if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]: |
| 901 | temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), ) |
| 902 | temp = temp + ( "ONOS" + str( count ), ) |
| 903 | temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], ) |
| 904 | temp = temp + \ |
| 905 | ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), ) |
| 906 | ctrls.append( temp ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 907 | count = count + 1 |
| 908 | else: |
| 909 | break |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 910 | MNTopo = TestONTopology( |
| 911 | main.Mininet1, |
| 912 | ctrls ) # can also add Intent API info for intent operations |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 913 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 914 | main.step( "Collecting topology information from ONOS" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 915 | devices = [] |
| 916 | devices.append( main.ONOScli1.devices() ) |
| 917 | devices.append( main.ONOScli2.devices() ) |
| 918 | devices.append( main.ONOScli3.devices() ) |
| 919 | devices.append( main.ONOScli4.devices() ) |
| 920 | devices.append( main.ONOScli5.devices() ) |
| 921 | devices.append( main.ONOScli6.devices() ) |
| 922 | devices.append( main.ONOScli7.devices() ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 923 | hosts = [] |
| 924 | hosts.append( main.ONOScli1.hosts() ) |
| 925 | hosts.append( main.ONOScli2.hosts() ) |
| 926 | hosts.append( main.ONOScli3.hosts() ) |
| 927 | hosts.append( main.ONOScli4.hosts() ) |
| 928 | hosts.append( main.ONOScli5.hosts() ) |
| 929 | hosts.append( main.ONOScli6.hosts() ) |
| 930 | hosts.append( main.ONOScli7.hosts() ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 931 | ports = [] |
| 932 | ports.append( main.ONOScli1.ports() ) |
| 933 | ports.append( main.ONOScli2.ports() ) |
| 934 | ports.append( main.ONOScli3.ports() ) |
| 935 | ports.append( main.ONOScli4.ports() ) |
| 936 | ports.append( main.ONOScli5.ports() ) |
| 937 | ports.append( main.ONOScli6.ports() ) |
| 938 | ports.append( main.ONOScli7.ports() ) |
| 939 | links = [] |
| 940 | links.append( main.ONOScli1.links() ) |
| 941 | links.append( main.ONOScli2.links() ) |
| 942 | links.append( main.ONOScli3.links() ) |
| 943 | links.append( main.ONOScli4.links() ) |
| 944 | links.append( main.ONOScli5.links() ) |
| 945 | links.append( main.ONOScli6.links() ) |
| 946 | links.append( main.ONOScli7.links() ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 947 | clusters = [] |
| 948 | clusters.append( main.ONOScli1.clusters() ) |
| 949 | clusters.append( main.ONOScli2.clusters() ) |
| 950 | clusters.append( main.ONOScli3.clusters() ) |
| 951 | clusters.append( main.ONOScli4.clusters() ) |
| 952 | clusters.append( main.ONOScli5.clusters() ) |
| 953 | clusters.append( main.ONOScli6.clusters() ) |
| 954 | clusters.append( main.ONOScli7.clusters() ) |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 955 | # Compare json objects for hosts and dataplane clusters |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 956 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 957 | # hosts |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 958 | consistentHostsResult = main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 959 | for controller in range( len( hosts ) ): |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 960 | controllerStr = str( controller + 1 ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 961 | if "Error" not in hosts[ controller ]: |
| 962 | if hosts[ controller ] == hosts[ 0 ]: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 963 | continue |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 964 | else: # hosts not consistent |
| 965 | main.log.report( "hosts from ONOS" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 966 | controllerStr + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 967 | " is inconsistent with ONOS1" ) |
| 968 | main.log.warn( repr( hosts[ controller ] ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 969 | consistentHostsResult = main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 970 | |
| 971 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 972 | main.log.report( "Error in getting ONOS hosts from ONOS" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 973 | controllerStr ) |
| 974 | consistentHostsResult = main.FALSE |
| 975 | main.log.warn( "ONOS" + controllerStr + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 976 | " hosts response: " + |
| 977 | repr( hosts[ controller ] ) ) |
| 978 | utilities.assert_equals( |
| 979 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 980 | actual=consistentHostsResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 981 | onpass="Hosts view is consistent across all ONOS nodes", |
| 982 | onfail="ONOS nodes have different views of hosts" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 983 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 984 | # Strongly connected clusters of devices |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 985 | consistentClustersResult = main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 986 | for controller in range( len( clusters ) ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 987 | if "Error" not in clusters[ controller ]: |
| 988 | if clusters[ controller ] == clusters[ 0 ]: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 989 | continue |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 990 | else: # clusters not consistent |
| 991 | main.log.report( "clusters from ONOS" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 992 | controllerStr + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 993 | " is inconsistent with ONOS1" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 994 | consistentClustersResult = main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 995 | |
| 996 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 997 | main.log.report( "Error in getting dataplane clusters " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 998 | "from ONOS" + controllerStr ) |
| 999 | consistentClustersResult = main.FALSE |
| 1000 | main.log.warn( "ONOS" + controllerStr + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1001 | " clusters response: " + |
| 1002 | repr( clusters[ controller ] ) ) |
| 1003 | utilities.assert_equals( |
| 1004 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1005 | actual=consistentClustersResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1006 | onpass="Clusters view is consistent across all ONOS nodes", |
| 1007 | onfail="ONOS nodes have different views of clusters" ) |
| 1008 | # there should always only be one cluster |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1009 | numClusters = len( json.loads( clusters[ 0 ] ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1010 | utilities.assert_equals( |
| 1011 | expect=1, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1012 | actual=numClusters, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1013 | onpass="ONOS shows 1 SCC", |
| 1014 | onfail="ONOS shows " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1015 | str( numClusters ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1016 | " SCCs" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1017 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1018 | main.step( "Comparing ONOS topology to MN" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1019 | devicesResults = main.TRUE |
| 1020 | portsResults = main.TRUE |
| 1021 | linksResults = main.TRUE |
| 1022 | for controller in range( numControllers ): |
| 1023 | controllerStr = str( controller + 1 ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1024 | if devices[ controller ] or "Error" not in devices[ controller ]: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1025 | currentDevicesResult = main.Mininet1.compareSwitches( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1026 | MNTopo, |
| 1027 | json.loads( |
| 1028 | devices[ controller ] ) ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1029 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1030 | currentDevicesResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1031 | utilities.assert_equals( expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1032 | actual=currentDevicesResult, |
| 1033 | onpass="ONOS" + controllerStr + |
| 1034 | " Switches view is correct", |
| 1035 | onfail="ONOS" + controllerStr + |
| 1036 | " Switches view is incorrect" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1037 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1038 | if ports[ controller ] or "Error" not in ports[ controller ]: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1039 | currentPortsResult = main.Mininet1.comparePorts( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1040 | MNTopo, |
| 1041 | json.loads( |
| 1042 | ports[ controller ] ) ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1043 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1044 | currentPortsResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1045 | utilities.assert_equals( expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1046 | actual=currentPortsResult, |
| 1047 | onpass="ONOS" + controllerStr + |
| 1048 | " ports view is correct", |
| 1049 | onfail="ONOS" + controllerStr + |
| 1050 | " ports view is incorrect" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1051 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1052 | if links[ controller ] or "Error" not in links[ controller ]: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1053 | currentLinksResult = main.Mininet1.compareLinks( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1054 | MNTopo, |
| 1055 | json.loads( |
| 1056 | links[ controller ] ) ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1057 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1058 | currentLinksResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1059 | utilities.assert_equals( expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1060 | actual=currentLinksResult, |
| 1061 | onpass="ONOS" + controllerStr + |
| 1062 | " links view is correct", |
| 1063 | onfail="ONOS" + controllerStr + |
| 1064 | " links view is incorrect" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1065 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1066 | devicesResults = devicesResults and currentDevicesResult |
| 1067 | portsResults = portsResults and currentPortsResult |
| 1068 | linksResults = linksResults and currentLinksResult |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1069 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1070 | topoResult = devicesResults and portsResults and linksResults\ |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1071 | and consistentHostsResult and consistentClustersResult |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1072 | utilities.assert_equals( expect=main.TRUE, actual=topoResult, |
| 1073 | onpass="Topology Check Test successful", |
| 1074 | onfail="Topology Check Test NOT successful" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1075 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1076 | finalAssert = main.TRUE |
| 1077 | finalAssert = finalAssert and topoResult and flowCheck \ |
| 1078 | and intentCheck and consistentMastership and rolesNotNull |
| 1079 | utilities.assert_equals( expect=main.TRUE, actual=finalAssert, |
| 1080 | onpass="State check successful", |
| 1081 | onfail="State check NOT successful" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1082 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1083 | def CASE6( self, main ): |
| 1084 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1085 | The Failure case. Since this is the Sanity test, we do nothing. |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1086 | """ |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 1087 | import time |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1088 | main.log.report( "Wait 60 seconds instead of inducing a failure" ) |
| 1089 | time.sleep( 60 ) |
| 1090 | utilities.assert_equals( |
| 1091 | expect=main.TRUE, |
| 1092 | actual=main.TRUE, |
| 1093 | onpass="Sleeping 60 seconds", |
| 1094 | onfail="Something is terribly wrong with my math" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1095 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1096 | def CASE7( self, main ): |
| 1097 | """ |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 1098 | Check state after ONOS failure |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1099 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1100 | import json |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1101 | main.case( "Running ONOS Constant State Tests" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1102 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1103 | # Assert that each device has a master |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1104 | ONOS1MasterNotNull = main.ONOScli1.rolesNotNull() |
| 1105 | ONOS2MasterNotNull = main.ONOScli2.rolesNotNull() |
| 1106 | ONOS3MasterNotNull = main.ONOScli3.rolesNotNull() |
| 1107 | ONOS4MasterNotNull = main.ONOScli4.rolesNotNull() |
| 1108 | ONOS5MasterNotNull = main.ONOScli5.rolesNotNull() |
| 1109 | ONOS6MasterNotNull = main.ONOScli6.rolesNotNull() |
| 1110 | ONOS7MasterNotNull = main.ONOScli7.rolesNotNull() |
| 1111 | rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\ |
| 1112 | ONOS3MasterNotNull and ONOS4MasterNotNull and\ |
| 1113 | ONOS5MasterNotNull and ONOS6MasterNotNull and\ |
| 1114 | ONOS7MasterNotNull |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1115 | utilities.assert_equals( |
| 1116 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1117 | actual=rolesNotNull, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1118 | onpass="Each device has a master", |
| 1119 | onfail="Some devices don't have a master assigned" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1120 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1121 | main.step( "Check if switch roles are consistent across all nodes" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1122 | ONOS1Mastership = main.ONOScli1.roles() |
| 1123 | ONOS2Mastership = main.ONOScli2.roles() |
| 1124 | ONOS3Mastership = main.ONOScli3.roles() |
| 1125 | ONOS4Mastership = main.ONOScli4.roles() |
| 1126 | ONOS5Mastership = main.ONOScli5.roles() |
| 1127 | ONOS6Mastership = main.ONOScli6.roles() |
| 1128 | ONOS7Mastership = main.ONOScli7.roles() |
| 1129 | # print json.dumps( json.loads( ONOS1Mastership ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1130 | # indent=4, separators=( ',', ': ' ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1131 | if "Error" in ONOS1Mastership or not ONOS1Mastership\ |
| 1132 | or "Error" in ONOS2Mastership or not ONOS2Mastership\ |
| 1133 | or "Error" in ONOS3Mastership or not ONOS3Mastership\ |
| 1134 | or "Error" in ONOS4Mastership or not ONOS4Mastership\ |
| 1135 | or "Error" in ONOS5Mastership or not ONOS5Mastership\ |
| 1136 | or "Error" in ONOS6Mastership or not ONOS6Mastership\ |
| 1137 | or "Error" in ONOS7Mastership or not ONOS7Mastership: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1138 | main.log.error( "Error in getting ONOS mastership" ) |
| 1139 | main.log.warn( "ONOS1 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1140 | repr( ONOS1Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1141 | main.log.warn( "ONOS2 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1142 | repr( ONOS2Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1143 | main.log.warn( "ONOS3 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1144 | repr( ONOS3Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1145 | main.log.warn( "ONOS4 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1146 | repr( ONOS4Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1147 | main.log.warn( "ONOS5 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1148 | repr( ONOS5Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1149 | main.log.warn( "ONOS6 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1150 | repr( ONOS6Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1151 | main.log.warn( "ONOS7 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1152 | repr( ONOS7Mastership ) ) |
| 1153 | consistentMastership = main.FALSE |
| 1154 | elif ONOS1Mastership == ONOS2Mastership\ |
| 1155 | and ONOS1Mastership == ONOS3Mastership\ |
| 1156 | and ONOS1Mastership == ONOS4Mastership\ |
| 1157 | and ONOS1Mastership == ONOS5Mastership\ |
| 1158 | and ONOS1Mastership == ONOS6Mastership\ |
| 1159 | and ONOS1Mastership == ONOS7Mastership: |
| 1160 | consistentMastership = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1161 | main.log.report( |
| 1162 | "Switch roles are consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1163 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1164 | main.log.warn( "ONOS1 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1165 | json.loads( ONOS1Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1166 | separators=( ',', ': ' ) ) ) |
| 1167 | main.log.warn( "ONOS2 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1168 | json.loads( ONOS2Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1169 | separators=( ',', ': ' ) ) ) |
| 1170 | main.log.warn( "ONOS3 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1171 | json.loads( ONOS3Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1172 | separators=( ',', ': ' ) ) ) |
| 1173 | main.log.warn( "ONOS4 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1174 | json.loads( ONOS4Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1175 | separators=( ',', ': ' ) ) ) |
| 1176 | main.log.warn( "ONOS5 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1177 | json.loads( ONOS5Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1178 | separators=( ',', ': ' ) ) ) |
| 1179 | main.log.warn( "ONOS6 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1180 | json.loads( ONOS6Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1181 | separators=( ',', ': ' ) ) ) |
| 1182 | main.log.warn( "ONOS7 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1183 | json.loads( ONOS7Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1184 | separators=( ',', ': ' ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1185 | consistentMastership = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1186 | utilities.assert_equals( |
| 1187 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1188 | actual=consistentMastership, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1189 | onpass="Switch roles are consistent across all ONOS nodes", |
| 1190 | onfail="ONOS nodes have different views of switch roles" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1191 | |
| 1192 | description2 = "Compare switch roles from before failure" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1193 | main.step( description2 ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1194 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1195 | currentJson = json.loads( ONOS1Mastership ) |
| 1196 | oldJson = json.loads( mastershipState ) |
| 1197 | mastershipCheck = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1198 | for i in range( 1, 29 ): |
| 1199 | switchDPID = str( |
| 1200 | main.Mininet1.getSwitchDPID( |
| 1201 | switch="s" + |
| 1202 | str( i ) ) ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1203 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1204 | current = [ switch[ 'master' ] for switch in currentJson |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1205 | if switchDPID in switch[ 'id' ] ] |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1206 | old = [ switch[ 'master' ] for switch in oldJson |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1207 | if switchDPID in switch[ 'id' ] ] |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1208 | if current == old: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1209 | mastershipCheck = mastershipCheck and main.TRUE |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1210 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1211 | main.log.warn( "Mastership of switch %s changed" % switchDPID ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1212 | mastershipCheck = main.FALSE |
| 1213 | if mastershipCheck == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1214 | main.log.report( "Mastership of Switches was not changed" ) |
| 1215 | utilities.assert_equals( |
| 1216 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1217 | actual=mastershipCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1218 | onpass="Mastership of Switches was not changed", |
| 1219 | onfail="Mastership of some switches changed" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1220 | mastershipCheck = mastershipCheck and consistentMastership |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1221 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1222 | main.step( "Get the intents and compare across all nodes" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1223 | ONOS1Intents = main.ONOScli1.intents( jsonFormat=True ) |
| 1224 | ONOS2Intents = main.ONOScli2.intents( jsonFormat=True ) |
| 1225 | ONOS3Intents = main.ONOScli3.intents( jsonFormat=True ) |
| 1226 | ONOS4Intents = main.ONOScli4.intents( jsonFormat=True ) |
| 1227 | ONOS5Intents = main.ONOScli5.intents( jsonFormat=True ) |
| 1228 | ONOS6Intents = main.ONOScli6.intents( jsonFormat=True ) |
| 1229 | ONOS7Intents = main.ONOScli7.intents( jsonFormat=True ) |
| 1230 | intentCheck = main.FALSE |
| 1231 | if "Error" in ONOS1Intents or not ONOS1Intents\ |
| 1232 | or "Error" in ONOS2Intents or not ONOS2Intents\ |
| 1233 | or "Error" in ONOS3Intents or not ONOS3Intents\ |
| 1234 | or "Error" in ONOS4Intents or not ONOS4Intents\ |
| 1235 | or "Error" in ONOS5Intents or not ONOS5Intents\ |
| 1236 | or "Error" in ONOS6Intents or not ONOS6Intents\ |
| 1237 | or "Error" in ONOS7Intents or not ONOS7Intents: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1238 | main.log.report( "Error in getting ONOS intents" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1239 | main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) ) |
| 1240 | main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) ) |
| 1241 | main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) ) |
| 1242 | main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) ) |
| 1243 | main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) ) |
| 1244 | main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) ) |
| 1245 | main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) ) |
| 1246 | elif ONOS1Intents == ONOS2Intents\ |
| 1247 | and ONOS1Intents == ONOS3Intents\ |
| 1248 | and ONOS1Intents == ONOS4Intents\ |
| 1249 | and ONOS1Intents == ONOS5Intents\ |
| 1250 | and ONOS1Intents == ONOS6Intents\ |
| 1251 | and ONOS1Intents == ONOS7Intents: |
| 1252 | intentCheck = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1253 | main.log.report( "Intents are consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1254 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1255 | main.log.warn( "ONOS1 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1256 | print json.dumps( json.loads( ONOS1Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1257 | indent=4, separators=( ',', ': ' ) ) |
| 1258 | main.log.warn( "ONOS2 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1259 | print json.dumps( json.loads( ONOS2Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1260 | indent=4, separators=( ',', ': ' ) ) |
| 1261 | main.log.warn( "ONOS3 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1262 | print json.dumps( json.loads( ONOS3Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1263 | indent=4, separators=( ',', ': ' ) ) |
| 1264 | main.log.warn( "ONOS4 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1265 | print json.dumps( json.loads( ONOS4Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1266 | indent=4, separators=( ',', ': ' ) ) |
| 1267 | main.log.warn( "ONOS5 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1268 | print json.dumps( json.loads( ONOS5Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1269 | indent=4, separators=( ',', ': ' ) ) |
| 1270 | main.log.warn( "ONOS6 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1271 | print json.dumps( json.loads( ONOS6Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1272 | indent=4, separators=( ',', ': ' ) ) |
| 1273 | main.log.warn( "ONOS7 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1274 | print json.dumps( json.loads( ONOS7Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1275 | indent=4, separators=( ',', ': ' ) ) |
| 1276 | utilities.assert_equals( |
| 1277 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1278 | actual=intentCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1279 | onpass="Intents are consistent across all ONOS nodes", |
| 1280 | onfail="ONOS nodes have different views of intents" ) |
Jon Hall | 1b8f54a | 2015-02-04 13:24:20 -0800 | [diff] [blame] | 1281 | # Print the intent states |
| 1282 | intents = [] |
| 1283 | intents.append( ONOS1Intents ) |
| 1284 | intents.append( ONOS2Intents ) |
| 1285 | intents.append( ONOS3Intents ) |
| 1286 | intents.append( ONOS4Intents ) |
| 1287 | intents.append( ONOS5Intents ) |
| 1288 | intents.append( ONOS6Intents ) |
| 1289 | intents.append( ONOS7Intents ) |
| 1290 | intentStates = [] |
| 1291 | for node in intents: # Iter through ONOS nodes |
| 1292 | nodeStates = [] |
| 1293 | for intent in json.loads( node ): # Iter through intents of a node |
| 1294 | nodeStates.append( intent[ 'state' ] ) |
| 1295 | intentStates.append( nodeStates ) |
| 1296 | out = [ (i, nodeStates.count( i ) ) for i in set( nodeStates ) ] |
| 1297 | main.log.info( dict( out ) ) |
| 1298 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1299 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1300 | # NOTE: Hazelcast has no durability, so intents are lost across system |
| 1301 | # restarts |
| 1302 | main.step( "Compare current intents with intents before the failure" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1303 | # NOTE: this requires case 5 to pass for intentState to be set. |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1304 | # maybe we should stop the test if that fails? |
Jon Hall | 1b8f54a | 2015-02-04 13:24:20 -0800 | [diff] [blame] | 1305 | sameIntents = main.TRUE |
| 1306 | if intentState and intentState == ONOS1Intents: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1307 | sameIntents = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1308 | main.log.report( "Intents are consistent with before failure" ) |
| 1309 | # TODO: possibly the states have changed? we may need to figure out |
| 1310 | # what the aceptable states are |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1311 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1312 | try: |
| 1313 | main.log.warn( "ONOS1 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1314 | print json.dumps( json.loads( ONOS1Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1315 | sort_keys=True, indent=4, |
| 1316 | separators=( ',', ': ' ) ) |
| 1317 | except: |
| 1318 | pass |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1319 | sameIntents = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1320 | utilities.assert_equals( |
| 1321 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1322 | actual=sameIntents, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1323 | onpass="Intents are consistent with before failure", |
| 1324 | onfail="The Intents changed during failure" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1325 | intentCheck = intentCheck and sameIntents |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1326 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1327 | main.step( "Get the OF Table entries and compare to before " + |
| 1328 | "component failure" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1329 | FlowTables = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1330 | flows2 = [] |
| 1331 | for i in range( 28 ): |
| 1332 | main.log.info( "Checking flow table on s" + str( i + 1 ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1333 | tmpFlows = main.Mininet2.getFlowTable( 1.3, "s" + str( i + 1 ) ) |
| 1334 | flows2.append( tmpFlows ) |
| 1335 | tempResult = main.Mininet2.flowComp( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1336 | flow1=flows[ i ], |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1337 | flow2=tmpFlows ) |
| 1338 | FlowTables = FlowTables and tempResult |
| 1339 | if FlowTables == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1340 | main.log.info( "Differences in flow table for switch: s" + |
| 1341 | str( i + 1 ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1342 | if FlowTables == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1343 | main.log.report( "No changes were found in the flow tables" ) |
| 1344 | utilities.assert_equals( |
| 1345 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1346 | actual=FlowTables, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1347 | onpass="No changes were found in the flow tables", |
| 1348 | onfail="Changes were found in the flow tables" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1349 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1350 | main.step( "Check the continuous pings to ensure that no packets " + |
| 1351 | "were dropped during component failure" ) |
| 1352 | # FIXME: This check is always failing. Investigate cause |
| 1353 | # NOTE: this may be something to do with file permsissions |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1354 | # or slight change in format |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1355 | main.Mininet2.pingKill( |
| 1356 | main.params[ 'TESTONUSER' ], |
| 1357 | main.params[ 'TESTONIP' ] ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1358 | LossInPings = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1359 | # NOTE: checkForLoss returns main.FALSE with 0% packet loss |
| 1360 | for i in range( 8, 18 ): |
| 1361 | main.log.info( |
| 1362 | "Checking for a loss in pings along flow from s" + |
| 1363 | str( i ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1364 | LossInPings = main.Mininet2.checkForLoss( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1365 | "/tmp/ping.h" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1366 | str( i ) ) or LossInPings |
| 1367 | if LossInPings == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1368 | main.log.info( "Loss in ping detected" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1369 | elif LossInPings == main.ERROR: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1370 | main.log.info( "There are multiple mininet process running" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1371 | elif LossInPings == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1372 | main.log.info( "No Loss in the pings" ) |
| 1373 | main.log.report( "No loss of dataplane connectivity" ) |
| 1374 | utilities.assert_equals( |
| 1375 | expect=main.FALSE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1376 | actual=LossInPings, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1377 | onpass="No Loss of connectivity", |
| 1378 | onfail="Loss of dataplane connectivity detected" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1379 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1380 | # Test of LeadershipElection |
| 1381 | # NOTE: this only works for the sanity test. In case of failures, |
| 1382 | # leader will likely change |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1383 | leader = ONOS1Ip |
| 1384 | leaderResult = main.TRUE |
| 1385 | for controller in range( 1, numControllers + 1 ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1386 | # loop through ONOScli handlers |
| 1387 | node = getattr( main, ( 'ONOScli' + str( controller ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1388 | leaderN = node.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1389 | # verify leader is ONOS1 |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1390 | if leaderN == leader: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1391 | # all is well |
| 1392 | # NOTE: In failure scenario, this could be a new node, maybe |
| 1393 | # check != ONOS1 |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1394 | pass |
| 1395 | elif leaderN == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1396 | # error in response |
| 1397 | main.log.report( "Something is wrong with " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1398 | "electionTestLeader function," + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1399 | " check the error logs" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1400 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1401 | elif leader != leaderN: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1402 | leaderResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1403 | main.log.report( "ONOS" + str( controller ) + " sees " + |
| 1404 | str( leaderN ) + |
| 1405 | " as the leader of the election app. " + |
| 1406 | "Leader should be " + str( leader ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1407 | if leaderResult: |
| 1408 | main.log.report( "Leadership election tests passed( consistent " + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1409 | "view of leader across listeners and a new " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1410 | "leader was re-elected if applicable )" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1411 | utilities.assert_equals( |
| 1412 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1413 | actual=leaderResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1414 | onpass="Leadership election passed", |
| 1415 | onfail="Something went wrong with Leadership election" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1416 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1417 | result = mastershipCheck and intentCheck and FlowTables and\ |
| 1418 | ( not LossInPings ) and rolesNotNull and leaderResult |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1419 | result = int( result ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1420 | if result == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1421 | main.log.report( "Constant State Tests Passed" ) |
| 1422 | utilities.assert_equals( expect=main.TRUE, actual=result, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1423 | onpass="Constant State Tests Passed", |
| 1424 | onfail="Constant state tests failed" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1425 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1426 | def CASE8( self, main ): |
| 1427 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1428 | Compare topo |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1429 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1430 | import sys |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1431 | # FIXME add this path to params |
| 1432 | sys.path.append( "/home/admin/sts" ) |
| 1433 | # assumes that sts is already in you PYTHONPATH |
| 1434 | from sts.topology.teston_topology import TestONTopology |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1435 | import json |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1436 | import time |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1437 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1438 | description = "Compare ONOS Topology view to Mininet topology" |
| 1439 | main.case( description ) |
| 1440 | main.log.report( description ) |
| 1441 | main.step( "Create TestONTopology object" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1442 | ctrls = [] |
| 1443 | count = 1 |
| 1444 | while True: |
| 1445 | temp = () |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1446 | if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]: |
| 1447 | temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), ) |
| 1448 | temp = temp + ( "ONOS" + str( count ), ) |
| 1449 | temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], ) |
| 1450 | temp = temp + \ |
| 1451 | ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), ) |
| 1452 | ctrls.append( temp ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1453 | count = count + 1 |
| 1454 | else: |
| 1455 | break |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1456 | MNTopo = TestONTopology( |
| 1457 | main.Mininet1, |
| 1458 | ctrls ) # can also add Intent API info for intent operations |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1459 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1460 | main.step( "Comparing ONOS topology to MN" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1461 | devicesResults = main.TRUE |
| 1462 | portsResults = main.TRUE |
| 1463 | linksResults = main.TRUE |
| 1464 | topoResult = main.FALSE |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1465 | elapsed = 0 |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 1466 | count = 0 |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1467 | main.step( "Collecting topology information from ONOS" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1468 | startTime = time.time() |
| 1469 | while topoResult == main.FALSE and elapsed < 60: |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 1470 | count = count + 1 |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1471 | if count > 1: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1472 | # TODO: Depricate STS usage |
| 1473 | MNTopo = TestONTopology( |
| 1474 | main.Mininet1, |
| 1475 | ctrls ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1476 | cliStart = time.time() |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1477 | devices = [] |
| 1478 | devices.append( main.ONOScli1.devices() ) |
| 1479 | devices.append( main.ONOScli2.devices() ) |
| 1480 | devices.append( main.ONOScli3.devices() ) |
| 1481 | devices.append( main.ONOScli4.devices() ) |
| 1482 | devices.append( main.ONOScli5.devices() ) |
| 1483 | devices.append( main.ONOScli6.devices() ) |
| 1484 | devices.append( main.ONOScli7.devices() ) |
| 1485 | hosts = [] |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1486 | hosts.append( json.loads( main.ONOScli1.hosts() ) ) |
| 1487 | hosts.append( json.loads( main.ONOScli2.hosts() ) ) |
| 1488 | hosts.append( json.loads( main.ONOScli3.hosts() ) ) |
| 1489 | hosts.append( json.loads( main.ONOScli4.hosts() ) ) |
| 1490 | hosts.append( json.loads( main.ONOScli5.hosts() ) ) |
| 1491 | hosts.append( json.loads( main.ONOScli6.hosts() ) ) |
| 1492 | hosts.append( json.loads( main.ONOScli7.hosts() ) ) |
| 1493 | for controller in range( 0, len( hosts ) ): |
| 1494 | controllerStr = str( controller + 1 ) |
| 1495 | for host in hosts[ controller ]: |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1496 | if host[ 'ips' ] == []: |
| 1497 | main.log.error( |
| 1498 | "DEBUG:Error with host ips on controller" + |
| 1499 | controllerStr + ": " + str( host ) ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1500 | ports = [] |
| 1501 | ports.append( main.ONOScli1.ports() ) |
| 1502 | ports.append( main.ONOScli2.ports() ) |
| 1503 | ports.append( main.ONOScli3.ports() ) |
| 1504 | ports.append( main.ONOScli4.ports() ) |
| 1505 | ports.append( main.ONOScli5.ports() ) |
| 1506 | ports.append( main.ONOScli6.ports() ) |
| 1507 | ports.append( main.ONOScli7.ports() ) |
| 1508 | links = [] |
| 1509 | links.append( main.ONOScli1.links() ) |
| 1510 | links.append( main.ONOScli2.links() ) |
| 1511 | links.append( main.ONOScli3.links() ) |
| 1512 | links.append( main.ONOScli4.links() ) |
| 1513 | links.append( main.ONOScli5.links() ) |
| 1514 | links.append( main.ONOScli6.links() ) |
| 1515 | links.append( main.ONOScli7.links() ) |
| 1516 | clusters = [] |
| 1517 | clusters.append( main.ONOScli1.clusters() ) |
| 1518 | clusters.append( main.ONOScli2.clusters() ) |
| 1519 | clusters.append( main.ONOScli3.clusters() ) |
| 1520 | clusters.append( main.ONOScli4.clusters() ) |
| 1521 | clusters.append( main.ONOScli5.clusters() ) |
| 1522 | clusters.append( main.ONOScli6.clusters() ) |
| 1523 | clusters.append( main.ONOScli7.clusters() ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1524 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1525 | elapsed = time.time() - startTime |
| 1526 | cliTime = time.time() - cliStart |
| 1527 | print "CLI time: " + str( cliTime ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1528 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1529 | try: |
| 1530 | for controller in range( numControllers ): |
| 1531 | controllerStr = str( controller + 1 ) |
| 1532 | if devices[ controller ] or "Error" not in devices[ |
| 1533 | controller ]: |
| 1534 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 1535 | MNTopo, |
| 1536 | json.loads( |
| 1537 | devices[ controller ] ) ) |
| 1538 | else: |
| 1539 | currentDevicesResult = main.FALSE |
| 1540 | utilities.assert_equals( expect=main.TRUE, |
| 1541 | actual=currentDevicesResult, |
| 1542 | onpass="ONOS" + controllerStr + |
| 1543 | " Switches view is correct", |
| 1544 | onfail="ONOS" + controllerStr + |
| 1545 | " Switches view is incorrect" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1546 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1547 | if ports[ controller ] or "Error" not in ports[ controller ]: |
| 1548 | currentPortsResult = main.Mininet1.comparePorts( |
| 1549 | MNTopo, |
| 1550 | json.loads( |
| 1551 | ports[ controller ] ) ) |
| 1552 | else: |
| 1553 | currentPortsResult = main.FALSE |
| 1554 | utilities.assert_equals( expect=main.TRUE, |
| 1555 | actual=currentPortsResult, |
| 1556 | onpass="ONOS" + controllerStr + |
| 1557 | " ports view is correct", |
| 1558 | onfail="ONOS" + controllerStr + |
| 1559 | " ports view is incorrect" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1560 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1561 | if links[ controller ] or "Error" not in links[ controller ]: |
| 1562 | currentLinksResult = main.Mininet1.compareLinks( |
| 1563 | MNTopo, |
| 1564 | json.loads( |
| 1565 | links[ controller ] ) ) |
| 1566 | else: |
| 1567 | currentLinksResult = main.FALSE |
| 1568 | utilities.assert_equals( expect=main.TRUE, |
| 1569 | actual=currentLinksResult, |
| 1570 | onpass="ONOS" + controllerStr + |
| 1571 | " links view is correct", |
| 1572 | onfail="ONOS" + controllerStr + |
| 1573 | " links view is incorrect" ) |
| 1574 | devicesResults = devicesResults and currentDevicesResult |
| 1575 | portsResults = portsResults and currentPortsResult |
| 1576 | linksResults = linksResults and currentLinksResult |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1577 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1578 | # Compare json objects for hosts and dataplane clusters |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1579 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1580 | # hosts |
| 1581 | consistentHostsResult = main.TRUE |
| 1582 | for controller in range( len( hosts ) ): |
| 1583 | controllerStr = str( controller + 1 ) |
| 1584 | if "Error" not in hosts[ controller ]: |
| 1585 | if hosts[ controller ] == hosts[ 0 ]: |
| 1586 | continue |
| 1587 | else: # hosts not consistent |
| 1588 | main.log.report( "hosts from ONOS" + controllerStr + |
| 1589 | " is inconsistent with ONOS1" ) |
| 1590 | main.log.warn( repr( hosts[ controller ] ) ) |
| 1591 | consistentHostsResult = main.FALSE |
| 1592 | |
| 1593 | else: |
| 1594 | main.log.report( "Error in getting ONOS hosts from ONOS" + |
| 1595 | controllerStr ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1596 | consistentHostsResult = main.FALSE |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1597 | main.log.warn( "ONOS" + controllerStr + |
| 1598 | " hosts response: " + |
| 1599 | repr( hosts[ controller ] ) ) |
| 1600 | utilities.assert_equals( |
| 1601 | expect=main.TRUE, |
| 1602 | actual=consistentHostsResult, |
| 1603 | onpass="Hosts view is consistent across all ONOS nodes", |
| 1604 | onfail="ONOS nodes have different views of hosts" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1605 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1606 | # Strongly connected clusters of devices |
| 1607 | consistentClustersResult = main.TRUE |
| 1608 | for controller in range( len( clusters ) ): |
| 1609 | controllerStr = str( controller + 1 ) |
| 1610 | if "Error" not in clusters[ controller ]: |
| 1611 | if clusters[ controller ] == clusters[ 0 ]: |
| 1612 | continue |
| 1613 | else: # clusters not consistent |
| 1614 | main.log.report( "clusters from ONOS" + |
| 1615 | controllerStr + |
| 1616 | " is inconsistent with ONOS1" ) |
| 1617 | consistentClustersResult = main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1618 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1619 | else: |
| 1620 | main.log.report( "Error in getting dataplane clusters " + |
| 1621 | "from ONOS" + controllerStr ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1622 | consistentClustersResult = main.FALSE |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1623 | main.log.warn( "ONOS" + controllerStr + |
| 1624 | " clusters response: " + |
| 1625 | repr( clusters[ controller ] ) ) |
| 1626 | utilities.assert_equals( |
| 1627 | expect=main.TRUE, |
| 1628 | actual=consistentClustersResult, |
| 1629 | onpass="Clusters view is consistent across all ONOS nodes", |
| 1630 | onfail="ONOS nodes have different views of clusters" ) |
| 1631 | # there should always only be one cluster |
| 1632 | numClusters = len( json.loads( clusters[ 0 ] ) ) |
| 1633 | utilities.assert_equals( |
| 1634 | expect=1, |
| 1635 | actual=numClusters, |
| 1636 | onpass="ONOS shows 1 SCC", |
| 1637 | onfail="ONOS shows " + |
| 1638 | str( numClusters ) + |
| 1639 | " SCCs" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1640 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1641 | topoResult = ( devicesResults and portsResults and linksResults |
| 1642 | and consistentHostsResult |
| 1643 | and consistentClustersResult ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1644 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1645 | topoResult = topoResult and int( count <= 2 ) |
| 1646 | note = "note it takes about " + str( int( cliTime ) ) + \ |
| 1647 | " seconds for the test to make all the cli calls to fetch " +\ |
| 1648 | "the topology from each ONOS instance" |
Jon Hall | 1b8f54a | 2015-02-04 13:24:20 -0800 | [diff] [blame] | 1649 | main.log.info( |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1650 | "Very crass estimate for topology discovery/convergence( " + |
| 1651 | str( note ) + " ): " + str( elapsed ) + " seconds, " + |
| 1652 | str( count ) + " tries" ) |
| 1653 | utilities.assert_equals( expect=main.TRUE, actual=topoResult, |
| 1654 | onpass="Topology Check Test successful", |
| 1655 | onfail="Topology Check Test NOT successful" ) |
| 1656 | if topoResult == main.TRUE: |
| 1657 | main.log.report( "ONOS topology view matches Mininet topology" ) |
| 1658 | except: |
| 1659 | main.log.info( self.name + " ::::::" ) |
| 1660 | main.log.error( traceback.print_exc() ) |
| 1661 | main.log.info( self.name + " ::::::" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1662 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1663 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1664 | def CASE9( self, main ): |
| 1665 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1666 | Link s3-s28 down |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1667 | """ |
| 1668 | import time |
| 1669 | # NOTE: You should probably run a topology check after this |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1670 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1671 | linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1672 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1673 | description = "Turn off a link to ensure that Link Discovery " +\ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1674 | "is working properly" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1675 | main.log.report( description ) |
| 1676 | main.case( description ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1677 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1678 | main.step( "Kill Link between s3 and s28" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1679 | LinkDown = main.Mininet1.link( END1="s3", END2="s28", OPTION="down" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1680 | main.log.info( |
| 1681 | "Waiting " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1682 | str( linkSleep ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1683 | " seconds for link down to be discovered" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1684 | time.sleep( linkSleep ) |
| 1685 | utilities.assert_equals( expect=main.TRUE, actual=LinkDown, |
| 1686 | onpass="Link down succesful", |
| 1687 | onfail="Failed to bring link down" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1688 | # TODO do some sort of check here |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1689 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1690 | def CASE10( self, main ): |
| 1691 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1692 | Link s3-s28 up |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1693 | """ |
| 1694 | import time |
| 1695 | # NOTE: You should probably run a topology check after this |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1696 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1697 | linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1698 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1699 | description = "Restore a link to ensure that Link Discovery is " + \ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1700 | "working properly" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1701 | main.log.report( description ) |
| 1702 | main.case( description ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1703 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1704 | main.step( "Bring link between s3 and s28 back up" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1705 | LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1706 | main.log.info( |
| 1707 | "Waiting " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1708 | str( linkSleep ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1709 | " seconds for link up to be discovered" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1710 | time.sleep( linkSleep ) |
| 1711 | utilities.assert_equals( expect=main.TRUE, actual=LinkUp, |
| 1712 | onpass="Link up succesful", |
| 1713 | onfail="Failed to bring link up" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1714 | # TODO do some sort of check here |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1715 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1716 | def CASE11( self, main ): |
| 1717 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1718 | Switch Down |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1719 | """ |
| 1720 | # NOTE: You should probably run a topology check after this |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1721 | import time |
| 1722 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1723 | switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1724 | |
| 1725 | description = "Killing a switch to ensure it is discovered correctly" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1726 | main.log.report( description ) |
| 1727 | main.case( description ) |
| 1728 | switch = main.params[ 'kill' ][ 'switch' ] |
| 1729 | switchDPID = main.params[ 'kill' ][ 'dpid' ] |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1730 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1731 | # TODO: Make this switch parameterizable |
| 1732 | main.step( "Kill " + switch ) |
| 1733 | main.log.report( "Deleting " + switch ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1734 | main.Mininet1.delSwitch( switch ) |
| 1735 | main.log.info( "Waiting " + str( switchSleep ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1736 | " seconds for switch down to be discovered" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1737 | time.sleep( switchSleep ) |
| 1738 | device = main.ONOScli1.getDevice( dpid=switchDPID ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1739 | # Peek at the deleted switch |
| 1740 | main.log.warn( str( device ) ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1741 | result = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1742 | if device and device[ 'available' ] is False: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1743 | result = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1744 | utilities.assert_equals( expect=main.TRUE, actual=result, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1745 | onpass="Kill switch succesful", |
| 1746 | onfail="Failed to kill switch?" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1747 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1748 | def CASE12( self, main ): |
| 1749 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1750 | Switch Up |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1751 | """ |
| 1752 | # NOTE: You should probably run a topology check after this |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1753 | import time |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1754 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1755 | switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1756 | switch = main.params[ 'kill' ][ 'switch' ] |
| 1757 | switchDPID = main.params[ 'kill' ][ 'dpid' ] |
| 1758 | links = main.params[ 'kill' ][ 'links' ].split() |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1759 | description = "Adding a switch to ensure it is discovered correctly" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1760 | main.log.report( description ) |
| 1761 | main.case( description ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1762 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1763 | main.step( "Add back " + switch ) |
| 1764 | main.log.report( "Adding back " + switch ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1765 | main.Mininet1.addSwitch( switch, dpid=switchDPID ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1766 | # TODO: New dpid or same? Ask Thomas? |
| 1767 | for peer in links: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1768 | main.Mininet1.addLink( switch, peer ) |
| 1769 | main.Mininet1.assignSwController( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1770 | sw=switch.split( 's' )[ 1 ], |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1771 | count=numControllers, |
| 1772 | ip1=ONOS1Ip, |
| 1773 | port1=ONOS1Port, |
| 1774 | ip2=ONOS2Ip, |
| 1775 | port2=ONOS2Port, |
| 1776 | ip3=ONOS3Ip, |
| 1777 | port3=ONOS3Port, |
| 1778 | ip4=ONOS4Ip, |
| 1779 | port4=ONOS4Port, |
| 1780 | ip5=ONOS5Ip, |
| 1781 | port5=ONOS5Port, |
| 1782 | ip6=ONOS6Ip, |
| 1783 | port6=ONOS6Port, |
| 1784 | ip7=ONOS7Ip, |
| 1785 | port7=ONOS7Port ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1786 | main.log.info( |
| 1787 | "Waiting " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1788 | str( switchSleep ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1789 | " seconds for switch up to be discovered" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1790 | time.sleep( switchSleep ) |
| 1791 | device = main.ONOScli1.getDevice( dpid=switchDPID ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1792 | # Peek at the deleted switch |
| 1793 | main.log.warn( str( device ) ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1794 | result = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1795 | if device and device[ 'available' ]: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1796 | result = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1797 | utilities.assert_equals( expect=main.TRUE, actual=result, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1798 | onpass="add switch succesful", |
| 1799 | onfail="Failed to add switch?" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1800 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1801 | def CASE13( self, main ): |
| 1802 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1803 | Clean up |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1804 | """ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1805 | import os |
| 1806 | import time |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1807 | # TODO: make use of this elsewhere |
| 1808 | ips = [] |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1809 | ips.append( ONOS1Ip ) |
| 1810 | ips.append( ONOS2Ip ) |
| 1811 | ips.append( ONOS3Ip ) |
| 1812 | ips.append( ONOS4Ip ) |
| 1813 | ips.append( ONOS5Ip ) |
| 1814 | ips.append( ONOS6Ip ) |
| 1815 | ips.append( ONOS7Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1816 | |
| 1817 | # printing colors to terminal |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1818 | colors = {} |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1819 | colors[ 'cyan' ] = '\033[96m' |
| 1820 | colors[ 'purple' ] = '\033[95m' |
| 1821 | colors[ 'blue' ] = '\033[94m' |
| 1822 | colors[ 'green' ] = '\033[92m' |
| 1823 | colors[ 'yellow' ] = '\033[93m' |
| 1824 | colors[ 'red' ] = '\033[91m' |
| 1825 | colors[ 'end' ] = '\033[0m' |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 1826 | description = "Test Cleanup" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1827 | main.log.report( description ) |
| 1828 | main.case( description ) |
| 1829 | main.step( "Killing tcpdumps" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1830 | main.Mininet2.stopTcpdump() |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1831 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1832 | main.step( "Checking ONOS Logs for errors" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1833 | for i in range( 7 ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1834 | print colors[ 'purple' ] + "Checking logs for errors on " + \ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1835 | "ONOS" + str( i + 1 ) + ":" + colors[ 'end' ] |
| 1836 | print main.ONOSbench.checkLogs( ips[ i ] ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1837 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1838 | main.step( "Copying MN pcap and ONOS log files to test station" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1839 | testname = main.TEST |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1840 | teststationUser = main.params[ 'TESTONUSER' ] |
| 1841 | teststationIP = main.params[ 'TESTONIP' ] |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1842 | # NOTE: MN Pcap file is being saved to ~/packet_captures |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1843 | # scp this file as MN and TestON aren't necessarily the same vm |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1844 | # FIXME: scp |
| 1845 | # mn files |
| 1846 | # TODO: Load these from params |
| 1847 | # NOTE: must end in / |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1848 | logFolder = "/opt/onos/log/" |
| 1849 | logFiles = [ "karaf.log", "karaf.log.1" ] |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1850 | # NOTE: must end in / |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1851 | dstDir = "~/packet_captures/" |
| 1852 | for f in logFiles: |
| 1853 | for i in range( 7 ): |
| 1854 | main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" + |
| 1855 | logFolder + f + " " + |
| 1856 | teststationUser + "@" + |
| 1857 | teststationIP + ":" + |
| 1858 | dstDir + str( testname ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1859 | "-ONOS" + str( i + 1 ) + "-" + |
| 1860 | f ) |
| 1861 | # std*.log's |
| 1862 | # NOTE: must end in / |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1863 | logFolder = "/opt/onos/var/" |
| 1864 | logFiles = [ "stderr.log", "stdout.log" ] |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1865 | # NOTE: must end in / |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1866 | dstDir = "~/packet_captures/" |
| 1867 | for f in logFiles: |
| 1868 | for i in range( 7 ): |
| 1869 | main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" + |
| 1870 | logFolder + f + " " + |
| 1871 | teststationUser + "@" + |
| 1872 | teststationIP + ":" + |
| 1873 | dstDir + str( testname ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1874 | "-ONOS" + str( i + 1 ) + "-" + |
| 1875 | f ) |
| 1876 | # sleep so scp can finish |
| 1877 | time.sleep( 10 ) |
| 1878 | main.step( "Packing and rotating pcap archives" ) |
| 1879 | os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1880 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1881 | # TODO: actually check something here |
| 1882 | utilities.assert_equals( expect=main.TRUE, actual=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1883 | onpass="Test cleanup successful", |
| 1884 | onfail="Test cleanup NOT successful" ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1885 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1886 | def CASE14( self, main ): |
| 1887 | """ |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1888 | start election app on all onos nodes |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1889 | """ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1890 | leaderResult = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1891 | # install app on onos 1 |
| 1892 | main.log.info( "Install leadership election app" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1893 | main.ONOScli1.featureInstall( "onos-app-election" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1894 | # wait for election |
| 1895 | # check for leader |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1896 | leader = main.ONOScli1.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1897 | # verify leader is ONOS1 |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1898 | if leader == ONOS1Ip: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1899 | # all is well |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1900 | pass |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1901 | elif leader is None: |
| 1902 | # No leader elected |
| 1903 | main.log.report( "No leader was elected" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1904 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1905 | elif leader == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1906 | # error in response |
| 1907 | # TODO: add check for "Command not found:" in the driver, this |
| 1908 | # means the app isn't loaded |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1909 | main.log.report( "Something is wrong with electionTestLeader" + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1910 | " function, check the error logs" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1911 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1912 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1913 | # error in response |
| 1914 | main.log.report( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1915 | "Unexpected response from electionTestLeader function:'" + |
| 1916 | str( leader ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1917 | "'" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1918 | leaderResult = main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1919 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1920 | # install on other nodes and check for leader. |
| 1921 | # Should be onos1 and each app should show the same leader |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1922 | for controller in range( 2, numControllers + 1 ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1923 | # loop through ONOScli handlers |
| 1924 | node = getattr( main, ( 'ONOScli' + str( controller ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1925 | node.featureInstall( "onos-app-election" ) |
| 1926 | leaderN = node.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1927 | # verify leader is ONOS1 |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1928 | if leaderN == ONOS1Ip: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1929 | # all is well |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1930 | pass |
| 1931 | elif leaderN == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1932 | # error in response |
| 1933 | # TODO: add check for "Command not found:" in the driver, this |
| 1934 | # means the app isn't loaded |
| 1935 | main.log.report( "Something is wrong with " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1936 | "electionTestLeader function, check the" + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1937 | " error logs" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1938 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1939 | elif leader != leaderN: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1940 | leaderResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1941 | main.log.report( "ONOS" + str( controller ) + " sees " + |
| 1942 | str( leaderN ) + |
| 1943 | " as the leader of the election app. Leader" + |
| 1944 | " should be " + |
| 1945 | str( leader ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1946 | if leaderResult: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1947 | main.log.report( "Leadership election tests passed( consistent " + |
| 1948 | "view of leader across listeners and a leader " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1949 | "was elected )" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1950 | utilities.assert_equals( |
| 1951 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1952 | actual=leaderResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1953 | onpass="Leadership election passed", |
| 1954 | onfail="Something went wrong with Leadership election" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1955 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1956 | def CASE15( self, main ): |
| 1957 | """ |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1958 | Check that Leadership Election is still functional |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1959 | """ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1960 | leaderResult = main.TRUE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1961 | description = "Check that Leadership Election is still functional" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1962 | main.log.report( description ) |
| 1963 | main.case( description ) |
| 1964 | main.step( "Find current leader and withdraw" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1965 | leader = main.ONOScli1.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1966 | # TODO: do some sanity checking on leader before using it |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1967 | withdrawResult = main.FALSE |
| 1968 | if leader == ONOS1Ip: |
| 1969 | oldLeader = getattr( main, "ONOScli1" ) |
| 1970 | elif leader == ONOS2Ip: |
| 1971 | oldLeader = getattr( main, "ONOScli2" ) |
| 1972 | elif leader == ONOS3Ip: |
| 1973 | oldLeader = getattr( main, "ONOScli3" ) |
| 1974 | elif leader == ONOS4Ip: |
| 1975 | oldLeader = getattr( main, "ONOScli4" ) |
| 1976 | elif leader == ONOS5Ip: |
| 1977 | oldLeader = getattr( main, "ONOScli5" ) |
| 1978 | elif leader == ONOS6Ip: |
| 1979 | oldLeader = getattr( main, "ONOScli6" ) |
| 1980 | elif leader == ONOS7Ip: |
| 1981 | oldLeader = getattr( main, "ONOScli7" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1982 | elif leader is None or leader == main.FALSE: |
| 1983 | main.log.report( |
| 1984 | "Leader for the election app should be an ONOS node," + |
| 1985 | "instead got '" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1986 | str( leader ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1987 | "'" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1988 | leaderResult = main.FALSE |
| 1989 | withdrawResult = oldLeader.electionTestWithdraw() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1990 | utilities.assert_equals( |
| 1991 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1992 | actual=withdrawResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1993 | onpass="App was withdrawn from election", |
| 1994 | onfail="App was not withdrawn from election" ) |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1995 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1996 | main.step( "Make sure new leader is elected" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1997 | leaderList = [] |
| 1998 | for controller in range( 1, numControllers + 1 ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1999 | # loop through ONOScli handlers |
| 2000 | node = getattr( main, ( 'ONOScli' + str( controller ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2001 | leaderList.append( node.electionTestLeader() ) |
| 2002 | for leaderN in leaderList: |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 2003 | if leaderN == leader: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2004 | main.log.report( |
| 2005 | "ONOS" + |
| 2006 | str( controller ) + |
| 2007 | " still sees " + |
| 2008 | str( leader ) + |
| 2009 | " as leader after they withdrew" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2010 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 2011 | elif leaderN == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2012 | # error in response |
| 2013 | # TODO: add check for "Command not found:" in the driver, this |
| 2014 | # means the app isn't loaded |
| 2015 | main.log.report( "Something is wrong with " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2016 | "electionTestLeader function, " + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2017 | "check the error logs" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2018 | leaderResult = main.FALSE |
| 2019 | consistentLeader = main.FALSE |
| 2020 | if len( set( leaderList ) ) == 1: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2021 | main.log.info( "Each Election-app sees '" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2022 | str( leaderList[ 0 ] ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2023 | "' as the leader" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2024 | consistentLeader = main.TRUE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 2025 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2026 | main.log.report( |
| 2027 | "Inconsistent responses for leader of Election-app:" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2028 | for n in range( len( leaderList ) ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2029 | main.log.report( "ONOS" + str( n + 1 ) + " response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2030 | str( leaderList[ n ] ) ) |
| 2031 | if leaderResult: |
| 2032 | main.log.report( "Leadership election tests passed( consistent " + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2033 | "view of leader across listeners and a new " + |
| 2034 | "leader was elected when the old leader " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2035 | "resigned )" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2036 | utilities.assert_equals( |
| 2037 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2038 | actual=leaderResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2039 | onpass="Leadership election passed", |
| 2040 | onfail="Something went wrong with Leadership election" ) |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 2041 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2042 | main.step( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2043 | "Run for election on old leader( just so everyone is in the hat )" ) |
| 2044 | runResult = oldLeader.electionTestRun() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2045 | utilities.assert_equals( |
| 2046 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2047 | actual=runResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2048 | onpass="App re-ran for election", |
| 2049 | onfail="App failed to run for election" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2050 | if consistentLeader == main.TRUE: |
| 2051 | afterRun = main.ONOScli1.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2052 | # verify leader didn't just change |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2053 | if afterRun == leaderList[ 0 ]: |
| 2054 | leaderResult = main.TRUE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 2055 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2056 | leaderResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2057 | # TODO: assert on run and withdraw results? |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 2058 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2059 | utilities.assert_equals( |
| 2060 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2061 | actual=leaderResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2062 | onpass="Leadership election passed", |
| 2063 | onfail="Something went wrong with Leadership election after " + |
| 2064 | "the old leader re-ran for election" ) |