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