blob: f13e60d2b93c42386204e7e057fe555b42fa5b73 [file] [log] [blame]
Cameron Franke2ea90e52015-01-21 10:04:16 -08001# ScaleOutTemplate --> IntentsLoad
2#
3# CASE1 starts number of nodes specified in param file
4#
5# cameron@onlab.us
6
7import sys
8import os
9
10
11class IntentsLoad:
12 def __init__(self):
13 self.default = ''
14
15 def CASE1(self, main):
16
17 global cluster_count
18 cluster_count = 1
19
20 checkout_branch = main.params['GIT']['checkout']
21 git_pull = main.params['GIT']['autopull']
22 cell_name = main.params['ENV']['cellName']
23 BENCH_ip = main.params['BENCH']['ip1']
24 BENCH_user = main.params['BENCH']['user']
25 ONOS1_ip = main.params['CTRL']['ip1']
26 ONOS2_ip = main.params['CTRL']['ip2']
27 ONOS3_ip = main.params['CTRL']['ip3']
28 MN1_ip = main.params['MN']['ip1']
29
30 main.log.step("Cleaning Enviornment...")
31 main.ONOSbench.onos_uninstall(ONOS1_ip)
32 main.ONOSbench.onos_uninstall(ONOS2_ip)
33 main.ONOSbench.onos_uninstall(ONOS3_ip)
34
35 main.step("Git checkout and pull "+checkout_branch)
36 if git_pull == 'on':
37 checkout_result = main.ONOSbench.git_checkout(checkout_branch)
38 pull_result = main.ONOSbench.git_pull()
39
40 else:
41 checkout_result = main.TRUE
42 pull_result = main.TRUE
43 main.log.info("Skipped git checkout and pull")
44
45 #mvn_result = main.ONOSbench.clean_install()
46
47 main.step("Set cell for ONOS cli env")
48 main.ONOS1cli.set_cell(cell_name)
49 main.ONOS2cli.set_cell(cell_name)
50 main.ONOS3cli.set_cell(cell_name)
51
52 main.step("Creating ONOS package")
53 package_result = main.ONOSbench.onos_package() #no file or directory
54
55 main.step("Installing ONOS package")
56 install1_result = main.ONOSbench.onos_install(node=ONOS1_ip)
57
58 cell_name = main.params['ENV']['cellName']
59 main.step("Applying cell file to environment")
60 cell_apply_result = main.ONOSbench.set_cell(cell_name)
61 main.step("verify cells")
62 verify_cell_result = main.ONOSbench.verify_cell()
63
64 main.step("Set cell for ONOS cli env")
65 main.ONOS1cli.set_cell(cell_name)
66
67 cli1 = main.ONOS1cli.start_onos_cli(ONOS1_ip)
68
69 def CASE2(self, main):
70
71 '''
72 Increase number of nodes and initiate CLI
73 '''
74 import time
75
76 global cluster_count
77
78 ONOS1_ip = main.params['CTRL']['ip1']
79 ONOS2_ip = main.params['CTRL']['ip2']
80 ONOS3_ip = main.params['CTRL']['ip3']
81 #ONOS4_ip = main.params['CTRL']['ip4']
82 #ONOS5_ip = main.params['CTRL']['ip5']
83 #ONOS6_ip = main.params['CTRL']['ip6']
84 #ONOS7_ip = main.params['CTRL']['ip7']
85 cell_name = main.params['ENV']['cellName']
86 scale = int(main.params['SCALE'])
87
88
89 #Cluster size increased everytime the case is defined
90 cluster_count += scale
91
92 main.log.report("Increasing cluster size to "+
93 str(cluster_count))
94 install_result = main.FALSE
95
96 if scale == 2:
97 if cluster_count == 3:
98 main.log.info("Installing nodes 2 and 3")
99 install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
100 install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
101 cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
102 cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
103 '''
104 elif cluster_count == 5:
105
106 main.log.info("Installing nodes 4 and 5")
107 node4_result = main.ONOSbench.onos_install(node=ONOS4_ip)
108 node5_result = main.ONOSbench.onos_install(node=ONOS5_ip)
109 install_result = node4_result and node5_result
110 time.sleep(5)
111
112 main.ONOS4cli.start_onos_cli(ONOS4_ip)
113 main.ONOS5cli.start_onos_cli(ONOS5_ip)
114
115 elif cluster_count == 7:
116
117 main.log.info("Installing nodes 4 and 5")
118 node6_result = main.ONOSbench.onos_install(node=ONOS6_ip)
119 node7_result = main.ONOSbench.onos_install(node=ONOS7_ip)
120 install_result = node6_result and node7_result
121 time.sleep(5)
122
123 main.ONOS6cli.start_onos_cli(ONOS6_ip)
124 main.ONOS7cli.start_onos_cli(ONOS7_ip)
125 '''
126 if scale == 1:
127 if cluster_count == 2:
128 main.log.info("Installing node 2")
129 install2_result = main.ONOSbench.onos_install(node=ONOS2_ip)
130 cli2 = main.ONOS2cli.start_onos_cli(ONOS2_ip)
131
132 if cluster_count == 3:
133 main.log.info("Installing node 3")
134 install3_result = main.ONOSbench.onos_install(node=ONOS3_ip)
135 cli3 = main.ONOS3cli.start_onos_cli(ONOS3_ip)
136
137
138
139 def CASE3(self,main):
140 import time
141 import json
142 import string
143
144 intents_rate = main.params['JSON']['intents_rate']
145
146 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
147
148 main.Mininet1.assign_sw_controller(sw="1", ip1=ONOS1_ip, port1=default_sw_port )
149 main.Mininet1.assign_sw_controller(sw="2", ip1=ONOS1_ip, port1=default_sw_port )
150 main.Mininet1.assign_sw_controller(sw="3", ip1=ONOS1_ip, port1=default_sw_port )
151 main.Mininet1.assign_sw_controller(sw="4", ip1=ONOS1_ip, port1=default_sw_port )
152 main.Mininet1.assign_sw_controller(sw="5", ip1=ONOS1_ip, port1=default_sw_port )
153 main.Mininet1.assign_sw_controller(sw="6", ip1=ONOS1_ip, port1=default_sw_port )
154 main.Mininet1.assign_sw_controller(sw="7", ip1=ONOS1_ip, port1=default_sw_port )
155
156 mn_arp = main.params['TEST']['arping']
157 main.Mininet1.handle.sendline(mn_arp)
158
159 generate_load = main.params['TEST']['loadstart']
160
161 main.ONOS1.handle.sendline(generate_load)
162 main.ONOS1.handle.expect("sdn")
163 print("before: ", main.ONOS1.handle.before)
164 print("after: ",main.ONOS1.handle.after)
165
166 load_confirm = main.ONOS1.handle.after
167 if load_confirm == "{}":
168 main.log.info("Load started")
169
170 else:
171 main.log.error("Load start failure")
172 main.log.error("expected '{}', got: " + str(load_confirm))
173
174 devices_json_str = main.ONOS1cli.devices()
175 devices_json_obj = json.loads(devices_json_str)
176
177 get_metric = main.params['TEST']['metric1']
178 test_duration = main.params['TEST']['duration']
179 stop = time.time() + float(test_duration)
180
181
182 main.log.info("Starting test loop...")
183 log_interval = main.params['TEST']['log_interval']
184
185 while time.time() < stop:
186 time.sleep(float(log_interval))
187
188 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
189 intents_json_obj_1 = json.loads(intents_json_str_1)
190 main.log.info("Node 1 rate: " + str(intents_json_obj_1[intents_rate]['m1_rate']))
191 last_rate_1 = intents_json_obj_1[intents_rate]['m1_rate']
192
193 stop_load = main.params['TEST']['loadstop']
194 main.ONOS1.handle.sendline(stop_load)
195
196
197 msg = ("Final rate on node 1: " + str(last_rate_1))
198 main.log.report(msg)
199
200 def CASE4(self, main): #2 node scale
201 import time
202 import json
203 import string
204
205 intents_rate = main.params['JSON']['intents_rate']
206
207 default_sw_port = main.params[ 'CTRL' ][ 'port1' ]
208
209 main.Mininet1.assign_sw_controller(sw="1", ip1=ONOS1_ip, port1=default_sw_port )
210 main.Mininet1.assign_sw_controller(sw="2", ip1=ONOS2_ip, port1=default_sw_port )
211 main.Mininet1.assign_sw_controller(sw="3", ip1=ONOS1_ip, port1=default_sw_port )
212 main.Mininet1.assign_sw_controller(sw="4", ip1=ONOS2_ip, port1=default_sw_port )
213 main.Mininet1.assign_sw_controller(sw="5", ip1=ONOS1_ip, port1=default_sw_port )
214 main.Mininet1.assign_sw_controller(sw="6", ip1=ONOS2_ip, port1=default_sw_port )
215 main.Mininet1.assign_sw_controller(sw="7", ip1=ONOS1_ip, port1=default_sw_port )
216
217 mn_arp = main.params['TEST']['arping']
218 main.Mininet1.handle.sendline(mn_arp)
219
220 generate_load = main.params['TEST']['loadstart']
221
222 main.ONOS1.handle.sendline(generate_load)
223 main.ONOS2.handle.sendline(generate_load)
224
225 devices_json_str_1 = main.ONOS1cli.devices()
226 devices_json_obj_1 = json.loads(devices_json_str_1)
227 devices_json_str_2 = main.ONOS2cli.devices()
228 devices_json_obj_2 = json.loads(devices_json_str_2)
229
230 get_metric = main.params['TEST']['metric1']
231 test_duration = main.params['TEST']['duration']
232 stop = time.time() + float(test_duration)
233
234
235 main.log.info("Starting test loop...")
236 log_interval = main.params['TEST']['log_interval']
237
238 while time.time() < stop:
239 time.sleep(float(log_interval))
240
241 intents_json_str_1 = main.ONOS1cli.intents_events_metrics()
242 intents_json_obj_1 = json.loads(intents_json_str_1)
243 main.log.info("Node 1 rate: " + str(intents_json_obj_1[intents_rate]['m1_rate']))
244 last_rate_1 = intents_json_obj_1[intents_rate]['m1_rate']
245
246 intents_json_str_2 = main.ONOS2cli.intents_events_metrics()
247 intents_json_obj_2 = json.loads(intents_json_str_2)
248 main.log.info("Node 2 rate: " + str(intents_json_obj_2[intents_rate]['m1_rate']))
249 last_rate_2 = intents_json_obj_2[intents_rate]['m1_rate']
250
251 stop_load = main.params['TEST']['loadstop']
252 main.ONOS1.handle.sendline(stop_load)
253 main.ONOS2.handle.sendline(stop_load)
254
255
256 msg = ("Final rate on node 1: " + str(last_rate_1))
257 main.log.report(msg)
258
259 msg = ("Final rate on node 2: " + str(last_rate_2))
260 main.log.report(msg)
261
262
263