blob: 8a96d0128ff599fa743ebef049150f01e63671e8 [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
34from CordTestConfig import setup_module, running_on_ciab
35from OnosCtrl import OnosCtrl
36from CordContainer import Onos
37log.setLevel('INFO')
38
39class scale_exchange(CordLogger):
40 HOST = "10.1.0.1"
41 USER = "vagrant"
42 PASS = "vagrant"
43 head_node = os.getenv('HEAD_NODE', 'prod')
44 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
45 test_path = os.path.dirname(os.path.realpath(__file__))
46 olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config.json'))
47 restApiXos = None
48 subscriber_account_num = 100
49 subscriber_s_tag = 500
50 subscriber_c_tag = 500
51 subscribers_per_s_tag = 8
52 subscriber_map = {}
53 subscriber_info = []
54 volt_subscriber_info = []
55 restore_methods = []
56 TIMEOUT=120
57 NUM_SUBSCRIBERS = 100
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +000058 wan_intf_ip = '10.6.1.129'
59 V_INF1 = 'veth0'
60 V_INF2 = 'veth1'
61 MGROUP1 = '239.1.2.3'
62 MGROUP2 = '239.2.2.3'
63 MINVALIDGROUP1 = '255.255.255.255'
64 MINVALIDGROUP2 = '239.255.255.255'
65 MMACGROUP1 = "01:00:5e:01:02:03"
66 MMACGROUP2 = "01:00:5e:02:02:03"
67 IGMP_DST_MAC = "01:00:5e:00:00:16"
68 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
69 IP_SRC = '1.2.3.4'
70 IP_DST = '224.0.0.22'
71 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
72 igmp_ip = IP(dst = IP_DST)
73 PORT_TX_DEFAULT = 2
74 PORT_RX_DEFAULT = 1
75 igmp_app = 'org.opencord.igmp'
76
Chetan Gaonker357f4892017-06-19 19:38:27 +000077
78 @classmethod
79 def getSubscriberCredentials(cls, subId):
80 """Generate our own account num, s_tag and c_tags"""
81 if subId in cls.subscriber_map:
82 return cls.subscriber_map[subId]
83 account_num = cls.subscriber_account_num
84 cls.subscriber_account_num += 1
85 s_tag, c_tag = cls.subscriber_s_tag, cls.subscriber_c_tag
86 cls.subscriber_c_tag += 1
87 if cls.subscriber_c_tag % cls.subscribers_per_s_tag == 0:
88 cls.subscriber_s_tag += 1
89 cls.subscriber_map[subId] = account_num, s_tag, c_tag
90 return cls.subscriber_map[subId]
91
92 @classmethod
93 def getXosCredentials(cls):
94 onos_cfg = OnosCtrl.get_config()
95 if onos_cfg is None:
96 return None
97 if 'apps' in onos_cfg and \
98 'org.opencord.vtn' in onos_cfg['apps'] and \
99 'cordvtn' in onos_cfg['apps']['org.opencord.vtn'] and \
100 'xos' in onos_cfg['apps']['org.opencord.vtn']['cordvtn']:
101 xos_cfg = onos_cfg['apps']['org.opencord.vtn']['cordvtn']['xos']
102 endpoint = xos_cfg['endpoint']
103 user = xos_cfg['user']
104 password = xos_cfg['password']
105 xos_endpoints = endpoint.split(':')
106 xos_host = xos_endpoints[1][len('//'):]
107 xos_port = xos_endpoints[2][:-1]
108 #log.info('xos_host: %s, port: %s, user: %s, password: %s' %(xos_host, xos_port, user, password))
109 return dict(host = xos_host, port = xos_port, user = user, password = password)
110
111 return None
112
113 @classmethod
114 def getSubscriberConfig(cls, num_subscribers):
115 features = {
116 'cdn': True,
117 'uplink_speed': 1000000000,
118 'downlink_speed': 1000000000,
119 'uverse': True,
120 'status': 'enabled'
121 }
122 subscriber_map = []
123 for i in xrange(num_subscribers):
124 subId = 'sub{}'.format(i)
125 account_num, _, _ = cls.getSubscriberCredentials(subId)
126 identity = { 'account_num' : str(account_num),
127 'name' : 'My House {}'.format(i)
128 }
129 sub_info = { 'features' : features,
130 'identity' : identity
131 }
132 subscriber_map.append(sub_info)
133
134 return subscriber_map
135
136 @classmethod
137 def getVoltSubscriberConfig(cls, num_subscribers):
138 voltSubscriberMap = []
139 for i in xrange(num_subscribers):
140 subId = 'sub{}'.format(i)
141 account_num, s_tag, c_tag = cls.getSubscriberCredentials(subId)
142 voltSubscriberInfo = {}
143 voltSubscriberInfo['voltTenant'] = dict(s_tag = str(s_tag),
144 c_tag = str(c_tag),
145 subscriber = '')
146 voltSubscriberInfo['account_num'] = account_num
147 voltSubscriberMap.append(voltSubscriberInfo)
148
149 return voltSubscriberMap
150
151 @classmethod
152 def setUpCordApi(cls):
153 our_path = os.path.dirname(os.path.realpath(__file__))
154 cord_api_path = os.path.join(our_path, '..', 'cord-api')
155 framework_path = os.path.join(cord_api_path, 'Framework')
156 utils_path = os.path.join(framework_path, 'utils')
157 data_path = os.path.join(cord_api_path, 'Tests', 'data')
158 subscriber_cfg = os.path.join(data_path, 'Subscriber.json')
159 volt_tenant_cfg = os.path.join(data_path, 'VoltTenant.json')
160 num_subscribers = max(cls.NUM_SUBSCRIBERS, 10)
161 cls.subscriber_info = cls.getSubscriberConfig(num_subscribers)
162 cls.volt_subscriber_info = cls.getVoltSubscriberConfig(num_subscribers)
163
164 sys.path.append(utils_path)
165 sys.path.append(framework_path)
166 from restApi import restApi
167 restApiXos = restApi()
168 xos_credentials = cls.getXosCredentials()
169 if xos_credentials is None:
170 restApiXos.controllerIP = cls.HEAD_NODE
171 restApiXos.controllerPort = '9000'
172 else:
173 restApiXos.controllerIP = xos_credentials['host']
174 restApiXos.controllerPort = xos_credentials['port']
175 restApiXos.user = xos_credentials['user']
176 restApiXos.password = xos_credentials['password']
177 cls.restApiXos = restApiXos
178
179 @classmethod
180 def getVoltId(cls, result, subId):
181 if type(result) is not type([]):
182 return None
183 for tenant in result:
184 if str(tenant['subscriber']) == str(subId):
185 return str(tenant['id'])
186 return None
187
188 @classmethod
189 def setUpClass(cls):
190 cls.controllers = get_controllers()
191 cls.controller = cls.controllers[0]
192 cls.cli = None
193 cls.on_pod = running_on_pod()
194 cls.on_ciab = running_on_ciab()
195 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
196 cls.vcpes = cls.olt.get_vcpes()
197 cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp')
198 cls.vcpes_reserved = cls.olt.get_vcpes_by_type('reserved')
199 cls.dhcp_vcpes_reserved = [ 'vcpe{}.{}.{}'.format(i, cls.vcpes_reserved[i]['s_tag'], cls.vcpes_reserved[i]['c_tag'])
200 for i in xrange(len(cls.vcpes_reserved)) ]
201 cls.untagged_dhcp_vcpes_reserved = [ 'vcpe{}'.format(i) for i in xrange(len(cls.vcpes_reserved)) ]
202 cls.container_vcpes_reserved = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ]
203 vcpe_dhcp_reserved = None
204 vcpe_container_reserved = None
205 if cls.vcpes_reserved:
206 vcpe_dhcp_reserved = cls.dhcp_vcpes_reserved[0]
207 if cls.on_pod is False:
208 vcpe_dhcp_reserved = cls.untagged_dhcp_vcpes_reserved[0]
209 vcpe_container_reserved = cls.container_vcpes_reserved[0]
210
211 cls.vcpe_dhcp_reserved = vcpe_dhcp_reserved
212 cls.vcpe_container_reserved = vcpe_container_reserved
213 dhcp_vcpe_offset = len(cls.vcpes_reserved)
214 cls.dhcp_vcpes = [ 'vcpe{}.{}.{}'.format(i+dhcp_vcpe_offset, cls.vcpes_dhcp[i]['s_tag'], cls.vcpes_dhcp[i]['c_tag'])
215 for i in xrange(len(cls.vcpes_dhcp)) ]
216 cls.untagged_dhcp_vcpes = [ 'vcpe{}'.format(i+dhcp_vcpe_offset) for i in xrange(len(cls.vcpes_dhcp)) ]
217 cls.container_vcpes = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_dhcp ]
218 vcpe_dhcp = None
219 vcpe_container = None
220 #cache the first dhcp vcpe in the class for quick testing
221 if cls.vcpes_dhcp:
222 vcpe_container = cls.container_vcpes[0]
223 vcpe_dhcp = cls.dhcp_vcpes[0]
224 if cls.on_pod is False:
225 vcpe_dhcp = cls.untagged_dhcp_vcpes[0]
226 cls.vcpe_container = vcpe_container_reserved or vcpe_container
227 cls.vcpe_dhcp = vcpe_dhcp_reserved or vcpe_dhcp
228 VSGAccess.setUp()
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000229 #cls.setUpCordApi()
Chetan Gaonker357f4892017-06-19 19:38:27 +0000230 if cls.on_pod is True:
231 cls.openVCPEAccess(cls.volt_subscriber_info)
232
233 @classmethod
234 def tearDownClass(cls):
235 VSGAccess.tearDown()
236 if cls.on_pod is True:
237 cls.closeVCPEAccess(cls.volt_subscriber_info)
238
239 def log_set(self, level = None, app = 'org.onosproject'):
240 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
241
242 @classmethod
243 def config_restore(cls):
244 """Restore the vsg test configuration on test case failures"""
245 for restore_method in cls.restore_methods:
246 restore_method()
247
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000248 def get_system_cpu_usage(self):
249 """ Getting compute node CPU usage """
250 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
251 cmd = "top -b -n1 | grep 'Cpu(s)' | awk '{print $2 + $4}'"
252 status, output = ssh_agent.run_cmd(cmd)
253 assert_equal(status, True)
254 return float(output)
255
Chetan Gaonker357f4892017-06-19 19:38:27 +0000256 def vsg_xos_subscriber_id(self, index):
257 log.info('index and its type are %s, %s'%(index, type(index)))
258 volt_subscriber_info = self.volt_subscriber_info[index]
259 result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER')
260 assert_not_equal(result, None)
261 subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num'])
262 return subId
263
264 def vsg_xos_subscriber_create(self, index, subscriber_info = None, volt_subscriber_info = None):
265 if self.on_pod is False:
266 return ''
267 if subscriber_info is None:
268 subscriber_info = self.subscriber_info[index]
269 if volt_subscriber_info is None:
270 volt_subscriber_info = self.volt_subscriber_info[index]
271 s_tag = int(volt_subscriber_info['voltTenant']['s_tag'])
272 c_tag = int(volt_subscriber_info['voltTenant']['c_tag'])
273 vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag)
274 log.info('Creating tenant with s_tag: %d, c_tag: %d' %(s_tag, c_tag))
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000275 """subId = ''
Chetan Gaonker357f4892017-06-19 19:38:27 +0000276 try:
277 result = self.restApiXos.ApiPost('TENANT_SUBSCRIBER', subscriber_info)
278 assert_equal(result, True)
279 result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER')
280 assert_not_equal(result, None)
281 subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num'])
282 assert_not_equal(subId, '0')
283 log.info('Subscriber ID for account num %s = %s' %(str(volt_subscriber_info['account_num']), subId))
284 volt_tenant = volt_subscriber_info['voltTenant']
285 #update the subscriber id in the tenant info before making the rest
286 volt_tenant['subscriber'] = subId
287 result = self.restApiXos.ApiPost('TENANT_VOLT', volt_tenant)
288 assert_equal(result, True)
289 #if the vsg instance was already instantiated, then reduce delay
290 if c_tag % self.subscribers_per_s_tag == 0:
291 delay = 350
292 else:
293 delay = 90
294 log.info('Delaying %d seconds for the VCPE to be provisioned' %(delay))
295 time.sleep(delay)
296 log.info('Testing for external connectivity to VCPE %s' %(vcpe))
297 self.vsg_for_external_connectivity(index)
298 finally:
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000299 return subId"""
Chetan Gaonker357f4892017-06-19 19:38:27 +0000300
301 def vsg_xos_subscriber_delete(self, index, subId = '', voltId = '', subscriber_info = None, volt_subscriber_info = None):
302 if self.on_pod is False:
303 return
304 if subscriber_info is None:
305 subscriber_info = self.subscriber_info[index]
306 if volt_subscriber_info is None:
307 volt_subscriber_info = self.volt_subscriber_info[index]
308 s_tag = int(volt_subscriber_info['voltTenant']['s_tag'])
309 c_tag = int(volt_subscriber_info['voltTenant']['c_tag'])
310 vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag)
311 log.info('Deleting tenant with s_tag: %d, c_tag: %d' %(s_tag, c_tag))
312 if not subId:
313 #get the subscriber id first
314 result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER')
315 assert_not_equal(result, None)
316 subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num'])
317 assert_not_equal(subId, '0')
318 if not voltId:
319 #get the volt id for the subscriber
320 result = self.restApiXos.ApiGet('TENANT_VOLT')
321 assert_not_equal(result, None)
322 voltId = self.getVoltId(result, subId)
323 assert_not_equal(voltId, None)
324 log.info('Deleting subscriber ID %s for account num %s' %(subId, str(volt_subscriber_info['account_num'])))
325 status = self.restApiXos.ApiDelete('TENANT_SUBSCRIBER', subId)
326 assert_equal(status, True)
327 #Delete the tenant
328 log.info('Deleting VOLT Tenant ID %s for subscriber %s' %(voltId, subId))
329 self.restApiXos.ApiDelete('TENANT_VOLT', voltId)
330
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000331 def onos_load_config(self, config):
332 #log_test.info('onos load config is %s'%config)
333 status, code = OnosCtrl.config(config)
334 if status is False:
335 log_test.info('JSON request returned status %d' %code)
336 assert_equal(status, True)
337 time.sleep(2)
338
339 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
340 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
341 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
342 if flag: #to maintain seperate group-source pair.
343 for i in range(len(groups)):
344 d = {}
345 d['source'] = src_list[i] or '0.0.0.0'
346 d['group'] = groups[i]
347 ssm_xlate_list.append(d)
348 else:
349 for g in groups:
350 for s in src_list:
351 d = {}
352 d['source'] = s or '0.0.0.0'
353 d['group'] = g
354 ssm_xlate_list.append(d)
355 self.onos_load_config(ssm_dict)
356 cord_port_map = {}
357 for g in groups:
358 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
359 IgmpChannel().cord_port_table_load(cord_port_map)
360 time.sleep(2)
361
362 def generate_random_multicast_ip_addresses(self,count=500):
363 multicast_ips = []
364 while(count >= 1):
365 ip = '.'.join([str(random.randint(224,239)),str(random.randint(1,254)),str(random.randint(1,254)),str(random.randint(1,254))])
366 if ip in multicast_ips:
367 pass
368 else:
369 multicast_ips.append(ip)
370 count -= 1
371 return multicast_ips
372
373 def generate_random_unicast_ip_addresses(self,count=500):
374 unicast_ips = []
375 while(count >= 1):
376 ip = '.'.join([str(random.randint(11,126)),str(random.randint(1,254)),str(random.randint(1,254)),str(random.randint(1,254))])
377 if ip in unicast_ips:
378 pass
379 else:
380 unicast_ips.append(ip)
381 count -= 1
382 return unicast_ips
383
384 def iptomac(self, mcast_ip):
385 mcast_mac = '01:00:5e:'
386 octets = mcast_ip.split('.')
387 second_oct = int(octets[1]) & 127
388 third_oct = int(octets[2])
389 fourth_oct = int(octets[3])
390 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
391 return mcast_mac
392
393 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
394 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1):
395 if ssm_load is True:
396 self.onos_ssm_table_load(groups, src_list)
397 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
398 gaddr=self.IP_DST)
399 for g in groups:
400 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
401 gr.sources = src_list
402 igmp.grps.append(gr)
403 if ip_pkt is None:
404 ip_pkt = self.igmp_eth/self.igmp_ip
405 pkt = ip_pkt/igmp
406 IGMPv3.fixup(pkt)
407 log.info('sending igmp join packet %s'%pkt.show())
408 sendp(pkt, iface=iface)
409 time.sleep(delay)
410
411 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
412 dst_mac = self.iptomac(group)
413 eth = Ether(dst= dst_mac)
414 ip = IP(dst=group,src=source)
415 data = repr(monotonic.monotonic())
416 sendp(eth/ip/data,count=20, iface = intf)
417
418 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
419 log_test.info('verifying multicast traffic for group %s from source %s'%(group,source))
420 self.success = False
421 def recv_task():
422 def igmp_recv_cb(pkt):
423 #log_test.info('received multicast data packet is %s'%pkt.show())
424 log_test.info('multicast data received for group %s from source %s'%(group,source))
425 self.success = True
426 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')
427 t = threading.Thread(target = recv_task)
428 t.start()
429 self.send_multicast_data_traffic(group,source=source)
430 t.join()
431 return self.success
432
Chetan Gaonker357f4892017-06-19 19:38:27 +0000433 def test_scale_for_vsg_vm_creations(self):
434 for index in xrange(len(self.subscriber_info)):
435 #check if the index exists
436 subId = self.vsg_xos_subscriber_id(index)
437 log.info('test_vsg_xos_subscriber_creation')
438 if subId and subId != '0':
439 self.vsg_xos_subscriber_delete(index, subId = subId)
440 subId = self.vsg_xos_subscriber_create(index)
441 log.info('Created Subscriber %s' %(subId))
442
443 def test_scale_for_vcpe_creations(self):
444 for index in xrange(len(self.subscriber_info)):
445 #check if the index exists
446 subId = self.vsg_xos_subscriber_id(index)
447 log.info('test_vsg_xos_subscriber_creation')
448 if subId and subId != '0':
449 self.vsg_xos_subscriber_delete(index, subId = subId)
450 subId = self.vsg_xos_subscriber_create(index)
451 log.info('Created Subscriber %s' %(subId))
452
453 def test_scale_of_subcriber_vcpe_creations_in_single_vsg_vm(self):
454 subId = self.vsg_xos_subscriber_create(100)
455 if subId and subId != '0':
456 self.vsg_xos_subscriber_delete(100, subId)
457
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000458 def test_scale_of_subcriber_vcpe_creations_in_multiple_vsg_vm(self):
459 subId = self.vsg_xos_subscriber_create(100)
460 if subId and subId != '0':
461 self.vsg_xos_subscriber_delete(100, subId)
462
463 def test_scale_of_subcriber_vcpe_creations_with_one_vcpe_in_one_vsg_vm(self):
464 subId = self.vsg_xos_subscriber_create(100)
465 if subId and subId != '0':
466 self.vsg_xos_subscriber_delete(100, subId)
467
Chetan Gaonker357f4892017-06-19 19:38:27 +0000468 def test_scale_for_cord_subscriber_creation_and_deletion(self):
469 subId = self.vsg_xos_subscriber_create(100)
470 if subId and subId != '0':
471 self.vsg_xos_subscriber_delete(100, subId)
472
473 def test_cord_for_scale_of_subscriber_containers_per_compute_node(self):
474 pass
475
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000476 def test_latency_of_cord_for_control_packets_using_icmp_packet(self):
477 cmd = "ping -c 4 {0} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip)
478 st, out = getstatusoutput(cmd)
479 if out != '':
480 out = out.split('/')
481 avg_rtt = out[1]
482 latency = float(avg_rtt)/float(2)
483 else:
484 latency = None
485 log.info('CORD setup latency calculated from icmp packet is = %s ms'%latency)
486 assert_not_equal(latency,None)
487
488 def test_latency_of_cord_for_control_packets_using_increasing_sizes_of_icmp_packet(self):
489 pckt_sizes = [100,500,1000,1500]
490 for size in pckt_sizes:
491 cmd = "ping -c 4 -s {} {} | tail -1| awk '{{print $4}}'".format(size,self.wan_intf_ip)
492 st, out = getstatusoutput(cmd)
493 if out != '':
494 out = out.split('/')
495 avg_rtt = out[1]
496 latency = float(avg_rtt)/float(2)
497 else:
498 latency = None
499 log.info('CORD setup latency calculated from icmp packet with size %s bytes is = %s ms'%(size,latency))
500 assert_not_equal(latency,None)
501
502 def test_latency_of_cord_with_traceroute(self):
503 cmd = "traceroute -q1 {} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip)
504 avg_rtt = float(0)
505 latency = None
506 for index in [1,2,3]:
507 st, out = getstatusoutput(cmd)
508 if out != '':
509 avg_rtt += float(out)
510 latency = float(avg_rtt)/float(6)
511 log.info('CORD setup latency calculated from traceroute is = %s ms'%latency)
512 assert_not_equal(latency,0.0)
513
514 def test_scale_with_igmp_joins_for_500_multicast_groups_and_check_cpu_usage(self, group_count=500):
515 OnosCtrl(self.igmp_app).activate()
516 groups = self.generate_random_multicast_ip_addresses(count = group_count)
517 sources = self.generate_random_unicast_ip_addresses(count = group_count)
518 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
519 for index in range(group_count):
520 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
521 iface = self.V_INF1)
522 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
523 assert_equal(status, True)
524 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
525 if index % 50 == 0:
526 cpu_usage = self.get_system_cpu_usage()
527 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
528
529 def test_scale_with_igmp_joins_for_1000_multicast_groups_and_check_cpu_usage(self, group_count=1000):
530 OnosCtrl(self.igmp_app).activate()
531 groups = self.generate_random_multicast_ip_addresses(count = group_count)
532 sources = self.generate_random_unicast_ip_addresses(count = group_count)
533 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
534 for index in range(group_count):
535 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
536 iface = self.V_INF1)
537 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
538 assert_equal(status, True)
539 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
540 if index % 50 == 0:
541 cpu_usage = self.get_system_cpu_usage()
542 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
543
544 def test_scale_with_igmp_joins_for_2000_multicast_groups_and_check_cpu_usage(self, group_count=2000):
545 OnosCtrl(self.igmp_app).activate()
546 groups = self.generate_random_multicast_ip_addresses(count = group_count)
547 sources = self.generate_random_unicast_ip_addresses(count = group_count)
548 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
549 for index in range(group_count):
550 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
551 iface = self.V_INF1)
552 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
553 assert_equal(status, True)
554 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
555 if index % 50 == 0:
556 cpu_usage = self.get_system_cpu_usage()
557 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
558
559 def test_scale_igmp_joins_for_2000_multicast_groups_and_check_cpu_usage_after_app_deactivation_and_activation(self,group_count=500):
560 OnosCtrl(self.igmp_app).activate()
561 groups = self.generate_random_multicast_ip_addresses(count = group_count)
562 sources = self.generate_random_unicast_ip_addresses(count = group_count)
563 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
564 for index in range(group_count):
565 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
566 iface = self.V_INF1)
567 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
568 assert_equal(status, True)
569 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
570 if index % 50 == 0:
571 cpu_usage = self.get_system_cpu_usage()
572 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
573 OnosCtrl(self.igmp_app).deactivate()
574 time.sleep(1)
575 cpu_usage = self.get_system_cpu_usage()
576 log.info('CPU usage is %s for multicast group entries %s after igmp app deactivated'%(cpu_usage,index+1))
577