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