blob: 0c4b1c387f77db5f990f65a2e0d4560c8cb69e17 [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 Sankafcb9a0f2017-07-22 00:24:35 +000029from Channels import Channels, IgmpChannel
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +000030from IGMP import *
Chetan Gaonker357f4892017-06-19 19:38:27 +000031from CordLogger import CordLogger
32from VSGAccess import VSGAccess
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +000033from OnosFlowCtrl import OnosFlowCtrl
34#imports for cord-subscriber module
35from subscriberDb import SubscriberDB
36from Stats import Stats
37from threadPool import ThreadPool
38import threading
39from EapTLS import TLSAuthTest
Chetan Gaonker357f4892017-06-19 19:38:27 +000040from CordTestUtils import log_test as log
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +000041from CordTestConfig import setup_module, running_on_ciab
Chetan Gaonker357f4892017-06-19 19:38:27 +000042from OnosCtrl import OnosCtrl
43from CordContainer import Onos
A R Karthicked3a2ca2017-07-06 15:50:03 -070044from CordSubscriberUtils import CordSubscriberUtils, XosUtils
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +000045from CordTestServer import cord_test_onos_restart, cord_test_quagga_restart, cord_test_shell, cord_test_radius_restart
46from Scale import scale
Chetan Gaonker357f4892017-06-19 19:38:27 +000047log.setLevel('INFO')
48
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +000049
Chetan Gaonker357f4892017-06-19 19:38:27 +000050class scale_exchange(CordLogger):
51 HOST = "10.1.0.1"
52 USER = "vagrant"
53 PASS = "vagrant"
54 head_node = os.getenv('HEAD_NODE', 'prod')
55 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
56 test_path = os.path.dirname(os.path.realpath(__file__))
57 olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config.json'))
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +000058 restApiXos = None
59 cord_subscriber = None
A R Karthicked3a2ca2017-07-06 15:50:03 -070060 SUBSCRIBER_ACCOUNT_NUM = 100
61 SUBSCRIBER_S_TAG = 500
62 SUBSCRIBER_C_TAG = 500
63 SUBSCRIBERS_PER_S_TAG = 8
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +000064 subscriber_info = []
65 volt_subscriber_info = []
Chetan Gaonker357f4892017-06-19 19:38:27 +000066 restore_methods = []
67 TIMEOUT=120
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +000068 NUM_SUBSCRIBERS = 16
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +000069 wan_intf_ip = '10.6.1.129'
70 V_INF1 = 'veth0'
71 V_INF2 = 'veth1'
72 MGROUP1 = '239.1.2.3'
73 MGROUP2 = '239.2.2.3'
74 MINVALIDGROUP1 = '255.255.255.255'
75 MINVALIDGROUP2 = '239.255.255.255'
76 MMACGROUP1 = "01:00:5e:01:02:03"
77 MMACGROUP2 = "01:00:5e:02:02:03"
78 IGMP_DST_MAC = "01:00:5e:00:00:16"
79 IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1"
80 IP_SRC = '1.2.3.4'
81 IP_DST = '224.0.0.22'
82 igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP)
83 igmp_ip = IP(dst = IP_DST)
84 PORT_TX_DEFAULT = 2
85 PORT_RX_DEFAULT = 1
86 igmp_app = 'org.opencord.igmp'
Anil Kumar Sanka8942c882017-07-07 17:05:11 +000087 acl_app = 'org.onosproject.acl'
88 aaa_app = 'org.opencord.aaa'
89 app = 'org.onosproject.cli'
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +000090 APP_NAME = 'org.ciena.xconnect'
Anil Kumar Sanka8942c882017-07-07 17:05:11 +000091 INTF_TX_DEFAULT = 'veth2'
92 INTF_RX_DEFAULT = 'veth0'
93 default_port_map = {
94 PORT_TX_DEFAULT : INTF_TX_DEFAULT,
95 PORT_RX_DEFAULT : INTF_RX_DEFAULT,
96 INTF_TX_DEFAULT : PORT_TX_DEFAULT,
97 INTF_RX_DEFAULT : PORT_RX_DEFAULT
98 }
99 vrouter_apps = ('org.onosproject.proxyarp', 'org.onosproject.hostprovider', 'org.onosproject.vrouter', 'org.onosproject.fwd')
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000100 MAX_PORTS = 100
101 subscriber_apps = ('org.opencord.aaa', 'org.onosproject.dhcp')
102 olt_apps = () #'org.opencord.cordmcast')
103 vtn_app = 'org.opencord.vtn'
104 table_app = 'org.ciena.cordigmp'
105 aaa_loaded = False
106 table_app_file = os.path.join(test_path, '..', 'apps/ciena-cordigmp-multitable-2.0-SNAPSHOT.oar')
107 app_file = os.path.join(test_path, '..', 'apps/ciena-cordigmp-2.0-SNAPSHOT.oar')
108 olt_app_file = os.path.join(test_path, '..', 'apps/olt-app-1.2-SNAPSHOT.oar')
109 olt_app_name = 'org.onosproject.olt'
110 onos_config_path = os.path.join(test_path, '..', 'setup/onos-config')
111 cpqd_path = os.path.join(test_path, '..', 'setup')
112 ovs_path = cpqd_path
113 test_services = ('IGMP', 'TRAFFIC')
114 num_joins = 0
115 num_subscribers = 0
116 leave_flag = True
117 num_channels = 0
118 recv_timeout = False
119 onos_restartable = bool(int(os.getenv('ONOS_RESTART', 0)))
120 SUBSCRIBER_TIMEOUT = 300
121 device_id = 'of:' + get_mac()
122
123 CLIENT_CERT = """-----BEGIN CERTIFICATE-----
124MIICuDCCAiGgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBizELMAkGA1UEBhMCVVMx
125CzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5h
126IEluYy4xHjAcBgkqhkiG9w0BCQEWD2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMd
127RXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTYwNjA2MjExMjI3WhcN
128MTcwNjAxMjExMjI3WjBnMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNV
129BAoTCkNpZW5hIEluYy4xFzAVBgNVBAMUDnVzZXJAY2llbmEuY29tMR0wGwYJKoZI
130hvcNAQkBFg51c2VyQGNpZW5hLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC
131gYEAwvXiSzb9LZ6c7uNziUfKvoHO7wu/uiFC5YUpXbmVGuGZizbVrny0xnR85Dfe
132+9R4diansfDhIhzOUl1XjN3YDeSS9OeF5YWNNE8XDhlz2d3rVzaN6hIhdotBkUjg
133rUewjTg5OFR31QEyG3v8xR3CLgiE9xQELjZbSA07pD79zuUCAwEAAaNPME0wEwYD
134VR0lBAwwCgYIKwYBBQUHAwIwNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL3d3dy5l
135eGFtcGxlLmNvbS9leGFtcGxlX2NhLmNybDANBgkqhkiG9w0BAQUFAAOBgQDAjkrY
1366tDChmKbvr8w6Du/t8vHjTCoCIocHTN0qzWOeb1YsAGX89+TrWIuO1dFyYd+Z0KC
137PDKB5j/ygml9Na+AklSYAVJIjvlzXKZrOaPmhZqDufi+rXWti/utVqY4VMW2+HKC
138nXp37qWeuFLGyR1519Y1d6F/5XzqmvbwURuEug==
139-----END CERTIFICATE-----"""
140
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000141 CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE-----
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000142MIIDvTCCAqWgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBizELMAkGA1UEBhMCVVMx
143CzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5h
144IEluYy4xHjAcBgkqhkiG9w0BCQEWD2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMd
145RXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTYwMzExMTg1MzM2WhcN
146MTcwMzA2MTg1MzM2WjBnMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNV
147BAoTCkNpZW5hIEluYy4xFzAVBgNVBAMUDnVzZXJAY2llbmEuY29tMR0wGwYJKoZI
148hvcNAQkBFg51c2VyQGNpZW5hLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
149AQoCggEBAOxemcBsPn9tZsCa5o2JA6sQDC7A6JgCNXXl2VFzKLNNvB9PS6D7ZBsQ
1505An0zEDMNzi51q7lnrYg1XyiE4S8FzMGAFr94RlGMQJUbRD9V/oqszMX4k++iAOK
151tIA1gr3x7Zi+0tkjVSVzXTmgNnhChAamdMsjYUG5+CY9WAicXyy+VEV3zTphZZDR
152OjcjEp4m/TSXVPYPgYDXI40YZKX5BdvqykWtT/tIgZb48RS1NPyN/XkCYzl3bv21
153qx7Mc0fcEbsJBIIRYTUkfxnsilcnmLxSYO+p+DZ9uBLBzcQt+4Rd5pLSfi21WM39
1542Z2oOi3vs/OYAPAqgmi2JWOv3mePa/8CAwEAAaNPME0wEwYDVR0lBAwwCgYIKwYB
155BQUHAwIwNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL3d3dy5leGFtcGxlLmNvbS9l
156eGFtcGxlX2NhLmNybDANBgkqhkiG9w0BAQUFAAOCAQEALBzMPDTIB6sLyPl0T6JV
157MjOkyldAVhXWiQsTjaGQGJUUe1cmUJyZbUZEc13MygXMPOM4x7z6VpXGuq1c/Vxn
158VzQ2fNnbJcIAHi/7G8W5/SQfPesIVDsHTEc4ZspPi5jlS/MVX3HOC+BDbOjdbwqP
159RX0JEr+uOyhjO+lRxG8ilMRACoBUbw1eDuVDoEBgErSUC44pq5ioDw2xelc+Y6hQ
160dmtYwfY0DbvwxHtA495frLyPcastDiT/zre7NL51MyUDPjjYjghNQEwvu66IKbQ3
161T1tJBrgI7/WI+dqhKBFolKGKTDWIHsZXQvZ1snGu/FRYzg1l+R/jT8cRB9BDwhUt
162yg==
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000163-----END CERTIFICATE-----'''
164
Chetan Gaonker357f4892017-06-19 19:38:27 +0000165 @classmethod
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000166 def setUpCordApi(cls):
A R Karthick037cb982017-07-07 17:35:30 -0700167 num_subscribers = max(cls.NUM_SUBSCRIBERS, 10)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000168 cls.cord_subscriber = CordSubscriberUtils(num_subscribers,
169 account_num = cls.SUBSCRIBER_ACCOUNT_NUM,
170 s_tag = cls.SUBSCRIBER_S_TAG,
171 c_tag = cls.SUBSCRIBER_C_TAG,
172 subscribers_per_s_tag = cls.SUBSCRIBERS_PER_S_TAG)
173 cls.restApiXos = XosUtils.getRestApi()
174
175 @classmethod
176 def setUpClass(cls):
177 log.info('in setUp class 00000000000000')
178 cls.controllers = get_controllers()
179 cls.controller = cls.controllers[0]
180 cls.cli = None
181 cls.on_pod = running_on_pod()
182 cls.on_ciab = running_on_ciab()
183 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
184 cls.vcpes = cls.olt.get_vcpes()
185 cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp')
186 cls.vcpes_reserved = cls.olt.get_vcpes_by_type('reserved')
187 cls.dhcp_vcpes_reserved = [ 'vcpe{}.{}.{}'.format(i, cls.vcpes_reserved[i]['s_tag'], cls.vcpes_reserved[i]['c_tag'])
188 for i in xrange(len(cls.vcpes_reserved)) ]
189 cls.untagged_dhcp_vcpes_reserved = [ 'vcpe{}'.format(i) for i in xrange(len(cls.vcpes_reserved)) ]
190 cls.container_vcpes_reserved = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ]
191 vcpe_dhcp_reserved = None
192 vcpe_container_reserved = None
193 if cls.vcpes_reserved:
194 vcpe_dhcp_reserved = cls.dhcp_vcpes_reserved[0]
195 if cls.on_pod is False:
196 vcpe_dhcp_reserved = cls.untagged_dhcp_vcpes_reserved[0]
197 vcpe_container_reserved = cls.container_vcpes_reserved[0]
198
199 cls.vcpe_dhcp_reserved = vcpe_dhcp_reserved
200 cls.vcpe_container_reserved = vcpe_container_reserved
201 dhcp_vcpe_offset = len(cls.vcpes_reserved)
202 cls.dhcp_vcpes = [ 'vcpe{}.{}.{}'.format(i+dhcp_vcpe_offset, cls.vcpes_dhcp[i]['s_tag'], cls.vcpes_dhcp[i]['c_tag'])
203 for i in xrange(len(cls.vcpes_dhcp)) ]
204 cls.untagged_dhcp_vcpes = [ 'vcpe{}'.format(i+dhcp_vcpe_offset) for i in xrange(len(cls.vcpes_dhcp)) ]
205 cls.container_vcpes = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_dhcp ]
206 vcpe_dhcp = None
207 vcpe_container = None
208 #cache the first dhcp vcpe in the class for quick testing
209 if cls.vcpes_dhcp:
210 vcpe_container = cls.container_vcpes[0]
211 vcpe_dhcp = cls.dhcp_vcpes[0]
212 if cls.on_pod is False:
213 vcpe_dhcp = cls.untagged_dhcp_vcpes[0]
214 cls.vcpe_container = vcpe_container_reserved or vcpe_container
215 cls.vcpe_dhcp = vcpe_dhcp_reserved or vcpe_dhcp
216 VSGAccess.setUp()
217 cls.setUpCordApi()
218 if cls.on_pod is True:
219 cls.openVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000220
221 @classmethod
222 def tearDownClass(cls):
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000223 VSGAccess.tearDown()
224 if cls.on_pod is True:
225 cls.closeVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000226
227 def log_set(self, level = None, app = 'org.onosproject'):
228 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000229######################## vsg - vcpe utility functions #########################
230 @classmethod
231 def closeVCPEAccess(cls, volt_subscriber_info):
232 OnosCtrl.uninstall_app(cls.APP_NAME, onos_ip = cls.HEAD_NODE)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000233
234 @classmethod
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000235 def openVCPEAccess(cls, volt_subscriber_info):
236 """
237 This code is used to configure leaf switch for head node access to compute node over fabric.
238 Care is to be taken to avoid overwriting existing/default vcpe flows.
239 The access is opened for generated subscriber info which should not overlap.
240 We target the fabric onos instance on head node.
241 """
242 version = Onos.getVersion(onos_ip = cls.HEAD_NODE)
243 app_version = '1.0-SNAPSHOT'
244 major = int(version.split('.')[0])
245 minor = int(version.split('.')[1])
246 if major > 1:
247 app_version = '2.0-SNAPSHOT'
248 elif major == 1 and minor > 10:
249 app_version = '2.0-SNAPSHOT'
250 cls.APP_FILE = os.path.join(cls.test_path, '..', 'apps/xconnect-{}.oar'.format(app_version))
251 OnosCtrl.install_app(cls.APP_FILE, onos_ip = cls.HEAD_NODE)
252 time.sleep(2)
253 s_tags = map(lambda tenant: int(tenant['voltTenant']['s_tag']), volt_subscriber_info)
254 #only get unique vlan tags
255 s_tags = list(set(s_tags))
256 devices = OnosCtrl.get_device_ids(controller = cls.HEAD_NODE)
257 if devices:
258 device_config = {}
259 for device in devices:
260 device_config[device] = []
261 for s_tag in s_tags:
262 xconnect_config = {'vlan': s_tag, 'ports' : [ cls.FABRIC_PORT_HEAD_NODE, cls.FABRIC_PORT_COMPUTE_NODE ] }
263 device_config[device].append(xconnect_config)
264
265 cfg = { 'apps' : { 'org.ciena.xconnect' : { 'xconnectTestConfig' : device_config } } }
266 OnosCtrl.config(cfg, controller = cls.HEAD_NODE)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000267
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000268 def get_system_cpu_usage(self):
269 """ Getting compute node CPU usage """
270 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
271 cmd = "top -b -n1 | grep 'Cpu(s)' | awk '{print $2 + $4}'"
272 status, output = ssh_agent.run_cmd(cmd)
273 assert_equal(status, True)
274 return float(output)
275
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000276 def vsg_for_external_connectivity(self, subscriber_index, reserved = False):
277 if reserved is True:
278 if self.on_pod is True:
279 vcpe = self.dhcp_vcpes_reserved[subscriber_index]
280 else:
281 vcpe = self.untagged_dhcp_vcpes_reserved[subscriber_index]
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000282 else:
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000283 if self.on_pod is True:
284 vcpe = self.dhcp_vcpes[subscriber_index]
285 else:
286 vcpe = self.untagged_dhcp_vcpes[subscriber_index]
287 mgmt = 'eth0'
288 host = '8.8.8.8'
289 self.success = False
290 assert_not_equal(vcpe, None)
291 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
292 assert_not_equal(vcpe_ip, None)
293 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
294 log.info('Sending icmp echo requests to external network 8.8.8.8')
295 st, _ = getstatusoutput('ping -c 3 8.8.8.8')
296 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
297 assert_equal(st, 0)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000298
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000299 def vsg_xos_subscriber_create(self, index, subscriber_info = None, volt_subscriber_info = None):
300 if self.on_pod is False:
301 return ''
302 if subscriber_info is None:
303 subscriber_info = self.cord_subscriber.subscriber_info[index]
304 if volt_subscriber_info is None:
305 volt_subscriber_info = self.cord_subscriber.volt_subscriber_info[index]
306 s_tag = int(volt_subscriber_info['voltTenant']['s_tag'])
307 c_tag = int(volt_subscriber_info['voltTenant']['c_tag'])
308 vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag)
309 subId = self.cord_subscriber.subscriberCreate(index, subscriber_info, volt_subscriber_info)
310 if subId:
311 #if the vsg instance was already instantiated, then reduce delay
312 if c_tag % self.SUBSCRIBERS_PER_S_TAG == 0:
313 delay = 350
314 else:
315 delay = 90
316 log.info('Delaying %d seconds for the VCPE to be provisioned' %(delay))
317 time.sleep(delay)
318 #log.info('Testing for external connectivity to VCPE %s' %(vcpe))
319 #self.vsg_for_external_connectivity(index)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000320
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000321 return subId
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000322
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000323 def vsg_delete(self, num_subscribers):
324 if self.on_pod is False:
325 return
326 num_subscribers = min(num_subscribers, len(self.cord_subscriber.subscriber_info))
327 for index in xrange(num_subscribers):
328 subId = self.vsg_xos_subscriber_id(index)
329 if subId and subId != '0':
330 self.vsg_xos_subscriber_delete(index, subId = subId)
331
332 def vsg_xos_subscriber_delete(self, index, subId = '', voltId = '', subscriber_info = None, volt_subscriber_info = None):
333 if self.on_pod is False:
334 return
335 self.cord_subscriber.subscriberDelete(index, subId = subId, voltId = voltId,
336 subscriber_info = subscriber_info,
337 volt_subscriber_info = volt_subscriber_info)
338
339 def vsg_xos_subscriber_id(self, index):
340 if self.on_pod is False:
341 return ''
342 return self.cord_subscriber.subscriberId(index)
343
344 def vsg_xos_subscriber_create_reserved(self):
345 if self.on_pod is False:
346 return
347 tags_reserved = [ (int(vcpe['s_tag']), int(vcpe['c_tag'])) for vcpe in self.vcpes_reserved ]
348 volt_tenants = self.restApiXos.ApiGet('TENANT_VOLT')
349 subscribers = self.restApiXos.ApiGet('TENANT_SUBSCRIBER')
350 reserved_tenants = filter(lambda tenant: (int(tenant['s_tag']), int(tenant['c_tag'])) in tags_reserved, volt_tenants)
351 reserved_config = []
352 for tenant in reserved_tenants:
353 for subscriber in subscribers:
354 if int(subscriber['id']) == int(tenant['subscriber']):
355 volt_subscriber_info = {}
356 volt_subscriber_info['voltTenant'] = dict(s_tag = tenant['s_tag'],
357 c_tag = tenant['c_tag'],
358 subscriber = tenant['subscriber'])
359 volt_subscriber_info['volt_id'] = tenant['id']
360 volt_subscriber_info['account_num'] = subscriber['identity']['account_num']
361 reserved_config.append( (subscriber, volt_subscriber_info) )
362 break
363 else:
364 log.info('Subscriber not found for tenant %s, s_tag: %s, c_tag: %s' %(str(tenant['subscriber']),
365 str(tenant['s_tag']),
366 str(tenant['c_tag'])))
367
368 for subscriber_info, volt_subscriber_info in reserved_config:
369 self.vsg_xos_subscriber_delete(0,
370 subId = str(subscriber_info['id']),
371 voltId = str(volt_subscriber_info['volt_id']),
372 subscriber_info = subscriber_info,
373 volt_subscriber_info = volt_subscriber_info)
374 subId = self.vsg_xos_subscriber_create(0,
375 subscriber_info = subscriber_info,
376 volt_subscriber_info = volt_subscriber_info)
377 log.info('Created reserved subscriber %s' %(subId))
378
379 @deferred(1800)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000380 def test_scale_for_vsg_vm_creations(self):
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000381 try:
382 df = defer.Deferred()
383 def scale_vsg_vms(df):
384 for index in xrange(len(self.cord_subscriber.subscriber_info)):
385 #check if the index exists
386 subId = self.vsg_xos_subscriber_id(index)
387 log.info('test_vsg_xos_subscriber_creation - subId is %s'%subId)
388 if subId and subId != '0':
389 self.vsg_xos_subscriber_delete(index, subId = subId)
390 subId = self.vsg_xos_subscriber_create(index)
391 log.info('Created Subscriber %s' %(subId))
392 df.callback(0)
393 reactor.callLater(0, scale_vsg_vms, df)
394 return df
395 finally:
396 pass
397 #self.vsg_delete(len(self.cord_subscriber.subscriber_info))
398 self.vsg_xos_subscriber_create_reserved
Chetan Gaonker357f4892017-06-19 19:38:27 +0000399
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000400 @deferred(1800)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000401 def test_scale_for_vcpe_creations(self):
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000402 try:
403 df = defer.Deferred()
404 def scale_vcpe_instances(df):
405 for index in xrange(len(self.cord_subscriber.subscriber_info)):
406 #check if the index exists
407 subId = self.vsg_xos_subscriber_id(index)
408 log.info('test_vsg_xos_subscriber_creation')
409 if subId and subId != '0':
410 self.vsg_xos_subscriber_delete(index, subId = subId)
411 subId = self.vsg_xos_subscriber_create(index)
412 log.info('Created Subscriber %s' %(subId))
413 df.callback(0)
414 reactor.callLater(0, scale_vcpe_instances, df)
415 return df
416 except:
417 self.vsg_delete(len(self.cord_subscriber.subscriber_info))
418 self.vsg_xos_subscriber_create_reserved
Chetan Gaonker357f4892017-06-19 19:38:27 +0000419
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000420 @deferred(1800)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000421 def test_scale_of_subcriber_vcpe_creations_in_single_vsg_vm(self):
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000422 try:
423 df = defer.Deferred()
424 def scale_vcpe_instances(df):
425 subId = self.vsg_xos_subscriber_create(100)
426 if subId and subId != '0':
427 self.vsg_xos_subscriber_delete(100, subId)
428 df.callback(0)
429 reactor.callLater(0, scale_vsg_vms, df)
430 return df
431 except:
432 self.vsg_delete(len(self.cord_subscriber.subscriber_info))
433 self.vsg_xos_subscriber_create_reserved
Chetan Gaonker357f4892017-06-19 19:38:27 +0000434
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000435 @deferred(1800)
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000436 def test_scale_of_subcriber_vcpe_creations_in_multiple_vsg_vm(self):
A R Karthick037cb982017-07-07 17:35:30 -0700437 try:
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000438 df = defer.Deferred()
439 def scale_vcpe_instances(df):
440 subId = self.vsg_xos_subscriber_create(100)
441 if subId and subId != '0':
442 self.vsg_xos_subscriber_delete(100, subId)
443 df.callback(0)
444 reactor.callLater(0, scale_vsg_vms, df)
445 return df
446 except:
447 self.vsg_delete(len(self.cord_subscriber.subscriber_info))
448 self.vsg_xos_subscriber_create_reserved
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000449
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000450 @deferred(1800)
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000451 def test_scale_of_subcriber_vcpe_creations_with_one_vcpe_in_one_vsg_vm(self):
A R Karthick037cb982017-07-07 17:35:30 -0700452 try:
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000453 df = defer.Deferred()
454 def scale_vcpe_instances(df):
455 subId = self.vsg_xos_subscriber_create(100)
456 if subId and subId != '0':
457 self.vsg_xos_subscriber_delete(100, subId)
458 df.callback(0)
459 reactor.callLater(0, scale_vsg_vms, df)
460 return df
461 except:
462 self.vsg_delete(len(self.cord_subscriber.subscriber_info))
463 self.vsg_xos_subscriber_create_reserved
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000464
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000465 @deferred(1800)
Chetan Gaonker357f4892017-06-19 19:38:27 +0000466 def test_scale_for_cord_subscriber_creation_and_deletion(self):
A R Karthick037cb982017-07-07 17:35:30 -0700467 try:
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000468 df = defer.Deferred()
469 def scale_vcpe_instances(df):
470 subId = self.vsg_xos_subscriber_create(100)
471 if subId and subId != '0':
472 self.vsg_xos_subscriber_delete(100, subId)
473 df.callback(0)
474 reactor.callLater(0, scale_vsg_vms, df)
475 return df
476 except:
477 self.vsg_delete(len(self.cord_subscriber.subscriber_info))
478 self.vsg_xos_subscriber_create_reserved
Chetan Gaonker357f4892017-06-19 19:38:27 +0000479
480 def test_cord_for_scale_of_subscriber_containers_per_compute_node(self):
481 pass
482
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000483 @deferred(10)
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000484 def test_latency_of_cord_for_control_packets_using_icmp_packet(self):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000485 """
486 Test-Method:
487 1. Ping from cord-tester to wan interface IP of CiaB setup
488 2. Grep latency of ping packets
489 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000490 df = defer.Deferred()
491 def scale_vcpe_instances(df):
492 cmd = "ping -c 4 {0} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip)
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000493 st, out = getstatusoutput(cmd)
494 if out != '':
495 out = out.split('/')
496 avg_rtt = out[1]
497 latency = float(avg_rtt)/float(2)
498 else:
499 latency = None
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000500 log.info('CORD setup latency calculated from icmp packet is = %s ms'%latency)
501 assert_not_equal(latency,None)
502 df.callback(0)
503 reactor.callLater(0, scale_vsg_vms, df)
504 return df
505
506 @deferred(20)
507 def test_latency_of_cord_for_control_packets_using_increasing_sizes_of_icmp_packet(self):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000508 """
509 Test-Method:
510 1. Ping from cord-tester to wan interface IP of CiaB setup
511 2. Grep the latency of ping packet
512 3. Repeat the process for varying sizes of ping packets
513 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000514 df = defer.Deferred()
515 def scale_vcpe_instances(df):
516 pckt_sizes = [100,500,1000,1500]
517 for size in pckt_sizes:
518 cmd = "ping -c 4 -s {} {} | tail -1| awk '{{print $4}}'".format(size,self.wan_intf_ip)
519 st, out = getstatusoutput(cmd)
520 if out != '':
521 out = out.split('/')
522 avg_rtt = out[1]
523 latency = float(avg_rtt)/float(2)
524 else:
525 latency = None
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000526 log.info('CORD setup latency calculated from icmp packet with size %s bytes is = %s ms'%(size,latency))
527 assert_not_equal(latency,None)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000528 df.callback(0)
529 reactor.callLater(0, scale_vsg_vms, df)
530 return df
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000531
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000532 @deferred(10)
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000533 def test_latency_of_cord_with_traceroute(self):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000534 """
535 Test-Method:
536 1. Traceroute from cord-tester to wan interface IP of CiaB setup
537 2. Grep the latency of ping packet
538 3. Repeat the process for varying sizes of ping packets
539 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000540 df = defer.Deferred()
541 def scale_vcpe_instances(df):
542 cmd = "traceroute -q1 {} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip)
543 avg_rtt = float(0)
544 latency = None
545 for index in [1,2,3]:
546 st, out = getstatusoutput(cmd)
547 if out != '':
548 avg_rtt += float(out)
549 latency = float(avg_rtt)/float(6)
550 log.info('CORD setup latency calculated from traceroute is = %s ms'%latency)
551 assert_not_equal(latency,0.0)
552 assert_not_equal(latency,None)
553 df.callback(0)
554 reactor.callLater(0, scale_vsg_vms, df)
555 return df
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000556
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000557 #tested with 50 igmp joins on CiaB setup
558 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000559 def test_scale_with_igmp_joins_for_multicast_groups_validating_cpu_usage(self, group_count=500):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000560 """
561 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000562 1. Register 500 (group count is number to test) igmp groups in onos
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000563 2. Send igmp joins for registered groups
564 3. Send multicast traffic to all registered groups
565 4. Verify traffic forwards properly
566 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000567 df = defer.Deferred()
568 def scale_igmp_joins(df):
569 OnosCtrl(self.igmp_app).activate()
570 groups = scale().generate_random_multicast_ip_addresses(count = group_count)
571 sources = scale().generate_random_unicast_ip_addresses(count = group_count)
572 scale().onos_ssm_table_load(groups,src_list=sources,flag=True)
573 try:
574 for index in range(group_count):
575 scale().send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000576 iface = self.V_INF1)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000577 status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
578 assert_equal(status, True)
579 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
580 except Exception as error:
581 log.info('Got unexpected error %s'%error)
582 raise
583 df.callback(0)
584 reactor.callLater(0, scale_igmp_joins, df)
585 return df
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000586
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000587 #tested with 50 igmp joins on CiaB setup
588 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000589 def test_scale_with_igmp_joins_for_multicast_groups_toggling_igmp_app(self, group_count=1000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000590 """
591 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000592 1. Register 1000 (group_count is a number to test, can increase the number)igmp groups in onos
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000593 2. Send igmp joins for registered groups
594 3. Send multicast traffic to all registered groups
595 4. Verify traffic forwards properly
596 5. deactivate and activate igmp app in onos
597 6. Verify multicast traffic do not forward after igmp app deactivated
598 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000599 df = defer.Deferred()
600 def scale_igmp_joins(df):
601 OnosCtrl(self.igmp_app).activate()
602 groups = scale().generate_random_multicast_ip_addresses(count = group_count)
603 sources = scale().generate_random_unicast_ip_addresses(count = group_count)
604 scale().onos_ssm_table_load(groups,src_list=sources,flag=True)
605 try:
606 for index in range(group_count):
607 scale().send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000608 iface = self.V_INF1)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000609 status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
610 assert_equal(status, True)
611 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
612 log_test.info('Deactivating igmp app in onos')
613 OnosCtrl(self.igmp_app).deactivate()
614 time.sleep(2)
615 for index in range(group_count):
616 status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
617 assert_equal(status, False)
618 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000619 OnosCtrl(self.igmp_app).activate()
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000620 except Exception as error:
621 log.info('Got unexpected error %s'%error)
622 OnosCtrl(self.igmp_app).activate()
623 raise
624 df.callback(0)
625 reactor.callLater(0, scale_igmp_joins, df)
626 return df
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000627
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000628 #tested with 50 igmp joins on CiaB setup
629 @deferred(1800)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000630 def test_scale_with_igmp_joins_for_multicast_groups_validating_cpu_usage(self, group_count=2000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000631 """
632 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000633 1. Register (group count value to test) igmp groups in onos
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000634 2. Send igmp joins for registered groups
635 3. Send multicast traffic to all registered groups
636 4. Verify traffic forwards properly
637 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000638 df = defer.Deferred()
639 def scale_igmp_joins(df):
640 OnosCtrl(self.igmp_app).activate()
641 groups = scale().generate_random_multicast_ip_addresses(count = group_count)
642 sources = scale().generate_random_unicast_ip_addresses(count = group_count)
643 scale().onos_ssm_table_load(groups,src_list=sources,flag=True)
644 try:
645 for index in range(group_count):
646 scale().send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000647 iface = self.V_INF1)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000648 status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
649 assert_equal(status, True)
650 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
651 if index % 50 == 0:
652 cpu_usage = scale().get_system_cpu_usage()
653 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
654 except Exception as error:
655 log.info('Got unexpected error %s'%error)
656 raise
657 df.callback(0)
658 reactor.callLater(0, scale_igmp_joins, df)
659 return df
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000660
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000661 #tested with 50 igmp joins on CiaB setup
662 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000663 def test_scale_of_igmp_joins_for_multicast_groups_validating_cpu_usage_after_app_deactivation_and_activation(self,group_count=2000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000664 """
665 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000666 1. Register 2000 (Number to test) igmp groups in onos
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000667 2. Send igmp joins for registered groups
668 3. Send multicast traffic to all registered groups
669 4. Verify traffic forwards properly
670 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000671 df = defer.Deferred()
672 def scale_igmp_joins(df):
673 cpu_usage1 = scale().get_system_cpu_usage()
674 OnosCtrl(self.igmp_app).activate()
675 groups = scale().generate_random_multicast_ip_addresses(count = group_count)
676 sources = scale().generate_random_unicast_ip_addresses(count = group_count)
677 scale().onos_ssm_table_load(groups,src_list=sources,flag=True)
678 try:
679 for index in range(group_count):
680 scale().send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
Anil Kumar Sanka12a5ec52017-06-29 18:41:51 +0000681 iface = self.V_INF1)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000682 status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
683 assert_equal(status, True)
684 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
685 if index % 50 == 0:
686 cpu_usage = self.get_system_cpu_usage()
687 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
688 cpu_usage2 = scale().get_system_cpu_usage()
689 OnosCtrl(self.igmp_app).deactivate()
690 time.sleep(2)
691 cpu_usage3 = scale().get_system_cpu_usage()
692 log.info('CPU usage before test start = %f after %d igmp entries registered in onos = %f and after the app deactivated = %f are'%(cpu_usage1,cpu_usage2,cpu_usage3))
693 except Exception as error:
694 log.info('Got unexpected error %s'%error)
695 raise
696 df.callback(0)
697 reactor.callLater(0, scale_igmp_joins, df)
698 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000699
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000700 #tested with 100 flow entries on CiaB setup
701 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000702 def test_scale_adding_large_number_of_flow_entries_for_tcp_ports(self,count=1000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000703 """
704 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000705 1. Add 1000 (Large number to test) flow entries with varying tcp port number in onos
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000706 2. Send data traffic for added tcp port numbers
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000707 3. Verify onos forwards data traffic properly
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000708 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000709 scale().flows_setup()
710 df = defer.Deferred()
711 def scale_flow_entries(df):
712 egress = 1
713 ingress = 2
714 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': random.randint(1024,65535) }
715 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': random.randint(1024,65535) }
716 try:
717 for index in range(0,count):
718 ingress_map['tcp_port'] = random.randint(1024,65535)
719 egress_map['tcp_port'] = random.randint(1024,65535)
720 src_port = ingress_map['tcp_port']
721 egr_port = egress_map['tcp_port']
722 #log.info('ingress port is %d and egress port is %d'%(src_port,egr_port))
723 flow = OnosFlowCtrl(deviceId = self.device_id,
724 egressPort = egress + scale().port_offset,
725 ingressPort = ingress + scale().port_offset,
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000726 tcpSrc = ingress_map['tcp_port'],
727 tcpDst = egress_map['tcp_port']
728 )
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000729 result = flow.addFlow()
730 assert_equal(result, True)
731 log_test.info("flow number = %d is added",index+1)
732 def mac_recv_task():
733 def recv_cb(pkt):
734 log_test.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport))
735 result = True
736 sniff(count=2, timeout=5,
737 lfilter = lambda p: TCP in p and p[TCP].dport == egr_port and p[TCP].sport == src_port ,prn = recv_cb, iface = scale().port_map[egress])
738 t = threading.Thread(target = mac_recv_task)
739 t.start()
740 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
741 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
742 L4 = TCP(sport = src_port, dport = egr_port)
743 pkt = L2/L3/L4
744 log_test.info('Sending packets to verify if flows are correct')
745 sendp(pkt, count=50, iface = scale().port_map[ingress])
746 t.join()
747 except Exception as error:
748 log.info('Got unexpected error %s'%error)
749 raise
750 df.callback(0)
751 reactor.callLater(0,scale_flow_entries, df)
752 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000753
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000754 #tested with 100 flow entries on CiaB setup
755 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000756 def test_scale_adding_ip_flow_entries_validating_cpu_usage(self,count=5000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000757 """
758 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000759 1. Add 5000(Edit count as per test requirement) flow entries with varying source and destination IP
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000760 2. Send data traffic matching flow entries
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000761 3. Verify onos forwards data traffic properly
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000762 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000763 scale().flows_setup()
764 df = defer.Deferred()
765 def scale_flow_entries(df):
766 cpu_usage1 = scale().get_system_cpu_usage()
767 egress = 1
768 ingress = 2
769 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' }
770 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' }
771 try:
772 for index in range(0,count):
773 ingress_map['ip'] = scale().generate_random_unicast_ip_addresses()[0] #next_ip(ingress_map['ip'])
774 assert_not_equal(ingress_map['ip'], None)
775 egress_map['ip'] = scale().generate_random_unicast_ip_addresses()[0] #to_egress_ip(ingress_map['ip'])
776 flow = OnosFlowCtrl(deviceId = self.device_id,
777 egressPort = egress + scale().port_offset,
778 ingressPort = ingress + scale().port_offset,
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000779 ethType = '0x0800',
780 ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'),
781 ipDst = ('IPV4_DST', egress_map['ip']+'/8')
782 )
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000783 if index % 50 == 0:
784 cpu_usage = scale().get_system_cpu_usage()
785 log.info('CPU usage is %s for flow number %d added'%(cpu_usage,index+1))
786 time.sleep(1)
787 def mac_recv_task():
788 def recv_cb(pkt):
789 log_test.info('Pkt seen with ingress source IP %s, destination IP %s' %(pkt[IP].src, pkt[IP].dst))
790 result = True
791 sniff(count=2, timeout=5,
792 lfilter = lambda p: IP in p and p[IP].dst == egress_map['ip'] and p[IP].src == ingress_map['ip'] ,prn = recv_cb, iface = scale().port_map[egress])
793 t = threading.Thread(target = mac_recv_task)
794 t.start()
795 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
796 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
797 pkt = L2/L3
798 log_test.info('Sending packets to verify if flows are correct')
799 sendp(pkt, count=50, iface = scale().port_map[ingress])
800 t.join()
801 cpu_usage2 = scale().get_system_cpu_usage()
802 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
803 except Exception as error:
804 log.info('Got unexpected error %s'%error)
805 raise
806 df.callback(0)
807 reactor.callLater(0, scale_flow_entries, df)
808 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000809
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000810 #tested with 100 flow entries on CiaB setup
811 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000812 def test_scale_adding_flow_entries_with_udp_ports(self,count=10000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000813 """
814 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000815 1. Add 10000 (Number as per test requirement)flow entries with varying udp port number in onos
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000816 2. Send data traffic matching flow entries
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000817 3. Verify onos forwards data traffic properly
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000818 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000819 scale().flows_setup()
820 df = defer.Deferred()
821 def scale_flow_entries(df):
822 egress = 1
823 ingress = 2
824 egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': random.randint(1024,65535) }
825 ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': random.randint(1024,65535) }
826 try:
827 for index in range(0,count):
828 ingress_map['udp_port'] = random.randint(1024,65535)
829 egress_map['udp_port'] = random.randint(1024,65535)
830 src_port = ingress_map['udp_port']
831 egr_port = egress_map['udp_port']
832 #log.info('ingress port is %d and egress port is %d'%(src_port,egr_port))
833 flow = OnosFlowCtrl(deviceId = self.device_id,
834 egressPort = egress + scale().port_offset,
835 ingressPort = ingress + scale().port_offset,
836 udpSrc = ingress_map['udp_port'],
837 udpDst = egress_map['udp_port']
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000838 )
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000839 result = flow.addFlow()
840 assert_equal(result, True)
841 log_test.info("flow number = %d is added",index+1)
842 def mac_recv_task():
843 def recv_cb(pkt):
844 log_test.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport))
845 result = True
846 sniff(count=2, timeout=5,
847 lfilter = lambda p: UDP in p and p[UDP].dport == egr_port and p[UDP].sport == src_port ,prn = recv_cb, iface = scale().port_map[egress])
848 t = threading.Thread(target = mac_recv_task)
849 t.start()
850 L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether'])
851 L3 = IP(src = ingress_map['ip'], dst = egress_map['ip'])
852 L4 = UDP(sport = src_port, dport = egr_port)
853 pkt = L2/L3/L4
854 log_test.info('Sending packets to verify if flows are correct')
855 sendp(pkt, count=50, iface = scale().port_map[ingress])
856 t.join()
857 except Exception as error:
858 log.info('Got unexpected error %s'%error)
859 raise
860 df.callback(0)
861 reactor.callLater(0,scale_flow_entries, df)
862 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000863
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000864 #tested with 100 flow entries on CiaB setup
865 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000866 def test_scale_adding_constant_destination_mac_flow_entries_validating_cpu_usage(self,count=100):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000867 """
868 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000869 1. Add 100(Change number as per requirement) flow entries with varying source mac
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000870 2. Send data traffic matching flow entries
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000871 3. Verify onos forwards data traffic properly
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000872 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000873 scale().flows_setup()
874 df = defer.Deferred()
875 def scale_flow_entries(df):
876 cpu_usage1 = self.get_system_cpu_usage()
877 egress = 1
878 ingress = 2
879 egress_mac = '02:00:00:00:0:0'
880 ingress_mac = '03:00:00:00:00:00'
881 try:
882 for index in range(0,count):
883 result = False
884 ingress_mac = scale().next_mac(ingress_mac)
885 flow = OnosFlowCtrl(deviceId = self.device_id,
886 egressPort = egress + scale().port_offset,
887 ingressPort = ingress + scale().port_offset,
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000888 ethSrc = ingress_mac,
889 ethDst = egress_mac)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000890 result = flow.addFlow()
891 assert_equal(result, True)
892 log.info("flow number = %d is added",index+1)
893 if index % 100 == 0:
894 cpu_usage = scale().get_system_cpu_usage()
895 log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1))
896 time.sleep(1)
897 def mac_recv_task():
898 def recv_cb(pkt):
899 log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src , pkt.dst))
900 result = True
901 sniff(count=2, timeout=5,
902 lfilter = lambda p: p.src == ingress_mac and p.dst == egress_mac ,prn = recv_cb, iface = scale().port_map[egress])
903 t = threading.Thread(target = mac_recv_task)
904 t.start()
905 L2 = Ether(src = ingress_mac, dst = egress_mac)
906 pkt = L2/IP()
907 log_test.info('Sending packets to verify if flows are correct')
908 sendp(pkt, count=50, iface = scale().port_map[ingress])
909 t.join()
910 assert_equal(result, True)
911 cpu_usage2 = self.get_system_cpu_usage()
912 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
913 except Exception as error:
914 log.info('Got unexpected error %s'%error)
915 raise
916 df.callback(0)
917 reactor.callLater(0,scale_flow_entries, df)
918 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +0000919
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000920
921 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000922 def test_scale_adding_acl_rules_to_deny_matching_destination_tcp_port_traffic(self,count=10000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000923 """
924 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000925 1. Add 10000 (Adjust number as per test requirement)acl deny rules with varying tcp port number
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000926 2. Send data traffic matching flow entries
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000927 3. Verify onos drops data traffic properly
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000928 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000929 df = defer.Deferred()
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000930 def scale_acl_rules(df):
931 acl_rule = ACLTest()
932 ingress = self.ingress_iface
933 egress = self.CURRENT_PORT_NUM
934 status, code, host_ip_mac = acl_rule.generate_onos_interface_config(iface_num= self.CURRENT_PORT_NUM, iface_name = 'b1',iface_count = 1, iface_ip = self.HOST_DST_IP)
935 self.CURRENT_PORT_NUM += 1
936 time.sleep(5)
937 assert_equal(status, True)
938 srcMac = '00:00:00:00:00:11'
939 dstMac = host_ip_mac[0][1]
940 scale().acl_hosts_add(dstHostIpMac = host_ip_mac, egress_iface_count = 1, egress_iface_num = egress )
941 try:
942 for index in range(0,count):
943 status,code,host_ip_mac = acl_rule.generate_onos_interface_config(iface_num= self.CURRENT_PORT_NUM, iface_name = 'b1',iface_count = 1, iface_ip = self.HOST_DST_IP)
944 self.CURRENT_PORT_NUM += 1
945 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
946 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
947 dst_port = random.randint(1024,65535)
948 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))
949 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip, ipProto ='TCP', dstTpPort =dst_port, action = 'deny')
950 assert_equal(status, True)
951 self.acl_rule_traffic_send_recv(srcMac = srcMac, dstMac = dstMac ,srcIp = src_ip, dstIp = dst_ip,ingress =ingress, egress = egress, ip_proto = 'TCP',positive_test = False)
952 scale().acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress)
953 except Exception as error:
954 log.info('Got unexpected error %s'%error)
955 self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress)
956 raise
957 df.callback(0)
958 reactor.callLater(0, scale_vsg_vms, df)
959 return df
960
961 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000962 def test_scale_adding_acl_rules_to_allow_src_and_dst_ip_matching_traffic_validating_cpu_usage(self,count=10000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000963 """
964 Test-Method:
965 1. Grep system usage before starting test case
Chetan Gaonker434b68c2017-08-04 17:10:03 +0000966 2. Configure 10000(As per test requirement) acl rules in onos
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000967 3. Verify traffic test for all 10000 acl rules configured
968 4. Grep system usage again now
969 """
970 df = defer.Deferred()
971 def scale_acl_rules(df):
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000972 cpu_usage1 = self.get_system_cpu_usage()
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000973 ingress = self.ingress_iface
974 egress = self.CURRENT_PORT_NUM
975 status, code, host_ip_mac = acl_rule.generate_onos_interface_config(iface_num= self.CURRENT_PORT_NUM, iface_name = 'b1',iface_count = 1, iface_ip = self.HOST_DST_IP)
976 self.CURRENT_PORT_NUM += 1
977 time.sleep(5)
978 assert_equal(status, True)
979 srcMac = '00:00:00:00:00:11'
980 dstMac = host_ip_mac[0][1]
981 self.acl_hosts_add(dstHostIpMac = host_ip_mac, egress_iface_count = 1, egress_iface_num = egress )
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +0000982 acl_rule = ACLTest()
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +0000983 try:
984 for index in range(0,count):
985 status,code,host_ip_mac = acl_rule.generate_onos_interface_config(iface_num= self.CURRENT_PORT_NUM, iface_name = 'b1',iface_count = 1, iface_ip = self.HOST_DST_IP)
986 self.CURRENT_PORT_NUM += 1
987 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
988 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
989 dst_port = random.randint(1024,65535)
990 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
991 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow')
992 assert_equal(status, True)
993 self.acl_rule_traffic_send_recv(srcMac = srcMac, dstMac = dstMac ,srcIp =self.ACL_SRC_IP, dstIp = self.ACL_DST_IP,ingress =ingress, egress = egress, ip_proto = 'UDP', dstPortNum = 456)
994 if index % 100 == 0:
995 cpu_usage = self.get_system_cpu_usage()
996 log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1))
997 time.sleep(1)
998 self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress)
999 except Exception as error:
1000 log.info('Got unexpected error %s'%error)
1001 self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress)
1002 raise
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001003 cpu_usage2 = self.get_system_cpu_usage()
1004 log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
1005 df.callback(0)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001006 reactor.callLater(0, scale_acl_rules, df)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001007 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001008
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001009 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001010 def test_scale_adding_and_deleting_acl_rules_to_allow_src_and_dst_ip_matching_traffic(self,count=10000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001011 """
1012 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001013 1. Add 10000 (Number as per requirement)acl rules to allow source and destinaiton IP matching traffic
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001014 2. Send acl rules matching traffic
1015 3. Delete all the added acl rules
1016 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001017 df = defer.Deferred()
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001018 def scale_acl_rules(df):
1019 ingress = self.ingress_iface
1020 egress = self.CURRENT_PORT_NUM
1021 status, code, host_ip_mac = acl_rule.generate_onos_interface_config(iface_num= self.CURRENT_PORT_NUM, iface_name = 'b1',iface_count = 1, iface_ip = self.HOST_DST_IP)
1022 self.CURRENT_PORT_NUM += 1
1023 time.sleep(5)
1024 assert_equal(status, True)
1025 srcMac = '00:00:00:00:00:11'
1026 dstMac = host_ip_mac[0][1]
1027 self.acl_hosts_add(dstHostIpMac = host_ip_mac, egress_iface_count = 1, egress_iface_num = egress )
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001028 acl_rule = ACLTest()
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001029 try:
1030 for index in range(0,count):
1031 status,code,host_ip_mac = acl_rule.generate_onos_interface_config(iface_num= self.CURRENT_PORT_NUM, iface_name = 'b1',iface_count = 1, iface_ip = self.HOST_DST_IP)
1032 self.CURRENT_PORT_NUM += 1
1033 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
1034 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
1035 dst_port = random.randint(1024,65535)
1036 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
1037 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow')
1038 assert_equal(status, True)
1039 self.acl_rule_traffic_send_recv(srcMac = srcMac, dstMac = dstMac ,srcIp =self.ACL_SRC_IP, dstIp = self.ACL_DST_IP,ingress =ingress, egress = egress, ip_proto = 'UDP', dstPortNum = 456)
1040 result = acl_rule.get_acl_rules()
1041 result = result.json()['aclRules']
1042 for acl in result:
1043 acl_rule.remove_acl_rule(acl['id'])
1044 log.info('removed acl with Id --> %s'%acl['id'])
1045 self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress)
1046 except Exception as error:
1047 log.info('Got unexpected error %s'%error)
1048 self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress)
1049 raise
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001050 df.callback(0)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001051 reactor.callLater(0, scale_acl_rules, df)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001052 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001053
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001054 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001055 def test_scale_adding_acl_rules_to_deny_src_and_dst_ip_matching_traffic_toggling_acl_app(self,count=20000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001056 """
1057 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001058 1. Add 20000 (Number as test requirement)acl rules to allow source and destinaiton IP matching traffic
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001059 2. Send acl rules matching traffic
1060 3. Verify onos drops the traffic as the rule is deny type
1061 4. Deactivate the acl app in onos
1062 4. Verify now onos forwards the traffic
1063 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001064 df = defer.Deferred()
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001065 def scale_acl_rules(df):
1066 ingress = self.ingress_iface
1067 egress = self.CURRENT_PORT_NUM
1068 status, code, host_ip_mac = acl_rule.generate_onos_interface_config(iface_num= self.CURRENT_PORT_NUM, iface_name = 'b1',iface_count = 1, iface_ip = self.HOST_DST_IP)
1069 self.CURRENT_PORT_NUM += 1
1070 time.sleep(5)
1071 assert_equal(status, True)
1072 srcMac = '00:00:00:00:00:11'
1073 dstMac = host_ip_mac[0][1]
1074 self.acl_hosts_add(dstHostIpMac = host_ip_mac, egress_iface_count = 1, egress_iface_num = egress )
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001075 acl_rule = ACLTest()
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001076 try:
1077 for index in range(0,count):
1078 status,code,host_ip_mac = acl_rule.generate_onos_interface_config(iface_num= self.CURRENT_PORT_NUM, iface_name = 'b1',iface_count = 1, iface_ip = self.HOST_DST_IP)
1079 self.CURRENT_PORT_NUM += 1
1080 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
1081 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
1082 dst_port = random.randint(1024,65535)
1083 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
1084 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'deny')
1085 assert_equal(status, True)
1086 self.acl_rule_traffic_send_recv(srcMac = srcMac, dstMac = dstMac ,srcIp =self.ACL_SRC_IP, dstIp = self.ACL_DST_IP,ingress =ingress, egress = egress, ip_proto = 'UDP', dstPortNum = 456)
1087 OnosCtrl(cls.acl_app).deactivate()
1088 time.sleep(3)
1089 except Exception as error:
1090 log.info('Got unexpected error %s'%error)
1091 raise
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001092 df.callback(0)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001093 reactor.callLater(0, scale_acl_rules, df)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001094 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001095
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001096 @deferred(1000)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001097 def test_scale_adding_igmp_and_acl_with_flow_entries_and_check_cpu_usage(self,igmp_groups=1300, flows_count=10000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001098 """
1099 Test-Method:
1100 1. Add igmp and flow entries in onos
1101 2. Send igmp joins for corresponding igmp entries
1102 3. Send multicast data traffic to registered igmp groups
1103 3. Verify onos forwards the traffic
1104 4. Send traffic matching the flow entries
1105 4. Verify onos forwards the traffic
1106 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001107 df = defer.Deferred()
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001108 def scale_igmp_acl_flows(df):
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001109 cpu_usage1 = self.get_system_cpu_usage()
1110 egress = 1
1111 ingress = 2
1112 egress_mac = '00:00:00:00:01:01'
1113 ingress_mac = '02:00:00:00:00:00'
1114 acl_rule = ACLTest()
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001115 OnosCtrl(self.igmp_app).activate()
1116 groups = self.generate_random_multicast_ip_addresses(count = igmp_groups)
1117 sources = self.generate_random_unicast_ip_addresses(count = igmp_groups)
1118 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1119 for index in range(igmp_groups):
1120 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001121 iface = self.V_INF1)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001122 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
1123 assert_equal(status, True)
1124 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001125 for index in range(flows_count):
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001126 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
1127 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
1128 log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip))
1129 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow')
1130 assert_equal(status, True)
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001131 ingress_mac = self.next_mac(ingress_mac)
1132 flow = OnosFlowCtrl(deviceId = self.device_id,
1133 egressPort = egress + self.port_offset,
1134 ingressPort = ingress + self.port_offset,
1135 ethSrc = ingress_mac,
1136 ethDst = egress_mac)
1137 result = flow.addFlow()
1138 assert_equal(result, True)
1139 log.info("flow number = %d is added",index+1)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001140 if index % 200 == 0:
1141 cpu_usage = self.get_system_cpu_usage()
1142 log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1))
1143 time.sleep(1)
1144 cpu_usage2 = self.get_system_cpu_usage()
1145 log.info('system cpu usage before flows added = %f, after %d flows added = %f'%(cpu_usage1,count,cpu_usage2))
1146 df.callback(0)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001147 reactor.callLater(0, scale_igmp_acl_flows, df)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001148 return df
1149
1150 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001151 def test_scale_adding_igmp_acl_and_flow_entries_and_simultaneously_toggling_app(self,igmp_groups=1300, flows_count=10000):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001152 """
1153 Test-Method:
1154 1. Add igmp, acl and flow entries in onos
1155 2. Send igmp joins for corresponding igmp entries
1156 3. Send multicast data traffic to registered igmp groups
1157 3. Verify onos forwards the traffic
1158 4. Send traffic matching the flow entries
1159 4. Verify onos forwards the traffic
1160 5. Send traffic matching acl rules
1161 6. Verify onos forwards the traffic
1162 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001163 df = defer.Deferred()
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001164 def scale_igmp_acl_flows(df):
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001165 cpu_usage1 = self.get_system_cpu_usage()
1166 def adding_igmp_entries():
1167 OnosCtrl(self.igmp_app).activate()
1168 groups = self.generate_random_multicast_ip_addresses(count = igmp_groups)
1169 sources = self.generate_random_unicast_ip_addresses(count = igmp_groups)
1170 self.onos_ssm_table_load(groups,src_list=sources,flag=True)
1171 for index in range(igmp_groups):
1172 self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE,
1173 iface = self.V_INF1)
1174 status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index])
1175 assert_equal(status, True)
1176 log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index))
1177 def adding_flow_entries():
1178 egress = 1
1179 ingress = 2
1180 egress_mac = '00:00:00:00:01:01'
1181 ingress_mac = '02:00:00:00:00:00'
1182 for index in range(flows_count):
1183 ingress_mac = self.next_mac(ingress_mac)
1184 flow = OnosFlowCtrl(deviceId = self.device_id,
1185 egressPort = egress + self.port_offset,
1186 ingressPort = ingress + self.port_offset,
1187 ethSrc = ingress_mac,
1188 ethDst = egress_mac)
1189 result = flow.addFlow()
1190 assert_equal(result, True)
1191 log.info("flow number = %d is added",index+1)
1192 def adding_acl_entries():
1193 OnosCtrl(self.acl_app).activate()
1194 for index in range(flows_count):
1195 src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
1196 dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32'
1197 dst_port = random.randint(1024,65535)
1198 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))
1199 status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip, ipProto ='TCP', dstTpPort =dst_port, action = 'deny')
1200 assert_equal(status, True)
1201 igmp_thread = threading.Thread(target = adding_igmp_entries)
1202 flows_thread = threading.Thread(target = adding_flow_entries)
1203 acl_thread = threading.Thread(target = adding_acl_entries)
1204 igmp_thread.start()
1205 flows_thread.start()
1206 acl_thread.start()
1207 time.sleep(1)
1208 igmp_thread.join()
1209 flows_thread.join()
1210 acl_thread.join()
1211 cpu_usage2 = self.get_system_cpu_usage()
1212 OnosCtrl(self.igmp_app).deactivate()
1213 OnosCtrl(self.acl_app).deactivate()
1214 cpu_usage3 = self.get_system_cpu_usage()
1215 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))
1216 OnosCtrl(self.igmp_app).activate()
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001217 OnosCtrl(self.acl_app).activate()
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001218 df.callback(0)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001219 reactor.callLater(0, scale_igmp_acl_flows, df)
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001220 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001221
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001222 #tested with 100 routes on CiaB
1223 @deferred(1000)
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001224 def test_scale_for_vrouter_with_large_number_of_routes_and_peers(self):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001225 """
1226 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001227 1. Add 100000 routes with 100 pairs in quagga(Change scale test number as per test requirement)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001228 2. Verify routes pushed to onos from quagga
1229 3. Send traffic destined the routes added
1230 3. Verify onos forwards the traffic
1231 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001232 scale().vrouter_setup()
1233 df = defer.Deferred()
1234 def scale_vrouter_routes(df):
1235 try:
1236 res = scale().vrouter_network_verify(10000, peers = 100)
1237 assert_equal(res, True)
1238 except Exception as error:
1239 log.info('Got Unexpected error %s'%error)
1240 raise
1241 df.callback(0)
1242 reactor.callLater(0, scale_vrouter_routes, df)
1243 return df
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001244
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001245 #tested with 100 subscribers on CiaB
1246 @deferred(1800)
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001247 def test_scale_of_eap_tls_with_huge_number_of_sessions_using_diff_mac(self):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001248 """
1249 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001250 1. Simulate eap authentication requests for 5000 users(Adjust user number as per requirement)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001251 2. Verify authentication is succes for all 5000 users
1252 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001253 OnosCtrl('org.opencord.aaa').activate()
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001254 df = defer.Deferred()
1255 def eap_tls_5k_with_diff_mac(df):
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001256 try:
1257 for i in xrange(5000):
1258 tls = TLSAuthTest(src_mac = 'random')
1259 tls.runTest()
1260 log_test.info('Authentication successfull for user %d'%i)
1261 except Exception as error:
1262 log.info('Got Unexpected error %s'%error)
1263 raise
Anil Kumar Sanka8942c882017-07-07 17:05:11 +00001264 df.callback(0)
1265 reactor.callLater(0, eap_tls_5k_with_diff_mac, df)
1266 return df
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001267
1268 #tested with 100 subscribers on CiaB
1269 @deferred(1800)
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001270 def test_scale_of_eap_tls_with_huge_number_of_sessions_using_diff_mac_with_aaa_app_deactivation_and_activation(self):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001271 """
1272 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001273 1. Simulate eap authentication requests for 5000 users(Adjust user number as per requirement)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001274 2. Verify authentication is succes for all 5000 users
1275 3. Deactivate and activate the aaa app in onos
1276 4. Simulate eap authentication requests for 5000 users
1277 5. Verify authentication is succes for all 5000 users
1278 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001279 OnosCtrl('org.opencord.aaa').activate()
1280 df = defer.Deferred()
1281 def eap_tls_5k_with_diff_mac(df):
1282 try:
1283 for i in xrange(5000):
1284 tls = TLSAuthTest(src_mac = 'random')
1285 tls.runTest()
1286 log_test.info('Authentication successfull for user %d'%i)
1287 OnosCtrl('org.opencord.aaa').deactivate()
1288 time.sleep(2)
1289 OnosCtrl('org.opencord.aaa').activate()
1290 for i in xrange(100):
1291 tls = TLSAuthTest(src_mac = 'random')
1292 tls.runTest()
1293 log_test.info('Authentication successfull for user %d'%i)
1294 OnosCtrl('org.opencord.aaa').activate()
1295 except Exception as error:
1296 log.info('Got Unexpected error %s'%error)
1297 OnosCtrl('org.opencord.aaa').activate()
1298 raise
1299 df.callback(0)
1300 reactor.callLater(0, eap_tls_5k_with_diff_mac, df)
1301 return df
1302
1303 #tested with 10 subscribers on CiaB
1304 @deferred(1800)
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001305 def test_scale_for_cord_subscribers_authentication_with_valid_and_invalid_certificates_and_channel_surfing(self):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001306 """
1307 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001308 1. Simulate 5000 subscribers to get authentication access(Adjust cord subscribers according to test)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001309 2. Send igmp joins from all the subcribers
1310 3. Verify multicast traffic received to all 5000 subscribers
1311 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001312 scale().subscriber_setup()
1313 df = defer.Deferred()
1314 def cordsub_auth_invalid_cert(df):
1315 num_subscribers = 2
1316 num_channels = 1
1317 try:
1318 test_status = scale().subscriber_join_verify(num_subscribers = num_subscribers,
1319 num_channels = num_channels,
1320 cbs = (scale().tls_invalid_cert, scale().dhcp_verify, scale().igmp_verify),
1321 port_list = scale().generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'half')
1322 assert_equal(test_status, True)
1323 except Exception as error:
1324 log.info('Got Unexpected error %s'%error)
1325 raise
1326 finally:
1327 scale().subscriber_teardown()
1328 df.callback(0)
1329 reactor.callLater(0, cordsub_auth_invalid_cert, df)
1330 return df
1331
1332 #tested with 10 subscribers on CiaB
1333 @deferred(1800)
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001334 def test_scale_for_cord_subscribers_with_igmp_join_and_jump_for_multiple_channels(self):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001335 """
1336 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001337 1. Simulate 5000 subscribers(Adjust number as per test)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001338 2. Send igmp joins from all the subcribers
1339 3. Verify multicast traffic received to all 5000 subscribers
1340 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001341 scale().subscriber_setup()
1342 df = defer.Deferred()
1343 def cordsub_igmp_join_jump(df):
1344 num_subscribers = 5000
1345 num_channels = 1500
1346 try:
1347 test_status = scale().subscriber_join_verify(num_subscribers = num_subscribers,
1348 num_channels = num_channels,
1349 cbs = (scale().tls_verify, scale().dhcp_jump_verify, scale().igmp_jump_verify),
1350 port_list = scale().generate_port_list(num_subscribers, num_channels),
1351 negative_subscriber_auth = 'all')
1352 assert_equal(test_status, True)
1353 except Exception as error:
1354 log.info('Got Unexpected error %s'%error)
1355 raise
1356 finally:
1357 scale().subscriber_teardown()
1358 df.callback(0)
1359 reactor.callLater(0, cordsub_igmp_join_jump, df)
1360 return df
1361
1362 #tested with 10 subscribers on CiaB
1363 @deferred(1800)
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001364 def test_scale_for_cord_subscribers_authentication_with_valid_and_non_ca_authorized_certificates_and_channel_surfing(self):
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001365 """
1366 Test-Method:
Chetan Gaonker434b68c2017-08-04 17:10:03 +00001367 1. Simulate 10000 subscribers to get authentication access(Adjust number as per test)
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001368 2. Send igmp joins from all the subcribers
1369 3. Verify multicast traffic received to all 10000 subscribers
1370 """
Anil Kumar Sankafcb9a0f2017-07-22 00:24:35 +00001371 scale().subscriber_setup()
1372 df = defer.Deferred()
1373 def cordsub_auth_valid_cert(df):
1374 num_subscribers = 10000
1375 num_channels = 1
1376 try:
1377 test_status = scale().subscriber_join_verify(num_subscribers = num_subscribers,
1378 num_channels = num_channels,
1379 cbs = (scale().tls_non_ca_authrized_cert, scale().dhcp_verify, scale().igmp_verify),
1380 port_list = scale().generate_port_list(num_subscribers, num_channels),
1381 negative_subscriber_auth = 'onethird')
1382 assert_equal(test_status, True)
1383 except Exception as error:
1384 log.info('Got Unexpected error %s'%error)
1385 raise
1386 finally:
1387 scale().subscriber_teardown()
1388 df.callback(0)
1389 reactor.callLater(0, cordsub_auth_valid_cert, df)
1390 return df
Anil Kumar Sanka35fc4452017-07-27 00:39:10 +00001391