blob: 2fe521b1dedb3af21b07dd31b4f0cf66500ad5e7 [file] [log] [blame]
andrewonlab2a6c9342014-10-16 13:40:15 -04001#TopoPerfNext
2#
3#Topology Performance test for ONOS-next
4#
5#andrew@onlab.us
6
7import time
8import sys
9import os
10import re
11
12class TopoPerfNext:
13 def __init__(self):
14 self.default = ''
15
16 def CASE1(self, main):
17 '''
18 ONOS startup sequence
19 '''
20 cell_name = main.params['ENV']['cellName']
21
22 git_pull = main.params['GIT']['autoPull']
23 checkout_branch = main.params['GIT']['checkout']
24
25 ONOS1_ip = main.params['CTRL']['ip1']
andrewonlabba44bcf2014-10-16 16:54:41 -040026 ONOS2_ip = main.params['CTRL']['ip2']
27 ONOS3_ip = main.params['CTRL']['ip3']
andrewonlab2a6c9342014-10-16 13:40:15 -040028 MN1_ip = main.params['MN']['ip1']
29 BENCH_ip = main.params['BENCH']['ip']
30
31 main.case("Setting up test environment")
32
33 main.step("Creating cell file")
34 cell_file_result = main.ONOSbench.create_cell_file(
andrewonlabe6745342014-10-17 14:29:13 -040035 BENCH_ip, cell_name, MN1_ip, "onos-core",
andrewonlabba44bcf2014-10-16 16:54:41 -040036 ONOS1_ip, ONOS2_ip, ONOS3_ip)
andrewonlab2a6c9342014-10-16 13:40:15 -040037
38 main.step("Applying cell file to environment")
39 cell_apply_result = main.ONOSbench.set_cell(cell_name)
40 verify_cell_result = main.ONOSbench.verify_cell()
41
42 main.step("Git checkout and pull "+checkout_branch)
43 if git_pull == 'on':
44 checkout_result = \
45 main.ONOSbench.git_checkout(checkout_branch)
46 pull_result = main.ONOSbench.git_pull()
47 else:
48 checkout_result = main.TRUE
49 pull_result = main.TRUE
50 main.log.info("Skipped git checkout and pull")
51
52 main.step("Using mvn clean & install")
andrewonlabba44bcf2014-10-16 16:54:41 -040053 mvn_result = main.ONOSbench.clean_install()
andrewonlab2a6c9342014-10-16 13:40:15 -040054
55 main.step("Creating ONOS package")
56 package_result = main.ONOSbench.onos_package()
57
58 main.step("Installing ONOS package")
59 install_result = main.ONOSbench.onos_install()
60
61 main.step("Starting ONOS service")
62 start_result = main.ONOSbench.onos_start(ONOS1_ip)
63
64 utilities.assert_equals(expect=main.TRUE,
65 actual= cell_file_result and cell_apply_result and\
66 verify_cell_result and checkout_result and\
67 pull_result and mvn_result and\
68 install_result and start_result,
69 onpass="Cell file created successfully",
70 onfail="Failed to create cell file")
71
andrewonlabba44bcf2014-10-16 16:54:41 -040072 def CASE2(self, main):
73 '''
74 Assign s1 to ONOS1 and measure latency
75 '''
76 import time
andrewonlabe6745342014-10-17 14:29:13 -040077 import subprocess
78 import json
79 import requests
80 import os
andrewonlabba44bcf2014-10-16 16:54:41 -040081
82 ONOS1_ip = main.params['CTRL']['ip1']
83 ONOS2_ip = main.params['CTRL']['ip2']
84 ONOS3_ip = main.params['CTRL']['ip3']
andrewonlabe6745342014-10-17 14:29:13 -040085 ONOS_user = main.params['CTRL']['user']
86
andrewonlabba44bcf2014-10-16 16:54:41 -040087 default_sw_port = main.params['CTRL']['port1']
88
89 #Number of iterations of case
90 num_iter = main.params['TEST']['numIter']
91
92 #Directory/file to store tshark results
93 tshark_of_output = "/tmp/tshark_of_topo.txt"
94 tshark_tcp_output = "/tmp/tshark_tcp_topo.txt"
95
96 #String to grep in tshark output
97 tshark_tcp_string = "TCP 74 "+default_sw_port
98 tshark_of_string = "OFP 86 Vendor"
andrewonlabe6745342014-10-17 14:29:13 -040099
100 #Initialize assertion to TRUE
101 assertion = main.TRUE
102
andrewonlabba44bcf2014-10-16 16:54:41 -0400103 main.log.report("Latency of adding one switch")
104
105 for i in range(0, int(num_iter)):
106 main.log.info("Starting tshark capture")
107
108 #* TCP [ACK, SYN] is used as t0_a, the
109 # very first "exchange" between ONOS and
110 # the switch for end-to-end measurement
111 #* OFP [Stats Reply] is used for t0_b
112 # the very last OFP message between ONOS
113 # and the switch for ONOS measurement
114 main.ONOS1.tshark_grep(tshark_tcp_string,
115 tshark_tcp_output)
116 main.ONOS1.tshark_grep(tshark_of_string,
117 tshark_of_output)
118
119 #Wait and ensure tshark is started and
120 #capturing
121 time.sleep(10)
122
123 main.log.info("Assigning s1 to controller")
124
125 main.Mininet1.assign_sw_controller(sw="1",
126 ip1=ONOS1_ip, port1=default_sw_port)
127
128 #Wait and ensure switch is assigned
129 #before stopping tshark
130 time.sleep(10)
131
132 main.ONOS1.stop_tshark()
133
andrewonlabe6745342014-10-17 14:29:13 -0400134 #tshark output is saved in ONOS. Use subprocess
135 #to copy over files to TestON for parsing
136 main.log.info("Copying over tshark files")
137
138 #TCP CAPTURE ****
139 ssh_tcp_file = subprocess.Popen(['ssh',
140 ONOS_user+"@"+ONOS1_ip, 'cat',
141 tshark_tcp_output], stdout=subprocess.PIPE)
142 temp_text = ssh_tcp_file.stdout.readline()
143 temp_text = temp_text.split(" ")
andrewonlabba44bcf2014-10-16 16:54:41 -0400144
andrewonlabe6745342014-10-17 14:29:13 -0400145 main.log.info("Object read in from TCP capture: "+
146 str(temp_text))
147 if len(temp_text) > 0:
148 t0_tcp = int(float(temp_text[1])*1000)
149 else:
150 main.log.error("Tshark output file for TCP"+
151 " returned unexpected results")
152 t0_tcp = 0
153 assertion = main.FALSE
154 #****************
andrewonlabba44bcf2014-10-16 16:54:41 -0400155
andrewonlabe6745342014-10-17 14:29:13 -0400156 #OF CAPTURE ****
157 ssh_of_file = subprocess.Popen(['ssh',
158 ONOS_user+"@"+ONOS1_ip, 'cat',
159 tshark_of_output], stdout=subprocess.PIPE)
andrewonlabba44bcf2014-10-16 16:54:41 -0400160
andrewonlabe6745342014-10-17 14:29:13 -0400161 while True:
162 temp_text = ssh_of_file.stdout.readline()
163 if line !='':
164 line_ofp = temp_text
165 else:
166 break
167 obj = line_ofp.split(" ")
168
169 main.log.info("Object read in from OFP capture: "+
170 str(line_ofp))
171
172 if len(line_ofp) > 0:
173 t0_ofp = int(float(obj[1])*1000)
174 else:
175 main.log.error("Tshark output file for OFP"+
176 " returned unexpected results")
177 t0_ofp = 0
178 assertion = main.FALSE
179 #****************
180
181 #TODO:
182 #Get json object from all 3 ONOS instances
183
184 #TODO:
185 #Parse json object for timestamp
186 topo_timestamp_1 = 0
187 topo_timestamp_2 = 0
188 topo_timestamp_3 = 0
andrewonlabba44bcf2014-10-16 16:54:41 -0400189
andrewonlabe6745342014-10-17 14:29:13 -0400190 #ONOS processing latency
191 delta_of_1 = int(topo_timestamp_1) - int(t0_ofp)
192 delta_of_2 = int(topo_timestamp_2) - int(t0_ofp)
193 delta_of_3 = int(topo_timestamp_3) - int(t0_ofp)
194
195 #End-to-end processing latency
196 delta_tcp_1 = int(topo_timestamp_1) - int(t0_tcp)
197 delta_tcp_2 = int(topo_timestamp_2) - int(t0_tcp)
198 delta_tcp_3 = int(topo_timestamp_3) - int(t0_tcp)
andrewonlabba44bcf2014-10-16 16:54:41 -0400199
andrewonlabe6745342014-10-17 14:29:13 -0400200 #TODO:
201 #Fetch logs upon threshold excess
andrewonlabba44bcf2014-10-16 16:54:41 -0400202
andrewonlabe6745342014-10-17 14:29:13 -0400203 main.log.info("ONOS1 delta OFP: "+str(delta_of_1))
204 main.log.info("ONOS2 delta OFP: "+str(delta_of_2))
205 main.log.info("ONOS3 delta OFP: "+str(delta_of_3))
andrewonlabba44bcf2014-10-16 16:54:41 -0400206
andrewonlabe6745342014-10-17 14:29:13 -0400207 main.log.info("ONOS1 delta TCP: "+str(delta_tcp_1))
208 main.log.info("ONOS2 delta TCP: "+str(delta_tcp_2))
209 main.log.info("ONOS3 delta TCP: "+str(delta_tcp_3))
210
andrewonlabba44bcf2014-10-16 16:54:41 -0400211
212
213
andrewonlab2a6c9342014-10-16 13:40:15 -0400214