blob: f6a1ee0676f85ca6f94e1f765c69fc9e143df7b6 [file] [log] [blame]
Chetan Gaonker357f4892017-06-19 19:38:27 +00001#copyright 2016-present Ciena Corporation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15import time
16import os
17import sys
18import json
19import requests
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +000020import random
Chetan Gaonker357f4892017-06-19 19:38:27 +000021from nose.tools import *
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +000022from scapy.all import *
Chetan Gaonker357f4892017-06-19 19:38:27 +000023from twisted.internet import defer
24from nose.twistedtools import reactor, deferred
25from CordTestUtils import *
26from OltConfig import OltConfig
27from onosclidriver import OnosCliDriver
28from SSHTestAgent import SSHTestAgent
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +000029from Channels import IgmpChannel
30from IGMP import *
Chetan Gaonker357f4892017-06-19 19:38:27 +000031from CordLogger import CordLogger
32from VSGAccess import VSGAccess
33from CordTestUtils import log_test as log
A R Karthick9dc6e922017-07-12 14:40:16 -070034from CordTestConfig import setup_module, running_on_ciab, teardown_module
Chetan Gaonker357f4892017-06-19 19:38:27 +000035from OnosCtrl import OnosCtrl
36from CordContainer import Onos
A R Karthicked3a2ca2017-07-06 15:50:03 -070037from CordSubscriberUtils import CordSubscriberUtils, XosUtils
A R Karthick037cb982017-07-07 17:35:30 -070038from vsgTest import vsg_exchange
Chetan Gaonker357f4892017-06-19 19:38:27 +000039log.setLevel('INFO')
40
41class scale_exchange(CordLogger):
42 HOST = "10.1.0.1"
43 USER = "vagrant"
44 PASS = "vagrant"
45 head_node = os.getenv('HEAD_NODE', 'prod')
46 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
47 test_path = os.path.dirname(os.path.realpath(__file__))
48 olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config.json'))
A R Karthicked3a2ca2017-07-06 15:50:03 -070049 SUBSCRIBER_ACCOUNT_NUM = 100
50 SUBSCRIBER_S_TAG = 500
51 SUBSCRIBER_C_TAG = 500
52 SUBSCRIBERS_PER_S_TAG = 8
Chetan Gaonker357f4892017-06-19 19:38:27 +000053 restore_methods = []
54 TIMEOUT=120
55 NUM_SUBSCRIBERS = 100
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +000056 wan_intf_ip = '10.6.1.129'
57 V_INF1 = 'veth0'
58 V_INF2 = 'veth1'
59 MGROUP1 = '239.1.2.3'
60 MGROUP2 = '239.2.2.3'
61 MINVALIDGROUP1 = '255.255.255.255'
62 MINVALIDGROUP2 = '239.255.255.255'
63 MMACGROUP1 = "01:00:5e:01:02:03"
64 MMACGROUP2 = "01:00:5e:02:02:03"
65 IGMP_DST_MAC = "01:00:5e:00:00:16"
66 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
67 IP_SRC = '1.2.3.4'
68 IP_DST = '224.0.0.22'
69 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
70 igmp_ip = IP(dst = IP_DST)
71 PORT_TX_DEFAULT = 2
72 PORT_RX_DEFAULT = 1
73 igmp_app = 'org.opencord.igmp'
Anil Kumar Sanka8942c882017-07-07 17:05:11 +000074 acl_app = 'org.onosproject.acl'
75 aaa_app = 'org.opencord.aaa'
76 app = 'org.onosproject.cli'
77 INTF_TX_DEFAULT = 'veth2'
78 INTF_RX_DEFAULT = 'veth0'
79 default_port_map = {
80 PORT_TX_DEFAULT : INTF_TX_DEFAULT,
81 PORT_RX_DEFAULT : INTF_RX_DEFAULT,
82 INTF_TX_DEFAULT : PORT_TX_DEFAULT,
83 INTF_RX_DEFAULT : PORT_RX_DEFAULT
84 }
85 vrouter_apps = ('org.onosproject.proxyarp', 'org.onosproject.hostprovider', 'org.onosproject.vrouter', 'org.onosproject.fwd')
86 CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE-----
87MIIEyTCCA7GgAwIBAgIJAN3OagiHm6AXMA0GCSqGSIb3DQEBCwUAMIGLMQswCQYD
88VQQGEwJVUzELMAkGA1UECAwCQ0ExEjAQBgNVBAcMCVNvbWV3aGVyZTETMBEGA1UE
89CgwKQ2llbmEgSW5jLjEeMBwGCSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYw
90JAYDVQQDDB1FeGFtcGxlIENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNzAzMTEw
91MDQ3NDNaFw0yMjEwMzEwMDQ3NDNaMIGLMQswCQYDVQQGEwJVUzELMAkGA1UECAwC
92Q0ExEjAQBgNVBAcMCVNvbWV3aGVyZTETMBEGA1UECgwKQ2llbmEgSW5jLjEeMBwG
93CSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYwJAYDVQQDDB1FeGFtcGxlIENl
94cnRpZmljYXRlIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
95ggEBALYkVvncfeRel/apXy5iODla5H7sUpU7a+pwT7nephmjKDh0GPX/t5GUwgkB
961zQAEj0IPoxZIfSAGSFP/mqTUK2sm7qerArih0E3kBRpnBKJZB/4r1OTZ04CsuRQ
97QJOqcI0mZJWUKEcahN4yZvRyxeiCeFFoc0Nw787MQHhD9lZTqJUoAvautUe1GCjG
9846DS4MzpWNGkqn5/ZC8lQ198AceMwf2pJRuOQg5cPwp65+dKNLUMLiSUV7JpvmAo
99of4MHtGaBxKHESZ2jPiNTT2uKI/7KxH3Pr/ctft3bcSX2d4q49B2tdEIRzC0ankm
100CrxFcq9Cb3MGaNuwWAtk3fOGKusCAwEAAaOCASwwggEoMB0GA1UdDgQWBBRtf8rH
101zJW7rliW1eZnbVbSb3obfDCBwAYDVR0jBIG4MIG1gBRtf8rHzJW7rliW1eZnbVbS
102b3obfKGBkaSBjjCBizELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRIwEAYDVQQH
103DAlTb21ld2hlcmUxEzARBgNVBAoMCkNpZW5hIEluYy4xHjAcBgkqhkiG9w0BCQEW
104D2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAwwdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBB
105dXRob3JpdHmCCQDdzmoIh5ugFzAMBgNVHRMEBTADAQH/MDYGA1UdHwQvMC0wK6Ap
106oCeGJWh0dHA6Ly93d3cuZXhhbXBsZS5jb20vZXhhbXBsZV9jYS5jcmwwDQYJKoZI
107hvcNAQELBQADggEBAKWjORcBc1WK3r8mq88ipUC2UR1qvxdON4K/hd+rdAj0E/xA
108QCJDORKno8f2MktqLfhU0amCVBvwdfmVFmVDtl38b1pu+mNFO+FDp04039Fd5ThM
109iYmiQjnJ2IcAi/CILtrjURvJUPSOX9lviOtcla0HW94dgA9IDRs5frrWO9jkcxXR
110+oz3LNMfVnXqhoHHQ1RtvqOozhEsUZZWY5MuUxRY25peeZ7m1vz+zDa/DbrV1wsP
111dxOocmYdGFIAT9AiRnR4Jc/hqabBVNMZlGAA+2dELajpaHqb4yx5gBLVkT7VgHjI
1127cp7jLRL7T+i4orZiAXpeEpAeOrP8r0DYTJi/8A=
113-----END CERTIFICATE-----'''
114
Chetan Gaonker357f4892017-06-19 19:38:27 +0000115 @classmethod
116 def setUpClass(cls):
A R Karthick037cb982017-07-07 17:35:30 -0700117 num_subscribers = max(cls.NUM_SUBSCRIBERS, 10)
118 vsg_exchange.vsgSetup(num_subscribers = num_subscribers,
119 account_num = cls.SUBSCRIBER_ACCOUNT_NUM,
120 s_tag = cls.SUBSCRIBER_S_TAG,
121 c_tag = cls.SUBSCRIBER_C_TAG,
122 subscribers_per_s_tag = cls.SUBSCRIBERS_PER_S_TAG)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000123
124 @classmethod
125 def tearDownClass(cls):
A R Karthick037cb982017-07-07 17:35:30 -0700126 vsg_exchange.vsgTeardown()
Chetan Gaonker357f4892017-06-19 19:38:27 +0000127
128 def log_set(self, level = None, app = 'org.onosproject'):
129 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
130
131 @classmethod
132 def config_restore(cls):
133 """Restore the vsg test configuration on test case failures"""
134 for restore_method in cls.restore_methods:
135 restore_method()
136
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000137 def get_system_cpu_usage(self):
138 """ Getting compute node CPU usage """
139 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
140 cmd = "top -b -n1 | grep 'Cpu(s)' | awk '{print $2 + $4}'"
141 status, output = ssh_agent.run_cmd(cmd)
142 assert_equal(status, True)
143 return float(output)
144
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000145 def onos_load_config(self, config):
146 #log_test.info('onos load config is %s'%config)
147 status, code = OnosCtrl.config(config)
148 if status is False:
149 log_test.info('JSON request returned status %d' %code)
150 assert_equal(status, True)
151 time.sleep(2)
152
153 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
154 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
155 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
156 if flag: #to maintain seperate group-source pair.
157 for i in range(len(groups)):
158 d = {}
159 d['source'] = src_list[i] or '0.0.0.0'
160 d['group'] = groups[i]
161 ssm_xlate_list.append(d)
162 else:
163 for g in groups:
164 for s in src_list:
165 d = {}
166 d['source'] = s or '0.0.0.0'
167 d['group'] = g
168 ssm_xlate_list.append(d)
169 self.onos_load_config(ssm_dict)
170 cord_port_map = {}
171 for g in groups:
172 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
173 IgmpChannel().cord_port_table_load(cord_port_map)
174 time.sleep(2)
175
176 def generate_random_multicast_ip_addresses(self,count=500):
177 multicast_ips = []
178 while(count >= 1):
179 ip = '.'.join([str(random.randint(224,239)),str(random.randint(1,254)),str(random.randint(1,254)),str(random.randint(1,254))])
180 if ip in multicast_ips:
181 pass
182 else:
183 multicast_ips.append(ip)
184 count -= 1
185 return multicast_ips
186
187 def generate_random_unicast_ip_addresses(self,count=500):
188 unicast_ips = []
189 while(count >= 1):
190 ip = '.'.join([str(random.randint(11,126)),str(random.randint(1,254)),str(random.randint(1,254)),str(random.randint(1,254))])
191 if ip in unicast_ips:
192 pass
193 else:
194 unicast_ips.append(ip)
195 count -= 1
196 return unicast_ips
197
198 def iptomac(self, mcast_ip):
199 mcast_mac = '01:00:5e:'
200 octets = mcast_ip.split('.')
201 second_oct = int(octets[1]) & 127
202 third_oct = int(octets[2])
203 fourth_oct = int(octets[3])
204 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
205 return mcast_mac
206
207 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
208 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1):
209 if ssm_load is True:
210 self.onos_ssm_table_load(groups, src_list)
211 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
212 gaddr=self.IP_DST)
213 for g in groups:
214 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
215 gr.sources = src_list
216 igmp.grps.append(gr)
217 if ip_pkt is None:
218 ip_pkt = self.igmp_eth/self.igmp_ip
219 pkt = ip_pkt/igmp
220 IGMPv3.fixup(pkt)
221 log.info('sending igmp join packet %s'%pkt.show())
222 sendp(pkt, iface=iface)
223 time.sleep(delay)
224
225 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
226 dst_mac = self.iptomac(group)
227 eth = Ether(dst= dst_mac)
228 ip = IP(dst=group,src=source)
229 data = repr(monotonic.monotonic())
230 sendp(eth/ip/data,count=20, iface = intf)
231
232 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
233 log_test.info('verifying multicast traffic for group %s from source %s'%(group,source))
234 self.success = False
235 def recv_task():
236 def igmp_recv_cb(pkt):
237 #log_test.info('received multicast data packet is %s'%pkt.show())
238 log_test.info('multicast data received for group %s from source %s'%(group,source))
239 self.success = True
240 sniff(prn = igmp_recv_cb,lfilter = lambda p: IP in p and p[IP].dst == group and p[IP].src == source, count=1,timeout = 2, iface='veth0')
241 t = threading.Thread(target = recv_task)
242 t.start()
243 self.send_multicast_data_traffic(group,source=source)
244 t.join()
245 return self.success
246
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000247 def incmac(self, mac):
248 tmp = str(hex(int('0x'+mac,16)+1).split('x')[1])
249 mac = '0'+ tmp if len(tmp) < 2 else tmp
250 return mac
251
252 def next_mac(self, mac):
253 mac = mac.split(":")
254 mac[5] = self.incmac(mac[5])
255
256 if len(mac[5]) > 2:
257 mac[0] = self.incmac(mac[0])
258 mac[5] = '01'
259
260 if len(mac[0]) > 2:
261 mac[0] = '01'
262 mac[1] = self.incmac(mac[1])
263 mac[5] = '01'
264 return ':'.join(mac)
265
266
267 def to_egress_mac(cls, mac):
268 mac = mac.split(":")
269 mac[4] = '01'
270
271 return ':'.join(mac)
272
273 def inc_ip(self, ip, i):
274
275 ip[i] =str(int(ip[i])+1)
276 return '.'.join(ip)
277
278
279 def next_ip(self, ip):
280
281 lst = ip.split('.')
282 for i in (3,0,-1):
283 if int(lst[i]) < 255:
284 return self.inc_ip(lst, i)
285 elif int(lst[i]) == 255:
286 lst[i] = '0'
287 if int(lst[i-1]) < 255:
288 return self.inc_ip(lst,i-1)
289 elif int(lst[i-2]) < 255:
290 lst[i-1] = '0'
291 return self.inc_ip(lst,i-2)
292 else:
293 break
294
295 def to_egress_ip(self, ip):
296 lst=ip.split('.')
297 lst[0] = '182'
298 return '.'.join(lst)
299
300 @classmethod
301 def start_onos(cls, network_cfg = None):
302 if type(network_cfg) is tuple:
303 res = []
304 for v in network_cfg:
305 res += v.items()
306 config = dict(res)
307 else:
308 config = network_cfg
309 log_test.info('Restarting ONOS with new network configuration')
310 return cord_test_onos_restart(config = config)
311
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000312 def onos_aaa_config(self):
313 aaa_dict = {'apps' : { self.app : { 'AAA' : { 'radiusSecret': 'radius_password',
314 'radiusIp': '172.17.0.2' } } } }
315 radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
316 aaa_dict['apps'][self.app]['AAA']['radiusIp'] = radius_ip
317 self.onos_ctrl.activate()
318 time.sleep(2)
319 self.onos_load_config(aaa_dict)
320
321 def onos_load_config(self, config):
322 status, code = OnosCtrl.config(config)
323 if status is False:
324 log_test.info('Configure request for AAA returned status %d' %code)
325 assert_equal(status, True)
326 time.sleep(3)
327
Chetan Gaonker357f4892017-06-19 19:38:27 +0000328 def test_scale_for_vsg_vm_creations(self):
A R Karthick037cb982017-07-07 17:35:30 -0700329 vsg = vsg_exchange('test_vsg_xos_subscriber_create_all')
330 vsg.test_vsg_xos_subscriber_create_all()
Chetan Gaonker357f4892017-06-19 19:38:27 +0000331
332 def test_scale_for_vcpe_creations(self):
A R Karthick037cb982017-07-07 17:35:30 -0700333 vsg = vsg_exchange('test_vsg_xos_subscriber_create_all')
334 vsg.test_vsg_xos_subscriber_create_all()
Chetan Gaonker357f4892017-06-19 19:38:27 +0000335
336 def test_scale_of_subcriber_vcpe_creations_in_single_vsg_vm(self):
A R Karthick037cb982017-07-07 17:35:30 -0700337 #create 100 subscribers and delete them after creation
338 vsg = vsg_exchange('vsg_create')
339 try:
340 vsg.vsg_create(100)
341 finally:
342 vsg.vsg_delete(100)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000343
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000344 def test_scale_of_subcriber_vcpe_creations_in_multiple_vsg_vm(self):
A R Karthick037cb982017-07-07 17:35:30 -0700345 #create 100 subscribers and delete them after creation
346 vsg = vsg_exchange('vsg_create')
347 try:
348 vsg.vsg_create(100)
349 finally:
350 vsg.vsg_delete(100)
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000351
352 def test_scale_of_subcriber_vcpe_creations_with_one_vcpe_in_one_vsg_vm(self):
A R Karthick037cb982017-07-07 17:35:30 -0700353 #create 100 subscribers and delete them after creation
354 vsg = vsg_exchange('vsg_create')
355 try:
356 vsg.vsg_create(100)
357 finally:
358 vsg.vsg_delete(100)
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000359
Chetan Gaonker357f4892017-06-19 19:38:27 +0000360 def test_scale_for_cord_subscriber_creation_and_deletion(self):
A R Karthick037cb982017-07-07 17:35:30 -0700361 #create 100 subscribers and delete them after creation
362 vsg = vsg_exchange('vsg_create')
363 try:
364 vsg.vsg_create(100)
365 finally:
366 vsg.vsg_delete(100)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000367
368 def test_cord_for_scale_of_subscriber_containers_per_compute_node(self):
369 pass
370
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000371 def test_latency_of_cord_for_control_packets_using_icmp_packet(self):
372 cmd = "ping -c 4 {0} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip)
373 st, out = getstatusoutput(cmd)
374 if out != '':
A R Karthick8f930292017-07-07 12:36:22 -0700375 out = out.split('/')
376 avg_rtt = out[1]
377 latency = float(avg_rtt)/float(2)
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000378 else:
379 latency = None
380 log.info('CORD setup latency calculated from icmp packet is = %s ms'%latency)
381 assert_not_equal(latency,None)
382
383 def test_latency_of_cord_for_control_packets_using_increasing_sizes_of_icmp_packet(self):
384 pckt_sizes = [100,500,1000,1500]
385 for size in pckt_sizes:
386 cmd = "ping -c 4 -s {} {} | tail -1| awk '{{print $4}}'".format(size,self.wan_intf_ip)
387 st, out = getstatusoutput(cmd)
388 if out != '':
389 out = out.split('/')
390 avg_rtt = out[1]
391 latency = float(avg_rtt)/float(2)
392 else:
393 latency = None
394 log.info('CORD setup latency calculated from icmp packet with size %s bytes is = %s ms'%(size,latency))
395 assert_not_equal(latency,None)
396
397 def test_latency_of_cord_with_traceroute(self):
398 cmd = "traceroute -q1 {} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip)
399 avg_rtt = float(0)
400 latency = None
401 for index in [1,2,3]:
402 st, out = getstatusoutput(cmd)
403 if out != '':
404 avg_rtt += float(out)
405 latency = float(avg_rtt)/float(6)
406 log.info('CORD setup latency calculated from traceroute is = %s ms'%latency)
407 assert_not_equal(latency,0.0)
408
409 def test_scale_with_igmp_joins_for_500_multicast_groups_and_check_cpu_usage(self, group_count=500):
410 OnosCtrl(self.igmp_app).activate()
411 groups = self.generate_random_multicast_ip_addresses(count = group_count)
412 sources = self.generate_random_unicast_ip_addresses(count = group_count)
413 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
414 for index in range(group_count):
415 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
416 iface = self.V_INF1)
417 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
418 assert_equal(status, True)
419 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
420 if index % 50 == 0:
421 cpu_usage = self.get_system_cpu_usage()
422 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
423
424 def test_scale_with_igmp_joins_for_1000_multicast_groups_and_check_cpu_usage(self, group_count=1000):
425 OnosCtrl(self.igmp_app).activate()
426 groups = self.generate_random_multicast_ip_addresses(count = group_count)
427 sources = self.generate_random_unicast_ip_addresses(count = group_count)
428 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
429 for index in range(group_count):
430 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
431 iface = self.V_INF1)
432 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
433 assert_equal(status, True)
434 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
435 if index % 50 == 0:
436 cpu_usage = self.get_system_cpu_usage()
437 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
438
439 def test_scale_with_igmp_joins_for_2000_multicast_groups_and_check_cpu_usage(self, group_count=2000):
440 OnosCtrl(self.igmp_app).activate()
441 groups = self.generate_random_multicast_ip_addresses(count = group_count)
442 sources = self.generate_random_unicast_ip_addresses(count = group_count)
443 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
444 for index in range(group_count):
445 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
446 iface = self.V_INF1)
447 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
448 assert_equal(status, True)
449 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
450 if index % 50 == 0:
451 cpu_usage = self.get_system_cpu_usage()
452 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
453
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000454 def test_scale_of_igmp_joins_for_2000_multicast_groups_and_check_cpu_usage_after_app_deactivation_and_activation(self,group_count=500):
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000455 OnosCtrl(self.igmp_app).activate()
456 groups = self.generate_random_multicast_ip_addresses(count = group_count)
457 sources = self.generate_random_unicast_ip_addresses(count = group_count)
458 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
459 for index in range(group_count):
460 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
461 iface = self.V_INF1)
462 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
463 assert_equal(status, True)
464 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
465 if index % 50 == 0:
466 cpu_usage = self.get_system_cpu_usage()
467 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
468 OnosCtrl(self.igmp_app).deactivate()
469 time.sleep(1)
470 cpu_usage = self.get_system_cpu_usage()
471 log.info('CPU usage is %s for multicast group entries %s after igmp app deactivated'%(cpu_usage,index+1))
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000472
473 def test_scale_adding_1k_flow_entries_in_onos_with_dynamic_tcp_ports(self,count=1000):
474 cpu_usage1 = self.get_system_cpu_usage()
475 egress = 1
476 ingress = 2
477 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': random.randint(1024,65535) }
478 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': random.randint(1024,65535) }
479 for index in range(0,count):
480 ingress_map['tcp_port'] = random.randint(1024,65535)
481 egress_map['tcp_port'] = random.randint(1024,65535)
482 flow = OnosFlowCtrl(deviceId = self.device_id,
483 egressPort = egress + self.port_offset,
484 ingressPort = ingress + self.port_offset,
485 tcpSrc = ingress_map['tcp_port'],
486 tcpDst = egress_map['tcp_port']
487 )
488 result = flow.addFlow()
489 assert_equal(result, True)
490 log_test.info("flow number = %d is added",index+1)
491 if index % 50 == 0:
492 cpu_usage = self.get_system_cpu_usage()
493 log.info('CPU usage is %s for flow number %d added'%(cpu_usage,index+1))
494 time.sleep(1)
495 cpu_usage2 = self.get_system_cpu_usage()
496 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
497
498 def test_scale_adding_5k_constant_source_ip_flow_entries_in_onos_and_checking_cpu_usage(self,count=5000):
499 cpu_usage1 = self.get_system_cpu_usage()
500 egress = 1
501 ingress = 2
502 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
503 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
504 for i in range(0,count):
505 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
506 assert_not_equal(ingress_map['ip'], None)
507 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
508
509 flow = OnosFlowCtrl(deviceId = self.device_id,
510 egressPort = egress + self.port_offset,
511 ingressPort = ingress + self.port_offset,
512 ethType = '0x0800',
513 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
514 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
515 )
516 if index % 50 == 0:
517 cpu_usage = self.get_system_cpu_usage()
518 log.info('CPU usage is %s for flow number %d added'%(cpu_usage,index+1))
519 time.sleep(1)
520 cpu_usage2 = self.get_system_cpu_usage()
521 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
522
523 def test_scale_adding_10k_flow_entries_in_onos_with_dynamic_udp_ports(self,count=10000):
524 cpu_usage1 = self.get_system_cpu_usage()
525 egress = 1
526 ingress = 2
527 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': random.randint(1024,65535) }
528 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': random.randint(1024,65535) }
529 for index in range(0,count):
530 ingress_map['tcp_port'] = random.randint(1024,65535)
531 egress_map['tcp_port'] = random.randint(1024,65535)
532 flow = OnosFlowCtrl(deviceId = self.device_id,
533 egressPort = egress + self.port_offset,
534 ingressPort = ingress + self.port_offset,
535 tcpSrc = ingress_map['tcp_port'],
536 tcpDst = egress_map['tcp_port']
537 )
538 result = flow.addFlow()
539 assert_equal(result, True)
540 ##wait for flows to be added to ONOS
541 log_test.info("flow number = %d is added",index+1)
542 if index % 50 == 0:
543 cpu_usage = self.get_system_cpu_usage()
544 log.info('CPU usage is %s for flow number %d added'%(cpu_usage,index+1))
545 time.sleep(1)
546 cpu_usage2 = self.get_system_cpu_usage()
547 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
548
549 def test_scale_adding_10k_constant_destination_mac_flow_entries_in_onos_and_check_cpu_usage(self,count=10000):
550 cpu_usage1 = self.get_system_cpu_usage()
551 egress = 1
552 ingress = 2
553 egress_mac = '00:00:00:00:01:01'
554 ingress_mac = '02:00:00:00:00:00'
555 for index in range(0,count):
556 ingress_mac = self.next_mac(ingress_mac)
557 flow = OnosFlowCtrl(deviceId = self.device_id,
558 egressPort = egress + self.port_offset,
559 ingressPort = ingress + self.port_offset,
560 ethSrc = ingress_mac,
561 ethDst = egress_mac)
562 result = flow.addFlow()
563 assert_equal(result, True)
564 log.info("flow number = %d is added",index+1)
565 if index % 100 == 0:
566 cpu_usage = self.get_system_cpu_usage()
567 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
568 time.sleep(1)
569 cpu_usage2 = self.get_system_cpu_usage()
570 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
571
572 def test_scale_adding_10k_acl_rules_to_deny_matching_destination_tcp_port_traffic(self,count=10000):
573 cpu_usage1 = self.get_system_cpu_usage()
574 acl_rule = ACLTest()
575 for index in range(0,count):
576 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
577 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
578 dst_port = random.randint(1024,65535)
579 log.info('adding acl rule = %d with src ip = %s, dst ip = %s and dst tcp port = %d'%(index+1, src_ip,dst_ip,dst_port))
580 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip, ipProto ='TCP', dstTpPort =dst_port, action = 'deny')
581 assert_equal(status, True)
582 if index % 100 == 0:
583 cpu_usage = self.get_system_cpu_usage()
584 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
585 time.sleep(1)
586 cpu_usage2 = self.get_system_cpu_usage()
587 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
588
589 def test_scale_adding_and_deleting_10k_acl_rules_to_allow_src_and_dst_ip_matching_traffic_check_cpu_usage(self,count=10000):
590 cpu_usage1 = self.get_system_cpu_usage()
591 acl_rule = ACLTest()
592 for index in range(0,count):
593 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
594 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
595 dst_port = random.randint(1024,65535)
596 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
597 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow')
598 assert_equal(status, True)
599 if index % 100 == 0:
600 cpu_usage = self.get_system_cpu_usage()
601 log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1))
602 time.sleep(1)
603 cpu_usage2 = self.get_system_cpu_usage()
604 result = acl_rule.get_acl_rules()
605 result = result.json()['aclRules']
606 for acl in result:
607 acl_rule.remove_acl_rule(acl['id'])
608 #log.info('acl is %s'%acl)
609 cpu_usage3 = self.get_system_cpu_usage()
610 log.info('system cpu usage before flows added = %f and after %d flows added = %f, after deleting all acl rules = %f'%(cpu_usage1,count,cpu_usage2,cpu_usage3))
611
612 def test_scale_adding_20k_acl_rules_to_allow_src_and_dst_ip_matching_traffic_and_deactivate_acl_app_checking_cpu_usage(self,count=20000):
613 cpu_usage1 = self.get_system_cpu_usage()
614 acl_rule = ACLTest()
615 for index in range(0,count):
616 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
617 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
618 dst_port = random.randint(1024,65535)
619 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
620 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow')
621 assert_equal(status, True)
622 if index % 200 == 0:
623 cpu_usage = self.get_system_cpu_usage()
624 log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1))
625 time.sleep(1)
626 cpu_usage2 = self.get_system_cpu_usage()
627 OnosCtrl(cls.acl_app).deactivate()
628 time.sleep(3)
629 cpu_usage3 = self.get_system_cpu_usage()
630 log.info('system cpu usage before flows added = %f, after %d flows added = %f, and after deactivating acl app = %f'%(cpu_usage1,count,cpu_usage2,cpu_usage3))
631
632 def test_scale_adding_igmp_and_acl_with_flow_entries_and_check_cpu_usage(self,igmp_groups=1300, flows_count=10000):
633 cpu_usage1 = self.get_system_cpu_usage()
634 egress = 1
635 ingress = 2
636 egress_mac = '00:00:00:00:01:01'
637 ingress_mac = '02:00:00:00:00:00'
638 acl_rule = ACLTest()
639 OnosCtrl(self.igmp_app).activate()
640 groups = self.generate_random_multicast_ip_addresses(count = igmp_groups)
641 sources = self.generate_random_unicast_ip_addresses(count = igmp_groups)
642 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
643 for index in range(igmp_groups):
644 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
645 iface = self.V_INF1)
646 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
647 assert_equal(status, True)
648 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
649 for index in range(flows_count):
650 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
651 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
652 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
653 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow')
654 assert_equal(status, True)
655 ingress_mac = self.next_mac(ingress_mac)
656 flow = OnosFlowCtrl(deviceId = self.device_id,
657 egressPort = egress + self.port_offset,
658 ingressPort = ingress + self.port_offset,
659 ethSrc = ingress_mac,
660 ethDst = egress_mac)
661 result = flow.addFlow()
662 assert_equal(result, True)
663 log.info("flow number = %d is added",index+1)
664 if index % 200 == 0:
665 cpu_usage = self.get_system_cpu_usage()
666 log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1))
667 time.sleep(1)
668 cpu_usage2 = self.get_system_cpu_usage()
669 log.info('system cpu usage before flows added = %f, after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
670
671 def test_scale_adding_igmp_acl_and_flow_entries_and_simultaneously_toggling_app_activation(self,igmp_groups=1300, flows_count=10000):
672 cpu_usage1 = self.get_system_cpu_usage()
673 def adding_igmp_entries():
674 OnosCtrl(self.igmp_app).activate()
675 groups = self.generate_random_multicast_ip_addresses(count = igmp_groups)
676 sources = self.generate_random_unicast_ip_addresses(count = igmp_groups)
677 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
678 for index in range(igmp_groups):
679 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
680 iface = self.V_INF1)
681 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
682 assert_equal(status, True)
683 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
684 def adding_flow_entries():
685 egress = 1
686 ingress = 2
687 egress_mac = '00:00:00:00:01:01'
688 ingress_mac = '02:00:00:00:00:00'
689 for index in range(flows_count):
690 ingress_mac = self.next_mac(ingress_mac)
691 flow = OnosFlowCtrl(deviceId = self.device_id,
692 egressPort = egress + self.port_offset,
693 ingressPort = ingress + self.port_offset,
694 ethSrc = ingress_mac,
695 ethDst = egress_mac)
696 result = flow.addFlow()
697 assert_equal(result, True)
698 log.info("flow number = %d is added",index+1)
699 def adding_acl_entries():
700 OnosCtrl(self.acl_app).activate()
701 for index in range(flows_count):
702 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
703 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
704 dst_port = random.randint(1024,65535)
705 log.info('adding acl rule = %d with src ip = %s, dst ip = %s and dst tcp port = %d'%(index+1, src_ip,dst_ip,dst_port))
706 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip, ipProto ='TCP', dstTpPort =dst_port, action = 'deny')
707 assert_equal(status, True)
708 igmp_thread = threading.Thread(target = adding_igmp_entries)
709 flows_thread = threading.Thread(target = adding_flow_entries)
710 acl_thread = threading.Thread(target = adding_acl_entries)
711 igmp_thread.start()
712 flows_thread.start()
713 acl_thread.start()
714 time.sleep(1)
715 igmp_thread.join()
716 flows_thread.join()
717 acl_thread.join()
718 cpu_usage2 = self.get_system_cpu_usage()
719 OnosCtrl(self.igmp_app).deactivate()
720 OnosCtrl(self.acl_app).deactivate()
721 cpu_usage3 = self.get_system_cpu_usage()
722 log.info('cpu usage before test start = %f, after igmp,flow and acl entries loaded = %f and after the apps deactivated = %f'%(cpu_usage1,cpu_usage2,cpu_usage3))
723 OnosCtrl(self.igmp_app).activate()
724 OnosCtrl(self.acl_app).activate()
725
A R Karthick8f930292017-07-07 12:36:22 -0700726 def vrouter_scale(self, num_routes, peers = 1):
727 from vrouterTest import vrouter_exchange
728 vrouter_exchange.setUpClass()
729 vrouter = vrouter_exchange('vrouter_scale')
730 res = vrouter.vrouter_scale(num_routes, peers = peers)
731 vrouter_exchange.tearDownClass()
732 assert_equal(res, True)
733
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000734 def test_scale_for_vrouter_with_10000_routes(self):
A R Karthick8f930292017-07-07 12:36:22 -0700735 self.vrouter_scale(10000, peers = 1)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000736
737 def test_scale_for_vrouter_with_20000_routes(self):
A R Karthick8f930292017-07-07 12:36:22 -0700738 self.vrouter_scale(20000, peers = 2)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000739
A R Karthick8f930292017-07-07 12:36:22 -0700740 def test_scale_for_vrouter_with_20000_routes_100_peers(self):
741 self.vrouter_scale(20000, peers = 100)
742
743 def tls_scale(self, num_sessions):
744 from tlsTest import eap_auth_exchange
745 tls = eap_auth_exchange('tls_scale')
746 tls.setUp()
747 tls.tls_scale(num_sessions)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000748
749 #simulating authentication for multiple users, 5K in this test case
A R Karthick8f930292017-07-07 12:36:22 -0700750 @deferred(TIMEOUT+1800)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000751 def test_scale_of_eap_tls_with_5k_sessions_using_diff_mac(self):
752 df = defer.Deferred()
753 def eap_tls_5k_with_diff_mac(df):
A R Karthick8f930292017-07-07 12:36:22 -0700754 self.tls_scale(5000)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000755 df.callback(0)
756 reactor.callLater(0, eap_tls_5k_with_diff_mac, df)
757 return df