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