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 | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 440 | host1Id = main.ONOScli1.getHost( host1 )[ 'id' ] |
| 441 | host2Id = main.ONOScli1.getHost( host2 )[ 'id' ] |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 442 | # NOTE: get host can return None |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 443 | if host1Id and host2Id: |
| 444 | tmpResult = main.ONOScli1.addHostIntent( |
| 445 | host1Id, |
| 446 | host2Id ) |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 447 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 448 | main.log.error( "Error, getHost() failed" ) |
| 449 | tmpResult = main.FALSE |
| 450 | intentAddResult = bool( pingResult and intentAddResult |
| 451 | and tmpResult ) |
| 452 | # TODO Check that intents were added? |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 453 | utilities.assert_equals( |
| 454 | expect=True, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 455 | actual=intentAddResult, |
| 456 | onpass="Pushed host intents to ONOS", |
| 457 | onfail="Error in pushing host intents to ONOS" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 458 | # TODO Check if intents all exist in datastore |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 459 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 460 | def CASE4( self, main ): |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 461 | """ |
| 462 | Ping across added host intents |
| 463 | """ |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 464 | description = " Ping across added host intents" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 465 | main.log.report( description ) |
| 466 | main.case( description ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 467 | PingResult = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 468 | for i in range( 8, 18 ): |
| 469 | ping = main.Mininet1.pingHost( |
| 470 | src="h" + str( i ), target="h" + str( i + 10 ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 471 | PingResult = PingResult and ping |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 472 | if ping == main.FALSE: |
| 473 | main.log.warn( "Ping failed between h" + str( i ) + |
| 474 | " and h" + str( i + 10 ) ) |
| 475 | elif ping == main.TRUE: |
| 476 | main.log.info( "Ping test passed!" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 477 | PingResult = main.TRUE |
| 478 | if PingResult == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 479 | main.log.report( |
| 480 | "Intents have not been installed correctly, pings failed." ) |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 481 | #TODO: pretty print |
| 482 | main.log.warn( "ONSO1 intents: " ) |
| 483 | main.log.warn( json.dumps( json.loads( main.ONOScli1.intents() ), |
| 484 | sort_keys=True, |
| 485 | indent=4, |
| 486 | separators=( ',', ': ' ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 487 | if PingResult == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 488 | main.log.report( |
| 489 | "Intents have been installed correctly and verified by pings" ) |
| 490 | utilities.assert_equals( |
| 491 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 492 | actual=PingResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 493 | onpass="Intents have been installed correctly and pings work", |
| 494 | onfail="Intents have not been installed correctly, pings failed." ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 495 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 496 | def CASE5( self, main ): |
| 497 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 498 | Reading state of ONOS |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 499 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 500 | import json |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 501 | # assumes that sts is already in you PYTHONPATH |
| 502 | from sts.topology.teston_topology import TestONTopology |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 503 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 504 | main.log.report( "Setting up and gathering data for current state" ) |
| 505 | main.case( "Setting up and gathering data for current state" ) |
| 506 | # The general idea for this test case is to pull the state of |
| 507 | # ( intents,flows, topology,... ) from each ONOS node |
| 508 | # We can then compare them with eachother and also with past states |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 509 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 510 | main.step( "Get the Mastership of each switch from each controller" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 511 | global mastershipState |
| 512 | mastershipState = [] |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 513 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 514 | # Assert that each device has a master |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 515 | ONOS1MasterNotNull = main.ONOScli1.rolesNotNull() |
| 516 | ONOS2MasterNotNull = main.ONOScli2.rolesNotNull() |
| 517 | ONOS3MasterNotNull = main.ONOScli3.rolesNotNull() |
| 518 | ONOS4MasterNotNull = main.ONOScli4.rolesNotNull() |
| 519 | ONOS5MasterNotNull = main.ONOScli5.rolesNotNull() |
| 520 | ONOS6MasterNotNull = main.ONOScli6.rolesNotNull() |
| 521 | ONOS7MasterNotNull = main.ONOScli7.rolesNotNull() |
| 522 | rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\ |
| 523 | ONOS3MasterNotNull and ONOS4MasterNotNull and\ |
| 524 | ONOS5MasterNotNull and ONOS6MasterNotNull and\ |
| 525 | ONOS7MasterNotNull |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 526 | utilities.assert_equals( |
| 527 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 528 | actual=rolesNotNull, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 529 | onpass="Each device has a master", |
| 530 | onfail="Some devices don't have a master assigned" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 531 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 532 | ONOS1Mastership = main.ONOScli1.roles() |
| 533 | ONOS2Mastership = main.ONOScli2.roles() |
| 534 | ONOS3Mastership = main.ONOScli3.roles() |
| 535 | ONOS4Mastership = main.ONOScli4.roles() |
| 536 | ONOS5Mastership = main.ONOScli5.roles() |
| 537 | ONOS6Mastership = main.ONOScli6.roles() |
| 538 | ONOS7Mastership = main.ONOScli7.roles() |
| 539 | # print json.dumps( json.loads( ONOS1Mastership ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 540 | # indent=4, separators=( ',', ': ' ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 541 | if "Error" in ONOS1Mastership or not ONOS1Mastership\ |
| 542 | or "Error" in ONOS2Mastership or not ONOS2Mastership\ |
| 543 | or "Error" in ONOS3Mastership or not ONOS3Mastership\ |
| 544 | or "Error" in ONOS4Mastership or not ONOS4Mastership\ |
| 545 | or "Error" in ONOS5Mastership or not ONOS5Mastership\ |
| 546 | or "Error" in ONOS6Mastership or not ONOS6Mastership\ |
| 547 | or "Error" in ONOS7Mastership or not ONOS7Mastership: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 548 | main.log.report( "Error in getting ONOS roles" ) |
| 549 | main.log.warn( |
| 550 | "ONOS1 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 551 | repr( ONOS1Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 552 | main.log.warn( |
| 553 | "ONOS2 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 554 | repr( ONOS2Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 555 | main.log.warn( |
| 556 | "ONOS3 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 557 | repr( ONOS3Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 558 | main.log.warn( |
| 559 | "ONOS4 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 560 | repr( ONOS4Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 561 | main.log.warn( |
| 562 | "ONOS5 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 563 | repr( ONOS5Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 564 | main.log.warn( |
| 565 | "ONOS6 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 566 | repr( ONOS6Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 567 | main.log.warn( |
| 568 | "ONOS7 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 569 | repr( ONOS7Mastership ) ) |
| 570 | consistentMastership = main.FALSE |
| 571 | elif ONOS1Mastership == ONOS2Mastership\ |
| 572 | and ONOS1Mastership == ONOS3Mastership\ |
| 573 | and ONOS1Mastership == ONOS4Mastership\ |
| 574 | and ONOS1Mastership == ONOS5Mastership\ |
| 575 | and ONOS1Mastership == ONOS6Mastership\ |
| 576 | and ONOS1Mastership == ONOS7Mastership: |
| 577 | mastershipState = ONOS1Mastership |
| 578 | consistentMastership = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 579 | main.log.report( |
| 580 | "Switch roles are consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 581 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 582 | main.log.warn( |
| 583 | "ONOS1 roles: ", |
| 584 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 585 | json.loads( ONOS1Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 586 | sort_keys=True, |
| 587 | indent=4, |
| 588 | separators=( |
| 589 | ',', |
| 590 | ': ' ) ) ) |
| 591 | main.log.warn( |
| 592 | "ONOS2 roles: ", |
| 593 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 594 | json.loads( ONOS2Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 595 | sort_keys=True, |
| 596 | indent=4, |
| 597 | separators=( |
| 598 | ',', |
| 599 | ': ' ) ) ) |
| 600 | main.log.warn( |
| 601 | "ONOS3 roles: ", |
| 602 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 603 | json.loads( ONOS3Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 604 | sort_keys=True, |
| 605 | indent=4, |
| 606 | separators=( |
| 607 | ',', |
| 608 | ': ' ) ) ) |
| 609 | main.log.warn( |
| 610 | "ONOS4 roles: ", |
| 611 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 612 | json.loads( ONOS4Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 613 | sort_keys=True, |
| 614 | indent=4, |
| 615 | separators=( |
| 616 | ',', |
| 617 | ': ' ) ) ) |
| 618 | main.log.warn( |
| 619 | "ONOS5 roles: ", |
| 620 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 621 | json.loads( ONOS5Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 622 | sort_keys=True, |
| 623 | indent=4, |
| 624 | separators=( |
| 625 | ',', |
| 626 | ': ' ) ) ) |
| 627 | main.log.warn( |
| 628 | "ONOS6 roles: ", |
| 629 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 630 | json.loads( ONOS6Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 631 | sort_keys=True, |
| 632 | indent=4, |
| 633 | separators=( |
| 634 | ',', |
| 635 | ': ' ) ) ) |
| 636 | main.log.warn( |
| 637 | "ONOS7 roles: ", |
| 638 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 639 | json.loads( ONOS7Mastership ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 640 | sort_keys=True, |
| 641 | indent=4, |
| 642 | separators=( |
| 643 | ',', |
| 644 | ': ' ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 645 | consistentMastership = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 646 | utilities.assert_equals( |
| 647 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 648 | actual=consistentMastership, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 649 | onpass="Switch roles are consistent across all ONOS nodes", |
| 650 | onfail="ONOS nodes have different views of switch roles" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 651 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 652 | main.step( "Get the intents from each controller" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 653 | global intentState |
| 654 | intentState = [] |
| 655 | ONOS1Intents = main.ONOScli1.intents( jsonFormat=True ) |
| 656 | ONOS2Intents = main.ONOScli2.intents( jsonFormat=True ) |
| 657 | ONOS3Intents = main.ONOScli3.intents( jsonFormat=True ) |
| 658 | ONOS4Intents = main.ONOScli4.intents( jsonFormat=True ) |
| 659 | ONOS5Intents = main.ONOScli5.intents( jsonFormat=True ) |
| 660 | ONOS6Intents = main.ONOScli6.intents( jsonFormat=True ) |
| 661 | ONOS7Intents = main.ONOScli7.intents( jsonFormat=True ) |
| 662 | intentCheck = main.FALSE |
| 663 | if "Error" in ONOS1Intents or not ONOS1Intents\ |
| 664 | or "Error" in ONOS2Intents or not ONOS2Intents\ |
| 665 | or "Error" in ONOS3Intents or not ONOS3Intents\ |
| 666 | or "Error" in ONOS4Intents or not ONOS4Intents\ |
| 667 | or "Error" in ONOS5Intents or not ONOS5Intents\ |
| 668 | or "Error" in ONOS6Intents or not ONOS6Intents\ |
| 669 | or "Error" in ONOS7Intents or not ONOS7Intents: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 670 | main.log.report( "Error in getting ONOS intents" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 671 | main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) ) |
| 672 | main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) ) |
| 673 | main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) ) |
| 674 | main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) ) |
| 675 | main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) ) |
| 676 | main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) ) |
| 677 | main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) ) |
| 678 | elif ONOS1Intents == ONOS2Intents\ |
| 679 | and ONOS1Intents == ONOS3Intents\ |
| 680 | and ONOS1Intents == ONOS4Intents\ |
| 681 | and ONOS1Intents == ONOS5Intents\ |
| 682 | and ONOS1Intents == ONOS6Intents\ |
| 683 | and ONOS1Intents == ONOS7Intents: |
| 684 | intentState = ONOS1Intents |
| 685 | intentCheck = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 686 | main.log.report( "Intents are consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 687 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 688 | main.log.warn( |
| 689 | "ONOS1 intents: ", |
| 690 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 691 | json.loads( ONOS1Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 692 | sort_keys=True, |
| 693 | indent=4, |
| 694 | separators=( |
| 695 | ',', |
| 696 | ': ' ) ) ) |
| 697 | main.log.warn( |
| 698 | "ONOS2 intents: ", |
| 699 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 700 | json.loads( ONOS2Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 701 | sort_keys=True, |
| 702 | indent=4, |
| 703 | separators=( |
| 704 | ',', |
| 705 | ': ' ) ) ) |
| 706 | main.log.warn( |
| 707 | "ONOS3 intents: ", |
| 708 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 709 | json.loads( ONOS3Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 710 | sort_keys=True, |
| 711 | indent=4, |
| 712 | separators=( |
| 713 | ',', |
| 714 | ': ' ) ) ) |
| 715 | main.log.warn( |
| 716 | "ONOS4 intents: ", |
| 717 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 718 | json.loads( ONOS4Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 719 | sort_keys=True, |
| 720 | indent=4, |
| 721 | separators=( |
| 722 | ',', |
| 723 | ': ' ) ) ) |
| 724 | main.log.warn( |
| 725 | "ONOS5 intents: ", |
| 726 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 727 | json.loads( ONOS5Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 728 | sort_keys=True, |
| 729 | indent=4, |
| 730 | separators=( |
| 731 | ',', |
| 732 | ': ' ) ) ) |
| 733 | main.log.warn( |
| 734 | "ONOS6 intents: ", |
| 735 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 736 | json.loads( ONOS6Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 737 | sort_keys=True, |
| 738 | indent=4, |
| 739 | separators=( |
| 740 | ',', |
| 741 | ': ' ) ) ) |
| 742 | main.log.warn( |
| 743 | "ONOS7 intents: ", |
| 744 | json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 745 | json.loads( ONOS7Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 746 | sort_keys=True, |
| 747 | indent=4, |
| 748 | separators=( |
| 749 | ',', |
| 750 | ': ' ) ) ) |
| 751 | utilities.assert_equals( |
| 752 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 753 | actual=intentCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 754 | onpass="Intents are consistent across all ONOS nodes", |
| 755 | onfail="ONOS nodes have different views of intents" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 756 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 757 | main.step( "Get the flows from each controller" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 758 | global flowState |
| 759 | flowState = [] |
| 760 | ONOS1Flows = main.ONOScli1.flows( jsonFormat=True ) |
| 761 | ONOS2Flows = main.ONOScli2.flows( jsonFormat=True ) |
| 762 | ONOS3Flows = main.ONOScli3.flows( jsonFormat=True ) |
| 763 | ONOS4Flows = main.ONOScli4.flows( jsonFormat=True ) |
| 764 | ONOS5Flows = main.ONOScli5.flows( jsonFormat=True ) |
| 765 | ONOS6Flows = main.ONOScli6.flows( jsonFormat=True ) |
| 766 | ONOS7Flows = main.ONOScli7.flows( jsonFormat=True ) |
| 767 | ONOS1FlowsJson = json.loads( ONOS1Flows ) |
| 768 | ONOS2FlowsJson = json.loads( ONOS2Flows ) |
| 769 | ONOS3FlowsJson = json.loads( ONOS3Flows ) |
| 770 | ONOS4FlowsJson = json.loads( ONOS4Flows ) |
| 771 | ONOS5FlowsJson = json.loads( ONOS5Flows ) |
| 772 | ONOS6FlowsJson = json.loads( ONOS6Flows ) |
| 773 | ONOS7FlowsJson = json.loads( ONOS7Flows ) |
| 774 | flowCheck = main.FALSE |
| 775 | if "Error" in ONOS1Flows or not ONOS1Flows\ |
| 776 | or "Error" in ONOS2Flows or not ONOS2Flows\ |
| 777 | or "Error" in ONOS3Flows or not ONOS3Flows\ |
| 778 | or "Error" in ONOS4Flows or not ONOS4Flows\ |
| 779 | or "Error" in ONOS5Flows or not ONOS5Flows\ |
| 780 | or "Error" in ONOS6Flows or not ONOS6Flows\ |
| 781 | or "Error" in ONOS7Flows or not ONOS7Flows: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 782 | main.log.report( "Error in getting ONOS intents" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 783 | main.log.warn( "ONOS1 flows repsponse: " + ONOS1Flows ) |
| 784 | main.log.warn( "ONOS2 flows repsponse: " + ONOS2Flows ) |
| 785 | main.log.warn( "ONOS3 flows repsponse: " + ONOS3Flows ) |
| 786 | main.log.warn( "ONOS4 flows repsponse: " + ONOS4Flows ) |
| 787 | main.log.warn( "ONOS5 flows repsponse: " + ONOS5Flows ) |
| 788 | main.log.warn( "ONOS6 flows repsponse: " + ONOS6Flows ) |
| 789 | main.log.warn( "ONOS7 flows repsponse: " + ONOS7Flows ) |
| 790 | elif len( ONOS1FlowsJson ) == len( ONOS2FlowsJson )\ |
| 791 | and len( ONOS1FlowsJson ) == len( ONOS3FlowsJson )\ |
| 792 | and len( ONOS1FlowsJson ) == len( ONOS4FlowsJson )\ |
| 793 | and len( ONOS1FlowsJson ) == len( ONOS5FlowsJson )\ |
| 794 | and len( ONOS1FlowsJson ) == len( ONOS6FlowsJson )\ |
| 795 | and len( ONOS1FlowsJson ) == len( ONOS7FlowsJson ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 796 | # TODO: Do a better check, maybe compare flows on switches? |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 797 | flowState = ONOS1Flows |
| 798 | flowCheck = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 799 | main.log.report( "Flow count is consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 800 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 801 | main.log.warn( "ONOS1 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 802 | json.dumps( ONOS1FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 803 | indent=4, separators=( ',', ': ' ) ) ) |
| 804 | main.log.warn( "ONOS2 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 805 | json.dumps( ONOS2FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 806 | indent=4, separators=( ',', ': ' ) ) ) |
| 807 | main.log.warn( "ONOS3 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 808 | json.dumps( ONOS3FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 809 | indent=4, separators=( ',', ': ' ) ) ) |
| 810 | main.log.warn( "ONOS4 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 811 | json.dumps( ONOS4FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 812 | indent=4, separators=( ',', ': ' ) ) ) |
| 813 | main.log.warn( "ONOS5 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 814 | json.dumps( ONOS5FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 815 | indent=4, separators=( ',', ': ' ) ) ) |
| 816 | main.log.warn( "ONOS6 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 817 | json.dumps( ONOS6FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 818 | indent=4, separators=( ',', ': ' ) ) ) |
| 819 | main.log.warn( "ONOS7 flows: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 820 | json.dumps( ONOS7FlowsJson, sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 821 | indent=4, separators=( ',', ': ' ) ) ) |
| 822 | utilities.assert_equals( |
| 823 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 824 | actual=flowCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 825 | onpass="The flow count is consistent across all ONOS nodes", |
| 826 | onfail="ONOS nodes have different flow counts" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 827 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 828 | main.step( "Get the OF Table entries" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 829 | global flows |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 830 | flows = [] |
| 831 | for i in range( 1, 29 ): |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 832 | flows.append( main.Mininet2.getFlowTable( 1.3, "s" + str( i ) ) ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 833 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 834 | # TODO: Compare switch flow tables with ONOS flow tables |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 835 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 836 | main.step( "Start continuous pings" ) |
| 837 | main.Mininet2.pingLong( |
| 838 | src=main.params[ 'PING' ][ 'source1' ], |
| 839 | target=main.params[ 'PING' ][ 'target1' ], |
| 840 | pingTime=500 ) |
| 841 | main.Mininet2.pingLong( |
| 842 | src=main.params[ 'PING' ][ 'source2' ], |
| 843 | target=main.params[ 'PING' ][ 'target2' ], |
| 844 | pingTime=500 ) |
| 845 | main.Mininet2.pingLong( |
| 846 | src=main.params[ 'PING' ][ 'source3' ], |
| 847 | target=main.params[ 'PING' ][ 'target3' ], |
| 848 | pingTime=500 ) |
| 849 | main.Mininet2.pingLong( |
| 850 | src=main.params[ 'PING' ][ 'source4' ], |
| 851 | target=main.params[ 'PING' ][ 'target4' ], |
| 852 | pingTime=500 ) |
| 853 | main.Mininet2.pingLong( |
| 854 | src=main.params[ 'PING' ][ 'source5' ], |
| 855 | target=main.params[ 'PING' ][ 'target5' ], |
| 856 | pingTime=500 ) |
| 857 | main.Mininet2.pingLong( |
| 858 | src=main.params[ 'PING' ][ 'source6' ], |
| 859 | target=main.params[ 'PING' ][ 'target6' ], |
| 860 | pingTime=500 ) |
| 861 | main.Mininet2.pingLong( |
| 862 | src=main.params[ 'PING' ][ 'source7' ], |
| 863 | target=main.params[ 'PING' ][ 'target7' ], |
| 864 | pingTime=500 ) |
| 865 | main.Mininet2.pingLong( |
| 866 | src=main.params[ 'PING' ][ 'source8' ], |
| 867 | target=main.params[ 'PING' ][ 'target8' ], |
| 868 | pingTime=500 ) |
| 869 | main.Mininet2.pingLong( |
| 870 | src=main.params[ 'PING' ][ 'source9' ], |
| 871 | target=main.params[ 'PING' ][ 'target9' ], |
| 872 | pingTime=500 ) |
| 873 | main.Mininet2.pingLong( |
| 874 | src=main.params[ 'PING' ][ 'source10' ], |
| 875 | target=main.params[ 'PING' ][ 'target10' ], |
| 876 | pingTime=500 ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 877 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 878 | main.step( "Create TestONTopology object" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 879 | ctrls = [] |
| 880 | count = 1 |
| 881 | while True: |
| 882 | temp = () |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 883 | if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]: |
| 884 | temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), ) |
| 885 | temp = temp + ( "ONOS" + str( count ), ) |
| 886 | temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], ) |
| 887 | temp = temp + \ |
| 888 | ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), ) |
| 889 | ctrls.append( temp ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 890 | count = count + 1 |
| 891 | else: |
| 892 | break |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 893 | MNTopo = TestONTopology( |
| 894 | main.Mininet1, |
| 895 | ctrls ) # can also add Intent API info for intent operations |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 896 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 897 | main.step( "Collecting topology information from ONOS" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 898 | devices = [] |
| 899 | devices.append( main.ONOScli1.devices() ) |
| 900 | devices.append( main.ONOScli2.devices() ) |
| 901 | devices.append( main.ONOScli3.devices() ) |
| 902 | devices.append( main.ONOScli4.devices() ) |
| 903 | devices.append( main.ONOScli5.devices() ) |
| 904 | devices.append( main.ONOScli6.devices() ) |
| 905 | devices.append( main.ONOScli7.devices() ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 906 | hosts = [] |
| 907 | hosts.append( main.ONOScli1.hosts() ) |
| 908 | hosts.append( main.ONOScli2.hosts() ) |
| 909 | hosts.append( main.ONOScli3.hosts() ) |
| 910 | hosts.append( main.ONOScli4.hosts() ) |
| 911 | hosts.append( main.ONOScli5.hosts() ) |
| 912 | hosts.append( main.ONOScli6.hosts() ) |
| 913 | hosts.append( main.ONOScli7.hosts() ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 914 | ports = [] |
| 915 | ports.append( main.ONOScli1.ports() ) |
| 916 | ports.append( main.ONOScli2.ports() ) |
| 917 | ports.append( main.ONOScli3.ports() ) |
| 918 | ports.append( main.ONOScli4.ports() ) |
| 919 | ports.append( main.ONOScli5.ports() ) |
| 920 | ports.append( main.ONOScli6.ports() ) |
| 921 | ports.append( main.ONOScli7.ports() ) |
| 922 | links = [] |
| 923 | links.append( main.ONOScli1.links() ) |
| 924 | links.append( main.ONOScli2.links() ) |
| 925 | links.append( main.ONOScli3.links() ) |
| 926 | links.append( main.ONOScli4.links() ) |
| 927 | links.append( main.ONOScli5.links() ) |
| 928 | links.append( main.ONOScli6.links() ) |
| 929 | links.append( main.ONOScli7.links() ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 930 | clusters = [] |
| 931 | clusters.append( main.ONOScli1.clusters() ) |
| 932 | clusters.append( main.ONOScli2.clusters() ) |
| 933 | clusters.append( main.ONOScli3.clusters() ) |
| 934 | clusters.append( main.ONOScli4.clusters() ) |
| 935 | clusters.append( main.ONOScli5.clusters() ) |
| 936 | clusters.append( main.ONOScli6.clusters() ) |
| 937 | clusters.append( main.ONOScli7.clusters() ) |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 938 | # Compare json objects for hosts and dataplane clusters |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 939 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 940 | # hosts |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 941 | consistentHostsResult = main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 942 | for controller in range( len( hosts ) ): |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 943 | controllerStr = str( controller + 1 ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 944 | if "Error" not in hosts[ controller ]: |
| 945 | if hosts[ controller ] == hosts[ 0 ]: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 946 | continue |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 947 | else: # hosts not consistent |
| 948 | main.log.report( "hosts from ONOS" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 949 | controllerStr + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 950 | " is inconsistent with ONOS1" ) |
| 951 | main.log.warn( repr( hosts[ controller ] ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 952 | consistentHostsResult = main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 953 | |
| 954 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 955 | main.log.report( "Error in getting ONOS hosts from ONOS" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 956 | controllerStr ) |
| 957 | consistentHostsResult = main.FALSE |
| 958 | main.log.warn( "ONOS" + controllerStr + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 959 | " hosts response: " + |
| 960 | repr( hosts[ controller ] ) ) |
| 961 | utilities.assert_equals( |
| 962 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 963 | actual=consistentHostsResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 964 | onpass="Hosts view is consistent across all ONOS nodes", |
| 965 | onfail="ONOS nodes have different views of hosts" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 966 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 967 | # Strongly connected clusters of devices |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 968 | consistentClustersResult = main.TRUE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 969 | for controller in range( len( clusters ) ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 970 | if "Error" not in clusters[ controller ]: |
| 971 | if clusters[ controller ] == clusters[ 0 ]: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 972 | continue |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 973 | else: # clusters not consistent |
| 974 | main.log.report( "clusters from ONOS" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 975 | controllerStr + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 976 | " is inconsistent with ONOS1" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 977 | consistentClustersResult = main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 978 | |
| 979 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 980 | main.log.report( "Error in getting dataplane clusters " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 981 | "from ONOS" + controllerStr ) |
| 982 | consistentClustersResult = main.FALSE |
| 983 | main.log.warn( "ONOS" + controllerStr + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 984 | " clusters response: " + |
| 985 | repr( clusters[ controller ] ) ) |
| 986 | utilities.assert_equals( |
| 987 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 988 | actual=consistentClustersResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 989 | onpass="Clusters view is consistent across all ONOS nodes", |
| 990 | onfail="ONOS nodes have different views of clusters" ) |
| 991 | # there should always only be one cluster |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 992 | numClusters = len( json.loads( clusters[ 0 ] ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 993 | utilities.assert_equals( |
| 994 | expect=1, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 995 | actual=numClusters, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 996 | onpass="ONOS shows 1 SCC", |
| 997 | onfail="ONOS shows " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 998 | str( numClusters ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 999 | " SCCs" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1000 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1001 | main.step( "Comparing ONOS topology to MN" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1002 | devicesResults = main.TRUE |
| 1003 | portsResults = main.TRUE |
| 1004 | linksResults = main.TRUE |
| 1005 | for controller in range( numControllers ): |
| 1006 | controllerStr = str( controller + 1 ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1007 | if devices[ controller ] or "Error" not in devices[ controller ]: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1008 | currentDevicesResult = main.Mininet1.compareSwitches( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1009 | MNTopo, |
| 1010 | json.loads( |
| 1011 | devices[ controller ] ) ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1012 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1013 | currentDevicesResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1014 | utilities.assert_equals( expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1015 | actual=currentDevicesResult, |
| 1016 | onpass="ONOS" + controllerStr + |
| 1017 | " Switches view is correct", |
| 1018 | onfail="ONOS" + controllerStr + |
| 1019 | " Switches view is incorrect" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1020 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1021 | if ports[ controller ] or "Error" not in ports[ controller ]: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1022 | currentPortsResult = main.Mininet1.comparePorts( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1023 | MNTopo, |
| 1024 | json.loads( |
| 1025 | ports[ controller ] ) ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1026 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1027 | currentPortsResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1028 | utilities.assert_equals( expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1029 | actual=currentPortsResult, |
| 1030 | onpass="ONOS" + controllerStr + |
| 1031 | " ports view is correct", |
| 1032 | onfail="ONOS" + controllerStr + |
| 1033 | " ports view is incorrect" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1034 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1035 | if links[ controller ] or "Error" not in links[ controller ]: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1036 | currentLinksResult = main.Mininet1.compareLinks( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1037 | MNTopo, |
| 1038 | json.loads( |
| 1039 | links[ controller ] ) ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1040 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1041 | currentLinksResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1042 | utilities.assert_equals( expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1043 | actual=currentLinksResult, |
| 1044 | onpass="ONOS" + controllerStr + |
| 1045 | " links view is correct", |
| 1046 | onfail="ONOS" + controllerStr + |
| 1047 | " links view is incorrect" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1048 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1049 | devicesResults = devicesResults and currentDevicesResult |
| 1050 | portsResults = portsResults and currentPortsResult |
| 1051 | linksResults = linksResults and currentLinksResult |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1052 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1053 | topoResult = devicesResults and portsResults and linksResults\ |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1054 | and consistentHostsResult and consistentClustersResult |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1055 | utilities.assert_equals( expect=main.TRUE, actual=topoResult, |
| 1056 | onpass="Topology Check Test successful", |
| 1057 | onfail="Topology Check Test NOT successful" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1058 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1059 | finalAssert = main.TRUE |
| 1060 | finalAssert = finalAssert and topoResult and flowCheck \ |
| 1061 | and intentCheck and consistentMastership and rolesNotNull |
| 1062 | utilities.assert_equals( expect=main.TRUE, actual=finalAssert, |
| 1063 | onpass="State check successful", |
| 1064 | onfail="State check NOT successful" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1065 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1066 | def CASE6( self, main ): |
| 1067 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1068 | The Failure case. Since this is the Sanity test, we do nothing. |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1069 | """ |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 1070 | import time |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1071 | main.log.report( "Wait 60 seconds instead of inducing a failure" ) |
| 1072 | time.sleep( 60 ) |
| 1073 | utilities.assert_equals( |
| 1074 | expect=main.TRUE, |
| 1075 | actual=main.TRUE, |
| 1076 | onpass="Sleeping 60 seconds", |
| 1077 | onfail="Something is terribly wrong with my math" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1078 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1079 | def CASE7( self, main ): |
| 1080 | """ |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 1081 | Check state after ONOS failure |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1082 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1083 | import json |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1084 | main.case( "Running ONOS Constant State Tests" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1085 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1086 | # Assert that each device has a master |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1087 | ONOS1MasterNotNull = main.ONOScli1.rolesNotNull() |
| 1088 | ONOS2MasterNotNull = main.ONOScli2.rolesNotNull() |
| 1089 | ONOS3MasterNotNull = main.ONOScli3.rolesNotNull() |
| 1090 | ONOS4MasterNotNull = main.ONOScli4.rolesNotNull() |
| 1091 | ONOS5MasterNotNull = main.ONOScli5.rolesNotNull() |
| 1092 | ONOS6MasterNotNull = main.ONOScli6.rolesNotNull() |
| 1093 | ONOS7MasterNotNull = main.ONOScli7.rolesNotNull() |
| 1094 | rolesNotNull = ONOS1MasterNotNull and ONOS2MasterNotNull and\ |
| 1095 | ONOS3MasterNotNull and ONOS4MasterNotNull and\ |
| 1096 | ONOS5MasterNotNull and ONOS6MasterNotNull and\ |
| 1097 | ONOS7MasterNotNull |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1098 | utilities.assert_equals( |
| 1099 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1100 | actual=rolesNotNull, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1101 | onpass="Each device has a master", |
| 1102 | onfail="Some devices don't have a master assigned" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1103 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1104 | main.step( "Check if switch roles are consistent across all nodes" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1105 | ONOS1Mastership = main.ONOScli1.roles() |
| 1106 | ONOS2Mastership = main.ONOScli2.roles() |
| 1107 | ONOS3Mastership = main.ONOScli3.roles() |
| 1108 | ONOS4Mastership = main.ONOScli4.roles() |
| 1109 | ONOS5Mastership = main.ONOScli5.roles() |
| 1110 | ONOS6Mastership = main.ONOScli6.roles() |
| 1111 | ONOS7Mastership = main.ONOScli7.roles() |
| 1112 | # print json.dumps( json.loads( ONOS1Mastership ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1113 | # indent=4, separators=( ',', ': ' ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1114 | if "Error" in ONOS1Mastership or not ONOS1Mastership\ |
| 1115 | or "Error" in ONOS2Mastership or not ONOS2Mastership\ |
| 1116 | or "Error" in ONOS3Mastership or not ONOS3Mastership\ |
| 1117 | or "Error" in ONOS4Mastership or not ONOS4Mastership\ |
| 1118 | or "Error" in ONOS5Mastership or not ONOS5Mastership\ |
| 1119 | or "Error" in ONOS6Mastership or not ONOS6Mastership\ |
| 1120 | or "Error" in ONOS7Mastership or not ONOS7Mastership: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1121 | main.log.error( "Error in getting ONOS mastership" ) |
| 1122 | main.log.warn( "ONOS1 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1123 | repr( ONOS1Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1124 | main.log.warn( "ONOS2 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1125 | repr( ONOS2Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1126 | main.log.warn( "ONOS3 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1127 | repr( ONOS3Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1128 | main.log.warn( "ONOS4 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1129 | repr( ONOS4Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1130 | main.log.warn( "ONOS5 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1131 | repr( ONOS5Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1132 | main.log.warn( "ONOS6 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1133 | repr( ONOS6Mastership ) ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1134 | main.log.warn( "ONOS7 mastership response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1135 | repr( ONOS7Mastership ) ) |
| 1136 | consistentMastership = main.FALSE |
| 1137 | elif ONOS1Mastership == ONOS2Mastership\ |
| 1138 | and ONOS1Mastership == ONOS3Mastership\ |
| 1139 | and ONOS1Mastership == ONOS4Mastership\ |
| 1140 | and ONOS1Mastership == ONOS5Mastership\ |
| 1141 | and ONOS1Mastership == ONOS6Mastership\ |
| 1142 | and ONOS1Mastership == ONOS7Mastership: |
| 1143 | consistentMastership = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1144 | main.log.report( |
| 1145 | "Switch roles are consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1146 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1147 | main.log.warn( "ONOS1 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1148 | json.loads( ONOS1Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1149 | separators=( ',', ': ' ) ) ) |
| 1150 | main.log.warn( "ONOS2 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1151 | json.loads( ONOS2Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1152 | separators=( ',', ': ' ) ) ) |
| 1153 | main.log.warn( "ONOS3 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1154 | json.loads( ONOS3Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1155 | separators=( ',', ': ' ) ) ) |
| 1156 | main.log.warn( "ONOS4 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1157 | json.loads( ONOS4Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1158 | separators=( ',', ': ' ) ) ) |
| 1159 | main.log.warn( "ONOS5 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1160 | json.loads( ONOS5Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1161 | separators=( ',', ': ' ) ) ) |
| 1162 | main.log.warn( "ONOS6 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1163 | json.loads( ONOS6Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1164 | separators=( ',', ': ' ) ) ) |
| 1165 | main.log.warn( "ONOS7 roles: ", json.dumps( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1166 | json.loads( ONOS7Mastership ), sort_keys=True, indent=4, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1167 | separators=( ',', ': ' ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1168 | consistentMastership = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1169 | utilities.assert_equals( |
| 1170 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1171 | actual=consistentMastership, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1172 | onpass="Switch roles are consistent across all ONOS nodes", |
| 1173 | onfail="ONOS nodes have different views of switch roles" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1174 | |
| 1175 | description2 = "Compare switch roles from before failure" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1176 | main.step( description2 ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1177 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1178 | currentJson = json.loads( ONOS1Mastership ) |
| 1179 | oldJson = json.loads( mastershipState ) |
| 1180 | mastershipCheck = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1181 | for i in range( 1, 29 ): |
| 1182 | switchDPID = str( |
| 1183 | main.Mininet1.getSwitchDPID( |
| 1184 | switch="s" + |
| 1185 | str( i ) ) ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1186 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1187 | current = [ switch[ 'master' ] for switch in currentJson |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1188 | if switchDPID in switch[ 'id' ] ] |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1189 | old = [ switch[ 'master' ] for switch in oldJson |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1190 | if switchDPID in switch[ 'id' ] ] |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1191 | if current == old: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1192 | mastershipCheck = mastershipCheck and main.TRUE |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1193 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1194 | main.log.warn( "Mastership of switch %s changed" % switchDPID ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1195 | mastershipCheck = main.FALSE |
| 1196 | if mastershipCheck == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1197 | main.log.report( "Mastership of Switches was not changed" ) |
| 1198 | utilities.assert_equals( |
| 1199 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1200 | actual=mastershipCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1201 | onpass="Mastership of Switches was not changed", |
| 1202 | onfail="Mastership of some switches changed" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1203 | mastershipCheck = mastershipCheck and consistentMastership |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1204 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1205 | main.step( "Get the intents and compare across all nodes" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1206 | ONOS1Intents = main.ONOScli1.intents( jsonFormat=True ) |
| 1207 | ONOS2Intents = main.ONOScli2.intents( jsonFormat=True ) |
| 1208 | ONOS3Intents = main.ONOScli3.intents( jsonFormat=True ) |
| 1209 | ONOS4Intents = main.ONOScli4.intents( jsonFormat=True ) |
| 1210 | ONOS5Intents = main.ONOScli5.intents( jsonFormat=True ) |
| 1211 | ONOS6Intents = main.ONOScli6.intents( jsonFormat=True ) |
| 1212 | ONOS7Intents = main.ONOScli7.intents( jsonFormat=True ) |
| 1213 | intentCheck = main.FALSE |
| 1214 | if "Error" in ONOS1Intents or not ONOS1Intents\ |
| 1215 | or "Error" in ONOS2Intents or not ONOS2Intents\ |
| 1216 | or "Error" in ONOS3Intents or not ONOS3Intents\ |
| 1217 | or "Error" in ONOS4Intents or not ONOS4Intents\ |
| 1218 | or "Error" in ONOS5Intents or not ONOS5Intents\ |
| 1219 | or "Error" in ONOS6Intents or not ONOS6Intents\ |
| 1220 | or "Error" in ONOS7Intents or not ONOS7Intents: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1221 | main.log.report( "Error in getting ONOS intents" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1222 | main.log.warn( "ONOS1 intents response: " + repr( ONOS1Intents ) ) |
| 1223 | main.log.warn( "ONOS2 intents response: " + repr( ONOS2Intents ) ) |
| 1224 | main.log.warn( "ONOS3 intents response: " + repr( ONOS3Intents ) ) |
| 1225 | main.log.warn( "ONOS4 intents response: " + repr( ONOS4Intents ) ) |
| 1226 | main.log.warn( "ONOS5 intents response: " + repr( ONOS5Intents ) ) |
| 1227 | main.log.warn( "ONOS6 intents response: " + repr( ONOS6Intents ) ) |
| 1228 | main.log.warn( "ONOS7 intents response: " + repr( ONOS7Intents ) ) |
| 1229 | elif ONOS1Intents == ONOS2Intents\ |
| 1230 | and ONOS1Intents == ONOS3Intents\ |
| 1231 | and ONOS1Intents == ONOS4Intents\ |
| 1232 | and ONOS1Intents == ONOS5Intents\ |
| 1233 | and ONOS1Intents == ONOS6Intents\ |
| 1234 | and ONOS1Intents == ONOS7Intents: |
| 1235 | intentCheck = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1236 | main.log.report( "Intents are consistent across all ONOS nodes" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1237 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1238 | main.log.warn( "ONOS1 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1239 | print json.dumps( json.loads( ONOS1Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1240 | indent=4, separators=( ',', ': ' ) ) |
| 1241 | main.log.warn( "ONOS2 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1242 | print json.dumps( json.loads( ONOS2Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1243 | indent=4, separators=( ',', ': ' ) ) |
| 1244 | main.log.warn( "ONOS3 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1245 | print json.dumps( json.loads( ONOS3Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1246 | indent=4, separators=( ',', ': ' ) ) |
| 1247 | main.log.warn( "ONOS4 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1248 | print json.dumps( json.loads( ONOS4Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1249 | indent=4, separators=( ',', ': ' ) ) |
| 1250 | main.log.warn( "ONOS5 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1251 | print json.dumps( json.loads( ONOS5Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1252 | indent=4, separators=( ',', ': ' ) ) |
| 1253 | main.log.warn( "ONOS6 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1254 | print json.dumps( json.loads( ONOS6Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1255 | indent=4, separators=( ',', ': ' ) ) |
| 1256 | main.log.warn( "ONOS7 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1257 | print json.dumps( json.loads( ONOS7Intents ), sort_keys=True, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1258 | indent=4, separators=( ',', ': ' ) ) |
| 1259 | utilities.assert_equals( |
| 1260 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1261 | actual=intentCheck, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1262 | onpass="Intents are consistent across all ONOS nodes", |
| 1263 | onfail="ONOS nodes have different views of intents" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1264 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1265 | # NOTE: Hazelcast has no durability, so intents are lost across system |
| 1266 | # restarts |
| 1267 | main.step( "Compare current intents with intents before the failure" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1268 | # NOTE: this requires case 5 to pass for intentState to be set. |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1269 | # maybe we should stop the test if that fails? |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1270 | if intentState == ONOS1Intents: |
| 1271 | sameIntents = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1272 | main.log.report( "Intents are consistent with before failure" ) |
| 1273 | # TODO: possibly the states have changed? we may need to figure out |
| 1274 | # what the aceptable states are |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1275 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1276 | try: |
| 1277 | main.log.warn( "ONOS1 intents: " ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1278 | print json.dumps( json.loads( ONOS1Intents ), |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1279 | sort_keys=True, indent=4, |
| 1280 | separators=( ',', ': ' ) ) |
| 1281 | except: |
| 1282 | pass |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1283 | sameIntents = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1284 | utilities.assert_equals( |
| 1285 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1286 | actual=sameIntents, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1287 | onpass="Intents are consistent with before failure", |
| 1288 | onfail="The Intents changed during failure" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1289 | intentCheck = intentCheck and sameIntents |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1290 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1291 | main.step( "Get the OF Table entries and compare to before " + |
| 1292 | "component failure" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1293 | FlowTables = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1294 | flows2 = [] |
| 1295 | for i in range( 28 ): |
| 1296 | main.log.info( "Checking flow table on s" + str( i + 1 ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1297 | tmpFlows = main.Mininet2.getFlowTable( 1.3, "s" + str( i + 1 ) ) |
| 1298 | flows2.append( tmpFlows ) |
| 1299 | tempResult = main.Mininet2.flowComp( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1300 | flow1=flows[ i ], |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1301 | flow2=tmpFlows ) |
| 1302 | FlowTables = FlowTables and tempResult |
| 1303 | if FlowTables == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1304 | main.log.info( "Differences in flow table for switch: s" + |
| 1305 | str( i + 1 ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1306 | if FlowTables == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1307 | main.log.report( "No changes were found in the flow tables" ) |
| 1308 | utilities.assert_equals( |
| 1309 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1310 | actual=FlowTables, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1311 | onpass="No changes were found in the flow tables", |
| 1312 | onfail="Changes were found in the flow tables" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1313 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1314 | main.step( "Check the continuous pings to ensure that no packets " + |
| 1315 | "were dropped during component failure" ) |
| 1316 | # FIXME: This check is always failing. Investigate cause |
| 1317 | # NOTE: this may be something to do with file permsissions |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1318 | # or slight change in format |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1319 | main.Mininet2.pingKill( |
| 1320 | main.params[ 'TESTONUSER' ], |
| 1321 | main.params[ 'TESTONIP' ] ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1322 | LossInPings = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1323 | # NOTE: checkForLoss returns main.FALSE with 0% packet loss |
| 1324 | for i in range( 8, 18 ): |
| 1325 | main.log.info( |
| 1326 | "Checking for a loss in pings along flow from s" + |
| 1327 | str( i ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1328 | LossInPings = main.Mininet2.checkForLoss( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1329 | "/tmp/ping.h" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1330 | str( i ) ) or LossInPings |
| 1331 | if LossInPings == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1332 | main.log.info( "Loss in ping detected" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1333 | elif LossInPings == main.ERROR: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1334 | main.log.info( "There are multiple mininet process running" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1335 | elif LossInPings == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1336 | main.log.info( "No Loss in the pings" ) |
| 1337 | main.log.report( "No loss of dataplane connectivity" ) |
| 1338 | utilities.assert_equals( |
| 1339 | expect=main.FALSE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1340 | actual=LossInPings, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1341 | onpass="No Loss of connectivity", |
| 1342 | onfail="Loss of dataplane connectivity detected" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1343 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1344 | # Test of LeadershipElection |
| 1345 | # NOTE: this only works for the sanity test. In case of failures, |
| 1346 | # leader will likely change |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1347 | leader = ONOS1Ip |
| 1348 | leaderResult = main.TRUE |
| 1349 | for controller in range( 1, numControllers + 1 ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1350 | # loop through ONOScli handlers |
| 1351 | node = getattr( main, ( 'ONOScli' + str( controller ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1352 | leaderN = node.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1353 | # verify leader is ONOS1 |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1354 | if leaderN == leader: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1355 | # all is well |
| 1356 | # NOTE: In failure scenario, this could be a new node, maybe |
| 1357 | # check != ONOS1 |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1358 | pass |
| 1359 | elif leaderN == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1360 | # error in response |
| 1361 | main.log.report( "Something is wrong with " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1362 | "electionTestLeader function," + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1363 | " check the error logs" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1364 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1365 | elif leader != leaderN: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1366 | leaderResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1367 | main.log.report( "ONOS" + str( controller ) + " sees " + |
| 1368 | str( leaderN ) + |
| 1369 | " as the leader of the election app. " + |
| 1370 | "Leader should be " + str( leader ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1371 | if leaderResult: |
| 1372 | main.log.report( "Leadership election tests passed( consistent " + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1373 | "view of leader across listeners and a new " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1374 | "leader was re-elected if applicable )" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1375 | utilities.assert_equals( |
| 1376 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1377 | actual=leaderResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1378 | onpass="Leadership election passed", |
| 1379 | onfail="Something went wrong with Leadership election" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1380 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1381 | result = mastershipCheck and intentCheck and FlowTables and\ |
| 1382 | ( not LossInPings ) and rolesNotNull and leaderResult |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1383 | result = int( result ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1384 | if result == main.TRUE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1385 | main.log.report( "Constant State Tests Passed" ) |
| 1386 | utilities.assert_equals( expect=main.TRUE, actual=result, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1387 | onpass="Constant State Tests Passed", |
| 1388 | onfail="Constant state tests failed" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1389 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1390 | def CASE8( self, main ): |
| 1391 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1392 | Compare topo |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1393 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1394 | import sys |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1395 | # FIXME add this path to params |
| 1396 | sys.path.append( "/home/admin/sts" ) |
| 1397 | # assumes that sts is already in you PYTHONPATH |
| 1398 | from sts.topology.teston_topology import TestONTopology |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1399 | import json |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1400 | import time |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1401 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1402 | description = "Compare ONOS Topology view to Mininet topology" |
| 1403 | main.case( description ) |
| 1404 | main.log.report( description ) |
| 1405 | main.step( "Create TestONTopology object" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1406 | ctrls = [] |
| 1407 | count = 1 |
| 1408 | while True: |
| 1409 | temp = () |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1410 | if ( 'ip' + str( count ) ) in main.params[ 'CTRL' ]: |
| 1411 | temp = temp + ( getattr( main, ( 'ONOS' + str( count ) ) ), ) |
| 1412 | temp = temp + ( "ONOS" + str( count ), ) |
| 1413 | temp = temp + ( main.params[ 'CTRL' ][ 'ip' + str( count ) ], ) |
| 1414 | temp = temp + \ |
| 1415 | ( eval( main.params[ 'CTRL' ][ 'port' + str( count ) ] ), ) |
| 1416 | ctrls.append( temp ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1417 | count = count + 1 |
| 1418 | else: |
| 1419 | break |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1420 | MNTopo = TestONTopology( |
| 1421 | main.Mininet1, |
| 1422 | ctrls ) # can also add Intent API info for intent operations |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1423 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1424 | main.step( "Comparing ONOS topology to MN" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1425 | devicesResults = main.TRUE |
| 1426 | portsResults = main.TRUE |
| 1427 | linksResults = main.TRUE |
| 1428 | topoResult = main.FALSE |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1429 | elapsed = 0 |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 1430 | count = 0 |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1431 | main.step( "Collecting topology information from ONOS" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1432 | startTime = time.time() |
| 1433 | while topoResult == main.FALSE and elapsed < 60: |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 1434 | count = count + 1 |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1435 | if count > 1: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1436 | # TODO: Depricate STS usage |
| 1437 | MNTopo = TestONTopology( |
| 1438 | main.Mininet1, |
| 1439 | ctrls ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1440 | cliStart = time.time() |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1441 | devices = [] |
| 1442 | devices.append( main.ONOScli1.devices() ) |
| 1443 | devices.append( main.ONOScli2.devices() ) |
| 1444 | devices.append( main.ONOScli3.devices() ) |
| 1445 | devices.append( main.ONOScli4.devices() ) |
| 1446 | devices.append( main.ONOScli5.devices() ) |
| 1447 | devices.append( main.ONOScli6.devices() ) |
| 1448 | devices.append( main.ONOScli7.devices() ) |
| 1449 | hosts = [] |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1450 | hosts.append( json.loads( main.ONOScli1.hosts() ) ) |
| 1451 | hosts.append( json.loads( main.ONOScli2.hosts() ) ) |
| 1452 | hosts.append( json.loads( main.ONOScli3.hosts() ) ) |
| 1453 | hosts.append( json.loads( main.ONOScli4.hosts() ) ) |
| 1454 | hosts.append( json.loads( main.ONOScli5.hosts() ) ) |
| 1455 | hosts.append( json.loads( main.ONOScli6.hosts() ) ) |
| 1456 | hosts.append( json.loads( main.ONOScli7.hosts() ) ) |
| 1457 | for controller in range( 0, len( hosts ) ): |
| 1458 | controllerStr = str( controller + 1 ) |
| 1459 | for host in hosts[ controller ]: |
| 1460 | host |
| 1461 | if host[ 'ips' ] == []: |
| 1462 | main.log.error( |
| 1463 | "DEBUG:Error with host ips on controller" + |
| 1464 | controllerStr + ": " + str( host ) ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1465 | ports = [] |
| 1466 | ports.append( main.ONOScli1.ports() ) |
| 1467 | ports.append( main.ONOScli2.ports() ) |
| 1468 | ports.append( main.ONOScli3.ports() ) |
| 1469 | ports.append( main.ONOScli4.ports() ) |
| 1470 | ports.append( main.ONOScli5.ports() ) |
| 1471 | ports.append( main.ONOScli6.ports() ) |
| 1472 | ports.append( main.ONOScli7.ports() ) |
| 1473 | links = [] |
| 1474 | links.append( main.ONOScli1.links() ) |
| 1475 | links.append( main.ONOScli2.links() ) |
| 1476 | links.append( main.ONOScli3.links() ) |
| 1477 | links.append( main.ONOScli4.links() ) |
| 1478 | links.append( main.ONOScli5.links() ) |
| 1479 | links.append( main.ONOScli6.links() ) |
| 1480 | links.append( main.ONOScli7.links() ) |
| 1481 | clusters = [] |
| 1482 | clusters.append( main.ONOScli1.clusters() ) |
| 1483 | clusters.append( main.ONOScli2.clusters() ) |
| 1484 | clusters.append( main.ONOScli3.clusters() ) |
| 1485 | clusters.append( main.ONOScli4.clusters() ) |
| 1486 | clusters.append( main.ONOScli5.clusters() ) |
| 1487 | clusters.append( main.ONOScli6.clusters() ) |
| 1488 | clusters.append( main.ONOScli7.clusters() ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1489 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1490 | elapsed = time.time() - startTime |
| 1491 | cliTime = time.time() - cliStart |
| 1492 | print "CLI time: " + str( cliTime ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1493 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1494 | try: |
| 1495 | for controller in range( numControllers ): |
| 1496 | controllerStr = str( controller + 1 ) |
| 1497 | if devices[ controller ] or "Error" not in devices[ |
| 1498 | controller ]: |
| 1499 | currentDevicesResult = main.Mininet1.compareSwitches( |
| 1500 | MNTopo, |
| 1501 | json.loads( |
| 1502 | devices[ controller ] ) ) |
| 1503 | else: |
| 1504 | currentDevicesResult = main.FALSE |
| 1505 | utilities.assert_equals( expect=main.TRUE, |
| 1506 | actual=currentDevicesResult, |
| 1507 | onpass="ONOS" + controllerStr + |
| 1508 | " Switches view is correct", |
| 1509 | onfail="ONOS" + controllerStr + |
| 1510 | " Switches view is incorrect" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1511 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1512 | if ports[ controller ] or "Error" not in ports[ controller ]: |
| 1513 | currentPortsResult = main.Mininet1.comparePorts( |
| 1514 | MNTopo, |
| 1515 | json.loads( |
| 1516 | ports[ controller ] ) ) |
| 1517 | else: |
| 1518 | currentPortsResult = main.FALSE |
| 1519 | utilities.assert_equals( expect=main.TRUE, |
| 1520 | actual=currentPortsResult, |
| 1521 | onpass="ONOS" + controllerStr + |
| 1522 | " ports view is correct", |
| 1523 | onfail="ONOS" + controllerStr + |
| 1524 | " ports view is incorrect" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1525 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1526 | if links[ controller ] or "Error" not in links[ controller ]: |
| 1527 | currentLinksResult = main.Mininet1.compareLinks( |
| 1528 | MNTopo, |
| 1529 | json.loads( |
| 1530 | links[ controller ] ) ) |
| 1531 | else: |
| 1532 | currentLinksResult = main.FALSE |
| 1533 | utilities.assert_equals( expect=main.TRUE, |
| 1534 | actual=currentLinksResult, |
| 1535 | onpass="ONOS" + controllerStr + |
| 1536 | " links view is correct", |
| 1537 | onfail="ONOS" + controllerStr + |
| 1538 | " links view is incorrect" ) |
| 1539 | devicesResults = devicesResults and currentDevicesResult |
| 1540 | portsResults = portsResults and currentPortsResult |
| 1541 | linksResults = linksResults and currentLinksResult |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1542 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1543 | # Compare json objects for hosts and dataplane clusters |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1544 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1545 | # hosts |
| 1546 | consistentHostsResult = main.TRUE |
| 1547 | for controller in range( len( hosts ) ): |
| 1548 | controllerStr = str( controller + 1 ) |
| 1549 | if "Error" not in hosts[ controller ]: |
| 1550 | if hosts[ controller ] == hosts[ 0 ]: |
| 1551 | continue |
| 1552 | else: # hosts not consistent |
| 1553 | main.log.report( "hosts from ONOS" + controllerStr + |
| 1554 | " is inconsistent with ONOS1" ) |
| 1555 | main.log.warn( repr( hosts[ controller ] ) ) |
| 1556 | consistentHostsResult = main.FALSE |
| 1557 | |
| 1558 | else: |
| 1559 | main.log.report( "Error in getting ONOS hosts from ONOS" + |
| 1560 | controllerStr ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1561 | consistentHostsResult = main.FALSE |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1562 | main.log.warn( "ONOS" + controllerStr + |
| 1563 | " hosts response: " + |
| 1564 | repr( hosts[ controller ] ) ) |
| 1565 | utilities.assert_equals( |
| 1566 | expect=main.TRUE, |
| 1567 | actual=consistentHostsResult, |
| 1568 | onpass="Hosts view is consistent across all ONOS nodes", |
| 1569 | onfail="ONOS nodes have different views of hosts" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1570 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1571 | # Strongly connected clusters of devices |
| 1572 | consistentClustersResult = main.TRUE |
| 1573 | for controller in range( len( clusters ) ): |
| 1574 | controllerStr = str( controller + 1 ) |
| 1575 | if "Error" not in clusters[ controller ]: |
| 1576 | if clusters[ controller ] == clusters[ 0 ]: |
| 1577 | continue |
| 1578 | else: # clusters not consistent |
| 1579 | main.log.report( "clusters from ONOS" + |
| 1580 | controllerStr + |
| 1581 | " is inconsistent with ONOS1" ) |
| 1582 | consistentClustersResult = main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1583 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1584 | else: |
| 1585 | main.log.report( "Error in getting dataplane clusters " + |
| 1586 | "from ONOS" + controllerStr ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1587 | consistentClustersResult = main.FALSE |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1588 | main.log.warn( "ONOS" + controllerStr + |
| 1589 | " clusters response: " + |
| 1590 | repr( clusters[ controller ] ) ) |
| 1591 | utilities.assert_equals( |
| 1592 | expect=main.TRUE, |
| 1593 | actual=consistentClustersResult, |
| 1594 | onpass="Clusters view is consistent across all ONOS nodes", |
| 1595 | onfail="ONOS nodes have different views of clusters" ) |
| 1596 | # there should always only be one cluster |
| 1597 | numClusters = len( json.loads( clusters[ 0 ] ) ) |
| 1598 | utilities.assert_equals( |
| 1599 | expect=1, |
| 1600 | actual=numClusters, |
| 1601 | onpass="ONOS shows 1 SCC", |
| 1602 | onfail="ONOS shows " + |
| 1603 | str( numClusters ) + |
| 1604 | " SCCs" ) |
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 | topoResult = ( devicesResults and portsResults and linksResults |
| 1607 | and consistentHostsResult |
| 1608 | and consistentClustersResult ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1609 | |
Jon Hall | 529a37f | 2015-01-28 10:02:00 -0800 | [diff] [blame] | 1610 | topoResult = topoResult and int( count <= 2 ) |
| 1611 | note = "note it takes about " + str( int( cliTime ) ) + \ |
| 1612 | " seconds for the test to make all the cli calls to fetch " +\ |
| 1613 | "the topology from each ONOS instance" |
| 1614 | main.log.report( |
| 1615 | "Very crass estimate for topology discovery/convergence( " + |
| 1616 | str( note ) + " ): " + str( elapsed ) + " seconds, " + |
| 1617 | str( count ) + " tries" ) |
| 1618 | utilities.assert_equals( expect=main.TRUE, actual=topoResult, |
| 1619 | onpass="Topology Check Test successful", |
| 1620 | onfail="Topology Check Test NOT successful" ) |
| 1621 | if topoResult == main.TRUE: |
| 1622 | main.log.report( "ONOS topology view matches Mininet topology" ) |
| 1623 | except: |
| 1624 | main.log.info( self.name + " ::::::" ) |
| 1625 | main.log.error( traceback.print_exc() ) |
| 1626 | main.log.info( self.name + " ::::::" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1627 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1628 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1629 | def CASE9( self, main ): |
| 1630 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1631 | Link s3-s28 down |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1632 | """ |
| 1633 | import time |
| 1634 | # NOTE: You should probably run a topology check after this |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1635 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1636 | linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1637 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1638 | description = "Turn off a link to ensure that Link Discovery " +\ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1639 | "is working properly" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1640 | main.log.report( description ) |
| 1641 | main.case( description ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1642 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1643 | main.step( "Kill Link between s3 and s28" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1644 | LinkDown = main.Mininet1.link( END1="s3", END2="s28", OPTION="down" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1645 | main.log.info( |
| 1646 | "Waiting " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1647 | str( linkSleep ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1648 | " seconds for link down to be discovered" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1649 | time.sleep( linkSleep ) |
| 1650 | utilities.assert_equals( expect=main.TRUE, actual=LinkDown, |
| 1651 | onpass="Link down succesful", |
| 1652 | onfail="Failed to bring link down" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1653 | # TODO do some sort of check here |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1654 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1655 | def CASE10( self, main ): |
| 1656 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1657 | Link s3-s28 up |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1658 | """ |
| 1659 | import time |
| 1660 | # NOTE: You should probably run a topology check after this |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1661 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1662 | linkSleep = float( main.params[ 'timers' ][ 'LinkDiscovery' ] ) |
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 | description = "Restore a link to ensure that Link Discovery is " + \ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1665 | "working properly" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1666 | main.log.report( description ) |
| 1667 | main.case( description ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1668 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1669 | main.step( "Bring link between s3 and s28 back up" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1670 | LinkUp = main.Mininet1.link( END1="s3", END2="s28", OPTION="up" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1671 | main.log.info( |
| 1672 | "Waiting " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1673 | str( linkSleep ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1674 | " seconds for link up to be discovered" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1675 | time.sleep( linkSleep ) |
| 1676 | utilities.assert_equals( expect=main.TRUE, actual=LinkUp, |
| 1677 | onpass="Link up succesful", |
| 1678 | onfail="Failed to bring link up" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1679 | # TODO do some sort of check here |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1680 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1681 | def CASE11( self, main ): |
| 1682 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1683 | Switch Down |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1684 | """ |
| 1685 | # NOTE: You should probably run a topology check after this |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1686 | import time |
| 1687 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1688 | switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1689 | |
| 1690 | description = "Killing a switch to ensure it is discovered correctly" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1691 | main.log.report( description ) |
| 1692 | main.case( description ) |
| 1693 | switch = main.params[ 'kill' ][ 'switch' ] |
| 1694 | switchDPID = main.params[ 'kill' ][ 'dpid' ] |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1695 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1696 | # TODO: Make this switch parameterizable |
| 1697 | main.step( "Kill " + switch ) |
| 1698 | main.log.report( "Deleting " + switch ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1699 | main.Mininet1.delSwitch( switch ) |
| 1700 | main.log.info( "Waiting " + str( switchSleep ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1701 | " seconds for switch down to be discovered" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1702 | time.sleep( switchSleep ) |
| 1703 | device = main.ONOScli1.getDevice( dpid=switchDPID ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1704 | # Peek at the deleted switch |
| 1705 | main.log.warn( str( device ) ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1706 | result = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1707 | if device and device[ 'available' ] is False: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1708 | result = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1709 | utilities.assert_equals( expect=main.TRUE, actual=result, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1710 | onpass="Kill switch succesful", |
| 1711 | onfail="Failed to kill switch?" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1712 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1713 | def CASE12( self, main ): |
| 1714 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1715 | Switch Up |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1716 | """ |
| 1717 | # NOTE: You should probably run a topology check after this |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1718 | import time |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1719 | |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1720 | switchSleep = float( main.params[ 'timers' ][ 'SwitchDiscovery' ] ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1721 | switch = main.params[ 'kill' ][ 'switch' ] |
| 1722 | switchDPID = main.params[ 'kill' ][ 'dpid' ] |
| 1723 | links = main.params[ 'kill' ][ 'links' ].split() |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1724 | description = "Adding a switch to ensure it is discovered correctly" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1725 | main.log.report( description ) |
| 1726 | main.case( description ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1727 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1728 | main.step( "Add back " + switch ) |
| 1729 | main.log.report( "Adding back " + switch ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1730 | main.Mininet1.addSwitch( switch, dpid=switchDPID ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1731 | # TODO: New dpid or same? Ask Thomas? |
| 1732 | for peer in links: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1733 | main.Mininet1.addLink( switch, peer ) |
| 1734 | main.Mininet1.assignSwController( |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1735 | sw=switch.split( 's' )[ 1 ], |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1736 | count=numControllers, |
| 1737 | ip1=ONOS1Ip, |
| 1738 | port1=ONOS1Port, |
| 1739 | ip2=ONOS2Ip, |
| 1740 | port2=ONOS2Port, |
| 1741 | ip3=ONOS3Ip, |
| 1742 | port3=ONOS3Port, |
| 1743 | ip4=ONOS4Ip, |
| 1744 | port4=ONOS4Port, |
| 1745 | ip5=ONOS5Ip, |
| 1746 | port5=ONOS5Port, |
| 1747 | ip6=ONOS6Ip, |
| 1748 | port6=ONOS6Port, |
| 1749 | ip7=ONOS7Ip, |
| 1750 | port7=ONOS7Port ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1751 | main.log.info( |
| 1752 | "Waiting " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1753 | str( switchSleep ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1754 | " seconds for switch up to be discovered" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1755 | time.sleep( switchSleep ) |
| 1756 | device = main.ONOScli1.getDevice( dpid=switchDPID ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1757 | # Peek at the deleted switch |
| 1758 | main.log.warn( str( device ) ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1759 | result = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1760 | if device and device[ 'available' ]: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1761 | result = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1762 | utilities.assert_equals( expect=main.TRUE, actual=result, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1763 | onpass="add switch succesful", |
| 1764 | onfail="Failed to add switch?" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1765 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1766 | def CASE13( self, main ): |
| 1767 | """ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1768 | Clean up |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1769 | """ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1770 | import os |
| 1771 | import time |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1772 | # TODO: make use of this elsewhere |
| 1773 | ips = [] |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1774 | ips.append( ONOS1Ip ) |
| 1775 | ips.append( ONOS2Ip ) |
| 1776 | ips.append( ONOS3Ip ) |
| 1777 | ips.append( ONOS4Ip ) |
| 1778 | ips.append( ONOS5Ip ) |
| 1779 | ips.append( ONOS6Ip ) |
| 1780 | ips.append( ONOS7Ip ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1781 | |
| 1782 | # printing colors to terminal |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1783 | colors = {} |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1784 | colors[ 'cyan' ] = '\033[96m' |
| 1785 | colors[ 'purple' ] = '\033[95m' |
| 1786 | colors[ 'blue' ] = '\033[94m' |
| 1787 | colors[ 'green' ] = '\033[92m' |
| 1788 | colors[ 'yellow' ] = '\033[93m' |
| 1789 | colors[ 'red' ] = '\033[91m' |
| 1790 | colors[ 'end' ] = '\033[0m' |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 1791 | description = "Test Cleanup" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1792 | main.log.report( description ) |
| 1793 | main.case( description ) |
| 1794 | main.step( "Killing tcpdumps" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1795 | main.Mininet2.stopTcpdump() |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1796 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1797 | main.step( "Checking ONOS Logs for errors" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1798 | for i in range( 7 ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1799 | print colors[ 'purple' ] + "Checking logs for errors on " + \ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1800 | "ONOS" + str( i + 1 ) + ":" + colors[ 'end' ] |
| 1801 | print main.ONOSbench.checkLogs( ips[ i ] ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1802 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1803 | main.step( "Copying MN pcap and ONOS log files to test station" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1804 | testname = main.TEST |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1805 | teststationUser = main.params[ 'TESTONUSER' ] |
| 1806 | teststationIP = main.params[ 'TESTONIP' ] |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1807 | # NOTE: MN Pcap file is being saved to ~/packet_captures |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1808 | # 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] | 1809 | # FIXME: scp |
| 1810 | # mn files |
| 1811 | # TODO: Load these from params |
| 1812 | # NOTE: must end in / |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1813 | logFolder = "/opt/onos/log/" |
| 1814 | logFiles = [ "karaf.log", "karaf.log.1" ] |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1815 | # NOTE: must end in / |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1816 | dstDir = "~/packet_captures/" |
| 1817 | for f in logFiles: |
| 1818 | for i in range( 7 ): |
| 1819 | main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" + |
| 1820 | logFolder + f + " " + |
| 1821 | teststationUser + "@" + |
| 1822 | teststationIP + ":" + |
| 1823 | dstDir + str( testname ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1824 | "-ONOS" + str( i + 1 ) + "-" + |
| 1825 | f ) |
| 1826 | # std*.log's |
| 1827 | # NOTE: must end in / |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1828 | logFolder = "/opt/onos/var/" |
| 1829 | logFiles = [ "stderr.log", "stdout.log" ] |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1830 | # NOTE: must end in / |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1831 | dstDir = "~/packet_captures/" |
| 1832 | for f in logFiles: |
| 1833 | for i in range( 7 ): |
| 1834 | main.ONOSbench.handle.sendline( "scp sdn@" + ips[ i ] + ":" + |
| 1835 | logFolder + f + " " + |
| 1836 | teststationUser + "@" + |
| 1837 | teststationIP + ":" + |
| 1838 | dstDir + str( testname ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1839 | "-ONOS" + str( i + 1 ) + "-" + |
| 1840 | f ) |
| 1841 | # sleep so scp can finish |
| 1842 | time.sleep( 10 ) |
| 1843 | main.step( "Packing and rotating pcap archives" ) |
| 1844 | os.system( "~/TestON/dependencies/rotate.sh " + str( testname ) ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1845 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1846 | # TODO: actually check something here |
| 1847 | utilities.assert_equals( expect=main.TRUE, actual=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1848 | onpass="Test cleanup successful", |
| 1849 | onfail="Test cleanup NOT successful" ) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1850 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1851 | def CASE14( self, main ): |
| 1852 | """ |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1853 | start election app on all onos nodes |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1854 | """ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1855 | leaderResult = main.TRUE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1856 | # install app on onos 1 |
| 1857 | main.log.info( "Install leadership election app" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1858 | main.ONOScli1.featureInstall( "onos-app-election" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1859 | # wait for election |
| 1860 | # check for leader |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1861 | leader = main.ONOScli1.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1862 | # verify leader is ONOS1 |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1863 | if leader == ONOS1Ip: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1864 | # all is well |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1865 | pass |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1866 | elif leader is None: |
| 1867 | # No leader elected |
| 1868 | main.log.report( "No leader was elected" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1869 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1870 | elif leader == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1871 | # error in response |
| 1872 | # TODO: add check for "Command not found:" in the driver, this |
| 1873 | # means the app isn't loaded |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1874 | main.log.report( "Something is wrong with electionTestLeader" + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1875 | " function, check the error logs" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1876 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1877 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1878 | # error in response |
| 1879 | main.log.report( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1880 | "Unexpected response from electionTestLeader function:'" + |
| 1881 | str( leader ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1882 | "'" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1883 | leaderResult = main.FALSE |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1884 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1885 | # install on other nodes and check for leader. |
| 1886 | # Should be onos1 and each app should show the same leader |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1887 | for controller in range( 2, numControllers + 1 ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1888 | # loop through ONOScli handlers |
| 1889 | node = getattr( main, ( 'ONOScli' + str( controller ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1890 | node.featureInstall( "onos-app-election" ) |
| 1891 | leaderN = node.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1892 | # verify leader is ONOS1 |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1893 | if leaderN == ONOS1Ip: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1894 | # all is well |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1895 | pass |
| 1896 | elif leaderN == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1897 | # error in response |
| 1898 | # TODO: add check for "Command not found:" in the driver, this |
| 1899 | # means the app isn't loaded |
| 1900 | main.log.report( "Something is wrong with " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1901 | "electionTestLeader function, check the" + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1902 | " error logs" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1903 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1904 | elif leader != leaderN: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1905 | leaderResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1906 | main.log.report( "ONOS" + str( controller ) + " sees " + |
| 1907 | str( leaderN ) + |
| 1908 | " as the leader of the election app. Leader" + |
| 1909 | " should be " + |
| 1910 | str( leader ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1911 | if leaderResult: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1912 | main.log.report( "Leadership election tests passed( consistent " + |
| 1913 | "view of leader across listeners and a leader " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1914 | "was elected )" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1915 | utilities.assert_equals( |
| 1916 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1917 | actual=leaderResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1918 | onpass="Leadership election passed", |
| 1919 | onfail="Something went wrong with Leadership election" ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame] | 1920 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1921 | def CASE15( self, main ): |
| 1922 | """ |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1923 | Check that Leadership Election is still functional |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1924 | """ |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1925 | leaderResult = main.TRUE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1926 | description = "Check that Leadership Election is still functional" |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1927 | main.log.report( description ) |
| 1928 | main.case( description ) |
| 1929 | main.step( "Find current leader and withdraw" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1930 | leader = main.ONOScli1.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1931 | # TODO: do some sanity checking on leader before using it |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1932 | withdrawResult = main.FALSE |
| 1933 | if leader == ONOS1Ip: |
| 1934 | oldLeader = getattr( main, "ONOScli1" ) |
| 1935 | elif leader == ONOS2Ip: |
| 1936 | oldLeader = getattr( main, "ONOScli2" ) |
| 1937 | elif leader == ONOS3Ip: |
| 1938 | oldLeader = getattr( main, "ONOScli3" ) |
| 1939 | elif leader == ONOS4Ip: |
| 1940 | oldLeader = getattr( main, "ONOScli4" ) |
| 1941 | elif leader == ONOS5Ip: |
| 1942 | oldLeader = getattr( main, "ONOScli5" ) |
| 1943 | elif leader == ONOS6Ip: |
| 1944 | oldLeader = getattr( main, "ONOScli6" ) |
| 1945 | elif leader == ONOS7Ip: |
| 1946 | oldLeader = getattr( main, "ONOScli7" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1947 | elif leader is None or leader == main.FALSE: |
| 1948 | main.log.report( |
| 1949 | "Leader for the election app should be an ONOS node," + |
| 1950 | "instead got '" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1951 | str( leader ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1952 | "'" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1953 | leaderResult = main.FALSE |
| 1954 | withdrawResult = oldLeader.electionTestWithdraw() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1955 | utilities.assert_equals( |
| 1956 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1957 | actual=withdrawResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1958 | onpass="App was withdrawn from election", |
| 1959 | onfail="App was not withdrawn from election" ) |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1960 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1961 | main.step( "Make sure new leader is elected" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1962 | leaderList = [] |
| 1963 | for controller in range( 1, numControllers + 1 ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1964 | # loop through ONOScli handlers |
| 1965 | node = getattr( main, ( 'ONOScli' + str( controller ) ) ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1966 | leaderList.append( node.electionTestLeader() ) |
| 1967 | for leaderN in leaderList: |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1968 | if leaderN == leader: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1969 | main.log.report( |
| 1970 | "ONOS" + |
| 1971 | str( controller ) + |
| 1972 | " still sees " + |
| 1973 | str( leader ) + |
| 1974 | " as leader after they withdrew" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1975 | leaderResult = main.FALSE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1976 | elif leaderN == main.FALSE: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1977 | # error in response |
| 1978 | # TODO: add check for "Command not found:" in the driver, this |
| 1979 | # means the app isn't loaded |
| 1980 | main.log.report( "Something is wrong with " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1981 | "electionTestLeader function, " + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1982 | "check the error logs" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1983 | leaderResult = main.FALSE |
| 1984 | consistentLeader = main.FALSE |
| 1985 | if len( set( leaderList ) ) == 1: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1986 | main.log.info( "Each Election-app sees '" + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1987 | str( leaderList[ 0 ] ) + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1988 | "' as the leader" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1989 | consistentLeader = main.TRUE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 1990 | else: |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1991 | main.log.report( |
| 1992 | "Inconsistent responses for leader of Election-app:" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1993 | for n in range( len( leaderList ) ): |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1994 | main.log.report( "ONOS" + str( n + 1 ) + " response: " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 1995 | str( leaderList[ n ] ) ) |
| 1996 | if leaderResult: |
| 1997 | main.log.report( "Leadership election tests passed( consistent " + |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 1998 | "view of leader across listeners and a new " + |
| 1999 | "leader was elected when the old leader " + |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2000 | "resigned )" ) |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2001 | utilities.assert_equals( |
| 2002 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2003 | actual=leaderResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2004 | onpass="Leadership election passed", |
| 2005 | onfail="Something went wrong with Leadership election" ) |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 2006 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2007 | main.step( |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2008 | "Run for election on old leader( just so everyone is in the hat )" ) |
| 2009 | runResult = oldLeader.electionTestRun() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2010 | utilities.assert_equals( |
| 2011 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2012 | actual=runResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2013 | onpass="App re-ran for election", |
| 2014 | onfail="App failed to run for election" ) |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2015 | if consistentLeader == main.TRUE: |
| 2016 | afterRun = main.ONOScli1.electionTestLeader() |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2017 | # verify leader didn't just change |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2018 | if afterRun == leaderList[ 0 ]: |
| 2019 | leaderResult = main.TRUE |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 2020 | else: |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2021 | leaderResult = main.FALSE |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2022 | # TODO: assert on run and withdraw results? |
Jon Hall | 669173b | 2014-12-17 11:36:30 -0800 | [diff] [blame] | 2023 | |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2024 | utilities.assert_equals( |
| 2025 | expect=main.TRUE, |
Jon Hall | 8f89dda | 2015-01-22 16:03:33 -0800 | [diff] [blame] | 2026 | actual=leaderResult, |
Jon Hall | 6aec96b | 2015-01-19 14:49:31 -0800 | [diff] [blame] | 2027 | onpass="Leadership election passed", |
| 2028 | onfail="Something went wrong with Leadership election after " + |
| 2029 | "the old leader re-ran for election" ) |