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