blob: f5eff3afb9425c81943d97c3c1776dba78b47820 [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
A R Karthicked3a2ca2017-07-06 15:50:03 -070037from CordSubscriberUtils import CordSubscriberUtils, XosUtils
Chetan Gaonker357f4892017-06-19 19:38:27 +000038log.setLevel('INFO')
39
40class scale_exchange(CordLogger):
41 HOST = "10.1.0.1"
42 USER = "vagrant"
43 PASS = "vagrant"
44 head_node = os.getenv('HEAD_NODE', 'prod')
45 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
46 test_path = os.path.dirname(os.path.realpath(__file__))
47 olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config.json'))
48 restApiXos = None
A R Karthicked3a2ca2017-07-06 15:50:03 -070049 cord_subscriber = None
50 SUBSCRIBER_ACCOUNT_NUM = 100
51 SUBSCRIBER_S_TAG = 500
52 SUBSCRIBER_C_TAG = 500
53 SUBSCRIBERS_PER_S_TAG = 8
Chetan Gaonker357f4892017-06-19 19:38:27 +000054 subscriber_info = []
55 volt_subscriber_info = []
56 restore_methods = []
57 TIMEOUT=120
58 NUM_SUBSCRIBERS = 100
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +000059 wan_intf_ip = '10.6.1.129'
60 V_INF1 = 'veth0'
61 V_INF2 = 'veth1'
62 MGROUP1 = '239.1.2.3'
63 MGROUP2 = '239.2.2.3'
64 MINVALIDGROUP1 = '255.255.255.255'
65 MINVALIDGROUP2 = '239.255.255.255'
66 MMACGROUP1 = "01:00:5e:01:02:03"
67 MMACGROUP2 = "01:00:5e:02:02:03"
68 IGMP_DST_MAC = "01:00:5e:00:00:16"
69 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
70 IP_SRC = '1.2.3.4'
71 IP_DST = '224.0.0.22'
72 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
73 igmp_ip = IP(dst = IP_DST)
74 PORT_TX_DEFAULT = 2
75 PORT_RX_DEFAULT = 1
76 igmp_app = 'org.opencord.igmp'
Anil Kumar Sanka8942c882017-07-07 17:05:11 +000077 acl_app = 'org.onosproject.acl'
78 aaa_app = 'org.opencord.aaa'
79 app = 'org.onosproject.cli'
80 INTF_TX_DEFAULT = 'veth2'
81 INTF_RX_DEFAULT = 'veth0'
82 default_port_map = {
83 PORT_TX_DEFAULT : INTF_TX_DEFAULT,
84 PORT_RX_DEFAULT : INTF_RX_DEFAULT,
85 INTF_TX_DEFAULT : PORT_TX_DEFAULT,
86 INTF_RX_DEFAULT : PORT_RX_DEFAULT
87 }
88 vrouter_apps = ('org.onosproject.proxyarp', 'org.onosproject.hostprovider', 'org.onosproject.vrouter', 'org.onosproject.fwd')
89 CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE-----
90MIIEyTCCA7GgAwIBAgIJAN3OagiHm6AXMA0GCSqGSIb3DQEBCwUAMIGLMQswCQYD
91VQQGEwJVUzELMAkGA1UECAwCQ0ExEjAQBgNVBAcMCVNvbWV3aGVyZTETMBEGA1UE
92CgwKQ2llbmEgSW5jLjEeMBwGCSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYw
93JAYDVQQDDB1FeGFtcGxlIENlcnRpZmljYXRlIEF1dGhvcml0eTAeFw0xNzAzMTEw
94MDQ3NDNaFw0yMjEwMzEwMDQ3NDNaMIGLMQswCQYDVQQGEwJVUzELMAkGA1UECAwC
95Q0ExEjAQBgNVBAcMCVNvbWV3aGVyZTETMBEGA1UECgwKQ2llbmEgSW5jLjEeMBwG
96CSqGSIb3DQEJARYPYWRtaW5AY2llbmEuY29tMSYwJAYDVQQDDB1FeGFtcGxlIENl
97cnRpZmljYXRlIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
98ggEBALYkVvncfeRel/apXy5iODla5H7sUpU7a+pwT7nephmjKDh0GPX/t5GUwgkB
991zQAEj0IPoxZIfSAGSFP/mqTUK2sm7qerArih0E3kBRpnBKJZB/4r1OTZ04CsuRQ
100QJOqcI0mZJWUKEcahN4yZvRyxeiCeFFoc0Nw787MQHhD9lZTqJUoAvautUe1GCjG
10146DS4MzpWNGkqn5/ZC8lQ198AceMwf2pJRuOQg5cPwp65+dKNLUMLiSUV7JpvmAo
102of4MHtGaBxKHESZ2jPiNTT2uKI/7KxH3Pr/ctft3bcSX2d4q49B2tdEIRzC0ankm
103CrxFcq9Cb3MGaNuwWAtk3fOGKusCAwEAAaOCASwwggEoMB0GA1UdDgQWBBRtf8rH
104zJW7rliW1eZnbVbSb3obfDCBwAYDVR0jBIG4MIG1gBRtf8rHzJW7rliW1eZnbVbS
105b3obfKGBkaSBjjCBizELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMRIwEAYDVQQH
106DAlTb21ld2hlcmUxEzARBgNVBAoMCkNpZW5hIEluYy4xHjAcBgkqhkiG9w0BCQEW
107D2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAwwdRXhhbXBsZSBDZXJ0aWZpY2F0ZSBB
108dXRob3JpdHmCCQDdzmoIh5ugFzAMBgNVHRMEBTADAQH/MDYGA1UdHwQvMC0wK6Ap
109oCeGJWh0dHA6Ly93d3cuZXhhbXBsZS5jb20vZXhhbXBsZV9jYS5jcmwwDQYJKoZI
110hvcNAQELBQADggEBAKWjORcBc1WK3r8mq88ipUC2UR1qvxdON4K/hd+rdAj0E/xA
111QCJDORKno8f2MktqLfhU0amCVBvwdfmVFmVDtl38b1pu+mNFO+FDp04039Fd5ThM
112iYmiQjnJ2IcAi/CILtrjURvJUPSOX9lviOtcla0HW94dgA9IDRs5frrWO9jkcxXR
113+oz3LNMfVnXqhoHHQ1RtvqOozhEsUZZWY5MuUxRY25peeZ7m1vz+zDa/DbrV1wsP
114dxOocmYdGFIAT9AiRnR4Jc/hqabBVNMZlGAA+2dELajpaHqb4yx5gBLVkT7VgHjI
1157cp7jLRL7T+i4orZiAXpeEpAeOrP8r0DYTJi/8A=
116-----END CERTIFICATE-----'''
117
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000118
Chetan Gaonker357f4892017-06-19 19:38:27 +0000119 @classmethod
120 def setUpCordApi(cls):
Chetan Gaonker357f4892017-06-19 19:38:27 +0000121 num_subscribers = max(cls.NUM_SUBSCRIBERS, 10)
A R Karthicked3a2ca2017-07-06 15:50:03 -0700122 cls.cord_subscriber = CordSubscriberUtils(num_subscribers,
123 account_num = cls.SUBSCRIBER_ACCOUNT_NUM,
124 s_tag = cls.SUBSCRIBER_S_TAG,
125 c_tag = cls.SUBSCRIBER_C_TAG,
126 subscribers_per_s_tag = cls.SUBSCRIBERS_PER_S_TAG)
127 cls.restApiXos = XosUtils.getRestApi()
Chetan Gaonker357f4892017-06-19 19:38:27 +0000128
129 @classmethod
130 def setUpClass(cls):
131 cls.controllers = get_controllers()
132 cls.controller = cls.controllers[0]
133 cls.cli = None
134 cls.on_pod = running_on_pod()
135 cls.on_ciab = running_on_ciab()
136 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
137 cls.vcpes = cls.olt.get_vcpes()
138 cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp')
139 cls.vcpes_reserved = cls.olt.get_vcpes_by_type('reserved')
140 cls.dhcp_vcpes_reserved = [ 'vcpe{}.{}.{}'.format(i, cls.vcpes_reserved[i]['s_tag'], cls.vcpes_reserved[i]['c_tag'])
141 for i in xrange(len(cls.vcpes_reserved)) ]
142 cls.untagged_dhcp_vcpes_reserved = [ 'vcpe{}'.format(i) for i in xrange(len(cls.vcpes_reserved)) ]
143 cls.container_vcpes_reserved = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ]
144 vcpe_dhcp_reserved = None
145 vcpe_container_reserved = None
146 if cls.vcpes_reserved:
147 vcpe_dhcp_reserved = cls.dhcp_vcpes_reserved[0]
148 if cls.on_pod is False:
149 vcpe_dhcp_reserved = cls.untagged_dhcp_vcpes_reserved[0]
150 vcpe_container_reserved = cls.container_vcpes_reserved[0]
151
152 cls.vcpe_dhcp_reserved = vcpe_dhcp_reserved
153 cls.vcpe_container_reserved = vcpe_container_reserved
154 dhcp_vcpe_offset = len(cls.vcpes_reserved)
155 cls.dhcp_vcpes = [ 'vcpe{}.{}.{}'.format(i+dhcp_vcpe_offset, cls.vcpes_dhcp[i]['s_tag'], cls.vcpes_dhcp[i]['c_tag'])
156 for i in xrange(len(cls.vcpes_dhcp)) ]
157 cls.untagged_dhcp_vcpes = [ 'vcpe{}'.format(i+dhcp_vcpe_offset) for i in xrange(len(cls.vcpes_dhcp)) ]
158 cls.container_vcpes = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_dhcp ]
159 vcpe_dhcp = None
160 vcpe_container = None
161 #cache the first dhcp vcpe in the class for quick testing
162 if cls.vcpes_dhcp:
163 vcpe_container = cls.container_vcpes[0]
164 vcpe_dhcp = cls.dhcp_vcpes[0]
165 if cls.on_pod is False:
166 vcpe_dhcp = cls.untagged_dhcp_vcpes[0]
167 cls.vcpe_container = vcpe_container_reserved or vcpe_container
168 cls.vcpe_dhcp = vcpe_dhcp_reserved or vcpe_dhcp
169 VSGAccess.setUp()
A R Karthicked3a2ca2017-07-06 15:50:03 -0700170 cls.setUpCordApi()
Chetan Gaonker357f4892017-06-19 19:38:27 +0000171 if cls.on_pod is True:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700172 cls.openVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000173 cls.activate_apps()
174
175 @classmethod
176 def activate_apps(cls, deactivate = False):
177 for app in cls.vrouter_apps:
178 onos_ctrl = OnosCtrl(app)
179 if deactivate is False:
180 onos_ctrl.activate()
181 else:
182 onos_ctrl.deactivate()
183 time.sleep(2)
184 OnosCtrl(cls.igmp_app).activate()
185 OnosCtrl(cls.acl_app).activate()
186 OnosCtrl(cls.aaa_app).activate()
Chetan Gaonker357f4892017-06-19 19:38:27 +0000187
188 @classmethod
189 def tearDownClass(cls):
190 VSGAccess.tearDown()
191 if cls.on_pod is True:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700192 cls.closeVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000193
194 def log_set(self, level = None, app = 'org.onosproject'):
195 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
196
197 @classmethod
198 def config_restore(cls):
199 """Restore the vsg test configuration on test case failures"""
200 for restore_method in cls.restore_methods:
201 restore_method()
202
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000203 def get_system_cpu_usage(self):
204 """ Getting compute node CPU usage """
205 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
206 cmd = "top -b -n1 | grep 'Cpu(s)' | awk '{print $2 + $4}'"
207 status, output = ssh_agent.run_cmd(cmd)
208 assert_equal(status, True)
209 return float(output)
210
A R Karthicked3a2ca2017-07-06 15:50:03 -0700211 def vsg_for_external_connectivity(self, subscriber_index, reserved = False):
212 if reserved is True:
213 if self.on_pod is True:
214 vcpe = self.dhcp_vcpes_reserved[subscriber_index]
215 else:
216 vcpe = self.untagged_dhcp_vcpes_reserved[subscriber_index]
217 else:
218 if self.on_pod is True:
219 vcpe = self.dhcp_vcpes[subscriber_index]
220 else:
221 vcpe = self.untagged_dhcp_vcpes[subscriber_index]
222 mgmt = 'eth0'
223 host = '8.8.8.8'
224 self.success = False
225 assert_not_equal(vcpe, None)
226 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
227 assert_not_equal(vcpe_ip, None)
228 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
229 log.info('Sending icmp echo requests to external network 8.8.8.8')
230 st, _ = getstatusoutput('ping -c 3 8.8.8.8')
231 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
232 assert_equal(st, 0)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000233
234 def vsg_xos_subscriber_create(self, index, subscriber_info = None, volt_subscriber_info = None):
235 if self.on_pod is False:
236 return ''
237 if subscriber_info is None:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700238 subscriber_info = self.cord_subscriber.subscriber_info[index]
Chetan Gaonker357f4892017-06-19 19:38:27 +0000239 if volt_subscriber_info is None:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700240 volt_subscriber_info = self.cord_subscriber.volt_subscriber_info[index]
Chetan Gaonker357f4892017-06-19 19:38:27 +0000241 s_tag = int(volt_subscriber_info['voltTenant']['s_tag'])
242 c_tag = int(volt_subscriber_info['voltTenant']['c_tag'])
243 vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag)
A R Karthicked3a2ca2017-07-06 15:50:03 -0700244 subId = self.cord_subscriber.subscriberCreate(index, subscriber_info, volt_subscriber_info)
245 if subId:
Chetan Gaonker357f4892017-06-19 19:38:27 +0000246 #if the vsg instance was already instantiated, then reduce delay
A R Karthicked3a2ca2017-07-06 15:50:03 -0700247 if c_tag % self.SUBSCRIBERS_PER_S_TAG == 0:
Chetan Gaonker357f4892017-06-19 19:38:27 +0000248 delay = 350
249 else:
250 delay = 90
251 log.info('Delaying %d seconds for the VCPE to be provisioned' %(delay))
252 time.sleep(delay)
253 log.info('Testing for external connectivity to VCPE %s' %(vcpe))
254 self.vsg_for_external_connectivity(index)
A R Karthicked3a2ca2017-07-06 15:50:03 -0700255
256 return subId
Chetan Gaonker357f4892017-06-19 19:38:27 +0000257
258 def vsg_xos_subscriber_delete(self, index, subId = '', voltId = '', subscriber_info = None, volt_subscriber_info = None):
259 if self.on_pod is False:
260 return
A R Karthicked3a2ca2017-07-06 15:50:03 -0700261 self.cord_subscriber.subscriberDelete(index, subId = subId, voltId = voltId,
262 subscriber_info = subscriber_info,
263 volt_subscriber_info = volt_subscriber_info)
264
265 def vsg_xos_subscriber_id(self, index):
266 if self.on_pod is False:
267 return ''
268 return self.cord_subscriber.subscriberId(index)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000269
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000270 def onos_load_config(self, config):
271 #log_test.info('onos load config is %s'%config)
272 status, code = OnosCtrl.config(config)
273 if status is False:
274 log_test.info('JSON request returned status %d' %code)
275 assert_equal(status, True)
276 time.sleep(2)
277
278 def onos_ssm_table_load(self, groups, src_list = ['1.2.3.4'],flag = False):
279 ssm_dict = {'apps' : { 'org.opencord.igmp' : { 'ssmTranslate' : [] } } }
280 ssm_xlate_list = ssm_dict['apps']['org.opencord.igmp']['ssmTranslate']
281 if flag: #to maintain seperate group-source pair.
282 for i in range(len(groups)):
283 d = {}
284 d['source'] = src_list[i] or '0.0.0.0'
285 d['group'] = groups[i]
286 ssm_xlate_list.append(d)
287 else:
288 for g in groups:
289 for s in src_list:
290 d = {}
291 d['source'] = s or '0.0.0.0'
292 d['group'] = g
293 ssm_xlate_list.append(d)
294 self.onos_load_config(ssm_dict)
295 cord_port_map = {}
296 for g in groups:
297 cord_port_map[g] = (self.PORT_TX_DEFAULT, self.PORT_RX_DEFAULT)
298 IgmpChannel().cord_port_table_load(cord_port_map)
299 time.sleep(2)
300
301 def generate_random_multicast_ip_addresses(self,count=500):
302 multicast_ips = []
303 while(count >= 1):
304 ip = '.'.join([str(random.randint(224,239)),str(random.randint(1,254)),str(random.randint(1,254)),str(random.randint(1,254))])
305 if ip in multicast_ips:
306 pass
307 else:
308 multicast_ips.append(ip)
309 count -= 1
310 return multicast_ips
311
312 def generate_random_unicast_ip_addresses(self,count=500):
313 unicast_ips = []
314 while(count >= 1):
315 ip = '.'.join([str(random.randint(11,126)),str(random.randint(1,254)),str(random.randint(1,254)),str(random.randint(1,254))])
316 if ip in unicast_ips:
317 pass
318 else:
319 unicast_ips.append(ip)
320 count -= 1
321 return unicast_ips
322
323 def iptomac(self, mcast_ip):
324 mcast_mac = '01:00:5e:'
325 octets = mcast_ip.split('.')
326 second_oct = int(octets[1]) & 127
327 third_oct = int(octets[2])
328 fourth_oct = int(octets[3])
329 mcast_mac = mcast_mac + format(second_oct,'02x') + ':' + format(third_oct, '02x') + ':' + format(fourth_oct, '02x')
330 return mcast_mac
331
332 def send_igmp_join(self, groups, src_list = ['1.2.3.4'], record_type=IGMP_V3_GR_TYPE_INCLUDE,
333 ip_pkt = None, iface = 'veth0', ssm_load = False, delay = 1):
334 if ssm_load is True:
335 self.onos_ssm_table_load(groups, src_list)
336 igmp = IGMPv3(type = IGMP_TYPE_V3_MEMBERSHIP_REPORT, max_resp_code=30,
337 gaddr=self.IP_DST)
338 for g in groups:
339 gr = IGMPv3gr(rtype= record_type, mcaddr=g)
340 gr.sources = src_list
341 igmp.grps.append(gr)
342 if ip_pkt is None:
343 ip_pkt = self.igmp_eth/self.igmp_ip
344 pkt = ip_pkt/igmp
345 IGMPv3.fixup(pkt)
346 log.info('sending igmp join packet %s'%pkt.show())
347 sendp(pkt, iface=iface)
348 time.sleep(delay)
349
350 def send_multicast_data_traffic(self, group, intf= 'veth2',source = '1.2.3.4'):
351 dst_mac = self.iptomac(group)
352 eth = Ether(dst= dst_mac)
353 ip = IP(dst=group,src=source)
354 data = repr(monotonic.monotonic())
355 sendp(eth/ip/data,count=20, iface = intf)
356
357 def verify_igmp_data_traffic(self, group, intf='veth0', source='1.2.3.4' ):
358 log_test.info('verifying multicast traffic for group %s from source %s'%(group,source))
359 self.success = False
360 def recv_task():
361 def igmp_recv_cb(pkt):
362 #log_test.info('received multicast data packet is %s'%pkt.show())
363 log_test.info('multicast data received for group %s from source %s'%(group,source))
364 self.success = True
365 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')
366 t = threading.Thread(target = recv_task)
367 t.start()
368 self.send_multicast_data_traffic(group,source=source)
369 t.join()
370 return self.success
371
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000372 def incmac(self, mac):
373 tmp = str(hex(int('0x'+mac,16)+1).split('x')[1])
374 mac = '0'+ tmp if len(tmp) < 2 else tmp
375 return mac
376
377 def next_mac(self, mac):
378 mac = mac.split(":")
379 mac[5] = self.incmac(mac[5])
380
381 if len(mac[5]) > 2:
382 mac[0] = self.incmac(mac[0])
383 mac[5] = '01'
384
385 if len(mac[0]) > 2:
386 mac[0] = '01'
387 mac[1] = self.incmac(mac[1])
388 mac[5] = '01'
389 return ':'.join(mac)
390
391
392 def to_egress_mac(cls, mac):
393 mac = mac.split(":")
394 mac[4] = '01'
395
396 return ':'.join(mac)
397
398 def inc_ip(self, ip, i):
399
400 ip[i] =str(int(ip[i])+1)
401 return '.'.join(ip)
402
403
404 def next_ip(self, ip):
405
406 lst = ip.split('.')
407 for i in (3,0,-1):
408 if int(lst[i]) < 255:
409 return self.inc_ip(lst, i)
410 elif int(lst[i]) == 255:
411 lst[i] = '0'
412 if int(lst[i-1]) < 255:
413 return self.inc_ip(lst,i-1)
414 elif int(lst[i-2]) < 255:
415 lst[i-1] = '0'
416 return self.inc_ip(lst,i-2)
417 else:
418 break
419
420 def to_egress_ip(self, ip):
421 lst=ip.split('.')
422 lst[0] = '182'
423 return '.'.join(lst)
424
425 @classmethod
426 def start_onos(cls, network_cfg = None):
427 if type(network_cfg) is tuple:
428 res = []
429 for v in network_cfg:
430 res += v.items()
431 config = dict(res)
432 else:
433 config = network_cfg
434 log_test.info('Restarting ONOS with new network configuration')
435 return cord_test_onos_restart(config = config)
436
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000437 def onos_aaa_config(self):
438 aaa_dict = {'apps' : { self.app : { 'AAA' : { 'radiusSecret': 'radius_password',
439 'radiusIp': '172.17.0.2' } } } }
440 radius_ip = os.getenv('ONOS_AAA_IP') or '172.17.0.2'
441 aaa_dict['apps'][self.app]['AAA']['radiusIp'] = radius_ip
442 self.onos_ctrl.activate()
443 time.sleep(2)
444 self.onos_load_config(aaa_dict)
445
446 def onos_load_config(self, config):
447 status, code = OnosCtrl.config(config)
448 if status is False:
449 log_test.info('Configure request for AAA returned status %d' %code)
450 assert_equal(status, True)
451 time.sleep(3)
452
Chetan Gaonker357f4892017-06-19 19:38:27 +0000453 def test_scale_for_vsg_vm_creations(self):
A R Karthicked3a2ca2017-07-06 15:50:03 -0700454 for index in xrange(len(self.cord_subscriber.subscriber_info)):
Chetan Gaonker357f4892017-06-19 19:38:27 +0000455 #check if the index exists
456 subId = self.vsg_xos_subscriber_id(index)
457 log.info('test_vsg_xos_subscriber_creation')
458 if subId and subId != '0':
459 self.vsg_xos_subscriber_delete(index, subId = subId)
460 subId = self.vsg_xos_subscriber_create(index)
461 log.info('Created Subscriber %s' %(subId))
462
463 def test_scale_for_vcpe_creations(self):
A R Karthicked3a2ca2017-07-06 15:50:03 -0700464 for index in xrange(len(self.cord_subscriber.subscriber_info)):
Chetan Gaonker357f4892017-06-19 19:38:27 +0000465 #check if the index exists
466 subId = self.vsg_xos_subscriber_id(index)
467 log.info('test_vsg_xos_subscriber_creation')
468 if subId and subId != '0':
469 self.vsg_xos_subscriber_delete(index, subId = subId)
470 subId = self.vsg_xos_subscriber_create(index)
471 log.info('Created Subscriber %s' %(subId))
472
473 def test_scale_of_subcriber_vcpe_creations_in_single_vsg_vm(self):
474 subId = self.vsg_xos_subscriber_create(100)
475 if subId and subId != '0':
476 self.vsg_xos_subscriber_delete(100, subId)
477
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000478 def test_scale_of_subcriber_vcpe_creations_in_multiple_vsg_vm(self):
479 subId = self.vsg_xos_subscriber_create(100)
480 if subId and subId != '0':
481 self.vsg_xos_subscriber_delete(100, subId)
482
483 def test_scale_of_subcriber_vcpe_creations_with_one_vcpe_in_one_vsg_vm(self):
484 subId = self.vsg_xos_subscriber_create(100)
485 if subId and subId != '0':
486 self.vsg_xos_subscriber_delete(100, subId)
487
Chetan Gaonker357f4892017-06-19 19:38:27 +0000488 def test_scale_for_cord_subscriber_creation_and_deletion(self):
489 subId = self.vsg_xos_subscriber_create(100)
490 if subId and subId != '0':
491 self.vsg_xos_subscriber_delete(100, subId)
492
493 def test_cord_for_scale_of_subscriber_containers_per_compute_node(self):
494 pass
495
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000496 def test_latency_of_cord_for_control_packets_using_icmp_packet(self):
497 cmd = "ping -c 4 {0} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip)
498 st, out = getstatusoutput(cmd)
499 if out != '':
A R Karthick8f930292017-07-07 12:36:22 -0700500 out = out.split('/')
501 avg_rtt = out[1]
502 latency = float(avg_rtt)/float(2)
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000503 else:
504 latency = None
505 log.info('CORD setup latency calculated from icmp packet is = %s ms'%latency)
506 assert_not_equal(latency,None)
507
508 def test_latency_of_cord_for_control_packets_using_increasing_sizes_of_icmp_packet(self):
509 pckt_sizes = [100,500,1000,1500]
510 for size in pckt_sizes:
511 cmd = "ping -c 4 -s {} {} | tail -1| awk '{{print $4}}'".format(size,self.wan_intf_ip)
512 st, out = getstatusoutput(cmd)
513 if out != '':
514 out = out.split('/')
515 avg_rtt = out[1]
516 latency = float(avg_rtt)/float(2)
517 else:
518 latency = None
519 log.info('CORD setup latency calculated from icmp packet with size %s bytes is = %s ms'%(size,latency))
520 assert_not_equal(latency,None)
521
522 def test_latency_of_cord_with_traceroute(self):
523 cmd = "traceroute -q1 {} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip)
524 avg_rtt = float(0)
525 latency = None
526 for index in [1,2,3]:
527 st, out = getstatusoutput(cmd)
528 if out != '':
529 avg_rtt += float(out)
530 latency = float(avg_rtt)/float(6)
531 log.info('CORD setup latency calculated from traceroute is = %s ms'%latency)
532 assert_not_equal(latency,0.0)
533
534 def test_scale_with_igmp_joins_for_500_multicast_groups_and_check_cpu_usage(self, group_count=500):
535 OnosCtrl(self.igmp_app).activate()
536 groups = self.generate_random_multicast_ip_addresses(count = group_count)
537 sources = self.generate_random_unicast_ip_addresses(count = group_count)
538 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
539 for index in range(group_count):
540 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
541 iface = self.V_INF1)
542 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
543 assert_equal(status, True)
544 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
545 if index % 50 == 0:
546 cpu_usage = self.get_system_cpu_usage()
547 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
548
549 def test_scale_with_igmp_joins_for_1000_multicast_groups_and_check_cpu_usage(self, group_count=1000):
550 OnosCtrl(self.igmp_app).activate()
551 groups = self.generate_random_multicast_ip_addresses(count = group_count)
552 sources = self.generate_random_unicast_ip_addresses(count = group_count)
553 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
554 for index in range(group_count):
555 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
556 iface = self.V_INF1)
557 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
558 assert_equal(status, True)
559 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
560 if index % 50 == 0:
561 cpu_usage = self.get_system_cpu_usage()
562 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
563
564 def test_scale_with_igmp_joins_for_2000_multicast_groups_and_check_cpu_usage(self, group_count=2000):
565 OnosCtrl(self.igmp_app).activate()
566 groups = self.generate_random_multicast_ip_addresses(count = group_count)
567 sources = self.generate_random_unicast_ip_addresses(count = group_count)
568 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
569 for index in range(group_count):
570 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
571 iface = self.V_INF1)
572 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
573 assert_equal(status, True)
574 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
575 if index % 50 == 0:
576 cpu_usage = self.get_system_cpu_usage()
577 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
578
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000579 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 +0000580 OnosCtrl(self.igmp_app).activate()
581 groups = self.generate_random_multicast_ip_addresses(count = group_count)
582 sources = self.generate_random_unicast_ip_addresses(count = group_count)
583 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
584 for index in range(group_count):
585 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
586 iface = self.V_INF1)
587 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
588 assert_equal(status, True)
589 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
590 if index % 50 == 0:
591 cpu_usage = self.get_system_cpu_usage()
592 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
593 OnosCtrl(self.igmp_app).deactivate()
594 time.sleep(1)
595 cpu_usage = self.get_system_cpu_usage()
596 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 +0000597
598 def test_scale_adding_1k_flow_entries_in_onos_with_dynamic_tcp_ports(self,count=1000):
599 cpu_usage1 = self.get_system_cpu_usage()
600 egress = 1
601 ingress = 2
602 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': random.randint(1024,65535) }
603 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': random.randint(1024,65535) }
604 for index in range(0,count):
605 ingress_map['tcp_port'] = random.randint(1024,65535)
606 egress_map['tcp_port'] = random.randint(1024,65535)
607 flow = OnosFlowCtrl(deviceId = self.device_id,
608 egressPort = egress + self.port_offset,
609 ingressPort = ingress + self.port_offset,
610 tcpSrc = ingress_map['tcp_port'],
611 tcpDst = egress_map['tcp_port']
612 )
613 result = flow.addFlow()
614 assert_equal(result, True)
615 log_test.info("flow number = %d is added",index+1)
616 if index % 50 == 0:
617 cpu_usage = self.get_system_cpu_usage()
618 log.info('CPU usage is %s for flow number %d added'%(cpu_usage,index+1))
619 time.sleep(1)
620 cpu_usage2 = self.get_system_cpu_usage()
621 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
622
623 def test_scale_adding_5k_constant_source_ip_flow_entries_in_onos_and_checking_cpu_usage(self,count=5000):
624 cpu_usage1 = self.get_system_cpu_usage()
625 egress = 1
626 ingress = 2
627 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
628 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
629 for i in range(0,count):
630 ingress_map['ip'] = self.next_ip(ingress_map['ip'])
631 assert_not_equal(ingress_map['ip'], None)
632 egress_map['ip'] = self.to_egress_ip(ingress_map['ip'])
633
634 flow = OnosFlowCtrl(deviceId = self.device_id,
635 egressPort = egress + self.port_offset,
636 ingressPort = ingress + self.port_offset,
637 ethType = '0x0800',
638 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
639 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
640 )
641 if index % 50 == 0:
642 cpu_usage = self.get_system_cpu_usage()
643 log.info('CPU usage is %s for flow number %d added'%(cpu_usage,index+1))
644 time.sleep(1)
645 cpu_usage2 = self.get_system_cpu_usage()
646 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
647
648 def test_scale_adding_10k_flow_entries_in_onos_with_dynamic_udp_ports(self,count=10000):
649 cpu_usage1 = self.get_system_cpu_usage()
650 egress = 1
651 ingress = 2
652 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': random.randint(1024,65535) }
653 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': random.randint(1024,65535) }
654 for index in range(0,count):
655 ingress_map['tcp_port'] = random.randint(1024,65535)
656 egress_map['tcp_port'] = random.randint(1024,65535)
657 flow = OnosFlowCtrl(deviceId = self.device_id,
658 egressPort = egress + self.port_offset,
659 ingressPort = ingress + self.port_offset,
660 tcpSrc = ingress_map['tcp_port'],
661 tcpDst = egress_map['tcp_port']
662 )
663 result = flow.addFlow()
664 assert_equal(result, True)
665 ##wait for flows to be added to ONOS
666 log_test.info("flow number = %d is added",index+1)
667 if index % 50 == 0:
668 cpu_usage = self.get_system_cpu_usage()
669 log.info('CPU usage is %s for flow number %d added'%(cpu_usage,index+1))
670 time.sleep(1)
671 cpu_usage2 = self.get_system_cpu_usage()
672 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
673
674 def test_scale_adding_10k_constant_destination_mac_flow_entries_in_onos_and_check_cpu_usage(self,count=10000):
675 cpu_usage1 = self.get_system_cpu_usage()
676 egress = 1
677 ingress = 2
678 egress_mac = '00:00:00:00:01:01'
679 ingress_mac = '02:00:00:00:00:00'
680 for index in range(0,count):
681 ingress_mac = self.next_mac(ingress_mac)
682 flow = OnosFlowCtrl(deviceId = self.device_id,
683 egressPort = egress + self.port_offset,
684 ingressPort = ingress + self.port_offset,
685 ethSrc = ingress_mac,
686 ethDst = egress_mac)
687 result = flow.addFlow()
688 assert_equal(result, True)
689 log.info("flow number = %d is added",index+1)
690 if index % 100 == 0:
691 cpu_usage = self.get_system_cpu_usage()
692 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
693 time.sleep(1)
694 cpu_usage2 = self.get_system_cpu_usage()
695 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
696
697 def test_scale_adding_10k_acl_rules_to_deny_matching_destination_tcp_port_traffic(self,count=10000):
698 cpu_usage1 = self.get_system_cpu_usage()
699 acl_rule = ACLTest()
700 for index in range(0,count):
701 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
702 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
703 dst_port = random.randint(1024,65535)
704 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))
705 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip, ipProto ='TCP', dstTpPort =dst_port, action = 'deny')
706 assert_equal(status, True)
707 if index % 100 == 0:
708 cpu_usage = self.get_system_cpu_usage()
709 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
710 time.sleep(1)
711 cpu_usage2 = self.get_system_cpu_usage()
712 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
713
714 def test_scale_adding_and_deleting_10k_acl_rules_to_allow_src_and_dst_ip_matching_traffic_check_cpu_usage(self,count=10000):
715 cpu_usage1 = self.get_system_cpu_usage()
716 acl_rule = ACLTest()
717 for index in range(0,count):
718 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
719 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
720 dst_port = random.randint(1024,65535)
721 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
722 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow')
723 assert_equal(status, True)
724 if index % 100 == 0:
725 cpu_usage = self.get_system_cpu_usage()
726 log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1))
727 time.sleep(1)
728 cpu_usage2 = self.get_system_cpu_usage()
729 result = acl_rule.get_acl_rules()
730 result = result.json()['aclRules']
731 for acl in result:
732 acl_rule.remove_acl_rule(acl['id'])
733 #log.info('acl is %s'%acl)
734 cpu_usage3 = self.get_system_cpu_usage()
735 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))
736
737 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):
738 cpu_usage1 = self.get_system_cpu_usage()
739 acl_rule = ACLTest()
740 for index in range(0,count):
741 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
742 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
743 dst_port = random.randint(1024,65535)
744 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
745 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow')
746 assert_equal(status, True)
747 if index % 200 == 0:
748 cpu_usage = self.get_system_cpu_usage()
749 log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1))
750 time.sleep(1)
751 cpu_usage2 = self.get_system_cpu_usage()
752 OnosCtrl(cls.acl_app).deactivate()
753 time.sleep(3)
754 cpu_usage3 = self.get_system_cpu_usage()
755 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))
756
757 def test_scale_adding_igmp_and_acl_with_flow_entries_and_check_cpu_usage(self,igmp_groups=1300, flows_count=10000):
758 cpu_usage1 = self.get_system_cpu_usage()
759 egress = 1
760 ingress = 2
761 egress_mac = '00:00:00:00:01:01'
762 ingress_mac = '02:00:00:00:00:00'
763 acl_rule = ACLTest()
764 OnosCtrl(self.igmp_app).activate()
765 groups = self.generate_random_multicast_ip_addresses(count = igmp_groups)
766 sources = self.generate_random_unicast_ip_addresses(count = igmp_groups)
767 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
768 for index in range(igmp_groups):
769 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
770 iface = self.V_INF1)
771 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
772 assert_equal(status, True)
773 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
774 for index in range(flows_count):
775 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
776 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
777 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
778 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow')
779 assert_equal(status, True)
780 ingress_mac = self.next_mac(ingress_mac)
781 flow = OnosFlowCtrl(deviceId = self.device_id,
782 egressPort = egress + self.port_offset,
783 ingressPort = ingress + self.port_offset,
784 ethSrc = ingress_mac,
785 ethDst = egress_mac)
786 result = flow.addFlow()
787 assert_equal(result, True)
788 log.info("flow number = %d is added",index+1)
789 if index % 200 == 0:
790 cpu_usage = self.get_system_cpu_usage()
791 log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1))
792 time.sleep(1)
793 cpu_usage2 = self.get_system_cpu_usage()
794 log.info('system cpu usage before flows added = %f, after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
795
796 def test_scale_adding_igmp_acl_and_flow_entries_and_simultaneously_toggling_app_activation(self,igmp_groups=1300, flows_count=10000):
797 cpu_usage1 = self.get_system_cpu_usage()
798 def adding_igmp_entries():
799 OnosCtrl(self.igmp_app).activate()
800 groups = self.generate_random_multicast_ip_addresses(count = igmp_groups)
801 sources = self.generate_random_unicast_ip_addresses(count = igmp_groups)
802 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
803 for index in range(igmp_groups):
804 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
805 iface = self.V_INF1)
806 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
807 assert_equal(status, True)
808 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
809 def adding_flow_entries():
810 egress = 1
811 ingress = 2
812 egress_mac = '00:00:00:00:01:01'
813 ingress_mac = '02:00:00:00:00:00'
814 for index in range(flows_count):
815 ingress_mac = self.next_mac(ingress_mac)
816 flow = OnosFlowCtrl(deviceId = self.device_id,
817 egressPort = egress + self.port_offset,
818 ingressPort = ingress + self.port_offset,
819 ethSrc = ingress_mac,
820 ethDst = egress_mac)
821 result = flow.addFlow()
822 assert_equal(result, True)
823 log.info("flow number = %d is added",index+1)
824 def adding_acl_entries():
825 OnosCtrl(self.acl_app).activate()
826 for index in range(flows_count):
827 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
828 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
829 dst_port = random.randint(1024,65535)
830 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))
831 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip, ipProto ='TCP', dstTpPort =dst_port, action = 'deny')
832 assert_equal(status, True)
833 igmp_thread = threading.Thread(target = adding_igmp_entries)
834 flows_thread = threading.Thread(target = adding_flow_entries)
835 acl_thread = threading.Thread(target = adding_acl_entries)
836 igmp_thread.start()
837 flows_thread.start()
838 acl_thread.start()
839 time.sleep(1)
840 igmp_thread.join()
841 flows_thread.join()
842 acl_thread.join()
843 cpu_usage2 = self.get_system_cpu_usage()
844 OnosCtrl(self.igmp_app).deactivate()
845 OnosCtrl(self.acl_app).deactivate()
846 cpu_usage3 = self.get_system_cpu_usage()
847 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))
848 OnosCtrl(self.igmp_app).activate()
849 OnosCtrl(self.acl_app).activate()
850
A R Karthick8f930292017-07-07 12:36:22 -0700851 def vrouter_scale(self, num_routes, peers = 1):
852 from vrouterTest import vrouter_exchange
853 vrouter_exchange.setUpClass()
854 vrouter = vrouter_exchange('vrouter_scale')
855 res = vrouter.vrouter_scale(num_routes, peers = peers)
856 vrouter_exchange.tearDownClass()
857 assert_equal(res, True)
858
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000859 def test_scale_for_vrouter_with_10000_routes(self):
A R Karthick8f930292017-07-07 12:36:22 -0700860 self.vrouter_scale(10000, peers = 1)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000861
862 def test_scale_for_vrouter_with_20000_routes(self):
A R Karthick8f930292017-07-07 12:36:22 -0700863 self.vrouter_scale(20000, peers = 2)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000864
A R Karthick8f930292017-07-07 12:36:22 -0700865 def test_scale_for_vrouter_with_20000_routes_100_peers(self):
866 self.vrouter_scale(20000, peers = 100)
867
868 def tls_scale(self, num_sessions):
869 from tlsTest import eap_auth_exchange
870 tls = eap_auth_exchange('tls_scale')
871 tls.setUp()
872 tls.tls_scale(num_sessions)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000873
874 #simulating authentication for multiple users, 5K in this test case
A R Karthick8f930292017-07-07 12:36:22 -0700875 @deferred(TIMEOUT+1800)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000876 def test_scale_of_eap_tls_with_5k_sessions_using_diff_mac(self):
877 df = defer.Deferred()
878 def eap_tls_5k_with_diff_mac(df):
A R Karthick8f930292017-07-07 12:36:22 -0700879 self.tls_scale(5000)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000880 df.callback(0)
881 reactor.callLater(0, eap_tls_5k_with_diff_mac, df)
882 return df