Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1 | ''' |
| 2 | Description: This test is to determine if the HA test setup is |
| 3 | working correctly. There are no failures so this test should |
| 4 | have a 100% pass rate |
| 5 | |
| 6 | List of test cases: |
| 7 | CASE1: Compile ONOS and push it to the test machines |
| 8 | CASE2: Assign mastership to controllers |
| 9 | CASE3: Assign intents |
| 10 | CASE4: Ping across added host intents |
| 11 | CASE5: Reading state of ONOS |
| 12 | CASE6: The Failure case. Since this is the Sanity test, we do nothing. |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 13 | CASE7: Check state after control plane failure |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 14 | CASE8: Compare topo |
| 15 | CASE9: Link s3-s28 down |
| 16 | CASE10: Link s3-s28 up |
| 17 | CASE11: Switch down |
| 18 | CASE12: Switch up |
| 19 | CASE13: Clean up |
| 20 | ''' |
| 21 | class HATestSanity: |
| 22 | |
| 23 | def __init__(self) : |
| 24 | self.default = '' |
| 25 | |
| 26 | def CASE1(self,main) : |
| 27 | ''' |
| 28 | CASE1 is to compile ONOS and push it to the test machines |
| 29 | |
| 30 | Startup sequence: |
| 31 | git pull |
| 32 | mvn clean install |
| 33 | onos-package |
| 34 | cell <name> |
| 35 | onos-verify-cell |
| 36 | NOTE: temporary - onos-remove-raft-logs |
| 37 | onos-install -f |
| 38 | onos-wait-for-start |
| 39 | ''' |
| 40 | import time |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 41 | main.log.report("ONOS HA Sanity test - initialization") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 42 | main.case("Setting up test environment") |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 43 | #TODO: save all the timers and output them for plotting |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 44 | |
| 45 | # load some vairables from the params file |
| 46 | PULL_CODE = False |
| 47 | if main.params['Git'] == 'True': |
| 48 | PULL_CODE = True |
| 49 | cell_name = main.params['ENV']['cellName'] |
| 50 | |
| 51 | #set global variables |
| 52 | global ONOS1_ip |
| 53 | global ONOS1_port |
| 54 | global ONOS2_ip |
| 55 | global ONOS2_port |
| 56 | global ONOS3_ip |
| 57 | global ONOS3_port |
| 58 | global ONOS4_ip |
| 59 | global ONOS4_port |
| 60 | global ONOS5_ip |
| 61 | global ONOS5_port |
| 62 | global ONOS6_ip |
| 63 | global ONOS6_port |
| 64 | global ONOS7_ip |
| 65 | global ONOS7_port |
| 66 | |
| 67 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 68 | ONOS1_port = main.params['CTRL']['port1'] |
| 69 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 70 | ONOS2_port = main.params['CTRL']['port2'] |
| 71 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 72 | ONOS3_port = main.params['CTRL']['port3'] |
| 73 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 74 | ONOS4_port = main.params['CTRL']['port4'] |
| 75 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 76 | ONOS5_port = main.params['CTRL']['port5'] |
| 77 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 78 | ONOS6_port = main.params['CTRL']['port6'] |
| 79 | ONOS7_ip = main.params['CTRL']['ip7'] |
| 80 | ONOS7_port = main.params['CTRL']['port7'] |
| 81 | |
| 82 | |
| 83 | main.step("Applying cell variable to environment") |
| 84 | cell_result = main.ONOSbench.set_cell(cell_name) |
| 85 | verify_result = main.ONOSbench.verify_cell() |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 86 | |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 87 | #FIXME:this is short term fix |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 88 | main.log.report("Removing raft logs") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 89 | main.ONOSbench.onos_remove_raft_logs() |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 90 | main.log.report("Uninstalling ONOS") |
| 91 | main.ONOSbench.onos_uninstall(ONOS1_ip) |
| 92 | main.ONOSbench.onos_uninstall(ONOS2_ip) |
| 93 | main.ONOSbench.onos_uninstall(ONOS3_ip) |
| 94 | main.ONOSbench.onos_uninstall(ONOS4_ip) |
| 95 | main.ONOSbench.onos_uninstall(ONOS5_ip) |
| 96 | main.ONOSbench.onos_uninstall(ONOS6_ip) |
| 97 | main.ONOSbench.onos_uninstall(ONOS7_ip) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 98 | |
| 99 | clean_install_result = main.TRUE |
| 100 | git_pull_result = main.TRUE |
| 101 | |
| 102 | main.step("Compiling the latest version of ONOS") |
| 103 | if PULL_CODE: |
| 104 | main.step("Git checkout and pull master") |
| 105 | main.ONOSbench.git_checkout("master") |
| 106 | git_pull_result = main.ONOSbench.git_pull() |
| 107 | |
| 108 | main.step("Using mvn clean & install") |
| 109 | clean_install_result = main.TRUE |
| 110 | if git_pull_result == main.TRUE: |
| 111 | clean_install_result = main.ONOSbench.clean_install() |
| 112 | else: |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 113 | main.log.warn("Did not pull new code so skipping mvn "+ \ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 114 | "clean install") |
| 115 | main.ONOSbench.get_version(report=True) |
| 116 | |
| 117 | main.step("Creating ONOS package") |
| 118 | package_result = main.ONOSbench.onos_package() |
| 119 | |
| 120 | main.step("Installing ONOS package") |
| 121 | onos1_install_result = main.ONOSbench.onos_install(options="-f", |
| 122 | node=ONOS1_ip) |
| 123 | onos2_install_result = main.ONOSbench.onos_install(options="-f", |
| 124 | node=ONOS2_ip) |
| 125 | onos3_install_result = main.ONOSbench.onos_install(options="-f", |
| 126 | node=ONOS3_ip) |
| 127 | onos4_install_result = main.ONOSbench.onos_install(options="-f", |
| 128 | node=ONOS4_ip) |
| 129 | onos5_install_result = main.ONOSbench.onos_install(options="-f", |
| 130 | node=ONOS5_ip) |
| 131 | onos6_install_result = main.ONOSbench.onos_install(options="-f", |
| 132 | node=ONOS6_ip) |
| 133 | onos7_install_result = main.ONOSbench.onos_install(options="-f", |
| 134 | node=ONOS7_ip) |
| 135 | onos_install_result = onos1_install_result and onos2_install_result\ |
| 136 | and onos3_install_result and onos4_install_result\ |
| 137 | and onos5_install_result and onos6_install_result\ |
| 138 | and onos7_install_result |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 139 | ''' |
| 140 | #FIXME: work around until onos is less fragile |
| 141 | main.ONOSbench.handle.sendline("onos-cluster-install") |
| 142 | print main.ONOSbench.handle.expect("\$") |
| 143 | onos_install_result = main.TRUE |
| 144 | ''' |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 145 | |
| 146 | |
| 147 | main.step("Checking if ONOS is up yet") |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 148 | #TODO: Refactor |
| 149 | # check bundle:list? |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 150 | for i in range(2): |
| 151 | onos1_isup = main.ONOSbench.isup(ONOS1_ip) |
| 152 | if not onos1_isup: |
| 153 | main.log.report("ONOS1 didn't start!") |
| 154 | onos2_isup = main.ONOSbench.isup(ONOS2_ip) |
| 155 | if not onos2_isup: |
| 156 | main.log.report("ONOS2 didn't start!") |
| 157 | onos3_isup = main.ONOSbench.isup(ONOS3_ip) |
| 158 | if not onos3_isup: |
| 159 | main.log.report("ONOS3 didn't start!") |
| 160 | onos4_isup = main.ONOSbench.isup(ONOS4_ip) |
| 161 | if not onos4_isup: |
| 162 | main.log.report("ONOS4 didn't start!") |
| 163 | onos5_isup = main.ONOSbench.isup(ONOS5_ip) |
| 164 | if not onos5_isup: |
| 165 | main.log.report("ONOS5 didn't start!") |
| 166 | onos6_isup = main.ONOSbench.isup(ONOS6_ip) |
| 167 | if not onos6_isup: |
| 168 | main.log.report("ONOS6 didn't start!") |
| 169 | onos7_isup = main.ONOSbench.isup(ONOS7_ip) |
| 170 | if not onos7_isup: |
| 171 | main.log.report("ONOS7 didn't start!") |
| 172 | onos_isup_result = onos1_isup and onos2_isup and onos3_isup\ |
| 173 | and onos4_isup and onos5_isup and onos6_isup and onos7_isup |
| 174 | if onos_isup_result == main.TRUE: |
| 175 | break |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 176 | # TODO: if it becomes an issue, we can retry this step a few times |
| 177 | |
| 178 | |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 179 | cli_result1 = main.ONOScli1.start_onos_cli(ONOS1_ip) |
| 180 | cli_result2 = main.ONOScli2.start_onos_cli(ONOS2_ip) |
| 181 | cli_result3 = main.ONOScli3.start_onos_cli(ONOS3_ip) |
| 182 | cli_result4 = main.ONOScli4.start_onos_cli(ONOS4_ip) |
| 183 | cli_result5 = main.ONOScli5.start_onos_cli(ONOS5_ip) |
| 184 | cli_result6 = main.ONOScli6.start_onos_cli(ONOS6_ip) |
| 185 | cli_result7 = main.ONOScli7.start_onos_cli(ONOS7_ip) |
| 186 | cli_results = cli_result1 and cli_result2 and cli_result3 and\ |
| 187 | cli_result4 and cli_result5 and cli_result6 and cli_result7 |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 188 | |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 189 | main.step("Start Packet Capture MN") |
| 190 | main.Mininet2.start_tcpdump( |
| 191 | str(main.params['MNtcpdump']['folder'])+str(main.TEST)+"-MN.pcap", |
| 192 | intf = main.params['MNtcpdump']['intf'], |
| 193 | port = main.params['MNtcpdump']['port']) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 194 | |
| 195 | |
| 196 | case1_result = (clean_install_result and package_result and |
| 197 | cell_result and verify_result and onos_install_result and |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 198 | onos_isup_result and cli_results) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 199 | |
| 200 | utilities.assert_equals(expect=main.TRUE, actual=case1_result, |
| 201 | onpass="Test startup successful", |
| 202 | onfail="Test startup NOT successful") |
| 203 | |
| 204 | |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 205 | if case1_result==main.FALSE: |
| 206 | main.cleanup() |
| 207 | main.exit() |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 208 | |
| 209 | def CASE2(self,main) : |
| 210 | ''' |
| 211 | Assign mastership to controllers |
| 212 | ''' |
| 213 | import time |
| 214 | import json |
| 215 | import re |
| 216 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 217 | main.log.report("Assigning switches to controllers") |
| 218 | main.case("Assigning Controllers") |
| 219 | main.step("Assign switches to controllers") |
| 220 | |
| 221 | for i in range (1,29): |
| 222 | main.Mininet1.assign_sw_controller(sw=str(i),count=7, |
| 223 | ip1=ONOS1_ip,port1=ONOS1_port, |
| 224 | ip2=ONOS2_ip,port2=ONOS2_port, |
| 225 | ip3=ONOS3_ip,port3=ONOS3_port, |
| 226 | ip4=ONOS4_ip,port4=ONOS4_port, |
| 227 | ip5=ONOS5_ip,port5=ONOS5_port, |
| 228 | ip6=ONOS6_ip,port6=ONOS6_port, |
| 229 | ip7=ONOS7_ip,port7=ONOS7_port) |
| 230 | |
| 231 | mastership_check = main.TRUE |
| 232 | for i in range (1,29): |
| 233 | response = main.Mininet1.get_sw_controller("s"+str(i)) |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 234 | try: |
| 235 | main.log.info(str(response)) |
| 236 | except: |
| 237 | main.log.info(repr(response)) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 238 | if re.search("tcp:"+ONOS1_ip,response)\ |
| 239 | and re.search("tcp:"+ONOS2_ip,response)\ |
| 240 | and re.search("tcp:"+ONOS3_ip,response)\ |
| 241 | and re.search("tcp:"+ONOS4_ip,response)\ |
| 242 | and re.search("tcp:"+ONOS5_ip,response)\ |
| 243 | and re.search("tcp:"+ONOS6_ip,response)\ |
| 244 | and re.search("tcp:"+ONOS7_ip,response): |
| 245 | mastership_check = mastership_check and main.TRUE |
| 246 | else: |
| 247 | mastership_check = main.FALSE |
| 248 | if mastership_check == main.TRUE: |
| 249 | main.log.report("Switch mastership assigned correctly") |
| 250 | utilities.assert_equals(expect = main.TRUE,actual=mastership_check, |
| 251 | onpass="Switch mastership assigned correctly", |
| 252 | onfail="Switches not assigned correctly to controllers") |
| 253 | |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 254 | #Manually assign mastership to the controller we want |
| 255 | role_call = main.TRUE |
| 256 | role_check = main.TRUE |
| 257 | |
| 258 | device_id = main.ONOScli1.get_device("1000")['id'] |
| 259 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS1_ip) |
| 260 | if ONOS1_ip in main.ONOScli1.get_role(device_id)['master']: |
| 261 | role_check = role_check and main.TRUE |
| 262 | else: |
| 263 | role_check = role_check and main.FALSE |
| 264 | |
| 265 | device_id = main.ONOScli1.get_device("2800")['id'] |
| 266 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS1_ip) |
| 267 | if ONOS1_ip in main.ONOScli1.get_role(device_id)['master']: |
| 268 | role_check = role_check and main.TRUE |
| 269 | else: |
| 270 | role_check = role_check and main.FALSE |
| 271 | |
| 272 | device_id = main.ONOScli1.get_device("2000")['id'] |
| 273 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS2_ip) |
| 274 | if ONOS2_ip in main.ONOScli1.get_role(device_id)['master']: |
| 275 | role_check = role_check and main.TRUE |
| 276 | else: |
| 277 | role_check = role_check and main.FALSE |
| 278 | |
| 279 | device_id = main.ONOScli1.get_device("3000")['id'] |
| 280 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS2_ip) |
| 281 | if ONOS2_ip in main.ONOScli1.get_role(device_id)['master']: |
| 282 | role_check = role_check and main.TRUE |
| 283 | else: |
| 284 | role_check = role_check and main.FALSE |
| 285 | |
| 286 | device_id = main.ONOScli1.get_device("5000")['id'] |
| 287 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS3_ip) |
| 288 | if ONOS3_ip in main.ONOScli1.get_role(device_id)['master']: |
| 289 | role_check = role_check and main.TRUE |
| 290 | else: |
| 291 | role_check = role_check and main.FALSE |
| 292 | |
| 293 | device_id = main.ONOScli1.get_device("6000")['id'] |
| 294 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS3_ip) |
| 295 | if ONOS3_ip in main.ONOScli1.get_role(device_id)['master']: |
| 296 | role_check = role_check and main.TRUE |
| 297 | else: |
| 298 | role_check = role_check and main.FALSE |
| 299 | |
| 300 | device_id = main.ONOScli1.get_device("3004")['id'] |
| 301 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS4_ip) |
| 302 | if ONOS4_ip in main.ONOScli1.get_role(device_id)['master']: |
| 303 | role_check = role_check and main.TRUE |
| 304 | else: |
| 305 | role_check = role_check and main.FALSE |
| 306 | |
| 307 | device_id = main.ONOScli1.get_device("3008")['id'] |
| 308 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 309 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 310 | role_check = role_check and main.TRUE |
| 311 | else: |
| 312 | role_check = role_check and main.FALSE |
| 313 | |
| 314 | device_id = main.ONOScli1.get_device("3009")['id'] |
| 315 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 316 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 317 | role_check = role_check and main.TRUE |
| 318 | else: |
| 319 | role_check = role_check and main.FALSE |
| 320 | |
| 321 | device_id = main.ONOScli1.get_device("3010")['id'] |
| 322 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 323 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 324 | role_check = role_check and main.TRUE |
| 325 | else: |
| 326 | role_check = role_check and main.FALSE |
| 327 | |
| 328 | device_id = main.ONOScli1.get_device("3011")['id'] |
| 329 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 330 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 331 | role_check = role_check and main.TRUE |
| 332 | else: |
| 333 | role_check = role_check and main.FALSE |
| 334 | |
| 335 | device_id = main.ONOScli1.get_device("3012")['id'] |
| 336 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 337 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 338 | role_check = role_check and main.TRUE |
| 339 | else: |
| 340 | role_check = role_check and main.FALSE |
| 341 | |
| 342 | device_id = main.ONOScli1.get_device("3013")['id'] |
| 343 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 344 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 345 | role_check = role_check and main.TRUE |
| 346 | else: |
| 347 | role_check = role_check and main.FALSE |
| 348 | |
| 349 | device_id = main.ONOScli1.get_device("3014")['id'] |
| 350 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 351 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 352 | role_check = role_check and main.TRUE |
| 353 | else: |
| 354 | role_check = role_check and main.FALSE |
| 355 | |
| 356 | device_id = main.ONOScli1.get_device("3015")['id'] |
| 357 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 358 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 359 | role_check = role_check and main.TRUE |
| 360 | else: |
| 361 | role_check = role_check and main.FALSE |
| 362 | |
| 363 | device_id = main.ONOScli1.get_device("3016")['id'] |
| 364 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 365 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 366 | role_check = role_check and main.TRUE |
| 367 | else: |
| 368 | role_check = role_check and main.FALSE |
| 369 | |
| 370 | device_id = main.ONOScli1.get_device("3017")['id'] |
| 371 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS5_ip) |
| 372 | if ONOS5_ip in main.ONOScli1.get_role(device_id)['master']: |
| 373 | role_check = role_check and main.TRUE |
| 374 | else: |
| 375 | role_check = role_check and main.FALSE |
| 376 | |
| 377 | device_id = main.ONOScli1.get_device("6007")['id'] |
| 378 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS6_ip) |
| 379 | if ONOS6_ip in main.ONOScli1.get_role(device_id)['master']: |
| 380 | role_check = role_check and main.TRUE |
| 381 | else: |
| 382 | role_check = role_check and main.FALSE |
| 383 | |
| 384 | device_id = main.ONOScli1.get_device("6018")['id'] |
| 385 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 386 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 387 | role_check = role_check and main.TRUE |
| 388 | else: |
| 389 | role_check = role_check and main.FALSE |
| 390 | |
| 391 | device_id = main.ONOScli1.get_device("6019")['id'] |
| 392 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 393 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 394 | role_check = role_check and main.TRUE |
| 395 | else: |
| 396 | role_check = role_check and main.FALSE |
| 397 | |
| 398 | device_id = main.ONOScli1.get_device("6020")['id'] |
| 399 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 400 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 401 | role_check = role_check and main.TRUE |
| 402 | else: |
| 403 | role_check = role_check and main.FALSE |
| 404 | |
| 405 | device_id = main.ONOScli1.get_device("6021")['id'] |
| 406 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 407 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 408 | role_check = role_check and main.TRUE |
| 409 | else: |
| 410 | role_check = role_check and main.FALSE |
| 411 | |
| 412 | device_id = main.ONOScli1.get_device("6022")['id'] |
| 413 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 414 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 415 | role_check = role_check and main.TRUE |
| 416 | else: |
| 417 | role_check = role_check and main.FALSE |
| 418 | |
| 419 | device_id = main.ONOScli1.get_device("6023")['id'] |
| 420 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 421 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 422 | role_check = role_check and main.TRUE |
| 423 | else: |
| 424 | role_check = role_check and main.FALSE |
| 425 | |
| 426 | device_id = main.ONOScli1.get_device("6024")['id'] |
| 427 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 428 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 429 | role_check = role_check and main.TRUE |
| 430 | else: |
| 431 | role_check = role_check and main.FALSE |
| 432 | |
| 433 | device_id = main.ONOScli1.get_device("6025")['id'] |
| 434 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 435 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 436 | role_check = role_check and main.TRUE |
| 437 | else: |
| 438 | role_check = role_check and main.FALSE |
| 439 | |
| 440 | device_id = main.ONOScli1.get_device("6026")['id'] |
| 441 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 442 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 443 | role_check = role_check and main.TRUE |
| 444 | else: |
| 445 | role_check = role_check and main.FALSE |
| 446 | |
| 447 | device_id = main.ONOScli1.get_device("6027")['id'] |
| 448 | role_call = role_call and main.ONOScli1.device_role(device_id, ONOS7_ip) |
| 449 | if ONOS7_ip in main.ONOScli1.get_role(device_id)['master']: |
| 450 | role_check = role_check and main.TRUE |
| 451 | else: |
| 452 | role_check = role_check and main.FALSE |
| 453 | |
| 454 | utilities.assert_equals(expect = main.TRUE,actual=role_call, |
| 455 | onpass="Re-assigned switch mastership to designated controller", |
| 456 | onfail="Something wrong with device_role calls") |
| 457 | |
| 458 | utilities.assert_equals(expect = main.TRUE,actual=role_check, |
| 459 | onpass="Switches were successfully reassigned to designated controller", |
| 460 | onfail="Switches were not successfully reassigned") |
| 461 | mastership_check = mastership_check and role_call and role_check |
| 462 | utilities.assert_equals(expect = main.TRUE,actual=mastership_check, |
| 463 | onpass="Switch mastership correctly assigned", |
| 464 | onfail="Error in (re)assigning switch mastership") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 465 | |
| 466 | |
| 467 | def CASE3(self,main) : |
| 468 | """ |
| 469 | Assign intents |
| 470 | |
| 471 | """ |
| 472 | import time |
| 473 | import json |
| 474 | import re |
| 475 | main.log.report("Adding host intents") |
| 476 | main.case("Adding host Intents") |
| 477 | |
| 478 | main.step("Discovering Hosts( Via pingall for now)") |
| 479 | #FIXME: Once we have a host discovery mechanism, use that instead |
| 480 | |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 481 | #install onos-app-fwd |
| 482 | main.log.info("Install reactive forwarding app") |
| 483 | main.ONOScli1.feature_install("onos-app-fwd") |
| 484 | main.ONOScli2.feature_install("onos-app-fwd") |
| 485 | main.ONOScli3.feature_install("onos-app-fwd") |
| 486 | main.ONOScli4.feature_install("onos-app-fwd") |
| 487 | main.ONOScli5.feature_install("onos-app-fwd") |
| 488 | main.ONOScli6.feature_install("onos-app-fwd") |
| 489 | main.ONOScli7.feature_install("onos-app-fwd") |
| 490 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 491 | #REACTIVE FWD test |
| 492 | ping_result = main.FALSE |
| 493 | time1 = time.time() |
| 494 | ping_result = main.Mininet1.pingall() |
| 495 | time2 = time.time() |
| 496 | main.log.info("Time for pingall: %2f seconds" % (time2 - time1)) |
| 497 | |
| 498 | #uninstall onos-app-fwd |
| 499 | main.log.info("Uninstall reactive forwarding app") |
| 500 | main.ONOScli1.feature_uninstall("onos-app-fwd") |
| 501 | main.ONOScli2.feature_uninstall("onos-app-fwd") |
| 502 | main.ONOScli3.feature_uninstall("onos-app-fwd") |
| 503 | main.ONOScli4.feature_uninstall("onos-app-fwd") |
| 504 | main.ONOScli5.feature_uninstall("onos-app-fwd") |
| 505 | main.ONOScli6.feature_uninstall("onos-app-fwd") |
| 506 | main.ONOScli7.feature_uninstall("onos-app-fwd") |
| 507 | |
| 508 | main.step("Add host intents") |
| 509 | #TODO: move the host numbers to params |
| 510 | import json |
| 511 | intents_json= json.loads(main.ONOScli1.hosts()) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 512 | intent_add_result = True |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 513 | for i in range(8,18): |
| 514 | main.log.info("Adding host intent between h"+str(i)+" and h"+str(i+10)) |
| 515 | host1 = "00:00:00:00:00:" + str(hex(i)[2:]).zfill(2).upper() |
| 516 | host2 = "00:00:00:00:00:" + str(hex(i+10)[2:]).zfill(2).upper() |
| 517 | #NOTE: get host can return None |
| 518 | #TODO: handle this |
| 519 | host1_id = main.ONOScli1.get_host(host1)['id'] |
| 520 | host2_id = main.ONOScli1.get_host(host2)['id'] |
| 521 | tmp_result = main.ONOScli1.add_host_intent(host1_id, host2_id ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 522 | intent_add_result = bool(intent_add_result and tmp_result) |
| 523 | utilities.assert_equals(expect=True, actual=intent_add_result, |
| 524 | onpass="Switch mastership correctly assigned", |
| 525 | onfail="Error in (re)assigning switch mastership") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 526 | #TODO Check if intents all exist in datastore |
| 527 | #NOTE: Do we need to print this once the test is working? |
| 528 | #main.log.info(json.dumps(json.loads(main.ONOScli1.intents(json_format=True)), |
| 529 | # sort_keys=True, indent=4, separators=(',', ': ') ) ) |
| 530 | |
| 531 | def CASE4(self,main) : |
| 532 | """ |
| 533 | Ping across added host intents |
| 534 | """ |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 535 | description = " Ping across added host intents" |
| 536 | main.log.report(description) |
| 537 | main.case(description) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 538 | Ping_Result = main.TRUE |
| 539 | for i in range(8,18): |
| 540 | ping = main.Mininet1.pingHost(src="h"+str(i),target="h"+str(i+10)) |
| 541 | Ping_Result = Ping_Result and ping |
| 542 | if ping==main.FALSE: |
| 543 | main.log.warn("Ping failed between h"+str(i)+" and h" + str(i+10)) |
| 544 | elif ping==main.TRUE: |
| 545 | main.log.info("Ping test passed!") |
| 546 | Ping_Result = main.TRUE |
| 547 | if Ping_Result==main.FALSE: |
| 548 | main.log.report("Intents have not been installed correctly, pings failed.") |
| 549 | if Ping_Result==main.TRUE: |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 550 | main.log.report("Intents have been installed correctly and verified by pings") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 551 | utilities.assert_equals(expect = main.TRUE,actual=Ping_Result, |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 552 | onpass="Intents have been installed correctly and pings work", |
| 553 | onfail ="Intents have not been installed correctly, pings failed." ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 554 | |
| 555 | def CASE5(self,main) : |
| 556 | ''' |
| 557 | Reading state of ONOS |
| 558 | ''' |
| 559 | import time |
| 560 | import json |
| 561 | from subprocess import Popen, PIPE |
| 562 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 563 | |
| 564 | main.log.report("Setting up and gathering data for current state") |
| 565 | main.case("Setting up and gathering data for current state") |
| 566 | #The general idea for this test case is to pull the state of (intents,flows, topology,...) from each ONOS node |
| 567 | #We can then compare them with eachother and also with past states |
| 568 | |
| 569 | main.step("Get the Mastership of each switch from each controller") |
| 570 | global mastership_state |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 571 | mastership_state = [] |
| 572 | |
| 573 | #Assert that each device has a master |
| 574 | ONOS1_master_not_null = main.ONOScli1.roles_not_null() |
| 575 | ONOS2_master_not_null = main.ONOScli2.roles_not_null() |
| 576 | ONOS3_master_not_null = main.ONOScli3.roles_not_null() |
| 577 | ONOS4_master_not_null = main.ONOScli4.roles_not_null() |
| 578 | ONOS5_master_not_null = main.ONOScli5.roles_not_null() |
| 579 | ONOS6_master_not_null = main.ONOScli6.roles_not_null() |
| 580 | ONOS7_master_not_null = main.ONOScli7.roles_not_null() |
| 581 | roles_not_null = ONOS1_master_not_null and ONOS2_master_not_null and\ |
| 582 | ONOS3_master_not_null and ONOS4_master_not_null and\ |
| 583 | ONOS5_master_not_null and ONOS6_master_not_null and\ |
| 584 | ONOS7_master_not_null |
| 585 | utilities.assert_equals(expect = main.TRUE,actual=roles_not_null, |
| 586 | onpass="Each device has a master", |
| 587 | onfail="Some devices don't have a master assigned") |
| 588 | |
| 589 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 590 | ONOS1_mastership = main.ONOScli1.roles() |
| 591 | ONOS2_mastership = main.ONOScli2.roles() |
| 592 | ONOS3_mastership = main.ONOScli3.roles() |
| 593 | ONOS4_mastership = main.ONOScli4.roles() |
| 594 | ONOS5_mastership = main.ONOScli5.roles() |
| 595 | ONOS6_mastership = main.ONOScli6.roles() |
| 596 | ONOS7_mastership = main.ONOScli7.roles() |
| 597 | #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': ')) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 598 | if "Error" in ONOS1_mastership or not ONOS1_mastership\ |
| 599 | or "Error" in ONOS2_mastership or not ONOS2_mastership\ |
| 600 | or "Error" in ONOS3_mastership or not ONOS3_mastership\ |
| 601 | or "Error" in ONOS4_mastership or not ONOS4_mastership\ |
| 602 | or "Error" in ONOS5_mastership or not ONOS5_mastership\ |
| 603 | or "Error" in ONOS6_mastership or not ONOS6_mastership\ |
| 604 | or "Error" in ONOS7_mastership or not ONOS7_mastership: |
| 605 | main.log.report("Error in getting ONOS roles") |
| 606 | main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership)) |
| 607 | main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership)) |
| 608 | main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership)) |
| 609 | main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership)) |
| 610 | main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership)) |
| 611 | main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership)) |
| 612 | main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership)) |
| 613 | consistent_mastership = main.FALSE |
| 614 | elif ONOS1_mastership == ONOS2_mastership\ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 615 | and ONOS1_mastership == ONOS3_mastership\ |
| 616 | and ONOS1_mastership == ONOS4_mastership\ |
| 617 | and ONOS1_mastership == ONOS5_mastership\ |
| 618 | and ONOS1_mastership == ONOS6_mastership\ |
| 619 | and ONOS1_mastership == ONOS7_mastership: |
| 620 | mastership_state = ONOS1_mastership |
| 621 | consistent_mastership = main.TRUE |
| 622 | main.log.report("Switch roles are consistent across all ONOS nodes") |
| 623 | else: |
| 624 | main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership), |
| 625 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 626 | main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership), |
| 627 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 628 | main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership), |
| 629 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 630 | main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership), |
| 631 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 632 | main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership), |
| 633 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 634 | main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership), |
| 635 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 636 | main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership), |
| 637 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 638 | consistent_mastership = main.FALSE |
| 639 | utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership, |
| 640 | onpass="Switch roles are consistent across all ONOS nodes", |
| 641 | onfail="ONOS nodes have different views of switch roles") |
| 642 | |
| 643 | |
| 644 | main.step("Get the intents from each controller") |
| 645 | global intent_state |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 646 | intent_state = [] |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 647 | ONOS1_intents = main.ONOScli1.intents( json_format=True ) |
| 648 | ONOS2_intents = main.ONOScli2.intents( json_format=True ) |
| 649 | ONOS3_intents = main.ONOScli3.intents( json_format=True ) |
| 650 | ONOS4_intents = main.ONOScli4.intents( json_format=True ) |
| 651 | ONOS5_intents = main.ONOScli5.intents( json_format=True ) |
| 652 | ONOS6_intents = main.ONOScli6.intents( json_format=True ) |
| 653 | ONOS7_intents = main.ONOScli7.intents( json_format=True ) |
| 654 | intent_check = main.FALSE |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 655 | if "Error" in ONOS1_intents or not ONOS1_intents\ |
| 656 | or "Error" in ONOS2_intents or not ONOS2_intents\ |
| 657 | or "Error" in ONOS3_intents or not ONOS3_intents\ |
| 658 | or "Error" in ONOS4_intents or not ONOS4_intents\ |
| 659 | or "Error" in ONOS5_intents or not ONOS5_intents\ |
| 660 | or "Error" in ONOS6_intents or not ONOS6_intents\ |
| 661 | or "Error" in ONOS7_intents or not ONOS7_intents: |
| 662 | main.log.report("Error in getting ONOS intents") |
| 663 | main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents)) |
| 664 | main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents)) |
| 665 | main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents)) |
| 666 | main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents)) |
| 667 | main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents)) |
| 668 | main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents)) |
| 669 | main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents)) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 670 | elif ONOS1_intents == ONOS2_intents\ |
| 671 | and ONOS1_intents == ONOS3_intents\ |
| 672 | and ONOS1_intents == ONOS4_intents\ |
| 673 | and ONOS1_intents == ONOS5_intents\ |
| 674 | and ONOS1_intents == ONOS6_intents\ |
| 675 | and ONOS1_intents == ONOS7_intents: |
| 676 | intent_state = ONOS1_intents |
| 677 | intent_check = main.TRUE |
| 678 | main.log.report("Intents are consistent across all ONOS nodes") |
| 679 | else: |
| 680 | main.log.warn("ONOS1 intents: ", json.dumps(json.loads(ONOS1_intents), |
| 681 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 682 | main.log.warn("ONOS2 intents: ", json.dumps(json.loads(ONOS2_intents), |
| 683 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 684 | main.log.warn("ONOS3 intents: ", json.dumps(json.loads(ONOS3_intents), |
| 685 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 686 | main.log.warn("ONOS4 intents: ", json.dumps(json.loads(ONOS4_intents), |
| 687 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 688 | main.log.warn("ONOS5 intents: ", json.dumps(json.loads(ONOS5_intents), |
| 689 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 690 | main.log.warn("ONOS6 intents: ", json.dumps(json.loads(ONOS6_intents), |
| 691 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 692 | main.log.warn("ONOS7 intents: ", json.dumps(json.loads(ONOS7_intents), |
| 693 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 694 | utilities.assert_equals(expect = main.TRUE,actual=intent_check, |
| 695 | onpass="Intents are consistent across all ONOS nodes", |
| 696 | onfail="ONOS nodes have different views of intents") |
| 697 | |
| 698 | |
| 699 | main.step("Get the flows from each controller") |
| 700 | global flow_state |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 701 | flow_state = [] |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 702 | ONOS1_flows = main.ONOScli1.flows( json_format=True ) |
| 703 | ONOS2_flows = main.ONOScli2.flows( json_format=True ) |
| 704 | ONOS3_flows = main.ONOScli3.flows( json_format=True ) |
| 705 | ONOS4_flows = main.ONOScli4.flows( json_format=True ) |
| 706 | ONOS5_flows = main.ONOScli5.flows( json_format=True ) |
| 707 | ONOS6_flows = main.ONOScli6.flows( json_format=True ) |
| 708 | ONOS7_flows = main.ONOScli7.flows( json_format=True ) |
| 709 | flow_check = main.FALSE |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 710 | if "Error" in ONOS1_flows or not ONOS1_flows\ |
| 711 | or "Error" in ONOS2_flows or not ONOS2_flows\ |
| 712 | or "Error" in ONOS3_flows or not ONOS3_flows\ |
| 713 | or "Error" in ONOS4_flows or not ONOS4_flows\ |
| 714 | or "Error" in ONOS5_flows or not ONOS5_flows\ |
| 715 | or "Error" in ONOS6_flows or not ONOS6_flows\ |
| 716 | or "Error" in ONOS7_flows or not ONOS7_flows: |
| 717 | main.log.report("Error in getting ONOS intents") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 718 | main.log.warn("ONOS1 flows repsponse: "+ ONOS1_flows) |
| 719 | main.log.warn("ONOS2 flows repsponse: "+ ONOS2_flows) |
| 720 | main.log.warn("ONOS3 flows repsponse: "+ ONOS3_flows) |
| 721 | main.log.warn("ONOS4 flows repsponse: "+ ONOS4_flows) |
| 722 | main.log.warn("ONOS5 flows repsponse: "+ ONOS5_flows) |
| 723 | main.log.warn("ONOS6 flows repsponse: "+ ONOS6_flows) |
| 724 | main.log.warn("ONOS7 flows repsponse: "+ ONOS7_flows) |
| 725 | elif len(json.loads(ONOS1_flows)) == len(json.loads(ONOS2_flows))\ |
| 726 | and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS3_flows))\ |
| 727 | and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS4_flows))\ |
| 728 | and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS5_flows))\ |
| 729 | and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS6_flows))\ |
| 730 | and len(json.loads(ONOS1_flows)) == len(json.loads(ONOS7_flows)): |
| 731 | #TODO: Do a better check, maybe compare flows on switches? |
| 732 | flow_state = ONOS1_flows |
| 733 | flow_check = main.TRUE |
| 734 | main.log.report("Flow count is consistent across all ONOS nodes") |
| 735 | else: |
| 736 | main.log.warn("ONOS1 flows: "+ json.dumps(json.loads(ONOS1_flows), |
| 737 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 738 | main.log.warn("ONOS2 flows: "+ json.dumps(json.loads(ONOS2_flows), |
| 739 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 740 | main.log.warn("ONOS3 flows: "+ json.dumps(json.loads(ONOS3_flows), |
| 741 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 742 | main.log.warn("ONOS4 flows: "+ json.dumps(json.loads(ONOS4_flows), |
| 743 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 744 | main.log.warn("ONOS5 flows: "+ json.dumps(json.loads(ONOS5_flows), |
| 745 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 746 | main.log.warn("ONOS6 flows: "+ json.dumps(json.loads(ONOS6_flows), |
| 747 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 748 | main.log.warn("ONOS7 flows: "+ json.dumps(json.loads(ONOS7_flows), |
| 749 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 750 | utilities.assert_equals(expect = main.TRUE,actual=flow_check, |
| 751 | onpass="The flow count is consistent across all ONOS nodes", |
| 752 | onfail="ONOS nodes have different flow counts") |
| 753 | |
| 754 | |
| 755 | main.step("Get the OF Table entries") |
| 756 | global flows |
| 757 | flows=[] |
| 758 | for i in range(1,29): |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 759 | flows.append(main.Mininet2.get_flowTable(1.3, "s"+str(i))) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 760 | |
| 761 | #TODO: Compare switch flow tables with ONOS flow tables |
| 762 | |
| 763 | main.step("Start continuous pings") |
| 764 | main.Mininet2.pingLong(src=main.params['PING']['source1'], |
| 765 | target=main.params['PING']['target1'],pingTime=500) |
| 766 | main.Mininet2.pingLong(src=main.params['PING']['source2'], |
| 767 | target=main.params['PING']['target2'],pingTime=500) |
| 768 | main.Mininet2.pingLong(src=main.params['PING']['source3'], |
| 769 | target=main.params['PING']['target3'],pingTime=500) |
| 770 | main.Mininet2.pingLong(src=main.params['PING']['source4'], |
| 771 | target=main.params['PING']['target4'],pingTime=500) |
| 772 | main.Mininet2.pingLong(src=main.params['PING']['source5'], |
| 773 | target=main.params['PING']['target5'],pingTime=500) |
| 774 | main.Mininet2.pingLong(src=main.params['PING']['source6'], |
| 775 | target=main.params['PING']['target6'],pingTime=500) |
| 776 | main.Mininet2.pingLong(src=main.params['PING']['source7'], |
| 777 | target=main.params['PING']['target7'],pingTime=500) |
| 778 | main.Mininet2.pingLong(src=main.params['PING']['source8'], |
| 779 | target=main.params['PING']['target8'],pingTime=500) |
| 780 | main.Mininet2.pingLong(src=main.params['PING']['source9'], |
| 781 | target=main.params['PING']['target9'],pingTime=500) |
| 782 | main.Mininet2.pingLong(src=main.params['PING']['source10'], |
| 783 | target=main.params['PING']['target10'],pingTime=500) |
| 784 | |
| 785 | main.step("Create TestONTopology object") |
| 786 | ctrls = [] |
| 787 | count = 1 |
| 788 | while True: |
| 789 | temp = () |
| 790 | if ('ip' + str(count)) in main.params['CTRL']: |
| 791 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 792 | temp = temp + ("ONOS"+str(count),) |
| 793 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 794 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 795 | ctrls.append(temp) |
| 796 | count = count + 1 |
| 797 | else: |
| 798 | break |
| 799 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 800 | |
| 801 | main.step("Collecting topology information from ONOS") |
| 802 | devices = [] |
| 803 | devices.append( main.ONOScli1.devices() ) |
| 804 | devices.append( main.ONOScli2.devices() ) |
| 805 | devices.append( main.ONOScli3.devices() ) |
| 806 | devices.append( main.ONOScli4.devices() ) |
| 807 | devices.append( main.ONOScli5.devices() ) |
| 808 | devices.append( main.ONOScli6.devices() ) |
| 809 | devices.append( main.ONOScli7.devices() ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 810 | hosts = [] |
| 811 | hosts.append( main.ONOScli1.hosts() ) |
| 812 | hosts.append( main.ONOScli2.hosts() ) |
| 813 | hosts.append( main.ONOScli3.hosts() ) |
| 814 | hosts.append( main.ONOScli4.hosts() ) |
| 815 | hosts.append( main.ONOScli5.hosts() ) |
| 816 | hosts.append( main.ONOScli6.hosts() ) |
| 817 | hosts.append( main.ONOScli7.hosts() ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 818 | ports = [] |
| 819 | ports.append( main.ONOScli1.ports() ) |
| 820 | ports.append( main.ONOScli2.ports() ) |
| 821 | ports.append( main.ONOScli3.ports() ) |
| 822 | ports.append( main.ONOScli4.ports() ) |
| 823 | ports.append( main.ONOScli5.ports() ) |
| 824 | ports.append( main.ONOScli6.ports() ) |
| 825 | ports.append( main.ONOScli7.ports() ) |
| 826 | links = [] |
| 827 | links.append( main.ONOScli1.links() ) |
| 828 | links.append( main.ONOScli2.links() ) |
| 829 | links.append( main.ONOScli3.links() ) |
| 830 | links.append( main.ONOScli4.links() ) |
| 831 | links.append( main.ONOScli5.links() ) |
| 832 | links.append( main.ONOScli6.links() ) |
| 833 | links.append( main.ONOScli7.links() ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 834 | clusters = [] |
| 835 | clusters.append( main.ONOScli1.clusters() ) |
| 836 | clusters.append( main.ONOScli2.clusters() ) |
| 837 | clusters.append( main.ONOScli3.clusters() ) |
| 838 | clusters.append( main.ONOScli4.clusters() ) |
| 839 | clusters.append( main.ONOScli5.clusters() ) |
| 840 | clusters.append( main.ONOScli6.clusters() ) |
| 841 | clusters.append( main.ONOScli7.clusters() ) |
| 842 | paths = [] |
| 843 | temp_topo = main.ONOSbench.get_topology( main.ONOScli1.topology() ) |
| 844 | paths.append( temp_topo.get('paths', False) ) |
| 845 | temp_topo = main.ONOSbench.get_topology( main.ONOScli2.topology() ) |
| 846 | paths.append( temp_topo.get('paths', False) ) |
| 847 | temp_topo = main.ONOSbench.get_topology( main.ONOScli3.topology() ) |
| 848 | paths.append( temp_topo.get('paths', False) ) |
| 849 | temp_topo = main.ONOSbench.get_topology( main.ONOScli4.topology() ) |
| 850 | paths.append( temp_topo.get('paths', False) ) |
| 851 | temp_topo = main.ONOSbench.get_topology( main.ONOScli5.topology() ) |
| 852 | paths.append( temp_topo.get('paths', False) ) |
| 853 | temp_topo = main.ONOSbench.get_topology( main.ONOScli6.topology() ) |
| 854 | paths.append( temp_topo.get('paths', False) ) |
| 855 | temp_topo = main.ONOSbench.get_topology( main.ONOScli7.topology() ) |
| 856 | paths.append( temp_topo.get('paths', False) ) |
| 857 | |
| 858 | #Compare json objects for hosts, dataplane clusters and paths |
| 859 | |
| 860 | #hosts |
| 861 | consistent_hosts_result = main.TRUE |
| 862 | for controller in range( len( hosts ) ): |
| 863 | if not "Error" in hosts[controller]: |
| 864 | if hosts[controller] == hosts[0]: |
| 865 | continue |
| 866 | else:#hosts not consistent |
| 867 | main.log.report("hosts from ONOS" + str(controller + 1) + " is inconsistent with ONOS1") |
| 868 | main.log.warn( repr( hosts[controller] ) ) |
| 869 | consistent_hosts_result = main.FALSE |
| 870 | |
| 871 | else: |
| 872 | main.log.report("Error in getting ONOS hosts from ONOS" + str(controller + 1) ) |
| 873 | consistent_hosts_result = main.FALSE |
| 874 | main.log.warn("ONOS" + str(controller + 1) + " hosts response: " + repr(hosts[controller]) ) |
| 875 | utilities.assert_equals(expect = main.TRUE,actual=consistent_hosts_result, |
| 876 | onpass="Hosts view is consistent across all ONOS nodes", |
| 877 | onfail="ONOS nodes have different views of hosts") |
| 878 | |
| 879 | #Strongly connected clusters of devices |
| 880 | consistent_clusters_result = main.TRUE |
| 881 | for controller in range( len( clusters ) ): |
| 882 | if not "Error" in clusters[controller]: |
| 883 | if clusters[controller] == clusters[0]: |
| 884 | continue |
| 885 | else:#clusters not consistent |
| 886 | main.log.report("clusters from ONOS" + str(controller + 1) + " is inconsistent with ONOS1") |
| 887 | consistent_clusters_result = main.FALSE |
| 888 | |
| 889 | else: |
| 890 | main.log.report("Error in getting dataplane clusters from ONOS" + str(controller + 1) ) |
| 891 | consistent_clusters_result = main.FALSE |
| 892 | main.log.warn("ONOS" + str(controller + 1) + " clusters response: " + repr(clusters[controller]) ) |
| 893 | utilities.assert_equals(expect = main.TRUE,actual=consistent_clusters_result, |
| 894 | onpass="Clusters view is consistent across all ONOS nodes", |
| 895 | onfail="ONOS nodes have different views of clusters") |
| 896 | num_clusters = len(json.loads(clusters[0])) #there should always only be one cluster |
| 897 | utilities.assert_equals(expect = 1, actual = num_clusters, |
| 898 | onpass="ONOS shows 1 SCC", |
| 899 | onfail="ONOS shows "+str(num_clusters) +" SCCs") |
| 900 | |
| 901 | |
| 902 | #paths |
| 903 | consistent_paths_result = main.TRUE |
| 904 | for controller in range( len( paths ) ): |
| 905 | if not "Error" in paths[controller]: |
| 906 | if paths[controller] == paths[0]: |
| 907 | continue |
| 908 | else:#paths not consistent |
| 909 | main.log.report("paths from ONOS" + str(controller + 1) + " is inconsistent with ONOS1") |
| 910 | consistent_paths_result = main.FALSE |
| 911 | |
| 912 | else: |
| 913 | main.log.report("Error in getting paths from ONOS" + str(controller + 1) ) |
| 914 | consistent_paths_result = main.FALSE |
| 915 | main.log.warn("ONOS" + str(controller + 1) + " paths response: " + repr(paths[controller]) ) |
| 916 | utilities.assert_equals(expect = main.TRUE,actual=consistent_paths_result, |
| 917 | onpass="Paths count is consistent across all ONOS nodes", |
| 918 | onfail="ONOS nodes have different counts of paths") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 919 | |
| 920 | |
| 921 | main.step("Comparing ONOS topology to MN") |
| 922 | devices_results = main.TRUE |
| 923 | ports_results = main.TRUE |
| 924 | links_results = main.TRUE |
| 925 | for controller in range(7): #TODO parameterize the number of controllers |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 926 | if devices[controller] or not "Error" in devices[controller]: |
| 927 | current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller])) |
| 928 | else: |
| 929 | current_devices_result = main.FALSE |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 930 | utilities.assert_equals(expect=main.TRUE, actual=current_devices_result, |
| 931 | onpass="ONOS"+str(int(controller+1))+" Switches view is correct", |
| 932 | onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect") |
| 933 | |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 934 | if ports[controller] or not "Error" in ports[controller]: |
| 935 | current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller])) |
| 936 | else: |
| 937 | current_ports_result = main.FALSE |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 938 | utilities.assert_equals(expect=main.TRUE, actual=current_ports_result, |
| 939 | onpass="ONOS"+str(int(controller+1))+" ports view is correct", |
| 940 | onfail="ONOS"+str(int(controller+1))+" ports view is incorrect") |
| 941 | |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 942 | if links[controller] or not "Error" in links[controller]: |
| 943 | current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller])) |
| 944 | else: |
| 945 | current_links_result = main.FALSE |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 946 | utilities.assert_equals(expect=main.TRUE, actual=current_links_result, |
| 947 | onpass="ONOS"+str(int(controller+1))+" links view is correct", |
| 948 | onfail="ONOS"+str(int(controller+1))+" links view is incorrect") |
| 949 | |
| 950 | devices_results = devices_results and current_devices_result |
| 951 | ports_results = ports_results and current_ports_result |
| 952 | links_results = links_results and current_links_result |
| 953 | |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 954 | topo_result = devices_results and ports_results and links_results\ |
| 955 | and consistent_hosts_result and consistent_clusters_result\ |
| 956 | and consistent_paths_result |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 957 | utilities.assert_equals(expect=main.TRUE, actual=topo_result, |
| 958 | onpass="Topology Check Test successful", |
| 959 | onfail="Topology Check Test NOT successful") |
| 960 | |
| 961 | final_assert = main.TRUE |
| 962 | final_assert = final_assert and topo_result and flow_check \ |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 963 | and intent_check and consistent_mastership and roles_not_null |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 964 | utilities.assert_equals(expect=main.TRUE, actual=final_assert, |
| 965 | onpass="State check successful", |
| 966 | onfail="State check NOT successful") |
| 967 | |
| 968 | |
| 969 | def CASE6(self,main) : |
| 970 | ''' |
| 971 | The Failure case. Since this is the Sanity test, we do nothing. |
| 972 | ''' |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 973 | import time |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 974 | main.log.report("Wait 60 seconds instead of inducing a failure") |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 975 | time.sleep(60) |
| 976 | utilities.assert_equals(expect=main.TRUE, actual=main.TRUE, |
| 977 | onpass="Sleeping 60 seconds", |
| 978 | onfail="Something is terribly wrong with my math") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 979 | |
| 980 | def CASE7(self,main) : |
| 981 | ''' |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 982 | Check state after ONOS failure |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 983 | ''' |
| 984 | import os |
| 985 | import json |
| 986 | main.case("Running ONOS Constant State Tests") |
| 987 | |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 988 | #Assert that each device has a master |
| 989 | ONOS1_master_not_null = main.ONOScli1.roles_not_null() |
| 990 | ONOS2_master_not_null = main.ONOScli2.roles_not_null() |
| 991 | ONOS3_master_not_null = main.ONOScli3.roles_not_null() |
| 992 | ONOS4_master_not_null = main.ONOScli4.roles_not_null() |
| 993 | ONOS5_master_not_null = main.ONOScli5.roles_not_null() |
| 994 | ONOS6_master_not_null = main.ONOScli6.roles_not_null() |
| 995 | ONOS7_master_not_null = main.ONOScli7.roles_not_null() |
| 996 | roles_not_null = ONOS1_master_not_null and ONOS2_master_not_null and\ |
| 997 | ONOS3_master_not_null and ONOS4_master_not_null and\ |
| 998 | ONOS5_master_not_null and ONOS6_master_not_null and\ |
| 999 | ONOS7_master_not_null |
| 1000 | utilities.assert_equals(expect = main.TRUE,actual=roles_not_null, |
| 1001 | onpass="Each device has a master", |
| 1002 | onfail="Some devices don't have a master assigned") |
| 1003 | |
| 1004 | |
| 1005 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1006 | main.step("Check if switch roles are consistent across all nodes") |
| 1007 | ONOS1_mastership = main.ONOScli1.roles() |
| 1008 | ONOS2_mastership = main.ONOScli2.roles() |
| 1009 | ONOS3_mastership = main.ONOScli3.roles() |
| 1010 | ONOS4_mastership = main.ONOScli4.roles() |
| 1011 | ONOS5_mastership = main.ONOScli5.roles() |
| 1012 | ONOS6_mastership = main.ONOScli6.roles() |
| 1013 | ONOS7_mastership = main.ONOScli7.roles() |
| 1014 | #print json.dumps(json.loads(ONOS1_mastership), sort_keys=True, indent=4, separators=(',', ': ')) |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1015 | if "Error" in ONOS1_mastership or not ONOS1_mastership\ |
| 1016 | or "Error" in ONOS2_mastership or not ONOS2_mastership\ |
| 1017 | or "Error" in ONOS3_mastership or not ONOS3_mastership\ |
| 1018 | or "Error" in ONOS4_mastership or not ONOS4_mastership\ |
| 1019 | or "Error" in ONOS5_mastership or not ONOS5_mastership\ |
| 1020 | or "Error" in ONOS6_mastership or not ONOS6_mastership\ |
| 1021 | or "Error" in ONOS7_mastership or not ONOS7_mastership: |
| 1022 | main.log.error("Error in getting ONOS mastership") |
| 1023 | main.log.warn("ONOS1 mastership response: " + repr(ONOS1_mastership)) |
| 1024 | main.log.warn("ONOS2 mastership response: " + repr(ONOS2_mastership)) |
| 1025 | main.log.warn("ONOS3 mastership response: " + repr(ONOS3_mastership)) |
| 1026 | main.log.warn("ONOS4 mastership response: " + repr(ONOS4_mastership)) |
| 1027 | main.log.warn("ONOS5 mastership response: " + repr(ONOS5_mastership)) |
| 1028 | main.log.warn("ONOS6 mastership response: " + repr(ONOS6_mastership)) |
| 1029 | main.log.warn("ONOS7 mastership response: " + repr(ONOS7_mastership)) |
| 1030 | consistent_mastership = main.FALSE |
| 1031 | elif ONOS1_mastership == ONOS2_mastership\ |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1032 | and ONOS1_mastership == ONOS3_mastership\ |
| 1033 | and ONOS1_mastership == ONOS4_mastership\ |
| 1034 | and ONOS1_mastership == ONOS5_mastership\ |
| 1035 | and ONOS1_mastership == ONOS6_mastership\ |
| 1036 | and ONOS1_mastership == ONOS7_mastership: |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1037 | consistent_mastership = main.TRUE |
| 1038 | main.log.report("Switch roles are consistent across all ONOS nodes") |
| 1039 | else: |
| 1040 | main.log.warn("ONOS1 roles: ", json.dumps(json.loads(ONOS1_mastership), |
| 1041 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 1042 | main.log.warn("ONOS2 roles: ", json.dumps(json.loads(ONOS2_mastership), |
| 1043 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 1044 | main.log.warn("ONOS3 roles: ", json.dumps(json.loads(ONOS3_mastership), |
| 1045 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 1046 | main.log.warn("ONOS4 roles: ", json.dumps(json.loads(ONOS4_mastership), |
| 1047 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 1048 | main.log.warn("ONOS5 roles: ", json.dumps(json.loads(ONOS5_mastership), |
| 1049 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 1050 | main.log.warn("ONOS6 roles: ", json.dumps(json.loads(ONOS6_mastership), |
| 1051 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 1052 | main.log.warn("ONOS7 roles: ", json.dumps(json.loads(ONOS7_mastership), |
| 1053 | sort_keys=True, indent=4, separators=(',', ': '))) |
| 1054 | consistent_mastership = main.FALSE |
| 1055 | utilities.assert_equals(expect = main.TRUE,actual=consistent_mastership, |
| 1056 | onpass="Switch roles are consistent across all ONOS nodes", |
| 1057 | onfail="ONOS nodes have different views of switch roles") |
| 1058 | |
| 1059 | |
| 1060 | description2 = "Compare switch roles from before failure" |
| 1061 | main.step(description2) |
| 1062 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1063 | current_json = json.loads(ONOS1_mastership) |
| 1064 | old_json = json.loads(mastership_state) |
| 1065 | mastership_check = main.TRUE |
| 1066 | for i in range(1,29): |
| 1067 | switchDPID = str(main.Mininet1.getSwitchDPID(switch="s"+str(i))) |
| 1068 | |
| 1069 | current = [switch['master'] for switch in current_json if switchDPID in switch['id']] |
| 1070 | old = [switch['master'] for switch in old_json if switchDPID in switch['id']] |
| 1071 | if current == old: |
| 1072 | mastership_check = mastership_check and main.TRUE |
| 1073 | else: |
| 1074 | main.log.warn("Mastership of switch %s changed" % switchDPID) |
| 1075 | mastership_check = main.FALSE |
| 1076 | if mastership_check == main.TRUE: |
| 1077 | main.log.report("Mastership of Switches was not changed") |
| 1078 | utilities.assert_equals(expect=main.TRUE,actual=mastership_check, |
| 1079 | onpass="Mastership of Switches was not changed", |
| 1080 | onfail="Mastership of some switches changed") |
| 1081 | mastership_check = mastership_check and consistent_mastership |
| 1082 | |
| 1083 | |
| 1084 | |
| 1085 | main.step("Get the intents and compare across all nodes") |
| 1086 | ONOS1_intents = main.ONOScli1.intents( json_format=True ) |
| 1087 | ONOS2_intents = main.ONOScli2.intents( json_format=True ) |
| 1088 | ONOS3_intents = main.ONOScli3.intents( json_format=True ) |
| 1089 | ONOS4_intents = main.ONOScli4.intents( json_format=True ) |
| 1090 | ONOS5_intents = main.ONOScli5.intents( json_format=True ) |
| 1091 | ONOS6_intents = main.ONOScli6.intents( json_format=True ) |
| 1092 | ONOS7_intents = main.ONOScli7.intents( json_format=True ) |
| 1093 | intent_check = main.FALSE |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1094 | if "Error" in ONOS1_intents or not ONOS1_intents\ |
| 1095 | or "Error" in ONOS2_intents or not ONOS2_intents\ |
| 1096 | or "Error" in ONOS3_intents or not ONOS3_intents\ |
| 1097 | or "Error" in ONOS4_intents or not ONOS4_intents\ |
| 1098 | or "Error" in ONOS5_intents or not ONOS5_intents\ |
| 1099 | or "Error" in ONOS6_intents or not ONOS6_intents\ |
| 1100 | or "Error" in ONOS7_intents or not ONOS7_intents: |
| 1101 | main.log.report("Error in getting ONOS intents") |
| 1102 | main.log.warn("ONOS1 intents response: " + repr(ONOS1_intents)) |
| 1103 | main.log.warn("ONOS2 intents response: " + repr(ONOS2_intents)) |
| 1104 | main.log.warn("ONOS3 intents response: " + repr(ONOS3_intents)) |
| 1105 | main.log.warn("ONOS4 intents response: " + repr(ONOS4_intents)) |
| 1106 | main.log.warn("ONOS5 intents response: " + repr(ONOS5_intents)) |
| 1107 | main.log.warn("ONOS6 intents response: " + repr(ONOS6_intents)) |
| 1108 | main.log.warn("ONOS7 intents response: " + repr(ONOS7_intents)) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1109 | elif ONOS1_intents == ONOS2_intents\ |
| 1110 | and ONOS1_intents == ONOS3_intents\ |
| 1111 | and ONOS1_intents == ONOS4_intents\ |
| 1112 | and ONOS1_intents == ONOS5_intents\ |
| 1113 | and ONOS1_intents == ONOS6_intents\ |
| 1114 | and ONOS1_intents == ONOS7_intents: |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1115 | intent_check = main.TRUE |
| 1116 | main.log.report("Intents are consistent across all ONOS nodes") |
| 1117 | else: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1118 | main.log.warn("ONOS1 intents: ") |
| 1119 | print json.dumps(json.loads(ONOS1_intents), |
| 1120 | sort_keys=True, indent=4, separators=(',', ': ')) |
| 1121 | main.log.warn("ONOS2 intents: ") |
| 1122 | print json.dumps(json.loads(ONOS2_intents), |
| 1123 | sort_keys=True, indent=4, separators=(',', ': ')) |
| 1124 | main.log.warn("ONOS3 intents: ") |
| 1125 | print json.dumps(json.loads(ONOS3_intents), |
| 1126 | sort_keys=True, indent=4, separators=(',', ': ')) |
| 1127 | main.log.warn("ONOS4 intents: ") |
| 1128 | print json.dumps(json.loads(ONOS4_intents), |
| 1129 | sort_keys=True, indent=4, separators=(',', ': ')) |
| 1130 | main.log.warn("ONOS5 intents: ") |
| 1131 | print json.dumps(json.loads(ONOS5_intents), |
| 1132 | sort_keys=True, indent=4, separators=(',', ': ')) |
| 1133 | main.log.warn("ONOS6 intents: ") |
| 1134 | print json.dumps(json.loads(ONOS6_intents), |
| 1135 | sort_keys=True, indent=4, separators=(',', ': ')) |
| 1136 | main.log.warn("ONOS7 intents: ") |
| 1137 | print json.dumps(json.loads(ONOS7_intents), |
| 1138 | sort_keys=True, indent=4, separators=(',', ': ')) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1139 | utilities.assert_equals(expect = main.TRUE,actual=intent_check, |
| 1140 | onpass="Intents are consistent across all ONOS nodes", |
| 1141 | onfail="ONOS nodes have different views of intents") |
| 1142 | |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1143 | #NOTE: Hazelcast has no durability, so intents are lost |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1144 | main.step("Compare current intents with intents before the failure") |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1145 | #NOTE: this requires case 5 to pass for intent_state to be set. |
| 1146 | # maybe we should stop the test if that fails? |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1147 | if intent_state == ONOS1_intents: |
| 1148 | same_intents = main.TRUE |
| 1149 | main.log.report("Intents are consistent with before failure") |
| 1150 | #TODO: possibly the states have changed? we may need to figure out what the aceptable states are |
| 1151 | else: |
| 1152 | same_intents = main.FALSE |
| 1153 | utilities.assert_equals(expect = main.TRUE,actual=same_intents, |
| 1154 | onpass="Intents are consistent with before failure", |
| 1155 | onfail="The Intents changed during failure") |
| 1156 | intent_check = intent_check and same_intents |
| 1157 | |
| 1158 | |
| 1159 | |
| 1160 | main.step("Get the OF Table entries and compare to before component failure") |
| 1161 | Flow_Tables = main.TRUE |
| 1162 | flows2=[] |
| 1163 | for i in range(28): |
| 1164 | main.log.info("Checking flow table on s" + str(i+1)) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1165 | tmp_flows = main.Mininet2.get_flowTable(1.3, "s"+str(i+1)) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1166 | flows2.append(tmp_flows) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1167 | temp_result = main.Mininet2.flow_comp(flow1=flows[i],flow2=tmp_flows) |
| 1168 | Flow_Tables = Flow_Tables and temp_result |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1169 | if Flow_Tables == main.FALSE: |
| 1170 | main.log.info("Differences in flow table for switch: "+str(i+1)) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1171 | if Flow_Tables == main.TRUE: |
| 1172 | main.log.report("No changes were found in the flow tables") |
| 1173 | utilities.assert_equals(expect=main.TRUE,actual=Flow_Tables, |
| 1174 | onpass="No changes were found in the flow tables", |
| 1175 | onfail="Changes were found in the flow tables") |
| 1176 | |
| 1177 | main.step("Check the continuous pings to ensure that no packets were dropped during component failure") |
| 1178 | #FIXME: This check is always failing. Investigate cause |
| 1179 | #NOTE: this may be something to do with file permsissions |
| 1180 | # or slight change in format |
| 1181 | main.Mininet2.pingKill(main.params['TESTONUSER'], main.params['TESTONIP']) |
| 1182 | Loss_In_Pings = main.FALSE |
| 1183 | #NOTE: checkForLoss returns main.FALSE with 0% packet loss |
| 1184 | for i in range(8,18): |
| 1185 | main.log.info("Checking for a loss in pings along flow from s" + str(i)) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1186 | Loss_In_Pings = main.Mininet2.checkForLoss("/tmp/ping.h"+str(i)) or Loss_In_Pings |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1187 | if Loss_In_Pings == main.TRUE: |
| 1188 | main.log.info("Loss in ping detected") |
| 1189 | elif Loss_In_Pings == main.ERROR: |
| 1190 | main.log.info("There are multiple mininet process running") |
| 1191 | elif Loss_In_Pings == main.FALSE: |
| 1192 | main.log.info("No Loss in the pings") |
| 1193 | main.log.report("No loss of dataplane connectivity") |
| 1194 | utilities.assert_equals(expect=main.FALSE,actual=Loss_In_Pings, |
| 1195 | onpass="No Loss of connectivity", |
| 1196 | onfail="Loss of dataplane connectivity detected") |
| 1197 | |
| 1198 | |
| 1199 | #TODO:add topology to this or leave as a seperate case? |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1200 | result = mastership_check and intent_check and Flow_Tables and (not Loss_In_Pings) and roles_not_null |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1201 | result = int(result) |
| 1202 | if result == main.TRUE: |
| 1203 | main.log.report("Constant State Tests Passed") |
| 1204 | utilities.assert_equals(expect=main.TRUE,actual=result, |
| 1205 | onpass="Constant State Tests Passed", |
| 1206 | onfail="Constant state tests failed") |
| 1207 | |
| 1208 | def CASE8 (self,main): |
| 1209 | ''' |
| 1210 | Compare topo |
| 1211 | ''' |
| 1212 | import sys |
| 1213 | sys.path.append("/home/admin/sts") # Trying to remove some dependancies, #FIXME add this path to params |
| 1214 | from sts.topology.teston_topology import TestONTopology # assumes that sts is already in you PYTHONPATH |
| 1215 | import json |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1216 | import time |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1217 | |
| 1218 | description ="Compare ONOS Topology view to Mininet topology" |
| 1219 | main.case(description) |
| 1220 | main.log.report(description) |
| 1221 | main.step("Create TestONTopology object") |
| 1222 | ctrls = [] |
| 1223 | count = 1 |
| 1224 | while True: |
| 1225 | temp = () |
| 1226 | if ('ip' + str(count)) in main.params['CTRL']: |
| 1227 | temp = temp + (getattr(main,('ONOS' + str(count))),) |
| 1228 | temp = temp + ("ONOS"+str(count),) |
| 1229 | temp = temp + (main.params['CTRL']['ip'+str(count)],) |
| 1230 | temp = temp + (eval(main.params['CTRL']['port'+str(count)]),) |
| 1231 | ctrls.append(temp) |
| 1232 | count = count + 1 |
| 1233 | else: |
| 1234 | break |
| 1235 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 1236 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1237 | main.step("Comparing ONOS topology to MN") |
| 1238 | devices_results = main.TRUE |
| 1239 | ports_results = main.TRUE |
| 1240 | links_results = main.TRUE |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1241 | topo_result = main.FALSE |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1242 | elapsed = 0 |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 1243 | count = 0 |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1244 | main.step("Collecting topology information from ONOS") |
| 1245 | start_time = time.time() |
| 1246 | while topo_result == main.FALSE and elapsed < 60: |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 1247 | count = count + 1 |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1248 | if count > 1: |
| 1249 | MNTopo = TestONTopology(main.Mininet1, ctrls) # can also add Intent API info for intent operations |
| 1250 | cli_start = time.time() |
| 1251 | devices = [] |
| 1252 | devices.append( main.ONOScli1.devices() ) |
| 1253 | devices.append( main.ONOScli2.devices() ) |
| 1254 | devices.append( main.ONOScli3.devices() ) |
| 1255 | devices.append( main.ONOScli4.devices() ) |
| 1256 | devices.append( main.ONOScli5.devices() ) |
| 1257 | devices.append( main.ONOScli6.devices() ) |
| 1258 | devices.append( main.ONOScli7.devices() ) |
| 1259 | hosts = [] |
| 1260 | hosts.append( main.ONOScli1.hosts() ) |
| 1261 | hosts.append( main.ONOScli2.hosts() ) |
| 1262 | hosts.append( main.ONOScli3.hosts() ) |
| 1263 | hosts.append( main.ONOScli4.hosts() ) |
| 1264 | hosts.append( main.ONOScli5.hosts() ) |
| 1265 | hosts.append( main.ONOScli6.hosts() ) |
| 1266 | hosts.append( main.ONOScli7.hosts() ) |
| 1267 | ports = [] |
| 1268 | ports.append( main.ONOScli1.ports() ) |
| 1269 | ports.append( main.ONOScli2.ports() ) |
| 1270 | ports.append( main.ONOScli3.ports() ) |
| 1271 | ports.append( main.ONOScli4.ports() ) |
| 1272 | ports.append( main.ONOScli5.ports() ) |
| 1273 | ports.append( main.ONOScli6.ports() ) |
| 1274 | ports.append( main.ONOScli7.ports() ) |
| 1275 | links = [] |
| 1276 | links.append( main.ONOScli1.links() ) |
| 1277 | links.append( main.ONOScli2.links() ) |
| 1278 | links.append( main.ONOScli3.links() ) |
| 1279 | links.append( main.ONOScli4.links() ) |
| 1280 | links.append( main.ONOScli5.links() ) |
| 1281 | links.append( main.ONOScli6.links() ) |
| 1282 | links.append( main.ONOScli7.links() ) |
| 1283 | clusters = [] |
| 1284 | clusters.append( main.ONOScli1.clusters() ) |
| 1285 | clusters.append( main.ONOScli2.clusters() ) |
| 1286 | clusters.append( main.ONOScli3.clusters() ) |
| 1287 | clusters.append( main.ONOScli4.clusters() ) |
| 1288 | clusters.append( main.ONOScli5.clusters() ) |
| 1289 | clusters.append( main.ONOScli6.clusters() ) |
| 1290 | clusters.append( main.ONOScli7.clusters() ) |
| 1291 | paths = [] |
| 1292 | temp_topo = main.ONOSbench.get_topology( main.ONOScli1.topology() ) |
| 1293 | paths.append( temp_topo.get('paths', False) ) |
| 1294 | temp_topo = main.ONOSbench.get_topology( main.ONOScli2.topology() ) |
| 1295 | paths.append( temp_topo.get('paths', False) ) |
| 1296 | temp_topo = main.ONOSbench.get_topology( main.ONOScli3.topology() ) |
| 1297 | paths.append( temp_topo.get('paths', False) ) |
| 1298 | temp_topo = main.ONOSbench.get_topology( main.ONOScli4.topology() ) |
| 1299 | paths.append( temp_topo.get('paths', False) ) |
| 1300 | temp_topo = main.ONOSbench.get_topology( main.ONOScli5.topology() ) |
| 1301 | paths.append( temp_topo.get('paths', False) ) |
| 1302 | temp_topo = main.ONOSbench.get_topology( main.ONOScli6.topology() ) |
| 1303 | paths.append( temp_topo.get('paths', False) ) |
| 1304 | temp_topo = main.ONOSbench.get_topology( main.ONOScli7.topology() ) |
| 1305 | paths.append( temp_topo.get('paths', False) ) |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 1306 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1307 | |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1308 | elapsed = time.time() - start_time |
| 1309 | cli_time = time.time() - cli_start |
| 1310 | print "CLI time: " + str(cli_time) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1311 | |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1312 | for controller in range(7): #TODO parameterize the number of controllers |
| 1313 | if devices[controller] or not "Error" in devices[controller]: |
| 1314 | current_devices_result = main.Mininet1.compare_switches(MNTopo, json.loads(devices[controller])) |
| 1315 | else: |
| 1316 | current_devices_result = main.FALSE |
| 1317 | utilities.assert_equals(expect=main.TRUE, actual=current_devices_result, |
| 1318 | onpass="ONOS"+str(int(controller+1))+" Switches view is correct", |
| 1319 | onfail="ONOS"+str(int(controller+1))+" Switches view is incorrect") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1320 | |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1321 | if ports[controller] or not "Error" in ports[controller]: |
| 1322 | current_ports_result = main.Mininet1.compare_ports(MNTopo, json.loads(ports[controller])) |
| 1323 | else: |
| 1324 | current_ports_result = main.FALSE |
| 1325 | utilities.assert_equals(expect=main.TRUE, actual=current_ports_result, |
| 1326 | onpass="ONOS"+str(int(controller+1))+" ports view is correct", |
| 1327 | onfail="ONOS"+str(int(controller+1))+" ports view is incorrect") |
| 1328 | |
| 1329 | if links[controller] or not "Error" in links[controller]: |
| 1330 | current_links_result = main.Mininet1.compare_links(MNTopo, json.loads(links[controller])) |
| 1331 | else: |
| 1332 | current_links_result = main.FALSE |
| 1333 | utilities.assert_equals(expect=main.TRUE, actual=current_links_result, |
| 1334 | onpass="ONOS"+str(int(controller+1))+" links view is correct", |
| 1335 | onfail="ONOS"+str(int(controller+1))+" links view is incorrect") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1336 | devices_results = devices_results and current_devices_result |
| 1337 | ports_results = ports_results and current_ports_result |
| 1338 | links_results = links_results and current_links_result |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1339 | |
| 1340 | #Compare json objects for hosts, dataplane clusters and paths |
| 1341 | |
| 1342 | #hosts |
| 1343 | consistent_hosts_result = main.TRUE |
| 1344 | for controller in range( len( hosts ) ): |
| 1345 | if not "Error" in hosts[controller]: |
| 1346 | if hosts[controller] == hosts[0]: |
| 1347 | continue |
| 1348 | else:#hosts not consistent |
| 1349 | main.log.report("hosts from ONOS" + str(controller + 1) + " is inconsistent with ONOS1") |
| 1350 | main.log.warn( repr( hosts[controller] ) ) |
| 1351 | consistent_hosts_result = main.FALSE |
| 1352 | |
| 1353 | else: |
| 1354 | main.log.report("Error in getting ONOS hosts from ONOS" + str(controller + 1) ) |
| 1355 | consistent_hosts_result = main.FALSE |
| 1356 | main.log.warn("ONOS" + str(controller + 1) + " hosts response: " + repr(hosts[controller]) ) |
| 1357 | utilities.assert_equals(expect = main.TRUE,actual=consistent_hosts_result, |
| 1358 | onpass="Hosts view is consistent across all ONOS nodes", |
| 1359 | onfail="ONOS nodes have different views of hosts") |
| 1360 | |
| 1361 | #Strongly connected clusters of devices |
| 1362 | consistent_clusters_result = main.TRUE |
| 1363 | for controller in range( len( clusters ) ): |
| 1364 | if not "Error" in clusters[controller]: |
| 1365 | if clusters[controller] == clusters[0]: |
| 1366 | continue |
| 1367 | else:#clusters not consistent |
| 1368 | main.log.report("clusters from ONOS" + str(controller + 1) + " is inconsistent with ONOS1") |
| 1369 | consistent_clusters_result = main.FALSE |
| 1370 | |
| 1371 | else: |
| 1372 | main.log.report("Error in getting dataplane clusters from ONOS" + str(controller + 1) ) |
| 1373 | consistent_clusters_result = main.FALSE |
| 1374 | main.log.warn("ONOS" + str(controller + 1) + " clusters response: " + repr(clusters[controller]) ) |
| 1375 | utilities.assert_equals(expect = main.TRUE,actual=consistent_clusters_result, |
| 1376 | onpass="Clusters view is consistent across all ONOS nodes", |
| 1377 | onfail="ONOS nodes have different views of clusters") |
| 1378 | num_clusters = len(json.loads(clusters[0])) #there should always only be one cluster |
| 1379 | utilities.assert_equals(expect = 1, actual = num_clusters, |
| 1380 | onpass="ONOS shows 1 SCC", |
| 1381 | onfail="ONOS shows "+str(num_clusters) +" SCCs") |
| 1382 | |
| 1383 | |
| 1384 | #paths |
| 1385 | consistent_paths_result = main.TRUE |
| 1386 | for controller in range( len( paths ) ): |
| 1387 | if not "Error" in paths[controller]: |
| 1388 | if paths[controller] == paths[0]: |
| 1389 | continue |
| 1390 | else:#paths not consistent |
| 1391 | main.log.report("paths from ONOS" + str(controller + 1) + " is inconsistent with ONOS1") |
| 1392 | consistent_paths_result = main.FALSE |
| 1393 | |
| 1394 | else: |
| 1395 | main.log.report("Error in getting paths from ONOS" + str(controller + 1) ) |
| 1396 | consistent_paths_result = main.FALSE |
| 1397 | main.log.warn("ONOS" + str(controller + 1) + " paths response: " + repr(paths[controller]) ) |
| 1398 | utilities.assert_equals(expect = main.TRUE,actual=consistent_paths_result, |
| 1399 | onpass="Paths count is consistent across all ONOS nodes", |
| 1400 | onfail="ONOS nodes have different counts of paths") |
| 1401 | |
| 1402 | |
| 1403 | topo_result = devices_results and ports_results and links_results\ |
| 1404 | and consistent_hosts_result and consistent_clusters_result and consistent_paths_result |
| 1405 | |
| 1406 | topo_result = topo_result and int(count <= 2) |
| 1407 | note = "note it takes about "+str( int(cli_time) )+" seconds for the test to make all the cli calls to fetch the topology from each ONOS instance" |
| 1408 | main.log.report("Very crass estimate for topology discovery/convergence("+ str(note) + "): " +\ |
Jon Hall | ffb386d | 2014-11-21 13:43:38 -0800 | [diff] [blame] | 1409 | str(elapsed) + " seconds, " + str(count) +" tries" ) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1410 | utilities.assert_equals(expect=main.TRUE, actual=topo_result, |
| 1411 | onpass="Topology Check Test successful", |
| 1412 | onfail="Topology Check Test NOT successful") |
| 1413 | if topo_result == main.TRUE: |
| 1414 | main.log.report("ONOS topology view matches Mininet topology") |
| 1415 | |
| 1416 | |
| 1417 | def CASE9 (self,main): |
| 1418 | ''' |
| 1419 | Link s3-s28 down |
| 1420 | ''' |
| 1421 | #NOTE: You should probably run a topology check after this |
| 1422 | |
| 1423 | link_sleep = int(main.params['timers']['LinkDiscovery']) |
| 1424 | |
| 1425 | description = "Turn off a link to ensure that Link Discovery is working properly" |
| 1426 | main.log.report(description) |
| 1427 | main.case(description) |
| 1428 | |
| 1429 | |
| 1430 | main.step("Kill Link between s3 and s28") |
| 1431 | Link_Down = main.Mininet1.link(END1="s3",END2="s28",OPTION="down") |
| 1432 | main.log.info("Waiting " + str(link_sleep) + " seconds for link down to be discovered") |
| 1433 | time.sleep(link_sleep) |
| 1434 | utilities.assert_equals(expect=main.TRUE,actual=Link_Down, |
| 1435 | onpass="Link down succesful", |
| 1436 | onfail="Failed to bring link down") |
| 1437 | #TODO do some sort of check here |
| 1438 | |
| 1439 | def CASE10 (self,main): |
| 1440 | ''' |
| 1441 | Link s3-s28 up |
| 1442 | ''' |
| 1443 | #NOTE: You should probably run a topology check after this |
| 1444 | |
| 1445 | link_sleep = int(main.params['timers']['LinkDiscovery']) |
| 1446 | |
| 1447 | description = "Restore a link to ensure that Link Discovery is working properly" |
| 1448 | main.log.report(description) |
| 1449 | main.case(description) |
| 1450 | |
| 1451 | main.step("Bring link between s3 and s28 back up") |
| 1452 | Link_Up = main.Mininet1.link(END1="s3",END2="s28",OPTION="up") |
| 1453 | main.log.info("Waiting " + str(link_sleep) + " seconds for link up to be discovered") |
| 1454 | time.sleep(link_sleep) |
| 1455 | utilities.assert_equals(expect=main.TRUE,actual=Link_Up, |
| 1456 | onpass="Link up succesful", |
| 1457 | onfail="Failed to bring link up") |
| 1458 | #TODO do some sort of check here |
| 1459 | |
| 1460 | |
| 1461 | def CASE11 (self, main) : |
| 1462 | ''' |
| 1463 | Switch Down |
| 1464 | ''' |
| 1465 | #NOTE: You should probably run a topology check after this |
| 1466 | import time |
| 1467 | |
| 1468 | switch_sleep = int(main.params['timers']['SwitchDiscovery']) |
| 1469 | |
| 1470 | description = "Killing a switch to ensure it is discovered correctly" |
| 1471 | main.log.report(description) |
| 1472 | main.case(description) |
| 1473 | |
| 1474 | #TODO: Make this switch parameterizable |
| 1475 | main.step("Kill s28 ") |
| 1476 | main.log.report("Deleting s28") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1477 | main.Mininet1.del_switch("s28") |
| 1478 | main.log.info("Waiting " + str(switch_sleep) + " seconds for switch down to be discovered") |
| 1479 | time.sleep(switch_sleep) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1480 | device = main.ONOScli1.get_device(dpid="0028") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1481 | #Peek at the deleted switch |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1482 | main.log.warn( str(device) ) |
| 1483 | result = main.FALSE |
| 1484 | if device and device['available'] == False: |
| 1485 | result = main.TRUE |
| 1486 | utilities.assert_equals(expect=main.TRUE,actual=result, |
| 1487 | onpass="Kill switch succesful", |
| 1488 | onfail="Failed to kill switch?") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1489 | |
| 1490 | def CASE12 (self, main) : |
| 1491 | ''' |
| 1492 | Switch Up |
| 1493 | ''' |
| 1494 | #NOTE: You should probably run a topology check after this |
| 1495 | import time |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1496 | description = "Adding a switch to ensure it is discovered correctly" |
| 1497 | main.log.report(description) |
| 1498 | main.case(description) |
| 1499 | |
| 1500 | main.step("Add back s28") |
| 1501 | main.log.report("Adding back s28") |
| 1502 | main.Mininet1.add_switch("s28", dpid = '0000000000002800') |
| 1503 | #TODO: New dpid or same? Ask Thomas? |
| 1504 | main.Mininet1.add_link('s28', 's3') |
| 1505 | main.Mininet1.add_link('s28', 's6') |
| 1506 | main.Mininet1.add_link('s28', 'h28') |
| 1507 | main.Mininet1.assign_sw_controller(sw="28",count=7, |
| 1508 | ip1=ONOS1_ip,port1=ONOS1_port, |
| 1509 | ip2=ONOS2_ip,port2=ONOS2_port, |
| 1510 | ip3=ONOS3_ip,port3=ONOS3_port, |
| 1511 | ip4=ONOS4_ip,port4=ONOS4_port, |
| 1512 | ip5=ONOS5_ip,port5=ONOS5_port, |
| 1513 | ip6=ONOS6_ip,port6=ONOS6_port, |
| 1514 | ip7=ONOS7_ip,port7=ONOS7_port) |
| 1515 | main.log.info("Waiting " + str(switch_sleep) + " seconds for switch up to be discovered") |
| 1516 | time.sleep(switch_sleep) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1517 | device = main.ONOScli1.get_device(dpid="0028") |
| 1518 | #Peek at the deleted switch |
| 1519 | main.log.warn( str(device) ) |
| 1520 | result = main.FALSE |
| 1521 | if device and device['available'] == True: |
| 1522 | result = main.TRUE |
| 1523 | utilities.assert_equals(expect=main.TRUE,actual=result, |
| 1524 | onpass="add switch succesful", |
| 1525 | onfail="Failed to add switch?") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1526 | |
| 1527 | def CASE13 (self, main) : |
| 1528 | ''' |
| 1529 | Clean up |
| 1530 | ''' |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1531 | import os |
| 1532 | import time |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 1533 | description = "Test Cleanup" |
| 1534 | main.log.report(description) |
| 1535 | main.case(description) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1536 | main.step("Killing tcpdumps") |
| 1537 | main.Mininet2.stop_tcpdump() |
| 1538 | |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1539 | main.step("Checking ONOS Logs for errors") |
| 1540 | print "Checking logs for errors on ONOS1:" |
| 1541 | print main.ONOSbench.check_logs(ONOS1_ip) |
| 1542 | print "Checking logs for errors on ONOS2:" |
| 1543 | print main.ONOSbench.check_logs(ONOS2_ip) |
| 1544 | print "Checking logs for errors on ONOS3:" |
| 1545 | print main.ONOSbench.check_logs(ONOS3_ip) |
| 1546 | print "Checking logs for errors on ONOS4:" |
| 1547 | print main.ONOSbench.check_logs(ONOS4_ip) |
| 1548 | print "Checking logs for errors on ONOS5:" |
| 1549 | print main.ONOSbench.check_logs(ONOS5_ip) |
| 1550 | print "Checking logs for errors on ONOS6:" |
| 1551 | print main.ONOSbench.check_logs(ONOS6_ip) |
| 1552 | print "Checking logs for errors on ONOS7:" |
| 1553 | print main.ONOSbench.check_logs(ONOS7_ip) |
| 1554 | |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1555 | main.step("Copying MN pcap and ONOS log files to test station") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1556 | testname = main.TEST |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1557 | teststation_user = main.params['TESTONUSER'] |
| 1558 | teststation_IP = main.params['TESTONIP'] |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1559 | #NOTE: MN Pcap file is being saved to ~/packet_captures |
| 1560 | # scp this file as MN and TestON aren't necessarily the same vm |
| 1561 | #FIXME: scp |
| 1562 | #####mn files |
| 1563 | #TODO: Load these from params |
| 1564 | #NOTE: must end in / |
| 1565 | log_folder = "/opt/onos/log/" |
| 1566 | log_files = ["karaf.log", "karaf.log.1"] |
| 1567 | #NOTE: must end in / |
| 1568 | dst_dir = "~/packet_captures/" |
| 1569 | for f in log_files: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1570 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS1_ip+":"+log_folder+f+" "+ |
| 1571 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1572 | dst_dir + str(testname) + "-ONOS1-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1573 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS2_ip+":"+log_folder+f+" "+ |
| 1574 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1575 | dst_dir + str(testname) + "-ONOS2-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1576 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS3_ip+":"+log_folder+f+" "+ |
| 1577 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1578 | dst_dir + str(testname) + "-ONOS3-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1579 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS4_ip+":"+log_folder+f+" "+ |
| 1580 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1581 | dst_dir + str(testname) + "-ONOS4-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1582 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS5_ip+":"+log_folder+f+" "+ |
| 1583 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1584 | dst_dir + str(testname) + "-ONOS5-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1585 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS6_ip+":"+log_folder+f+" "+ |
| 1586 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1587 | dst_dir + str(testname) + "-ONOS6-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1588 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS7_ip+":"+log_folder+f+" "+ |
| 1589 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1590 | dst_dir + str(testname) + "-ONOS7-"+f ) |
| 1591 | |
| 1592 | #std*.log's |
| 1593 | #NOTE: must end in / |
| 1594 | log_folder = "/opt/onos/var/" |
| 1595 | log_files = ["stderr.log", "stdout.log"] |
| 1596 | #NOTE: must end in / |
| 1597 | dst_dir = "~/packet_captures/" |
| 1598 | for f in log_files: |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1599 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS1_ip+":"+log_folder+f+" "+ |
| 1600 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1601 | dst_dir + str(testname) + "-ONOS1-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1602 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS2_ip+":"+log_folder+f+" "+ |
| 1603 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1604 | dst_dir + str(testname) + "-ONOS2-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1605 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS3_ip+":"+log_folder+f+" "+ |
| 1606 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1607 | dst_dir + str(testname) + "-ONOS3-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1608 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS4_ip+":"+log_folder+f+" "+ |
| 1609 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1610 | dst_dir + str(testname) + "-ONOS4-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1611 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS5_ip+":"+log_folder+f+" "+ |
| 1612 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1613 | dst_dir + str(testname) + "-ONOS5-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1614 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS6_ip+":"+log_folder+f+" "+ |
| 1615 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1616 | dst_dir + str(testname) + "-ONOS6-"+f ) |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1617 | main.ONOSbench.handle.sendline( "scp sdn@"+ONOS7_ip+":"+log_folder+f+" "+ |
| 1618 | teststation_user +"@"+teststation_IP+":"+\ |
Jon Hall | 73cf9cc | 2014-11-20 22:28:38 -0800 | [diff] [blame] | 1619 | dst_dir + str(testname) + "-ONOS7-"+f ) |
| 1620 | |
| 1621 | |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1622 | #sleep so scp can finish |
| 1623 | time.sleep(10) |
| 1624 | main.step("Packing and rotating pcap archives") |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1625 | os.system("~/TestON/dependencies/rotate.sh "+ str(testname)) |
Jon Hall | b1290e8 | 2014-11-18 16:17:48 -0500 | [diff] [blame] | 1626 | |
Jon Hall | 368769f | 2014-11-19 15:43:35 -0800 | [diff] [blame] | 1627 | |
| 1628 | #TODO: actually check something here |
| 1629 | utilities.assert_equals(expect=main.TRUE, actual=main.TRUE, |
| 1630 | onpass="Test cleanup successful", |
| 1631 | onfail="Test cleanup NOT successful") |
Jon Hall | 94fd047 | 2014-12-08 11:52:42 -0800 | [diff] [blame^] | 1632 | def CASE14 ( self, main ) : |
| 1633 | ''' |
| 1634 | start election app on all onos nodes |
| 1635 | ''' |
| 1636 | #install app on onos 1 |
| 1637 | #wait for election |
| 1638 | #check for leader |
| 1639 | #install on other nodes |
| 1640 | #check for leader. Should be onos1 and each app shows same leader |
| 1641 | # |
| 1642 | |
| 1643 | |
| 1644 | |
| 1645 | |
| 1646 | |
| 1647 | #Next Case |
| 1648 | #add to reboot case? |
| 1649 | #check for conistent leader |
| 1650 | #new leader should have been elected |