andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1 | #TopoPerfNext |
| 2 | # |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 3 | #Topology Convergence scale-out test for ONOS-next |
| 4 | #NOTE: This test supports up to 7 nodes scale-out scenario |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 5 | # |
| 6 | #andrew@onlab.us |
| 7 | |
| 8 | import time |
| 9 | import sys |
| 10 | import os |
| 11 | import re |
| 12 | |
| 13 | class TopoConvNext: |
| 14 | def __init__(self): |
| 15 | self.default = '' |
| 16 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 17 | def CASE1(self, main): |
| 18 | ''' |
| 19 | ONOS startup sequence |
| 20 | ''' |
| 21 | import time |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 22 | |
| 23 | #****** |
| 24 | #Global cluster count for scale-out purposes |
| 25 | global cluster_count |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 26 | cluster_count = 1 |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 27 | #****** |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 28 | cell_name = main.params['ENV']['cellName'] |
| 29 | |
| 30 | git_pull = main.params['GIT']['autoPull'] |
| 31 | checkout_branch = main.params['GIT']['checkout'] |
| 32 | |
| 33 | ONOS1_ip = main.params['CTRL']['ip1'] |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 34 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 35 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 36 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 37 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 38 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 39 | ONOS7_ip = main.params['CTRL']['ip7'] |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 40 | MN1_ip = main.params['MN']['ip1'] |
| 41 | BENCH_ip = main.params['BENCH']['ip'] |
| 42 | |
| 43 | main.case("Setting up test environment") |
| 44 | main.log.report("Setting up test environment") |
| 45 | |
| 46 | main.step("Creating cell file") |
| 47 | cell_file_result = main.ONOSbench.create_cell_file( |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 48 | BENCH_ip, cell_name, MN1_ip, |
| 49 | "onos-core,onos-app-metrics", ONOS1_ip) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 50 | |
| 51 | main.step("Applying cell file to environment") |
| 52 | cell_apply_result = main.ONOSbench.set_cell(cell_name) |
| 53 | verify_cell_result = main.ONOSbench.verify_cell() |
| 54 | |
| 55 | main.step("Git checkout and pull "+checkout_branch) |
| 56 | if git_pull == 'on': |
| 57 | checkout_result = \ |
| 58 | main.ONOSbench.git_checkout(checkout_branch) |
| 59 | pull_result = main.ONOSbench.git_pull() |
| 60 | else: |
| 61 | checkout_result = main.TRUE |
| 62 | pull_result = main.TRUE |
| 63 | main.log.info("Skipped git checkout and pull") |
| 64 | |
| 65 | main.step("Using mvn clean & install") |
| 66 | #mvn_result = main.ONOSbench.clean_install() |
| 67 | mvn_result = main.TRUE |
| 68 | |
| 69 | main.step("Set cell for ONOS cli env") |
| 70 | main.ONOS1cli.set_cell(cell_name) |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 71 | main.ONOS2cli.set_cell(cell_name) |
| 72 | main.ONOS3cli.set_cell(cell_name) |
| 73 | main.ONOS4cli.set_cell(cell_name) |
| 74 | main.ONOS5cli.set_cell(cell_name) |
| 75 | main.ONOS6cli.set_cell(cell_name) |
| 76 | main.ONOS7cli.set_cell(cell_name) |
| 77 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 78 | main.step("Creating ONOS package") |
| 79 | package_result = main.ONOSbench.onos_package() |
| 80 | |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 81 | #Start test with single node only |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 82 | main.step("Installing ONOS package") |
| 83 | install1_result = main.ONOSbench.onos_install(node=ONOS1_ip) |
| 84 | |
| 85 | time.sleep(10) |
| 86 | |
| 87 | main.step("Start onos cli") |
| 88 | cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 89 | |
| 90 | main.step("Enable metrics feature") |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 91 | #main.ONOS1cli.feature_install("onos-app-metrics") |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 92 | |
| 93 | utilities.assert_equals(expect=main.TRUE, |
| 94 | actual= cell_file_result and cell_apply_result and\ |
| 95 | verify_cell_result and checkout_result and\ |
| 96 | pull_result and mvn_result and\ |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 97 | install1_result, |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 98 | onpass="Test Environment setup successful", |
| 99 | onfail="Failed to setup test environment") |
| 100 | |
| 101 | def CASE2(self, main): |
| 102 | ''' |
| 103 | 100 Switch discovery latency |
| 104 | |
| 105 | Important: |
| 106 | This test case can be potentially dangerous if |
| 107 | your machine has previously set iptables rules. |
| 108 | One of the steps of the test case will flush |
| 109 | all existing iptables rules. |
| 110 | Note: |
| 111 | You can specify the number of switches in the |
| 112 | params file to adjust the switch discovery size |
| 113 | (and specify the corresponding topology in Mininet1 |
| 114 | .topo file) |
| 115 | ''' |
| 116 | import time |
| 117 | import subprocess |
| 118 | import os |
| 119 | import requests |
| 120 | import json |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 121 | import numpy |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 122 | |
| 123 | ONOS_ip_list = [] |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 124 | ONOS_ip_list.append('0') |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 125 | ONOS_ip_list.append(main.params['CTRL']['ip1']) |
| 126 | ONOS_ip_list.append(main.params['CTRL']['ip2']) |
| 127 | ONOS_ip_list.append(main.params['CTRL']['ip3']) |
| 128 | ONOS_ip_list.append(main.params['CTRL']['ip4']) |
| 129 | ONOS_ip_list.append(main.params['CTRL']['ip5']) |
| 130 | ONOS_ip_list.append(main.params['CTRL']['ip6']) |
| 131 | ONOS_ip_list.append(main.params['CTRL']['ip7']) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 132 | MN1_ip = main.params['MN']['ip1'] |
| 133 | ONOS_user = main.params['CTRL']['user'] |
| 134 | |
| 135 | default_sw_port = main.params['CTRL']['port1'] |
| 136 | |
| 137 | #Number of iterations of case |
| 138 | num_iter = main.params['TEST']['numIter'] |
| 139 | num_sw = main.params['TEST']['numSwitch'] |
| 140 | |
| 141 | #Timestamp 'keys' for json metrics output. |
| 142 | #These are subject to change, hence moved into params |
| 143 | deviceTimestamp = main.params['JSON']['deviceTimestamp'] |
| 144 | graphTimestamp = main.params['JSON']['graphTimestamp'] |
| 145 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 146 | #Threshold for this test case |
| 147 | sw_disc_threshold_str = main.params['TEST']['swDisc100Threshold'] |
| 148 | sw_disc_threshold_obj = sw_disc_threshold_str.split(",") |
| 149 | sw_disc_threshold_min = int(sw_disc_threshold_obj[0]) |
| 150 | sw_disc_threshold_max = int(sw_disc_threshold_obj[1]) |
| 151 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 152 | assertion = main.TRUE |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 153 | sw_discovery_lat_list = [] |
| 154 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 155 | main.case(str(num_sw)+" switch per "+str(cluster_count)+ |
| 156 | " nodes convergence latency") |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 157 | |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 158 | main.log.report("Large topology convergence and scale-out test") |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 159 | main.log.report("Currently active ONOS node(s): ") |
| 160 | report_str = "Node " |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 161 | for node in range(1, cluster_count+1): |
| 162 | report_str += (str(node) + " ") |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 163 | main.log.report(report_str) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 164 | |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 165 | main.step("Assigning "+num_sw+" switches to each ONOS") |
| 166 | index = 1 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 167 | for node in range(1, cluster_count+1): |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 168 | for i in range(index, int(num_sw)+index): |
| 169 | main.Mininet1.assign_sw_controller( |
| 170 | sw=str(i), |
| 171 | ip1=ONOS_ip_list[node], |
| 172 | port1=default_sw_port) |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 173 | index = i+1 |
| 174 | |
| 175 | main.log.info("Please check ptpd configuration to ensure "+\ |
| 176 | "all nodes' system times are in sync") |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 177 | |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 178 | time.sleep(10) |
| 179 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 180 | for i in range(0, int(num_iter)): |
| 181 | main.step("Set iptables rule to block sw connections") |
| 182 | |
| 183 | #INPUT rules |
| 184 | main.ONOS1.handle.sendline( |
| 185 | "sudo iptables -A INPUT -p tcp -s "+ |
| 186 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 187 | main.ONOS2.handle.sendline( |
| 188 | "sudo iptables -A INPUT -p tcp -s "+ |
| 189 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 190 | main.ONOS3.handle.sendline( |
| 191 | "sudo iptables -A INPUT -p tcp -s "+ |
| 192 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 193 | main.ONOS4.handle.sendline( |
| 194 | "sudo iptables -A INPUT -p tcp -s "+ |
| 195 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 196 | main.ONOS5.handle.sendline( |
| 197 | "sudo iptables -A INPUT -p tcp -s "+ |
| 198 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 199 | main.ONOS6.handle.sendline( |
| 200 | "sudo iptables -A INPUT -p tcp -s "+ |
| 201 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 202 | main.ONOS7.handle.sendline( |
| 203 | "sudo iptables -A INPUT -p tcp -s "+ |
| 204 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 205 | |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 206 | #OUTPUT rules |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 207 | main.ONOS1.handle.sendline( |
| 208 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 209 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 210 | main.ONOS2.handle.sendline( |
| 211 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 212 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 213 | main.ONOS3.handle.sendline( |
| 214 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 215 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 216 | main.ONOS4.handle.sendline( |
| 217 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 218 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 219 | main.ONOS5.handle.sendline( |
| 220 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 221 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 222 | main.ONOS6.handle.sendline( |
| 223 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 224 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
| 225 | main.ONOS7.handle.sendline( |
| 226 | "sudo iptables -A OUTPUT -p tcp -s "+ |
| 227 | MN1_ip+" --dport "+default_sw_port+" -j DROP") |
andrewonlab | 0d4478f | 2014-11-11 20:31:20 -0500 | [diff] [blame] | 228 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 229 | main.log.info("Please wait for switch connection to timeout") |
| 230 | time.sleep(60) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 231 | |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 232 | main.step("Flushing iptables and obtaining t0") |
| 233 | t0_system = time.time()*1000 |
| 234 | main.ONOS1.handle.sendline("sudo iptables -F") |
| 235 | main.ONOS2.handle.sendline("sudo iptables -F") |
| 236 | main.ONOS3.handle.sendline("sudo iptables -F") |
| 237 | main.ONOS4.handle.sendline("sudo iptables -F") |
| 238 | main.ONOS5.handle.sendline("sudo iptables -F") |
| 239 | main.ONOS6.handle.sendline("sudo iptables -F") |
| 240 | main.ONOS7.handle.sendline("sudo iptables -F") |
| 241 | |
| 242 | counter_loop = 0 |
| 243 | counter_avail1 = 0 |
| 244 | counter_avail2 = 0 |
| 245 | counter_avail3 = 0 |
| 246 | counter_avail4 = 0 |
| 247 | counter_avail5 = 0 |
| 248 | counter_avail6 = 0 |
| 249 | counter_avail7 = 0 |
| 250 | onos1_dev = False |
| 251 | onos2_dev = False |
| 252 | onos3_dev = False |
| 253 | onos4_dev = False |
| 254 | onos5_dev = False |
| 255 | onos6_dev = False |
| 256 | onos7_dev = False |
| 257 | |
| 258 | #TODO: Think of a more elegant way to check all |
| 259 | # switches across all nodes |
| 260 | #Goodluck debugging this loop |
| 261 | while counter_loop < 60: |
| 262 | for node in range(1, cluster_count+1): |
| 263 | if node == 1 and not onos1_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 264 | main.log.info("Checking node 1 for device "+ |
| 265 | "discovery") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 266 | device_str_obj1 = main.ONOS1cli.devices() |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 267 | device_json1 = json.loads(device_str_obj1) |
| 268 | for device1 in device_json1: |
| 269 | if device1['available'] == True: |
| 270 | counter_avail1 += 1 |
| 271 | if counter_avail1 == int(num_sw): |
| 272 | onos1_dev = True |
| 273 | main.log.info("All devices have been"+ |
| 274 | " discovered on ONOS1") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 275 | else: |
| 276 | counter_avail1 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 277 | if node == 2 and not onos2_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 278 | main.log.info("Checking node 2 for device "+ |
| 279 | "discovery") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 280 | device_str_obj2 = main.ONOS2cli.devices() |
| 281 | device_json2 = json.loads(device_str_obj2) |
| 282 | for device2 in device_json2: |
| 283 | if device2['available'] == True: |
| 284 | counter_avail2 += 1 |
| 285 | if counter_avail2 == int(num_sw): |
| 286 | onos2_dev = True |
| 287 | main.log.info("All devices have been"+ |
| 288 | " discovered on ONOS2") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 289 | else: |
| 290 | counter_avail2 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 291 | if node == 3 and not onos3_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 292 | main.log.info("Checking node 3 for device "+ |
| 293 | "discovery") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 294 | device_str_obj3 = main.ONOS3cli.devices() |
| 295 | device_json3 = json.loads(device_str_obj3) |
| 296 | for device3 in device_json3: |
| 297 | if device3['available'] == True: |
| 298 | counter_avail3 += 1 |
| 299 | if counter_avail3 == int(num_sw): |
| 300 | onos3_dev = True |
| 301 | main.log.info("All devices have been"+ |
| 302 | " discovered on ONOS3") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 303 | else: |
| 304 | counter_avail3 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 305 | if node == 4 and not onos4_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 306 | main.log.info("Checking node 4 for device "+ |
| 307 | "discovery") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 308 | device_str_obj4 = main.ONOS4cli.devices() |
| 309 | device_json4 = json.loads(device_str_obj4) |
| 310 | for device4 in device_json4: |
| 311 | if device4['available'] == True: |
| 312 | counter_avail4 += 1 |
| 313 | if counter_avail4 == int(num_sw): |
| 314 | onos4_dev = True |
| 315 | main.log.info("All devices have been"+ |
| 316 | " discovered on ONOS4") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 317 | else: |
| 318 | counter_avail4 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 319 | if node == 5 and not onos5_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 320 | main.log.info("Checking node 5 for device "+ |
| 321 | "discovery") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 322 | device_str_obj5 = main.ONOS5cli.devices() |
| 323 | device_json5 = json.loads(device_str_obj5) |
| 324 | for device5 in device_json5: |
| 325 | if device5['available'] == True: |
| 326 | counter_avail5 += 1 |
| 327 | if counter_avail5 == int(num_sw): |
| 328 | onos5_dev = True |
| 329 | main.log.info("All devices have been"+ |
| 330 | " discovered on ONOS5") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 331 | else: |
| 332 | counter_avail5 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 333 | if node == 6 and not onos6_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 334 | main.log.info("Checking node 6 for device "+ |
| 335 | "discovery") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 336 | device_str_obj6 = main.ONOS6cli.devices() |
| 337 | device_json6 = json.loads(device_str_obj6) |
| 338 | for device6 in device_json6: |
| 339 | if device6['available'] == True: |
| 340 | counter_avail6 += 1 |
| 341 | if counter_avail6 == int(num_sw): |
| 342 | onos6_dev = True |
| 343 | main.log.info("All devices have been"+ |
| 344 | " discovered on ONOS6") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 345 | else: |
| 346 | counter_avail6 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 347 | if node == 7 and not onos7_dev: |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 348 | main.log.info("Checking node 7 for device "+ |
| 349 | "discovery") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 350 | device_str_obj7 = main.ONOS7cli.devices() |
| 351 | device_json7 = json.loads(device_str_obj7) |
| 352 | for device7 in device_json7: |
| 353 | if device7['available'] == True: |
| 354 | counter_avail7 += 1 |
| 355 | if counter_avail7 == int(num_sw): |
| 356 | onos7_dev = True |
| 357 | main.log.info("All devices have been"+ |
| 358 | " discovered on ONOS7") |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 359 | else: |
| 360 | counter_avail7 = 0 |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 361 | #END node loop |
| 362 | |
| 363 | #TODO: clean up this mess of an if statements if possible |
| 364 | #Treat each if as a separate test case with the given |
| 365 | # cluster count. Hence when the cluster count changes |
| 366 | # the desired calculations will be made |
| 367 | if cluster_count == 1: |
| 368 | if onos1_dev: |
| 369 | main.log.info("All devices have been discovered"+ |
| 370 | " on all ONOS instances") |
| 371 | json_str_metrics_1 =\ |
| 372 | main.ONOS1cli.topology_events_metrics() |
| 373 | json_obj_1 = json.loads(json_str_metrics_1) |
| 374 | graph_timestamp_1 =\ |
| 375 | json_obj_1[graphTimestamp]['value'] |
| 376 | |
| 377 | graph_lat_1 = \ |
| 378 | int(graph_timestamp_1) - int(t0_system) |
| 379 | |
| 380 | if graph_lat_1 > sw_disc_threshold_min\ |
| 381 | and graph_lat_1 < sw_disc_threshold_max: |
| 382 | sw_discovery_lat_list.append( |
| 383 | graph_lat_1) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 384 | main.log.info("Sw discovery latency of "+ |
| 385 | str(cluster_count)+" node(s): "+ |
| 386 | str(graph_lat_1)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 387 | else: |
| 388 | main.log.info("Switch discovery latency "+ |
| 389 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 390 | main.log.info(graph_lat_1) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 391 | #Break while loop |
| 392 | break |
| 393 | if cluster_count == 2: |
| 394 | if onos1_dev and onos2_dev: |
| 395 | main.log.info("All devices have been discovered"+ |
| 396 | " on all ONOS instances") |
| 397 | json_str_metrics_1 =\ |
| 398 | main.ONOS1cli.topology_events_metrics() |
| 399 | json_str_metrics_2 =\ |
| 400 | main.ONOS2cli.topology_events_metrics() |
| 401 | json_obj_1 = json.loads(json_str_metrics_1) |
| 402 | json_obj_2 = json.loads(json_str_metrics_2) |
| 403 | graph_timestamp_1 =\ |
| 404 | json_obj_1[graphTimestamp]['value'] |
| 405 | graph_timestamp_2 =\ |
| 406 | json_obj_2[graphTimestamp]['value'] |
| 407 | |
| 408 | graph_lat_1 = \ |
| 409 | int(graph_timestamp_1) - int(t0_system) |
| 410 | graph_lat_2 = \ |
| 411 | int(graph_timestamp_2) - int(t0_system) |
| 412 | |
| 413 | avg_graph_lat = \ |
| 414 | (int(graph_lat_1) +\ |
| 415 | int(graph_lat_2)) / 2 |
| 416 | |
| 417 | if avg_graph_lat > sw_disc_threshold_min\ |
| 418 | and avg_graph_lat < sw_disc_threshold_max: |
| 419 | sw_discovery_lat_list.append( |
| 420 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 421 | main.log.info("Sw discovery latency of "+ |
| 422 | str(cluster_count)+" node(s): "+ |
| 423 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 424 | else: |
| 425 | main.log.info("Switch discovery latency "+ |
| 426 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 427 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 428 | break |
| 429 | if cluster_count == 3: |
| 430 | if onos1_dev and onos2_dev and onos3_dev: |
| 431 | main.log.info("All devices have been discovered"+ |
| 432 | " on all ONOS instances") |
| 433 | json_str_metrics_1 =\ |
| 434 | main.ONOS1cli.topology_events_metrics() |
| 435 | json_str_metrics_2 =\ |
| 436 | main.ONOS2cli.topology_events_metrics() |
| 437 | json_str_metrics_3 =\ |
| 438 | main.ONOS3cli.topology_events_metrics() |
| 439 | json_obj_1 = json.loads(json_str_metrics_1) |
| 440 | json_obj_2 = json.loads(json_str_metrics_2) |
| 441 | json_obj_3 = json.loads(json_str_metrics_3) |
| 442 | graph_timestamp_1 =\ |
| 443 | json_obj_1[graphTimestamp]['value'] |
| 444 | graph_timestamp_2 =\ |
| 445 | json_obj_2[graphTimestamp]['value'] |
| 446 | graph_timestamp_3 =\ |
| 447 | json_obj_3[graphTimestamp]['value'] |
| 448 | |
| 449 | graph_lat_1 = \ |
| 450 | int(graph_timestamp_1) - int(t0_system) |
| 451 | graph_lat_2 = \ |
| 452 | int(graph_timestamp_2) - int(t0_system) |
| 453 | graph_lat_3 = \ |
| 454 | int(graph_timestamp_3) - int(t0_system) |
| 455 | |
| 456 | avg_graph_lat = \ |
| 457 | (int(graph_lat_1) +\ |
| 458 | int(graph_lat_2) +\ |
| 459 | int(graph_lat_3)) / 3 |
| 460 | |
| 461 | if avg_graph_lat > sw_disc_threshold_min\ |
| 462 | and avg_graph_lat < sw_disc_threshold_max: |
| 463 | sw_discovery_lat_list.append( |
| 464 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 465 | main.log.info("Sw discovery latency of "+ |
| 466 | str(cluster_count)+" node(s): "+ |
| 467 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 468 | else: |
| 469 | main.log.info("Switch discovery latency "+ |
| 470 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 471 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 472 | |
| 473 | break |
| 474 | if cluster_count == 4: |
| 475 | if onos1_dev and onos2_dev and onos3_dev and\ |
| 476 | onos4_dev: |
| 477 | main.log.info("All devices have been discovered"+ |
| 478 | " on all ONOS instances") |
| 479 | json_str_metrics_1 =\ |
| 480 | main.ONOS1cli.topology_events_metrics() |
| 481 | json_str_metrics_2 =\ |
| 482 | main.ONOS2cli.topology_events_metrics() |
| 483 | json_str_metrics_3 =\ |
| 484 | main.ONOS3cli.topology_events_metrics() |
| 485 | json_str_metrics_4 =\ |
| 486 | main.ONOS4cli.topology_events_metrics() |
| 487 | json_obj_1 = json.loads(json_str_metrics_1) |
| 488 | json_obj_2 = json.loads(json_str_metrics_2) |
| 489 | json_obj_3 = json.loads(json_str_metrics_3) |
| 490 | json_obj_4 = json.loads(json_str_metrics_4) |
| 491 | graph_timestamp_1 =\ |
| 492 | json_obj_1[graphTimestamp]['value'] |
| 493 | graph_timestamp_2 =\ |
| 494 | json_obj_2[graphTimestamp]['value'] |
| 495 | graph_timestamp_3 =\ |
| 496 | json_obj_3[graphTimestamp]['value'] |
| 497 | graph_timestamp_4 =\ |
| 498 | json_obj_4[graphTimestamp]['value'] |
| 499 | |
| 500 | graph_lat_1 = \ |
| 501 | int(graph_timestamp_1) - int(t0_system) |
| 502 | graph_lat_2 = \ |
| 503 | int(graph_timestamp_2) - int(t0_system) |
| 504 | graph_lat_3 = \ |
| 505 | int(graph_timestamp_3) - int(t0_system) |
| 506 | graph_lat_4 = \ |
| 507 | int(graph_timestamp_4) - int(t0_system) |
| 508 | |
| 509 | avg_graph_lat = \ |
| 510 | (int(graph_lat_1) +\ |
| 511 | int(graph_lat_2) +\ |
| 512 | int(graph_lat_3) +\ |
| 513 | int(graph_lat_4)) / 4 |
| 514 | |
| 515 | if avg_graph_lat > sw_disc_threshold_min\ |
| 516 | and avg_graph_lat < sw_disc_threshold_max: |
| 517 | sw_discovery_lat_list.append( |
| 518 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 519 | main.log.info("Sw discovery latency of "+ |
| 520 | str(cluster_count)+" node(s): "+ |
| 521 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 522 | else: |
| 523 | main.log.info("Switch discovery latency "+ |
| 524 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 525 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 526 | |
| 527 | break |
| 528 | if cluster_count == 5: |
| 529 | if onos1_dev and onos2_dev and onos3_dev and\ |
| 530 | onos4_dev and onos5_dev: |
| 531 | main.log.info("All devices have been discovered"+ |
| 532 | " on all ONOS instances") |
| 533 | json_str_metrics_1 =\ |
| 534 | main.ONOS1cli.topology_events_metrics() |
| 535 | json_str_metrics_2 =\ |
| 536 | main.ONOS2cli.topology_events_metrics() |
| 537 | json_str_metrics_3 =\ |
| 538 | main.ONOS3cli.topology_events_metrics() |
| 539 | json_str_metrics_4 =\ |
| 540 | main.ONOS4cli.topology_events_metrics() |
| 541 | json_str_metrics_5 =\ |
| 542 | main.ONOS5cli.topology_events_metrics() |
| 543 | json_obj_1 = json.loads(json_str_metrics_1) |
| 544 | json_obj_2 = json.loads(json_str_metrics_2) |
| 545 | json_obj_3 = json.loads(json_str_metrics_3) |
| 546 | json_obj_4 = json.loads(json_str_metrics_4) |
| 547 | json_obj_5 = json.loads(json_str_metrics_5) |
| 548 | graph_timestamp_1 =\ |
| 549 | json_obj_1[graphTimestamp]['value'] |
| 550 | graph_timestamp_2 =\ |
| 551 | json_obj_2[graphTimestamp]['value'] |
| 552 | graph_timestamp_3 =\ |
| 553 | json_obj_3[graphTimestamp]['value'] |
| 554 | graph_timestamp_4 =\ |
| 555 | json_obj_4[graphTimestamp]['value'] |
| 556 | graph_timestamp_5 =\ |
| 557 | json_obj_5[graphTimestamp]['value'] |
| 558 | |
| 559 | graph_lat_1 = \ |
| 560 | int(graph_timestamp_1) - int(t0_system) |
| 561 | graph_lat_2 = \ |
| 562 | int(graph_timestamp_2) - int(t0_system) |
| 563 | graph_lat_3 = \ |
| 564 | int(graph_timestamp_3) - int(t0_system) |
| 565 | graph_lat_4 = \ |
| 566 | int(graph_timestamp_4) - int(t0_system) |
| 567 | graph_lat_5 = \ |
| 568 | int(graph_timestamp_5) - int(t0_system) |
| 569 | |
| 570 | avg_graph_lat = \ |
| 571 | (int(graph_lat_1) +\ |
| 572 | int(graph_lat_2) +\ |
| 573 | int(graph_lat_3) +\ |
| 574 | int(graph_lat_4) +\ |
| 575 | int(graph_lat_5)) / 5 |
| 576 | |
| 577 | if avg_graph_lat > sw_disc_threshold_min\ |
| 578 | and avg_graph_lat < sw_disc_threshold_max: |
| 579 | sw_discovery_lat_list.append( |
| 580 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 581 | main.log.info("Sw discovery latency of "+ |
| 582 | str(cluster_count)+" node(s): "+ |
| 583 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 584 | else: |
| 585 | main.log.info("Switch discovery latency "+ |
| 586 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 587 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 588 | |
| 589 | break |
| 590 | if cluster_count == 6: |
| 591 | if onos1_dev and onos2_dev and onos3_dev and\ |
| 592 | onos4_dev and onos5_dev and onos6_dev: |
| 593 | main.log.info("All devices have been discovered"+ |
| 594 | " on all ONOS instances") |
| 595 | json_str_metrics_1 =\ |
| 596 | main.ONOS1cli.topology_events_metrics() |
| 597 | json_str_metrics_2 =\ |
| 598 | main.ONOS2cli.topology_events_metrics() |
| 599 | json_str_metrics_3 =\ |
| 600 | main.ONOS3cli.topology_events_metrics() |
| 601 | json_str_metrics_4 =\ |
| 602 | main.ONOS4cli.topology_events_metrics() |
| 603 | json_str_metrics_5 =\ |
| 604 | main.ONOS5cli.topology_events_metrics() |
| 605 | json_str_metrics_6 =\ |
| 606 | main.ONOS6cli.topology_events_metrics() |
| 607 | json_obj_1 = json.loads(json_str_metrics_1) |
| 608 | json_obj_2 = json.loads(json_str_metrics_2) |
| 609 | json_obj_3 = json.loads(json_str_metrics_3) |
| 610 | json_obj_4 = json.loads(json_str_metrics_4) |
| 611 | json_obj_5 = json.loads(json_str_metrics_5) |
| 612 | json_obj_6 = json.loads(json_str_metrics_6) |
| 613 | graph_timestamp_1 =\ |
| 614 | json_obj_1[graphTimestamp]['value'] |
| 615 | graph_timestamp_2 =\ |
| 616 | json_obj_2[graphTimestamp]['value'] |
| 617 | graph_timestamp_3 =\ |
| 618 | json_obj_3[graphTimestamp]['value'] |
| 619 | graph_timestamp_4 =\ |
| 620 | json_obj_4[graphTimestamp]['value'] |
| 621 | graph_timestamp_5 =\ |
| 622 | json_obj_5[graphTimestamp]['value'] |
| 623 | graph_timestamp_6 =\ |
| 624 | json_obj_6[graphTimestamp]['value'] |
| 625 | |
| 626 | graph_lat_1 = \ |
| 627 | int(graph_timestamp_1) - int(t0_system) |
| 628 | graph_lat_2 = \ |
| 629 | int(graph_timestamp_2) - int(t0_system) |
| 630 | graph_lat_3 = \ |
| 631 | int(graph_timestamp_3) - int(t0_system) |
| 632 | graph_lat_4 = \ |
| 633 | int(graph_timestamp_4) - int(t0_system) |
| 634 | graph_lat_5 = \ |
| 635 | int(graph_timestamp_5) - int(t0_system) |
| 636 | graph_lat_6 = \ |
| 637 | int(graph_timestamp_6) - int(t0_system) |
| 638 | |
| 639 | avg_graph_lat = \ |
| 640 | (int(graph_lat_1) +\ |
| 641 | int(graph_lat_2) +\ |
| 642 | int(graph_lat_3) +\ |
| 643 | int(graph_lat_4) +\ |
| 644 | int(graph_lat_5) +\ |
| 645 | int(graph_lat_6)) / 6 |
| 646 | |
| 647 | if avg_graph_lat > sw_disc_threshold_min\ |
| 648 | and avg_graph_lat < sw_disc_threshold_max: |
| 649 | sw_discovery_lat_list.append( |
| 650 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 651 | main.log.info("Sw discovery latency of "+ |
| 652 | str(cluster_count)+" node(s): "+ |
| 653 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 654 | else: |
| 655 | main.log.info("Switch discovery latency "+ |
| 656 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 657 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 658 | |
| 659 | break |
| 660 | if cluster_count == 7: |
| 661 | if onos1_dev and onos2_dev and onos3_dev and\ |
| 662 | onos4_dev and onos5_dev and onos6_dev and\ |
| 663 | onos7_dev: |
| 664 | main.log.info("All devices have been discovered"+ |
| 665 | " on all ONOS instances") |
| 666 | json_str_metrics_1 =\ |
| 667 | main.ONOS1cli.topology_events_metrics() |
| 668 | json_str_metrics_2 =\ |
| 669 | main.ONOS2cli.topology_events_metrics() |
| 670 | json_str_metrics_3 =\ |
| 671 | main.ONOS3cli.topology_events_metrics() |
| 672 | json_str_metrics_4 =\ |
| 673 | main.ONOS4cli.topology_events_metrics() |
| 674 | json_str_metrics_5 =\ |
| 675 | main.ONOS5cli.topology_events_metrics() |
| 676 | json_str_metrics_6 =\ |
| 677 | main.ONOS6cli.topology_events_metrics() |
| 678 | json_str_metrics_7 =\ |
| 679 | main.ONOS7cli.topology_events_metrics() |
| 680 | json_obj_1 = json.loads(json_str_metrics_1) |
| 681 | json_obj_2 = json.loads(json_str_metrics_2) |
| 682 | json_obj_3 = json.loads(json_str_metrics_3) |
| 683 | json_obj_4 = json.loads(json_str_metrics_4) |
| 684 | json_obj_5 = json.loads(json_str_metrics_5) |
| 685 | json_obj_6 = json.loads(json_str_metrics_6) |
| 686 | json_obj_7 = json.loads(json_str_metrics_7) |
| 687 | graph_timestamp_1 =\ |
| 688 | json_obj_1[graphTimestamp]['value'] |
| 689 | graph_timestamp_2 =\ |
| 690 | json_obj_2[graphTimestamp]['value'] |
| 691 | graph_timestamp_3 =\ |
| 692 | json_obj_3[graphTimestamp]['value'] |
| 693 | graph_timestamp_4 =\ |
| 694 | json_obj_4[graphTimestamp]['value'] |
| 695 | graph_timestamp_5 =\ |
| 696 | json_obj_5[graphTimestamp]['value'] |
| 697 | graph_timestamp_6 =\ |
| 698 | json_obj_6[graphTimestamp]['value'] |
| 699 | graph_timestamp_7 =\ |
| 700 | json_obj_7[graphTimestamp]['value'] |
| 701 | |
| 702 | graph_lat_1 = \ |
| 703 | int(graph_timestamp_1) - int(t0_system) |
| 704 | graph_lat_2 = \ |
| 705 | int(graph_timestamp_2) - int(t0_system) |
| 706 | graph_lat_3 = \ |
| 707 | int(graph_timestamp_3) - int(t0_system) |
| 708 | graph_lat_4 = \ |
| 709 | int(graph_timestamp_4) - int(t0_system) |
| 710 | graph_lat_5 = \ |
| 711 | int(graph_timestamp_5) - int(t0_system) |
| 712 | graph_lat_6 = \ |
| 713 | int(graph_timestamp_6) - int(t0_system) |
| 714 | graph_lat_7 = \ |
| 715 | int(graph_timestamp_7) - int(t0_system) |
| 716 | |
| 717 | avg_graph_lat = \ |
| 718 | (int(graph_lat_1) +\ |
| 719 | int(graph_lat_2) +\ |
| 720 | int(graph_lat_3) +\ |
| 721 | int(graph_lat_4) +\ |
| 722 | int(graph_lat_5) +\ |
| 723 | int(graph_lat_6) +\ |
| 724 | int(graph_lat_7)) / 7 |
| 725 | |
| 726 | if avg_graph_lat > sw_disc_threshold_min\ |
| 727 | and avg_graph_lat < sw_disc_threshold_max: |
| 728 | sw_discovery_lat_list.append( |
| 729 | avg_graph_lat) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 730 | main.log.info("Sw discovery latency of "+ |
| 731 | str(cluster_count)+" node(s): "+ |
| 732 | str(avg_graph_lat)+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 733 | else: |
| 734 | main.log.info("Switch discovery latency "+ |
| 735 | "exceeded the threshold.") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 736 | main.log.info(avg_graph_lat) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 737 | |
| 738 | break |
| 739 | |
| 740 | counter_loop += 1 |
| 741 | time.sleep(3) |
| 742 | #END WHILE LOOP |
| 743 | #END ITERATION LOOP |
| 744 | #REPORT HERE |
| 745 | |
| 746 | if len(sw_discovery_lat_list) > 0: |
| 747 | sw_lat_avg = sum(sw_discovery_lat_list) / \ |
| 748 | len(sw_discovery_lat_list) |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 749 | sw_lat_dev = numpy.std(sw_discovery_lat_list) |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 750 | else: |
| 751 | assertion = main.FALSE |
| 752 | |
| 753 | main.log.report("Switch discovery lat for "+\ |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 754 | str(cluster_count)+" instance(s), 100 sw each: ") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 755 | main.log.report("Avg: "+str(sw_lat_avg)+" ms") |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 756 | main.log.report("Std Deviation: "+ |
| 757 | str(round(sw_lat_dev,1))+" ms") |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 758 | |
| 759 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 760 | onpass="Switch discovery convergence latency" +\ |
andrewonlab | fd8325f | 2014-11-12 19:14:06 -0500 | [diff] [blame] | 761 | " for "+str(cluster_count)+" nodes successful", |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 762 | onfail="Switch discovery convergence latency" +\ |
| 763 | " test failed") |
| 764 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 765 | def CASE3(self, main): |
| 766 | ''' |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 767 | Increase number of nodes and initiate CLI |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 768 | ''' |
| 769 | import time |
| 770 | import subprocess |
| 771 | import os |
| 772 | import requests |
| 773 | import json |
| 774 | |
| 775 | ONOS_ip_list = [] |
andrewonlab | 51b180b | 2014-11-12 18:19:28 -0500 | [diff] [blame] | 776 | ONOS_ip_list.append('0') #Append 0 for index 0 |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 777 | ONOS_ip_list.append(main.params['CTRL']['ip1']) |
| 778 | ONOS_ip_list.append(main.params['CTRL']['ip2']) |
| 779 | ONOS_ip_list.append(main.params['CTRL']['ip3']) |
| 780 | ONOS_ip_list.append(main.params['CTRL']['ip4']) |
| 781 | ONOS_ip_list.append(main.params['CTRL']['ip5']) |
| 782 | ONOS_ip_list.append(main.params['CTRL']['ip6']) |
| 783 | ONOS_ip_list.append(main.params['CTRL']['ip7']) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 784 | |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 785 | ONOS1_ip = main.params['CTRL']['ip1'] |
| 786 | ONOS2_ip = main.params['CTRL']['ip2'] |
| 787 | ONOS3_ip = main.params['CTRL']['ip3'] |
| 788 | ONOS4_ip = main.params['CTRL']['ip4'] |
| 789 | ONOS5_ip = main.params['CTRL']['ip5'] |
| 790 | ONOS6_ip = main.params['CTRL']['ip6'] |
| 791 | ONOS7_ip = main.params['CTRL']['ip7'] |
| 792 | |
| 793 | cell_name = main.params['ENV']['cellName'] |
| 794 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 795 | MN1_ip = main.params['MN']['ip1'] |
| 796 | BENCH_ip = main.params['BENCH']['ip'] |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 797 | |
| 798 | main.step("Creating cell file") |
| 799 | cell_file_result = main.ONOSbench.create_cell_file( |
| 800 | BENCH_ip, cell_name, MN1_ip, "onos-core", |
| 801 | ONOS1_ip, ONOS2_ip, ONOS3_ip, ONOS4_ip, |
| 802 | ONOS5_ip, ONOS6_ip, ONOS7_ip) |
| 803 | |
| 804 | main.step("Applying cell file to environment") |
| 805 | cell_apply_result = main.ONOSbench.set_cell(cell_name) |
| 806 | verify_cell_result = main.ONOSbench.verify_cell() |
| 807 | |
| 808 | |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 809 | #NOTE:We start with cluster_count at 1. The first |
| 810 | #case already initialized ONOS1. Increase the |
| 811 | #cluster count and start from 2. |
| 812 | #You can optionally change the increment to |
| 813 | #test steps of node sizes, such as 1,3,5,7 |
| 814 | |
| 815 | global cluster_count |
andrewonlab | 54cec4b | 2014-11-12 13:30:23 -0500 | [diff] [blame] | 816 | cluster_count += 2 |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 817 | |
| 818 | #Supports up to 7 node configuration |
andrewonlab | 81763ee | 2014-11-13 17:31:34 -0500 | [diff] [blame] | 819 | #TODO: Cleanup this ridiculous repetitive code |
| 820 | if cluster_count == 2: |
| 821 | main.log.info("Closing previous ONOS connections") |
| 822 | main.ONOS1cli.logout() |
| 823 | main.log.info("Creating new cell file with "+ |
| 824 | str(node)+" nodes") |
| 825 | main.ONOSbench.create_cell_file(BENCH_ip, cell_name, |
| 826 | MN1_ip, "onos-core", ONOS1_ip, ONOS2_ip) |
| 827 | main.log.info("Applying cell file to environment") |
| 828 | main.ONOSbench.set_cell(cell_name) |
| 829 | main.ONOS1cli.set_cell(cell_name) |
| 830 | main.ONOS2cli.set_cell(cell_name) |
| 831 | main.log.info("Packaging new ONOS") |
| 832 | main.ONOSbench.onos_package() |
| 833 | main.log.info("Installing ONOS") |
| 834 | main.ONOSbench.onos_install(node=ONOS1_ip) |
| 835 | main.ONOSbench.onos_install(node=ONOS2_ip) |
| 836 | main.log.info("Starting CLI") |
| 837 | main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 838 | main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 839 | main.log.info("Installing metrics feature") |
| 840 | main.ONOS1cli.feature_install("onos-app-metrics") |
| 841 | main.ONOS2cli.feature_install("onos-app-metrics") |
| 842 | elif cluster_count == 3: |
| 843 | main.log.info("Closing previous ONOS connections") |
| 844 | main.ONOS1cli.logout() |
| 845 | main.ONOS2cli.logout() |
| 846 | main.log.info("Creating new cell file with "+ |
| 847 | str(node)+" nodes") |
| 848 | main.ONOSbench.create_cell_file(BENCH_ip, cell_name, |
| 849 | MN1_ip, "onos-core", ONOS1_ip, ONOS2_ip, ONOS3_ip) |
| 850 | main.log.info("Applying cell file to environment") |
| 851 | main.ONOSbench.set_cell(cell_name) |
| 852 | main.ONOS1cli.set_cell(cell_name) |
| 853 | main.ONOS2cli.set_cell(cell_name) |
| 854 | main.ONOS3cli.set_cell(cell_name) |
| 855 | main.log.info("Packaging new ONOS") |
| 856 | main.ONOSbench.onos_package() |
| 857 | main.log.info("Installing ONOS") |
| 858 | main.ONOSbench.onos_install(node=ONOS1_ip) |
| 859 | main.ONOSbench.onos_install(node=ONOS2_ip) |
| 860 | main.ONOSbench.onos_install(node=ONOS3_ip) |
| 861 | main.log.info("Starting CLI") |
| 862 | main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 863 | main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 864 | main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 865 | main.log.info("Installing metrics feature") |
| 866 | main.ONOS1cli.feature_install("onos-app-metrics") |
| 867 | main.ONOS2cli.feature_install("onos-app-metrics") |
| 868 | main.ONOS3cli.feature_install("onos-app-metrics") |
| 869 | elif cluster_count == 4: |
| 870 | main.log.info("Closing previous ONOS connections") |
| 871 | main.ONOS1cli.logout() |
| 872 | main.ONOS2cli.logout() |
| 873 | main.ONOS3cli.logout() |
| 874 | main.log.info("Creating new cell file with "+ |
| 875 | str(node)+" nodes") |
| 876 | main.ONOSbench.create_cell_file(BENCH_ip, cell_name, |
| 877 | MN1_ip, "onos-core", ONOS1_ip, ONOS2_ip, ONOS3_ip, |
| 878 | ONOS4_ip) |
| 879 | main.log.info("Applying cell file to environment") |
| 880 | main.ONOSbench.set_cell(cell_name) |
| 881 | main.ONOS1cli.set_cell(cell_name) |
| 882 | main.ONOS2cli.set_cell(cell_name) |
| 883 | main.ONOS3cli.set_cell(cell_name) |
| 884 | main.ONOS4cli.set_cell(cell_name) |
| 885 | main.log.info("Packaging new ONOS") |
| 886 | main.ONOSbench.onos_package() |
| 887 | main.log.info("Installing ONOS") |
| 888 | main.ONOSbench.onos_install(node=ONOS1_ip) |
| 889 | main.ONOSbench.onos_install(node=ONOS2_ip) |
| 890 | main.ONOSbench.onos_install(node=ONOS3_ip) |
| 891 | main.ONOSbench.onos_install(node=ONOS4_ip) |
| 892 | main.log.info("Starting CLI") |
| 893 | main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 894 | main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 895 | main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 896 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 897 | main.log.info("Installing metrics feature") |
| 898 | main.ONOS1cli.feature_install("onos-app-metrics") |
| 899 | main.ONOS2cli.feature_install("onos-app-metrics") |
| 900 | main.ONOS3cli.feature_install("onos-app-metrics") |
| 901 | main.ONOS4cli.feature_install("onos-app-metrics") |
| 902 | elif cluster_count == 5: |
| 903 | main.log.info("Closing previous ONOS connections") |
| 904 | main.ONOS1cli.logout() |
| 905 | main.ONOS2cli.logout() |
| 906 | main.ONOS3cli.logout() |
| 907 | main.ONOS4cli.logout() |
| 908 | main.log.info("Creating new cell file with "+ |
| 909 | str(node)+" nodes") |
| 910 | main.ONOSbench.create_cell_file(BENCH_ip, cell_name, |
| 911 | MN1_ip, "onos-core", ONOS1_ip, ONOS2_ip, ONOS3_ip, |
| 912 | ONOS4_ip, ONOS5_ip) |
| 913 | main.log.info("Applying cell file to environment") |
| 914 | main.ONOSbench.set_cell(cell_name) |
| 915 | main.ONOS1cli.set_cell(cell_name) |
| 916 | main.ONOS2cli.set_cell(cell_name) |
| 917 | main.ONOS3cli.set_cell(cell_name) |
| 918 | main.ONOS4cli.set_cell(cell_name) |
| 919 | main.ONOS5cli.set_cell(cell_name) |
| 920 | main.log.info("Packaging new ONOS") |
| 921 | main.ONOSbench.onos_package() |
| 922 | main.log.info("Installing ONOS") |
| 923 | main.ONOSbench.onos_install(node=ONOS1_ip) |
| 924 | main.ONOSbench.onos_install(node=ONOS2_ip) |
| 925 | main.ONOSbench.onos_install(node=ONOS3_ip) |
| 926 | main.ONOSbench.onos_install(node=ONOS4_ip) |
| 927 | main.ONOSbench.onos_install(node=ONOS5_ip) |
| 928 | main.log.info("Starting CLI") |
| 929 | main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 930 | main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 931 | main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 932 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 933 | main.ONOS5cli.start_onos_cli(ONOS5_ip) |
| 934 | main.log.info("Installing metrics feature") |
| 935 | main.ONOS1cli.feature_install("onos-app-metrics") |
| 936 | main.ONOS2cli.feature_install("onos-app-metrics") |
| 937 | main.ONOS3cli.feature_install("onos-app-metrics") |
| 938 | main.ONOS4cli.feature_install("onos-app-metrics") |
| 939 | main.ONOS5cli.feature_install("onos-app-metrics") |
| 940 | elif cluster_count == 6: |
| 941 | main.log.info("Closing previous ONOS connections") |
| 942 | main.ONOS1cli.logout() |
| 943 | main.ONOS2cli.logout() |
| 944 | main.ONOS3cli.logout() |
| 945 | main.ONOS4cli.logout() |
| 946 | main.ONOS5cli.logout() |
| 947 | main.log.info("Creating new cell file with "+ |
| 948 | str(node)+" nodes") |
| 949 | main.ONOSbench.create_cell_file(BENCH_ip, cell_name, |
| 950 | MN1_ip, "onos-core", ONOS1_ip, ONOS2_ip, ONOS3_ip, |
| 951 | ONOS4_ip, ONOS5_ip, ONOS6_ip) |
| 952 | main.log.info("Applying cell file to environment") |
| 953 | main.ONOSbench.set_cell(cell_name) |
| 954 | main.ONOS1cli.set_cell(cell_name) |
| 955 | main.ONOS2cli.set_cell(cell_name) |
| 956 | main.ONOS3cli.set_cell(cell_name) |
| 957 | main.ONOS4cli.set_cell(cell_name) |
| 958 | main.ONOS5cli.set_cell(cell_name) |
| 959 | main.ONOS6cli.set_cell(cell_name) |
| 960 | main.log.info("Packaging new ONOS") |
| 961 | main.ONOSbench.onos_package() |
| 962 | main.log.info("Installing ONOS") |
| 963 | main.ONOSbench.onos_install(node=ONOS1_ip) |
| 964 | main.ONOSbench.onos_install(node=ONOS2_ip) |
| 965 | main.ONOSbench.onos_install(node=ONOS3_ip) |
| 966 | main.ONOSbench.onos_install(node=ONOS4_ip) |
| 967 | main.ONOSbench.onos_install(node=ONOS5_ip) |
| 968 | main.ONOSbench.onos_install(node=ONOS6_ip) |
| 969 | main.log.info("Starting CLI") |
| 970 | main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 971 | main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 972 | main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 973 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 974 | main.ONOS5cli.start_onos_cli(ONOS5_ip) |
| 975 | main.ONOS6cli.start_onos_cli(ONOS6_ip) |
| 976 | main.log.info("Installing metrics feature") |
| 977 | main.ONOS1cli.feature_install("onos-app-metrics") |
| 978 | main.ONOS2cli.feature_install("onos-app-metrics") |
| 979 | main.ONOS3cli.feature_install("onos-app-metrics") |
| 980 | main.ONOS4cli.feature_install("onos-app-metrics") |
| 981 | main.ONOS5cli.feature_install("onos-app-metrics") |
| 982 | main.ONOS6cli.feature_install("onos-app-metrics") |
| 983 | elif cluster_count == 7: |
| 984 | main.log.info("Closing previous ONOS connections") |
| 985 | main.ONOS1cli.logout() |
| 986 | main.ONOS2cli.logout() |
| 987 | main.ONOS3cli.logout() |
| 988 | main.ONOS4cli.logout() |
| 989 | main.ONOS5cli.logout() |
| 990 | main.log.info("Creating new cell file with "+ |
| 991 | str(node)+" nodes") |
| 992 | main.ONOSbench.create_cell_file(BENCH_ip, cell_name, |
| 993 | MN1_ip, "onos-core", ONOS1_ip, ONOS2_ip, ONOS3_ip, |
| 994 | ONOS4_ip, ONOS5_ip, ONOS6_ip, ONOS7_ip) |
| 995 | main.log.info("Applying cell file to environment") |
| 996 | main.ONOSbench.set_cell(cell_name) |
| 997 | main.ONOS1cli.set_cell(cell_name) |
| 998 | main.ONOS2cli.set_cell(cell_name) |
| 999 | main.ONOS3cli.set_cell(cell_name) |
| 1000 | main.ONOS4cli.set_cell(cell_name) |
| 1001 | main.ONOS5cli.set_cell(cell_name) |
| 1002 | main.ONOS6cli.set_cell(cell_name) |
| 1003 | main.ONOS7cli.set_cell(cell_name) |
| 1004 | main.log.info("Packaging new ONOS") |
| 1005 | main.ONOSbench.onos_package() |
| 1006 | main.log.info("Installing ONOS") |
| 1007 | main.ONOSbench.onos_install(node=ONOS1_ip) |
| 1008 | main.ONOSbench.onos_install(node=ONOS2_ip) |
| 1009 | main.ONOSbench.onos_install(node=ONOS3_ip) |
| 1010 | main.ONOSbench.onos_install(node=ONOS4_ip) |
| 1011 | main.ONOSbench.onos_install(node=ONOS5_ip) |
| 1012 | main.ONOSbench.onos_install(node=ONOS6_ip) |
| 1013 | main.ONOSbench.onos_install(node=ONOS7_ip) |
| 1014 | main.log.info("Starting CLI") |
| 1015 | main.ONOS1cli.start_onos_cli(ONOS1_ip) |
| 1016 | main.ONOS2cli.start_onos_cli(ONOS2_ip) |
| 1017 | main.ONOS3cli.start_onos_cli(ONOS3_ip) |
| 1018 | main.ONOS4cli.start_onos_cli(ONOS4_ip) |
| 1019 | main.ONOS5cli.start_onos_cli(ONOS5_ip) |
| 1020 | main.ONOS6cli.start_onos_cli(ONOS6_ip) |
| 1021 | main.ONOS7cli.start_onos_cli(ONOS7_ip) |
| 1022 | main.log.info("Installing metrics feature") |
| 1023 | main.ONOS1cli.feature_install("onos-app-metrics") |
| 1024 | main.ONOS2cli.feature_install("onos-app-metrics") |
| 1025 | main.ONOS3cli.feature_install("onos-app-metrics") |
| 1026 | main.ONOS4cli.feature_install("onos-app-metrics") |
| 1027 | main.ONOS5cli.feature_install("onos-app-metrics") |
| 1028 | main.ONOS6cli.feature_install("onos-app-metrics") |
| 1029 | main.ONOS7cli.feature_install("onos-app-metrics") |
| 1030 | |
| 1031 | install_result = main.TRUE |
| 1032 | |
| 1033 | time.sleep(5) |
andrewonlab | add2fd6 | 2014-11-11 18:37:35 -0500 | [diff] [blame] | 1034 | |
andrewonlab | 0cfc7ad | 2014-11-13 16:29:26 -0500 | [diff] [blame] | 1035 | if install_result == main.TRUE: |
| 1036 | assertion = main.TRUE |
| 1037 | else: |
| 1038 | assertion = main.FALSE |
| 1039 | |
| 1040 | utilities.assert_equals(expect=main.TRUE, actual=assertion, |
| 1041 | onpass="Scale out to "+str(cluster_count)+\ |
| 1042 | " nodes successful", |
| 1043 | onfail="Scale out to "+str(cluster_count)+\ |
| 1044 | " nodes failed") |