Matteo Scandolo | 48d3d2d | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 17 | #copyright 2016-present Ciena Corporation |
| 18 | # |
| 19 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 20 | # you may not use this file except in compliance with the License. |
| 21 | # You may obtain a copy of the License at |
| 22 | # |
| 23 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 24 | # |
| 25 | # Unless required by applicable law or agreed to in writing, software |
| 26 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 27 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 28 | # See the License for the specific language governing permissions and |
| 29 | # limitations under the License. |
| 30 | # |
| 31 | import time |
| 32 | import os |
| 33 | import sys |
| 34 | import json |
| 35 | import requests |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 36 | import random |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 37 | from nose.tools import * |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 38 | from scapy.all import * |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 39 | from twisted.internet import defer |
| 40 | from nose.twistedtools import reactor, deferred |
| 41 | from CordTestUtils import * |
| 42 | from OltConfig import OltConfig |
| 43 | from onosclidriver import OnosCliDriver |
| 44 | from SSHTestAgent import SSHTestAgent |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 45 | from Channels import Channels, IgmpChannel |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 46 | from IGMP import * |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 47 | from CordLogger import CordLogger |
| 48 | from VSGAccess import VSGAccess |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 49 | from OnosFlowCtrl import OnosFlowCtrl |
| 50 | #imports for cord-subscriber module |
| 51 | from subscriberDb import SubscriberDB |
| 52 | from Stats import Stats |
| 53 | from threadPool import ThreadPool |
| 54 | import threading |
| 55 | from EapTLS import TLSAuthTest |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 56 | from CordTestUtils import log_test as log |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 57 | from CordTestConfig import setup_module, running_on_ciab |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 58 | from OnosCtrl import OnosCtrl |
| 59 | from CordContainer import Onos |
A R Karthick | ed3a2ca | 2017-07-06 15:50:03 -0700 | [diff] [blame] | 60 | from CordSubscriberUtils import CordSubscriberUtils, XosUtils |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 61 | from CordTestServer import cord_test_onos_restart, cord_test_quagga_restart, cord_test_shell, cord_test_radius_restart |
| 62 | from Scale import scale |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 63 | log.setLevel('INFO') |
| 64 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 65 | |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 66 | class scale_exchange(CordLogger): |
| 67 | HOST = "10.1.0.1" |
| 68 | USER = "vagrant" |
| 69 | PASS = "vagrant" |
| 70 | head_node = os.getenv('HEAD_NODE', 'prod') |
| 71 | HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node |
| 72 | test_path = os.path.dirname(os.path.realpath(__file__)) |
| 73 | olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config.json')) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 74 | restApiXos = None |
| 75 | cord_subscriber = None |
A R Karthick | ed3a2ca | 2017-07-06 15:50:03 -0700 | [diff] [blame] | 76 | SUBSCRIBER_ACCOUNT_NUM = 100 |
| 77 | SUBSCRIBER_S_TAG = 500 |
| 78 | SUBSCRIBER_C_TAG = 500 |
| 79 | SUBSCRIBERS_PER_S_TAG = 8 |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 80 | subscriber_info = [] |
| 81 | volt_subscriber_info = [] |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 82 | restore_methods = [] |
| 83 | TIMEOUT=120 |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 84 | NUM_SUBSCRIBERS = 16 |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 85 | wan_intf_ip = '10.6.1.129' |
| 86 | V_INF1 = 'veth0' |
| 87 | V_INF2 = 'veth1' |
| 88 | MGROUP1 = '239.1.2.3' |
| 89 | MGROUP2 = '239.2.2.3' |
| 90 | MINVALIDGROUP1 = '255.255.255.255' |
| 91 | MINVALIDGROUP2 = '239.255.255.255' |
| 92 | MMACGROUP1 = "01:00:5e:01:02:03" |
| 93 | MMACGROUP2 = "01:00:5e:02:02:03" |
| 94 | IGMP_DST_MAC = "01:00:5e:00:00:16" |
| 95 | IGMP_SRC_MAC = "5a:e1:ac:ec:4d:a1" |
| 96 | IP_SRC = '1.2.3.4' |
| 97 | IP_DST = '224.0.0.22' |
| 98 | igmp_eth = Ether(dst = IGMP_DST_MAC, type = ETH_P_IP) |
| 99 | igmp_ip = IP(dst = IP_DST) |
| 100 | PORT_TX_DEFAULT = 2 |
| 101 | PORT_RX_DEFAULT = 1 |
| 102 | igmp_app = 'org.opencord.igmp' |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 103 | acl_app = 'org.onosproject.acl' |
| 104 | aaa_app = 'org.opencord.aaa' |
| 105 | app = 'org.onosproject.cli' |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 106 | APP_NAME = 'org.ciena.xconnect' |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 107 | INTF_TX_DEFAULT = 'veth2' |
| 108 | INTF_RX_DEFAULT = 'veth0' |
| 109 | default_port_map = { |
| 110 | PORT_TX_DEFAULT : INTF_TX_DEFAULT, |
| 111 | PORT_RX_DEFAULT : INTF_RX_DEFAULT, |
| 112 | INTF_TX_DEFAULT : PORT_TX_DEFAULT, |
| 113 | INTF_RX_DEFAULT : PORT_RX_DEFAULT |
| 114 | } |
| 115 | vrouter_apps = ('org.onosproject.proxyarp', 'org.onosproject.hostprovider', 'org.onosproject.vrouter', 'org.onosproject.fwd') |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 116 | MAX_PORTS = 100 |
| 117 | subscriber_apps = ('org.opencord.aaa', 'org.onosproject.dhcp') |
| 118 | olt_apps = () #'org.opencord.cordmcast') |
| 119 | vtn_app = 'org.opencord.vtn' |
| 120 | table_app = 'org.ciena.cordigmp' |
| 121 | aaa_loaded = False |
| 122 | table_app_file = os.path.join(test_path, '..', 'apps/ciena-cordigmp-multitable-2.0-SNAPSHOT.oar') |
| 123 | app_file = os.path.join(test_path, '..', 'apps/ciena-cordigmp-2.0-SNAPSHOT.oar') |
| 124 | olt_app_file = os.path.join(test_path, '..', 'apps/olt-app-1.2-SNAPSHOT.oar') |
| 125 | olt_app_name = 'org.onosproject.olt' |
| 126 | onos_config_path = os.path.join(test_path, '..', 'setup/onos-config') |
| 127 | cpqd_path = os.path.join(test_path, '..', 'setup') |
| 128 | ovs_path = cpqd_path |
| 129 | test_services = ('IGMP', 'TRAFFIC') |
| 130 | num_joins = 0 |
| 131 | num_subscribers = 0 |
| 132 | leave_flag = True |
| 133 | num_channels = 0 |
| 134 | recv_timeout = False |
| 135 | onos_restartable = bool(int(os.getenv('ONOS_RESTART', 0))) |
| 136 | SUBSCRIBER_TIMEOUT = 300 |
| 137 | device_id = 'of:' + get_mac() |
| 138 | |
| 139 | CLIENT_CERT = """-----BEGIN CERTIFICATE----- |
| 140 | MIICuDCCAiGgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBizELMAkGA1UEBhMCVVMx |
| 141 | CzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5h |
| 142 | IEluYy4xHjAcBgkqhkiG9w0BCQEWD2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMd |
| 143 | RXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTYwNjA2MjExMjI3WhcN |
| 144 | MTcwNjAxMjExMjI3WjBnMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNV |
| 145 | BAoTCkNpZW5hIEluYy4xFzAVBgNVBAMUDnVzZXJAY2llbmEuY29tMR0wGwYJKoZI |
| 146 | hvcNAQkBFg51c2VyQGNpZW5hLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC |
| 147 | gYEAwvXiSzb9LZ6c7uNziUfKvoHO7wu/uiFC5YUpXbmVGuGZizbVrny0xnR85Dfe |
| 148 | +9R4diansfDhIhzOUl1XjN3YDeSS9OeF5YWNNE8XDhlz2d3rVzaN6hIhdotBkUjg |
| 149 | rUewjTg5OFR31QEyG3v8xR3CLgiE9xQELjZbSA07pD79zuUCAwEAAaNPME0wEwYD |
| 150 | VR0lBAwwCgYIKwYBBQUHAwIwNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL3d3dy5l |
| 151 | eGFtcGxlLmNvbS9leGFtcGxlX2NhLmNybDANBgkqhkiG9w0BAQUFAAOBgQDAjkrY |
| 152 | 6tDChmKbvr8w6Du/t8vHjTCoCIocHTN0qzWOeb1YsAGX89+TrWIuO1dFyYd+Z0KC |
| 153 | PDKB5j/ygml9Na+AklSYAVJIjvlzXKZrOaPmhZqDufi+rXWti/utVqY4VMW2+HKC |
| 154 | nXp37qWeuFLGyR1519Y1d6F/5XzqmvbwURuEug== |
| 155 | -----END CERTIFICATE-----""" |
| 156 | |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 157 | CLIENT_CERT_INVALID = '''-----BEGIN CERTIFICATE----- |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 158 | MIIDvTCCAqWgAwIBAgIBAjANBgkqhkiG9w0BAQUFADCBizELMAkGA1UEBhMCVVMx |
| 159 | CzAJBgNVBAgTAkNBMRIwEAYDVQQHEwlTb21ld2hlcmUxEzARBgNVBAoTCkNpZW5h |
| 160 | IEluYy4xHjAcBgkqhkiG9w0BCQEWD2FkbWluQGNpZW5hLmNvbTEmMCQGA1UEAxMd |
| 161 | RXhhbXBsZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMTYwMzExMTg1MzM2WhcN |
| 162 | MTcwMzA2MTg1MzM2WjBnMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNV |
| 163 | BAoTCkNpZW5hIEluYy4xFzAVBgNVBAMUDnVzZXJAY2llbmEuY29tMR0wGwYJKoZI |
| 164 | hvcNAQkBFg51c2VyQGNpZW5hLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC |
| 165 | AQoCggEBAOxemcBsPn9tZsCa5o2JA6sQDC7A6JgCNXXl2VFzKLNNvB9PS6D7ZBsQ |
| 166 | 5An0zEDMNzi51q7lnrYg1XyiE4S8FzMGAFr94RlGMQJUbRD9V/oqszMX4k++iAOK |
| 167 | tIA1gr3x7Zi+0tkjVSVzXTmgNnhChAamdMsjYUG5+CY9WAicXyy+VEV3zTphZZDR |
| 168 | OjcjEp4m/TSXVPYPgYDXI40YZKX5BdvqykWtT/tIgZb48RS1NPyN/XkCYzl3bv21 |
| 169 | qx7Mc0fcEbsJBIIRYTUkfxnsilcnmLxSYO+p+DZ9uBLBzcQt+4Rd5pLSfi21WM39 |
| 170 | 2Z2oOi3vs/OYAPAqgmi2JWOv3mePa/8CAwEAAaNPME0wEwYDVR0lBAwwCgYIKwYB |
| 171 | BQUHAwIwNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL3d3dy5leGFtcGxlLmNvbS9l |
| 172 | eGFtcGxlX2NhLmNybDANBgkqhkiG9w0BAQUFAAOCAQEALBzMPDTIB6sLyPl0T6JV |
| 173 | MjOkyldAVhXWiQsTjaGQGJUUe1cmUJyZbUZEc13MygXMPOM4x7z6VpXGuq1c/Vxn |
| 174 | VzQ2fNnbJcIAHi/7G8W5/SQfPesIVDsHTEc4ZspPi5jlS/MVX3HOC+BDbOjdbwqP |
| 175 | RX0JEr+uOyhjO+lRxG8ilMRACoBUbw1eDuVDoEBgErSUC44pq5ioDw2xelc+Y6hQ |
| 176 | dmtYwfY0DbvwxHtA495frLyPcastDiT/zre7NL51MyUDPjjYjghNQEwvu66IKbQ3 |
| 177 | T1tJBrgI7/WI+dqhKBFolKGKTDWIHsZXQvZ1snGu/FRYzg1l+R/jT8cRB9BDwhUt |
| 178 | yg== |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 179 | -----END CERTIFICATE-----''' |
| 180 | |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 181 | @classmethod |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 182 | def setUpCordApi(cls): |
A R Karthick | 037cb98 | 2017-07-07 17:35:30 -0700 | [diff] [blame] | 183 | num_subscribers = max(cls.NUM_SUBSCRIBERS, 10) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 184 | cls.cord_subscriber = CordSubscriberUtils(num_subscribers, |
| 185 | account_num = cls.SUBSCRIBER_ACCOUNT_NUM, |
| 186 | s_tag = cls.SUBSCRIBER_S_TAG, |
| 187 | c_tag = cls.SUBSCRIBER_C_TAG, |
| 188 | subscribers_per_s_tag = cls.SUBSCRIBERS_PER_S_TAG) |
| 189 | cls.restApiXos = XosUtils.getRestApi() |
| 190 | |
| 191 | @classmethod |
| 192 | def setUpClass(cls): |
| 193 | log.info('in setUp class 00000000000000') |
| 194 | cls.controllers = get_controllers() |
| 195 | cls.controller = cls.controllers[0] |
| 196 | cls.cli = None |
| 197 | cls.on_pod = running_on_pod() |
| 198 | cls.on_ciab = running_on_ciab() |
| 199 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
| 200 | cls.vcpes = cls.olt.get_vcpes() |
| 201 | cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp') |
| 202 | cls.vcpes_reserved = cls.olt.get_vcpes_by_type('reserved') |
| 203 | cls.dhcp_vcpes_reserved = [ 'vcpe{}.{}.{}'.format(i, cls.vcpes_reserved[i]['s_tag'], cls.vcpes_reserved[i]['c_tag']) |
| 204 | for i in xrange(len(cls.vcpes_reserved)) ] |
| 205 | cls.untagged_dhcp_vcpes_reserved = [ 'vcpe{}'.format(i) for i in xrange(len(cls.vcpes_reserved)) ] |
| 206 | cls.container_vcpes_reserved = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ] |
| 207 | vcpe_dhcp_reserved = None |
| 208 | vcpe_container_reserved = None |
| 209 | if cls.vcpes_reserved: |
| 210 | vcpe_dhcp_reserved = cls.dhcp_vcpes_reserved[0] |
| 211 | if cls.on_pod is False: |
| 212 | vcpe_dhcp_reserved = cls.untagged_dhcp_vcpes_reserved[0] |
| 213 | vcpe_container_reserved = cls.container_vcpes_reserved[0] |
| 214 | |
| 215 | cls.vcpe_dhcp_reserved = vcpe_dhcp_reserved |
| 216 | cls.vcpe_container_reserved = vcpe_container_reserved |
| 217 | dhcp_vcpe_offset = len(cls.vcpes_reserved) |
| 218 | cls.dhcp_vcpes = [ 'vcpe{}.{}.{}'.format(i+dhcp_vcpe_offset, cls.vcpes_dhcp[i]['s_tag'], cls.vcpes_dhcp[i]['c_tag']) |
| 219 | for i in xrange(len(cls.vcpes_dhcp)) ] |
| 220 | cls.untagged_dhcp_vcpes = [ 'vcpe{}'.format(i+dhcp_vcpe_offset) for i in xrange(len(cls.vcpes_dhcp)) ] |
| 221 | cls.container_vcpes = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_dhcp ] |
| 222 | vcpe_dhcp = None |
| 223 | vcpe_container = None |
| 224 | #cache the first dhcp vcpe in the class for quick testing |
| 225 | if cls.vcpes_dhcp: |
| 226 | vcpe_container = cls.container_vcpes[0] |
| 227 | vcpe_dhcp = cls.dhcp_vcpes[0] |
| 228 | if cls.on_pod is False: |
| 229 | vcpe_dhcp = cls.untagged_dhcp_vcpes[0] |
| 230 | cls.vcpe_container = vcpe_container_reserved or vcpe_container |
| 231 | cls.vcpe_dhcp = vcpe_dhcp_reserved or vcpe_dhcp |
| 232 | VSGAccess.setUp() |
| 233 | cls.setUpCordApi() |
| 234 | if cls.on_pod is True: |
| 235 | cls.openVCPEAccess(cls.cord_subscriber.volt_subscriber_info) |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 236 | |
| 237 | @classmethod |
| 238 | def tearDownClass(cls): |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 239 | VSGAccess.tearDown() |
| 240 | if cls.on_pod is True: |
| 241 | cls.closeVCPEAccess(cls.cord_subscriber.volt_subscriber_info) |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 242 | |
| 243 | def log_set(self, level = None, app = 'org.onosproject'): |
| 244 | CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 245 | ######################## vsg - vcpe utility functions ######################### |
| 246 | @classmethod |
| 247 | def closeVCPEAccess(cls, volt_subscriber_info): |
| 248 | OnosCtrl.uninstall_app(cls.APP_NAME, onos_ip = cls.HEAD_NODE) |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 249 | |
| 250 | @classmethod |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 251 | def openVCPEAccess(cls, volt_subscriber_info): |
| 252 | """ |
| 253 | This code is used to configure leaf switch for head node access to compute node over fabric. |
| 254 | Care is to be taken to avoid overwriting existing/default vcpe flows. |
| 255 | The access is opened for generated subscriber info which should not overlap. |
| 256 | We target the fabric onos instance on head node. |
| 257 | """ |
| 258 | version = Onos.getVersion(onos_ip = cls.HEAD_NODE) |
| 259 | app_version = '1.0-SNAPSHOT' |
| 260 | major = int(version.split('.')[0]) |
| 261 | minor = int(version.split('.')[1]) |
| 262 | if major > 1: |
| 263 | app_version = '2.0-SNAPSHOT' |
| 264 | elif major == 1 and minor > 10: |
| 265 | app_version = '2.0-SNAPSHOT' |
| 266 | cls.APP_FILE = os.path.join(cls.test_path, '..', 'apps/xconnect-{}.oar'.format(app_version)) |
| 267 | OnosCtrl.install_app(cls.APP_FILE, onos_ip = cls.HEAD_NODE) |
| 268 | time.sleep(2) |
| 269 | s_tags = map(lambda tenant: int(tenant['voltTenant']['s_tag']), volt_subscriber_info) |
| 270 | #only get unique vlan tags |
| 271 | s_tags = list(set(s_tags)) |
| 272 | devices = OnosCtrl.get_device_ids(controller = cls.HEAD_NODE) |
| 273 | if devices: |
| 274 | device_config = {} |
| 275 | for device in devices: |
| 276 | device_config[device] = [] |
| 277 | for s_tag in s_tags: |
| 278 | xconnect_config = {'vlan': s_tag, 'ports' : [ cls.FABRIC_PORT_HEAD_NODE, cls.FABRIC_PORT_COMPUTE_NODE ] } |
| 279 | device_config[device].append(xconnect_config) |
| 280 | |
| 281 | cfg = { 'apps' : { 'org.ciena.xconnect' : { 'xconnectTestConfig' : device_config } } } |
| 282 | OnosCtrl.config(cfg, controller = cls.HEAD_NODE) |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 283 | |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 284 | def get_system_cpu_usage(self): |
| 285 | """ Getting compute node CPU usage """ |
| 286 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 287 | cmd = "top -b -n1 | grep 'Cpu(s)' | awk '{print $2 + $4}'" |
| 288 | status, output = ssh_agent.run_cmd(cmd) |
| 289 | assert_equal(status, True) |
| 290 | return float(output) |
| 291 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 292 | def vsg_for_external_connectivity(self, subscriber_index, reserved = False): |
| 293 | if reserved is True: |
| 294 | if self.on_pod is True: |
| 295 | vcpe = self.dhcp_vcpes_reserved[subscriber_index] |
| 296 | else: |
| 297 | vcpe = self.untagged_dhcp_vcpes_reserved[subscriber_index] |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 298 | else: |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 299 | if self.on_pod is True: |
| 300 | vcpe = self.dhcp_vcpes[subscriber_index] |
| 301 | else: |
| 302 | vcpe = self.untagged_dhcp_vcpes[subscriber_index] |
| 303 | mgmt = 'eth0' |
| 304 | host = '8.8.8.8' |
| 305 | self.success = False |
| 306 | assert_not_equal(vcpe, None) |
| 307 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 308 | assert_not_equal(vcpe_ip, None) |
| 309 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 310 | log.info('Sending icmp echo requests to external network 8.8.8.8') |
| 311 | st, _ = getstatusoutput('ping -c 3 8.8.8.8') |
| 312 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 313 | assert_equal(st, 0) |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 314 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 315 | def vsg_xos_subscriber_create(self, index, subscriber_info = None, volt_subscriber_info = None): |
| 316 | if self.on_pod is False: |
| 317 | return '' |
| 318 | if subscriber_info is None: |
| 319 | subscriber_info = self.cord_subscriber.subscriber_info[index] |
| 320 | if volt_subscriber_info is None: |
| 321 | volt_subscriber_info = self.cord_subscriber.volt_subscriber_info[index] |
| 322 | s_tag = int(volt_subscriber_info['voltTenant']['s_tag']) |
| 323 | c_tag = int(volt_subscriber_info['voltTenant']['c_tag']) |
| 324 | vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag) |
| 325 | subId = self.cord_subscriber.subscriberCreate(index, subscriber_info, volt_subscriber_info) |
| 326 | if subId: |
| 327 | #if the vsg instance was already instantiated, then reduce delay |
| 328 | if c_tag % self.SUBSCRIBERS_PER_S_TAG == 0: |
| 329 | delay = 350 |
| 330 | else: |
| 331 | delay = 90 |
| 332 | log.info('Delaying %d seconds for the VCPE to be provisioned' %(delay)) |
| 333 | time.sleep(delay) |
| 334 | #log.info('Testing for external connectivity to VCPE %s' %(vcpe)) |
| 335 | #self.vsg_for_external_connectivity(index) |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 336 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 337 | return subId |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 338 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 339 | def vsg_delete(self, num_subscribers): |
| 340 | if self.on_pod is False: |
| 341 | return |
| 342 | num_subscribers = min(num_subscribers, len(self.cord_subscriber.subscriber_info)) |
| 343 | for index in xrange(num_subscribers): |
| 344 | subId = self.vsg_xos_subscriber_id(index) |
| 345 | if subId and subId != '0': |
| 346 | self.vsg_xos_subscriber_delete(index, subId = subId) |
| 347 | |
| 348 | def vsg_xos_subscriber_delete(self, index, subId = '', voltId = '', subscriber_info = None, volt_subscriber_info = None): |
| 349 | if self.on_pod is False: |
| 350 | return |
| 351 | self.cord_subscriber.subscriberDelete(index, subId = subId, voltId = voltId, |
| 352 | subscriber_info = subscriber_info, |
| 353 | volt_subscriber_info = volt_subscriber_info) |
| 354 | |
| 355 | def vsg_xos_subscriber_id(self, index): |
| 356 | if self.on_pod is False: |
| 357 | return '' |
| 358 | return self.cord_subscriber.subscriberId(index) |
| 359 | |
| 360 | def vsg_xos_subscriber_create_reserved(self): |
| 361 | if self.on_pod is False: |
| 362 | return |
| 363 | tags_reserved = [ (int(vcpe['s_tag']), int(vcpe['c_tag'])) for vcpe in self.vcpes_reserved ] |
| 364 | volt_tenants = self.restApiXos.ApiGet('TENANT_VOLT') |
| 365 | subscribers = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 366 | reserved_tenants = filter(lambda tenant: (int(tenant['s_tag']), int(tenant['c_tag'])) in tags_reserved, volt_tenants) |
| 367 | reserved_config = [] |
| 368 | for tenant in reserved_tenants: |
| 369 | for subscriber in subscribers: |
| 370 | if int(subscriber['id']) == int(tenant['subscriber']): |
| 371 | volt_subscriber_info = {} |
| 372 | volt_subscriber_info['voltTenant'] = dict(s_tag = tenant['s_tag'], |
| 373 | c_tag = tenant['c_tag'], |
| 374 | subscriber = tenant['subscriber']) |
| 375 | volt_subscriber_info['volt_id'] = tenant['id'] |
| 376 | volt_subscriber_info['account_num'] = subscriber['identity']['account_num'] |
| 377 | reserved_config.append( (subscriber, volt_subscriber_info) ) |
| 378 | break |
| 379 | else: |
| 380 | log.info('Subscriber not found for tenant %s, s_tag: %s, c_tag: %s' %(str(tenant['subscriber']), |
| 381 | str(tenant['s_tag']), |
| 382 | str(tenant['c_tag']))) |
| 383 | |
| 384 | for subscriber_info, volt_subscriber_info in reserved_config: |
| 385 | self.vsg_xos_subscriber_delete(0, |
| 386 | subId = str(subscriber_info['id']), |
| 387 | voltId = str(volt_subscriber_info['volt_id']), |
| 388 | subscriber_info = subscriber_info, |
| 389 | volt_subscriber_info = volt_subscriber_info) |
| 390 | subId = self.vsg_xos_subscriber_create(0, |
| 391 | subscriber_info = subscriber_info, |
| 392 | volt_subscriber_info = volt_subscriber_info) |
| 393 | log.info('Created reserved subscriber %s' %(subId)) |
| 394 | |
| 395 | @deferred(1800) |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 396 | def test_scale_for_vsg_vm_creations(self): |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 397 | try: |
| 398 | df = defer.Deferred() |
| 399 | def scale_vsg_vms(df): |
| 400 | for index in xrange(len(self.cord_subscriber.subscriber_info)): |
| 401 | #check if the index exists |
| 402 | subId = self.vsg_xos_subscriber_id(index) |
| 403 | log.info('test_vsg_xos_subscriber_creation - subId is %s'%subId) |
| 404 | if subId and subId != '0': |
| 405 | self.vsg_xos_subscriber_delete(index, subId = subId) |
| 406 | subId = self.vsg_xos_subscriber_create(index) |
| 407 | log.info('Created Subscriber %s' %(subId)) |
| 408 | df.callback(0) |
| 409 | reactor.callLater(0, scale_vsg_vms, df) |
| 410 | return df |
| 411 | finally: |
| 412 | pass |
| 413 | #self.vsg_delete(len(self.cord_subscriber.subscriber_info)) |
| 414 | self.vsg_xos_subscriber_create_reserved |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 415 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 416 | @deferred(1800) |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 417 | def test_scale_for_vcpe_creations(self): |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 418 | try: |
| 419 | df = defer.Deferred() |
| 420 | def scale_vcpe_instances(df): |
| 421 | for index in xrange(len(self.cord_subscriber.subscriber_info)): |
| 422 | #check if the index exists |
| 423 | subId = self.vsg_xos_subscriber_id(index) |
| 424 | log.info('test_vsg_xos_subscriber_creation') |
| 425 | if subId and subId != '0': |
| 426 | self.vsg_xos_subscriber_delete(index, subId = subId) |
| 427 | subId = self.vsg_xos_subscriber_create(index) |
| 428 | log.info('Created Subscriber %s' %(subId)) |
| 429 | df.callback(0) |
| 430 | reactor.callLater(0, scale_vcpe_instances, df) |
| 431 | return df |
| 432 | except: |
| 433 | self.vsg_delete(len(self.cord_subscriber.subscriber_info)) |
| 434 | self.vsg_xos_subscriber_create_reserved |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 435 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 436 | @deferred(1800) |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 437 | def test_scale_of_subcriber_vcpe_creations_in_single_vsg_vm(self): |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 438 | try: |
| 439 | df = defer.Deferred() |
| 440 | def scale_vcpe_instances(df): |
| 441 | subId = self.vsg_xos_subscriber_create(100) |
| 442 | if subId and subId != '0': |
| 443 | self.vsg_xos_subscriber_delete(100, subId) |
| 444 | df.callback(0) |
| 445 | reactor.callLater(0, scale_vsg_vms, df) |
| 446 | return df |
| 447 | except: |
| 448 | self.vsg_delete(len(self.cord_subscriber.subscriber_info)) |
| 449 | self.vsg_xos_subscriber_create_reserved |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 450 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 451 | @deferred(1800) |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 452 | def test_scale_of_subcriber_vcpe_creations_in_multiple_vsg_vm(self): |
A R Karthick | 037cb98 | 2017-07-07 17:35:30 -0700 | [diff] [blame] | 453 | try: |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 454 | df = defer.Deferred() |
| 455 | def scale_vcpe_instances(df): |
| 456 | subId = self.vsg_xos_subscriber_create(100) |
| 457 | if subId and subId != '0': |
| 458 | self.vsg_xos_subscriber_delete(100, subId) |
| 459 | df.callback(0) |
| 460 | reactor.callLater(0, scale_vsg_vms, df) |
| 461 | return df |
| 462 | except: |
| 463 | self.vsg_delete(len(self.cord_subscriber.subscriber_info)) |
| 464 | self.vsg_xos_subscriber_create_reserved |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 465 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 466 | @deferred(1800) |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 467 | def test_scale_of_subcriber_vcpe_creations_with_one_vcpe_in_one_vsg_vm(self): |
A R Karthick | 037cb98 | 2017-07-07 17:35:30 -0700 | [diff] [blame] | 468 | try: |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 469 | df = defer.Deferred() |
| 470 | def scale_vcpe_instances(df): |
| 471 | subId = self.vsg_xos_subscriber_create(100) |
| 472 | if subId and subId != '0': |
| 473 | self.vsg_xos_subscriber_delete(100, subId) |
| 474 | df.callback(0) |
| 475 | reactor.callLater(0, scale_vsg_vms, df) |
| 476 | return df |
| 477 | except: |
| 478 | self.vsg_delete(len(self.cord_subscriber.subscriber_info)) |
| 479 | self.vsg_xos_subscriber_create_reserved |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 480 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 481 | @deferred(1800) |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 482 | def test_scale_for_cord_subscriber_creation_and_deletion(self): |
A R Karthick | 037cb98 | 2017-07-07 17:35:30 -0700 | [diff] [blame] | 483 | try: |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 484 | df = defer.Deferred() |
| 485 | def scale_vcpe_instances(df): |
| 486 | subId = self.vsg_xos_subscriber_create(100) |
| 487 | if subId and subId != '0': |
| 488 | self.vsg_xos_subscriber_delete(100, subId) |
| 489 | df.callback(0) |
| 490 | reactor.callLater(0, scale_vsg_vms, df) |
| 491 | return df |
| 492 | except: |
| 493 | self.vsg_delete(len(self.cord_subscriber.subscriber_info)) |
| 494 | self.vsg_xos_subscriber_create_reserved |
Chetan Gaonker | 357f489 | 2017-06-19 19:38:27 +0000 | [diff] [blame] | 495 | |
| 496 | def test_cord_for_scale_of_subscriber_containers_per_compute_node(self): |
| 497 | pass |
| 498 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 499 | @deferred(10) |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 500 | def test_latency_of_cord_for_control_packets_using_icmp_packet(self): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 501 | """ |
| 502 | Test-Method: |
| 503 | 1. Ping from cord-tester to wan interface IP of CiaB setup |
| 504 | 2. Grep latency of ping packets |
| 505 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 506 | df = defer.Deferred() |
| 507 | def scale_vcpe_instances(df): |
| 508 | cmd = "ping -c 4 {0} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip) |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 509 | st, out = getstatusoutput(cmd) |
| 510 | if out != '': |
| 511 | out = out.split('/') |
| 512 | avg_rtt = out[1] |
| 513 | latency = float(avg_rtt)/float(2) |
| 514 | else: |
| 515 | latency = None |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 516 | log.info('CORD setup latency calculated from icmp packet is = %s ms'%latency) |
| 517 | assert_not_equal(latency,None) |
| 518 | df.callback(0) |
| 519 | reactor.callLater(0, scale_vsg_vms, df) |
| 520 | return df |
| 521 | |
| 522 | @deferred(20) |
| 523 | def test_latency_of_cord_for_control_packets_using_increasing_sizes_of_icmp_packet(self): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 524 | """ |
| 525 | Test-Method: |
| 526 | 1. Ping from cord-tester to wan interface IP of CiaB setup |
| 527 | 2. Grep the latency of ping packet |
| 528 | 3. Repeat the process for varying sizes of ping packets |
| 529 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 530 | df = defer.Deferred() |
| 531 | def scale_vcpe_instances(df): |
| 532 | pckt_sizes = [100,500,1000,1500] |
| 533 | for size in pckt_sizes: |
| 534 | cmd = "ping -c 4 -s {} {} | tail -1| awk '{{print $4}}'".format(size,self.wan_intf_ip) |
| 535 | st, out = getstatusoutput(cmd) |
| 536 | if out != '': |
| 537 | out = out.split('/') |
| 538 | avg_rtt = out[1] |
| 539 | latency = float(avg_rtt)/float(2) |
| 540 | else: |
| 541 | latency = None |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 542 | log.info('CORD setup latency calculated from icmp packet with size %s bytes is = %s ms'%(size,latency)) |
| 543 | assert_not_equal(latency,None) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 544 | df.callback(0) |
| 545 | reactor.callLater(0, scale_vsg_vms, df) |
| 546 | return df |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 547 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 548 | @deferred(10) |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 549 | def test_latency_of_cord_with_traceroute(self): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 550 | """ |
| 551 | Test-Method: |
| 552 | 1. Traceroute from cord-tester to wan interface IP of CiaB setup |
| 553 | 2. Grep the latency of ping packet |
| 554 | 3. Repeat the process for varying sizes of ping packets |
| 555 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 556 | df = defer.Deferred() |
| 557 | def scale_vcpe_instances(df): |
| 558 | cmd = "traceroute -q1 {} | tail -1| awk '{{print $4}}'".format(self.wan_intf_ip) |
| 559 | avg_rtt = float(0) |
| 560 | latency = None |
| 561 | for index in [1,2,3]: |
| 562 | st, out = getstatusoutput(cmd) |
| 563 | if out != '': |
| 564 | avg_rtt += float(out) |
| 565 | latency = float(avg_rtt)/float(6) |
| 566 | log.info('CORD setup latency calculated from traceroute is = %s ms'%latency) |
| 567 | assert_not_equal(latency,0.0) |
| 568 | assert_not_equal(latency,None) |
| 569 | df.callback(0) |
| 570 | reactor.callLater(0, scale_vsg_vms, df) |
| 571 | return df |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 572 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 573 | #tested with 50 igmp joins on CiaB setup |
| 574 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 575 | def test_scale_with_igmp_joins_for_multicast_groups_validating_cpu_usage(self, group_count=500): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 576 | """ |
| 577 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 578 | 1. Register 500 (group count is number to test) igmp groups in onos |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 579 | 2. Send igmp joins for registered groups |
| 580 | 3. Send multicast traffic to all registered groups |
| 581 | 4. Verify traffic forwards properly |
| 582 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 583 | df = defer.Deferred() |
| 584 | def scale_igmp_joins(df): |
| 585 | OnosCtrl(self.igmp_app).activate() |
| 586 | groups = scale().generate_random_multicast_ip_addresses(count = group_count) |
| 587 | sources = scale().generate_random_unicast_ip_addresses(count = group_count) |
| 588 | scale().onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 589 | try: |
| 590 | for index in range(group_count): |
| 591 | scale().send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 592 | iface = self.V_INF1) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 593 | status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index]) |
| 594 | assert_equal(status, True) |
| 595 | log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index)) |
| 596 | except Exception as error: |
| 597 | log.info('Got unexpected error %s'%error) |
| 598 | raise |
| 599 | df.callback(0) |
| 600 | reactor.callLater(0, scale_igmp_joins, df) |
| 601 | return df |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 602 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 603 | #tested with 50 igmp joins on CiaB setup |
| 604 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 605 | def test_scale_with_igmp_joins_for_multicast_groups_toggling_igmp_app(self, group_count=1000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 606 | """ |
| 607 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 608 | 1. Register 1000 (group_count is a number to test, can increase the number)igmp groups in onos |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 609 | 2. Send igmp joins for registered groups |
| 610 | 3. Send multicast traffic to all registered groups |
| 611 | 4. Verify traffic forwards properly |
| 612 | 5. deactivate and activate igmp app in onos |
| 613 | 6. Verify multicast traffic do not forward after igmp app deactivated |
| 614 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 615 | df = defer.Deferred() |
| 616 | def scale_igmp_joins(df): |
| 617 | OnosCtrl(self.igmp_app).activate() |
| 618 | groups = scale().generate_random_multicast_ip_addresses(count = group_count) |
| 619 | sources = scale().generate_random_unicast_ip_addresses(count = group_count) |
| 620 | scale().onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 621 | try: |
| 622 | for index in range(group_count): |
| 623 | scale().send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 624 | iface = self.V_INF1) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 625 | status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index]) |
| 626 | assert_equal(status, True) |
| 627 | log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index)) |
| 628 | log_test.info('Deactivating igmp app in onos') |
| 629 | OnosCtrl(self.igmp_app).deactivate() |
| 630 | time.sleep(2) |
| 631 | for index in range(group_count): |
| 632 | status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index]) |
| 633 | assert_equal(status, False) |
| 634 | log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index)) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 635 | OnosCtrl(self.igmp_app).activate() |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 636 | except Exception as error: |
| 637 | log.info('Got unexpected error %s'%error) |
| 638 | OnosCtrl(self.igmp_app).activate() |
| 639 | raise |
| 640 | df.callback(0) |
| 641 | reactor.callLater(0, scale_igmp_joins, df) |
| 642 | return df |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 643 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 644 | #tested with 50 igmp joins on CiaB setup |
| 645 | @deferred(1800) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 646 | def test_scale_with_igmp_joins_for_multicast_groups_validating_cpu_usage(self, group_count=2000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 647 | """ |
| 648 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 649 | 1. Register (group count value to test) igmp groups in onos |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 650 | 2. Send igmp joins for registered groups |
| 651 | 3. Send multicast traffic to all registered groups |
| 652 | 4. Verify traffic forwards properly |
| 653 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 654 | df = defer.Deferred() |
| 655 | def scale_igmp_joins(df): |
| 656 | OnosCtrl(self.igmp_app).activate() |
| 657 | groups = scale().generate_random_multicast_ip_addresses(count = group_count) |
| 658 | sources = scale().generate_random_unicast_ip_addresses(count = group_count) |
| 659 | scale().onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 660 | try: |
| 661 | for index in range(group_count): |
| 662 | scale().send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 663 | iface = self.V_INF1) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 664 | status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index]) |
| 665 | assert_equal(status, True) |
| 666 | log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index)) |
| 667 | if index % 50 == 0: |
| 668 | cpu_usage = scale().get_system_cpu_usage() |
| 669 | log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1)) |
| 670 | except Exception as error: |
| 671 | log.info('Got unexpected error %s'%error) |
| 672 | raise |
| 673 | df.callback(0) |
| 674 | reactor.callLater(0, scale_igmp_joins, df) |
| 675 | return df |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 676 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 677 | #tested with 50 igmp joins on CiaB setup |
| 678 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 679 | def test_scale_of_igmp_joins_for_multicast_groups_validating_cpu_usage_after_app_deactivation_and_activation(self,group_count=2000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 680 | """ |
| 681 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 682 | 1. Register 2000 (Number to test) igmp groups in onos |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 683 | 2. Send igmp joins for registered groups |
| 684 | 3. Send multicast traffic to all registered groups |
| 685 | 4. Verify traffic forwards properly |
| 686 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 687 | df = defer.Deferred() |
| 688 | def scale_igmp_joins(df): |
| 689 | cpu_usage1 = scale().get_system_cpu_usage() |
| 690 | OnosCtrl(self.igmp_app).activate() |
| 691 | groups = scale().generate_random_multicast_ip_addresses(count = group_count) |
| 692 | sources = scale().generate_random_unicast_ip_addresses(count = group_count) |
| 693 | scale().onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 694 | try: |
| 695 | for index in range(group_count): |
| 696 | scale().send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
Anil Kumar Sanka | 12a5ec5 | 2017-06-29 18:41:51 +0000 | [diff] [blame] | 697 | iface = self.V_INF1) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 698 | status = scale().verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index]) |
| 699 | assert_equal(status, True) |
| 700 | log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index)) |
| 701 | if index % 50 == 0: |
| 702 | cpu_usage = self.get_system_cpu_usage() |
| 703 | log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1)) |
| 704 | cpu_usage2 = scale().get_system_cpu_usage() |
| 705 | OnosCtrl(self.igmp_app).deactivate() |
| 706 | time.sleep(2) |
| 707 | cpu_usage3 = scale().get_system_cpu_usage() |
| 708 | 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)) |
| 709 | except Exception as error: |
| 710 | log.info('Got unexpected error %s'%error) |
| 711 | raise |
| 712 | df.callback(0) |
| 713 | reactor.callLater(0, scale_igmp_joins, df) |
| 714 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 715 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 716 | #tested with 100 flow entries on CiaB setup |
| 717 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 718 | def test_scale_adding_large_number_of_flow_entries_for_tcp_ports(self,count=1000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 719 | """ |
| 720 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 721 | 1. Add 1000 (Large number to test) flow entries with varying tcp port number in onos |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 722 | 2. Send data traffic for added tcp port numbers |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 723 | 3. Verify onos forwards data traffic properly |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 724 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 725 | scale().flows_setup() |
| 726 | df = defer.Deferred() |
| 727 | def scale_flow_entries(df): |
| 728 | egress = 1 |
| 729 | ingress = 2 |
| 730 | egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'tcp_port': random.randint(1024,65535) } |
| 731 | ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'tcp_port': random.randint(1024,65535) } |
| 732 | try: |
| 733 | for index in range(0,count): |
| 734 | ingress_map['tcp_port'] = random.randint(1024,65535) |
| 735 | egress_map['tcp_port'] = random.randint(1024,65535) |
| 736 | src_port = ingress_map['tcp_port'] |
| 737 | egr_port = egress_map['tcp_port'] |
| 738 | #log.info('ingress port is %d and egress port is %d'%(src_port,egr_port)) |
| 739 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 740 | egressPort = egress + scale().port_offset, |
| 741 | ingressPort = ingress + scale().port_offset, |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 742 | tcpSrc = ingress_map['tcp_port'], |
| 743 | tcpDst = egress_map['tcp_port'] |
| 744 | ) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 745 | result = flow.addFlow() |
| 746 | assert_equal(result, True) |
| 747 | log_test.info("flow number = %d is added",index+1) |
| 748 | def mac_recv_task(): |
| 749 | def recv_cb(pkt): |
| 750 | log_test.info('Pkt seen with ingress TCP port %s, egress TCP port %s' %(pkt[TCP].sport, pkt[TCP].dport)) |
| 751 | result = True |
| 752 | sniff(count=2, timeout=5, |
| 753 | 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]) |
| 754 | t = threading.Thread(target = mac_recv_task) |
| 755 | t.start() |
| 756 | L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether']) |
| 757 | L3 = IP(src = ingress_map['ip'], dst = egress_map['ip']) |
| 758 | L4 = TCP(sport = src_port, dport = egr_port) |
| 759 | pkt = L2/L3/L4 |
| 760 | log_test.info('Sending packets to verify if flows are correct') |
| 761 | sendp(pkt, count=50, iface = scale().port_map[ingress]) |
| 762 | t.join() |
| 763 | except Exception as error: |
| 764 | log.info('Got unexpected error %s'%error) |
| 765 | raise |
| 766 | df.callback(0) |
| 767 | reactor.callLater(0,scale_flow_entries, df) |
| 768 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 769 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 770 | #tested with 100 flow entries on CiaB setup |
| 771 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 772 | def test_scale_adding_ip_flow_entries_validating_cpu_usage(self,count=5000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 773 | """ |
| 774 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 775 | 1. Add 5000(Edit count as per test requirement) flow entries with varying source and destination IP |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 776 | 2. Send data traffic matching flow entries |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 777 | 3. Verify onos forwards data traffic properly |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 778 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 779 | scale().flows_setup() |
| 780 | df = defer.Deferred() |
| 781 | def scale_flow_entries(df): |
| 782 | cpu_usage1 = scale().get_system_cpu_usage() |
| 783 | egress = 1 |
| 784 | ingress = 2 |
| 785 | egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '182.0.0.0' } |
| 786 | ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.0.0.0' } |
| 787 | try: |
| 788 | for index in range(0,count): |
| 789 | ingress_map['ip'] = scale().generate_random_unicast_ip_addresses()[0] #next_ip(ingress_map['ip']) |
| 790 | assert_not_equal(ingress_map['ip'], None) |
| 791 | egress_map['ip'] = scale().generate_random_unicast_ip_addresses()[0] #to_egress_ip(ingress_map['ip']) |
| 792 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 793 | egressPort = egress + scale().port_offset, |
| 794 | ingressPort = ingress + scale().port_offset, |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 795 | ethType = '0x0800', |
| 796 | ipSrc = ('IPV4_SRC', ingress_map['ip']+'/8'), |
| 797 | ipDst = ('IPV4_DST', egress_map['ip']+'/8') |
| 798 | ) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 799 | if index % 50 == 0: |
| 800 | cpu_usage = scale().get_system_cpu_usage() |
| 801 | log.info('CPU usage is %s for flow number %d added'%(cpu_usage,index+1)) |
| 802 | time.sleep(1) |
| 803 | def mac_recv_task(): |
| 804 | def recv_cb(pkt): |
| 805 | log_test.info('Pkt seen with ingress source IP %s, destination IP %s' %(pkt[IP].src, pkt[IP].dst)) |
| 806 | result = True |
| 807 | sniff(count=2, timeout=5, |
| 808 | 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]) |
| 809 | t = threading.Thread(target = mac_recv_task) |
| 810 | t.start() |
| 811 | L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether']) |
| 812 | L3 = IP(src = ingress_map['ip'], dst = egress_map['ip']) |
| 813 | pkt = L2/L3 |
| 814 | log_test.info('Sending packets to verify if flows are correct') |
| 815 | sendp(pkt, count=50, iface = scale().port_map[ingress]) |
| 816 | t.join() |
| 817 | cpu_usage2 = scale().get_system_cpu_usage() |
| 818 | log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2)) |
| 819 | except Exception as error: |
| 820 | log.info('Got unexpected error %s'%error) |
| 821 | raise |
| 822 | df.callback(0) |
| 823 | reactor.callLater(0, scale_flow_entries, df) |
| 824 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 825 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 826 | #tested with 100 flow entries on CiaB setup |
| 827 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 828 | def test_scale_adding_flow_entries_with_udp_ports(self,count=10000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 829 | """ |
| 830 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 831 | 1. Add 10000 (Number as per test requirement)flow entries with varying udp port number in onos |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 832 | 2. Send data traffic matching flow entries |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 833 | 3. Verify onos forwards data traffic properly |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 834 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 835 | scale().flows_setup() |
| 836 | df = defer.Deferred() |
| 837 | def scale_flow_entries(df): |
| 838 | egress = 1 |
| 839 | ingress = 2 |
| 840 | egress_map = { 'ether': '00:00:00:00:00:03', 'ip': '192.168.30.1', 'udp_port': random.randint(1024,65535) } |
| 841 | ingress_map = { 'ether': '00:00:00:00:00:04', 'ip': '192.168.40.1', 'udp_port': random.randint(1024,65535) } |
| 842 | try: |
| 843 | for index in range(0,count): |
| 844 | ingress_map['udp_port'] = random.randint(1024,65535) |
| 845 | egress_map['udp_port'] = random.randint(1024,65535) |
| 846 | src_port = ingress_map['udp_port'] |
| 847 | egr_port = egress_map['udp_port'] |
| 848 | #log.info('ingress port is %d and egress port is %d'%(src_port,egr_port)) |
| 849 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 850 | egressPort = egress + scale().port_offset, |
| 851 | ingressPort = ingress + scale().port_offset, |
| 852 | udpSrc = ingress_map['udp_port'], |
| 853 | udpDst = egress_map['udp_port'] |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 854 | ) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 855 | result = flow.addFlow() |
| 856 | assert_equal(result, True) |
| 857 | log_test.info("flow number = %d is added",index+1) |
| 858 | def mac_recv_task(): |
| 859 | def recv_cb(pkt): |
| 860 | log_test.info('Pkt seen with ingress UDP port %s, egress UDP port %s' %(pkt[UDP].sport, pkt[UDP].dport)) |
| 861 | result = True |
| 862 | sniff(count=2, timeout=5, |
| 863 | 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]) |
| 864 | t = threading.Thread(target = mac_recv_task) |
| 865 | t.start() |
| 866 | L2 = Ether(src = ingress_map['ether'], dst = egress_map['ether']) |
| 867 | L3 = IP(src = ingress_map['ip'], dst = egress_map['ip']) |
| 868 | L4 = UDP(sport = src_port, dport = egr_port) |
| 869 | pkt = L2/L3/L4 |
| 870 | log_test.info('Sending packets to verify if flows are correct') |
| 871 | sendp(pkt, count=50, iface = scale().port_map[ingress]) |
| 872 | t.join() |
| 873 | except Exception as error: |
| 874 | log.info('Got unexpected error %s'%error) |
| 875 | raise |
| 876 | df.callback(0) |
| 877 | reactor.callLater(0,scale_flow_entries, df) |
| 878 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 879 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 880 | #tested with 100 flow entries on CiaB setup |
| 881 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 882 | def test_scale_adding_constant_destination_mac_flow_entries_validating_cpu_usage(self,count=100): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 883 | """ |
| 884 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 885 | 1. Add 100(Change number as per requirement) flow entries with varying source mac |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 886 | 2. Send data traffic matching flow entries |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 887 | 3. Verify onos forwards data traffic properly |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 888 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 889 | scale().flows_setup() |
| 890 | df = defer.Deferred() |
| 891 | def scale_flow_entries(df): |
| 892 | cpu_usage1 = self.get_system_cpu_usage() |
| 893 | egress = 1 |
| 894 | ingress = 2 |
| 895 | egress_mac = '02:00:00:00:0:0' |
| 896 | ingress_mac = '03:00:00:00:00:00' |
| 897 | try: |
| 898 | for index in range(0,count): |
| 899 | result = False |
| 900 | ingress_mac = scale().next_mac(ingress_mac) |
| 901 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 902 | egressPort = egress + scale().port_offset, |
| 903 | ingressPort = ingress + scale().port_offset, |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 904 | ethSrc = ingress_mac, |
| 905 | ethDst = egress_mac) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 906 | result = flow.addFlow() |
| 907 | assert_equal(result, True) |
| 908 | log.info("flow number = %d is added",index+1) |
| 909 | if index % 100 == 0: |
| 910 | cpu_usage = scale().get_system_cpu_usage() |
| 911 | log.info('CPU usage is %s for multicast group entries %s'%(cpu_usage,index+1)) |
| 912 | time.sleep(1) |
| 913 | def mac_recv_task(): |
| 914 | def recv_cb(pkt): |
| 915 | log_test.info('Pkt seen with ingress mac %s, egress mac %s' %(pkt.src , pkt.dst)) |
| 916 | result = True |
| 917 | sniff(count=2, timeout=5, |
| 918 | lfilter = lambda p: p.src == ingress_mac and p.dst == egress_mac ,prn = recv_cb, iface = scale().port_map[egress]) |
| 919 | t = threading.Thread(target = mac_recv_task) |
| 920 | t.start() |
| 921 | L2 = Ether(src = ingress_mac, dst = egress_mac) |
| 922 | pkt = L2/IP() |
| 923 | log_test.info('Sending packets to verify if flows are correct') |
| 924 | sendp(pkt, count=50, iface = scale().port_map[ingress]) |
| 925 | t.join() |
| 926 | assert_equal(result, True) |
| 927 | cpu_usage2 = self.get_system_cpu_usage() |
| 928 | log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2)) |
| 929 | except Exception as error: |
| 930 | log.info('Got unexpected error %s'%error) |
| 931 | raise |
| 932 | df.callback(0) |
| 933 | reactor.callLater(0,scale_flow_entries, df) |
| 934 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 935 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 936 | |
| 937 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 938 | def test_scale_adding_acl_rules_to_deny_matching_destination_tcp_port_traffic(self,count=10000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 939 | """ |
| 940 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 941 | 1. Add 10000 (Adjust number as per test requirement)acl deny rules with varying tcp port number |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 942 | 2. Send data traffic matching flow entries |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 943 | 3. Verify onos drops data traffic properly |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 944 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 945 | df = defer.Deferred() |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 946 | def scale_acl_rules(df): |
| 947 | acl_rule = ACLTest() |
| 948 | ingress = self.ingress_iface |
| 949 | egress = self.CURRENT_PORT_NUM |
| 950 | 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) |
| 951 | self.CURRENT_PORT_NUM += 1 |
| 952 | time.sleep(5) |
| 953 | assert_equal(status, True) |
| 954 | srcMac = '00:00:00:00:00:11' |
| 955 | dstMac = host_ip_mac[0][1] |
| 956 | scale().acl_hosts_add(dstHostIpMac = host_ip_mac, egress_iface_count = 1, egress_iface_num = egress ) |
| 957 | try: |
| 958 | for index in range(0,count): |
| 959 | 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) |
| 960 | self.CURRENT_PORT_NUM += 1 |
| 961 | src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 962 | dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 963 | dst_port = random.randint(1024,65535) |
| 964 | 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)) |
| 965 | status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip, ipProto ='TCP', dstTpPort =dst_port, action = 'deny') |
| 966 | assert_equal(status, True) |
| 967 | 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) |
| 968 | scale().acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress) |
| 969 | except Exception as error: |
| 970 | log.info('Got unexpected error %s'%error) |
| 971 | self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress) |
| 972 | raise |
| 973 | df.callback(0) |
| 974 | reactor.callLater(0, scale_vsg_vms, df) |
| 975 | return df |
| 976 | |
| 977 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 978 | def test_scale_adding_acl_rules_to_allow_src_and_dst_ip_matching_traffic_validating_cpu_usage(self,count=10000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 979 | """ |
| 980 | Test-Method: |
| 981 | 1. Grep system usage before starting test case |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 982 | 2. Configure 10000(As per test requirement) acl rules in onos |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 983 | 3. Verify traffic test for all 10000 acl rules configured |
| 984 | 4. Grep system usage again now |
| 985 | """ |
| 986 | df = defer.Deferred() |
| 987 | def scale_acl_rules(df): |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 988 | cpu_usage1 = self.get_system_cpu_usage() |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 989 | ingress = self.ingress_iface |
| 990 | egress = self.CURRENT_PORT_NUM |
| 991 | 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) |
| 992 | self.CURRENT_PORT_NUM += 1 |
| 993 | time.sleep(5) |
| 994 | assert_equal(status, True) |
| 995 | srcMac = '00:00:00:00:00:11' |
| 996 | dstMac = host_ip_mac[0][1] |
| 997 | self.acl_hosts_add(dstHostIpMac = host_ip_mac, egress_iface_count = 1, egress_iface_num = egress ) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 998 | acl_rule = ACLTest() |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 999 | try: |
| 1000 | for index in range(0,count): |
| 1001 | 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) |
| 1002 | self.CURRENT_PORT_NUM += 1 |
| 1003 | src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1004 | dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1005 | dst_port = random.randint(1024,65535) |
| 1006 | log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip)) |
| 1007 | status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow') |
| 1008 | assert_equal(status, True) |
| 1009 | 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) |
| 1010 | if index % 100 == 0: |
| 1011 | cpu_usage = self.get_system_cpu_usage() |
| 1012 | log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1)) |
| 1013 | time.sleep(1) |
| 1014 | self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress) |
| 1015 | except Exception as error: |
| 1016 | log.info('Got unexpected error %s'%error) |
| 1017 | self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress) |
| 1018 | raise |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1019 | cpu_usage2 = self.get_system_cpu_usage() |
| 1020 | log.info('system cpu usage before flows added = %f and after %d flows added = %f'%(cpu_usage1,count,cpu_usage2)) |
| 1021 | df.callback(0) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1022 | reactor.callLater(0, scale_acl_rules, df) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1023 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1024 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1025 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1026 | def test_scale_adding_and_deleting_acl_rules_to_allow_src_and_dst_ip_matching_traffic(self,count=10000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1027 | """ |
| 1028 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1029 | 1. Add 10000 (Number as per requirement)acl rules to allow source and destinaiton IP matching traffic |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1030 | 2. Send acl rules matching traffic |
| 1031 | 3. Delete all the added acl rules |
| 1032 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1033 | df = defer.Deferred() |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1034 | def scale_acl_rules(df): |
| 1035 | ingress = self.ingress_iface |
| 1036 | egress = self.CURRENT_PORT_NUM |
| 1037 | 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) |
| 1038 | self.CURRENT_PORT_NUM += 1 |
| 1039 | time.sleep(5) |
| 1040 | assert_equal(status, True) |
| 1041 | srcMac = '00:00:00:00:00:11' |
| 1042 | dstMac = host_ip_mac[0][1] |
| 1043 | self.acl_hosts_add(dstHostIpMac = host_ip_mac, egress_iface_count = 1, egress_iface_num = egress ) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1044 | acl_rule = ACLTest() |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1045 | try: |
| 1046 | for index in range(0,count): |
| 1047 | 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) |
| 1048 | self.CURRENT_PORT_NUM += 1 |
| 1049 | src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1050 | dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1051 | dst_port = random.randint(1024,65535) |
| 1052 | log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip)) |
| 1053 | status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow') |
| 1054 | assert_equal(status, True) |
| 1055 | 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) |
| 1056 | result = acl_rule.get_acl_rules() |
| 1057 | result = result.json()['aclRules'] |
| 1058 | for acl in result: |
| 1059 | acl_rule.remove_acl_rule(acl['id']) |
| 1060 | log.info('removed acl with Id --> %s'%acl['id']) |
| 1061 | self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress) |
| 1062 | except Exception as error: |
| 1063 | log.info('Got unexpected error %s'%error) |
| 1064 | self.acl_hosts_remove(egress_iface_count = 1, egress_iface_num = egress) |
| 1065 | raise |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1066 | df.callback(0) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1067 | reactor.callLater(0, scale_acl_rules, df) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1068 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1069 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1070 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1071 | def test_scale_adding_acl_rules_to_deny_src_and_dst_ip_matching_traffic_toggling_acl_app(self,count=20000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1072 | """ |
| 1073 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1074 | 1. Add 20000 (Number as test requirement)acl rules to allow source and destinaiton IP matching traffic |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1075 | 2. Send acl rules matching traffic |
| 1076 | 3. Verify onos drops the traffic as the rule is deny type |
| 1077 | 4. Deactivate the acl app in onos |
| 1078 | 4. Verify now onos forwards the traffic |
| 1079 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1080 | df = defer.Deferred() |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1081 | def scale_acl_rules(df): |
| 1082 | ingress = self.ingress_iface |
| 1083 | egress = self.CURRENT_PORT_NUM |
| 1084 | 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) |
| 1085 | self.CURRENT_PORT_NUM += 1 |
| 1086 | time.sleep(5) |
| 1087 | assert_equal(status, True) |
| 1088 | srcMac = '00:00:00:00:00:11' |
| 1089 | dstMac = host_ip_mac[0][1] |
| 1090 | self.acl_hosts_add(dstHostIpMac = host_ip_mac, egress_iface_count = 1, egress_iface_num = egress ) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1091 | acl_rule = ACLTest() |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1092 | try: |
| 1093 | for index in range(0,count): |
| 1094 | 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) |
| 1095 | self.CURRENT_PORT_NUM += 1 |
| 1096 | src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1097 | dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1098 | dst_port = random.randint(1024,65535) |
| 1099 | log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip)) |
| 1100 | status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'deny') |
| 1101 | assert_equal(status, True) |
| 1102 | 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) |
| 1103 | OnosCtrl(cls.acl_app).deactivate() |
| 1104 | time.sleep(3) |
| 1105 | except Exception as error: |
| 1106 | log.info('Got unexpected error %s'%error) |
| 1107 | raise |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1108 | df.callback(0) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1109 | reactor.callLater(0, scale_acl_rules, df) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1110 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1111 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1112 | @deferred(1000) |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1113 | def test_scale_adding_igmp_and_acl_with_flow_entries_and_check_cpu_usage(self,igmp_groups=1300, flows_count=10000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1114 | """ |
| 1115 | Test-Method: |
| 1116 | 1. Add igmp and flow entries in onos |
| 1117 | 2. Send igmp joins for corresponding igmp entries |
| 1118 | 3. Send multicast data traffic to registered igmp groups |
| 1119 | 3. Verify onos forwards the traffic |
| 1120 | 4. Send traffic matching the flow entries |
| 1121 | 4. Verify onos forwards the traffic |
| 1122 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1123 | df = defer.Deferred() |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1124 | def scale_igmp_acl_flows(df): |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1125 | cpu_usage1 = self.get_system_cpu_usage() |
| 1126 | egress = 1 |
| 1127 | ingress = 2 |
| 1128 | egress_mac = '00:00:00:00:01:01' |
| 1129 | ingress_mac = '02:00:00:00:00:00' |
| 1130 | acl_rule = ACLTest() |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1131 | OnosCtrl(self.igmp_app).activate() |
| 1132 | groups = self.generate_random_multicast_ip_addresses(count = igmp_groups) |
| 1133 | sources = self.generate_random_unicast_ip_addresses(count = igmp_groups) |
| 1134 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 1135 | for index in range(igmp_groups): |
| 1136 | self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1137 | iface = self.V_INF1) |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1138 | status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index]) |
| 1139 | assert_equal(status, True) |
| 1140 | log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index)) |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1141 | for index in range(flows_count): |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1142 | src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1143 | dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1144 | log.info('adding acl rule = %d with src ip = %s, dst ip = %s '%(index+1, src_ip,dst_ip)) |
| 1145 | status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip,action = 'allow') |
| 1146 | assert_equal(status, True) |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1147 | ingress_mac = self.next_mac(ingress_mac) |
| 1148 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 1149 | egressPort = egress + self.port_offset, |
| 1150 | ingressPort = ingress + self.port_offset, |
| 1151 | ethSrc = ingress_mac, |
| 1152 | ethDst = egress_mac) |
| 1153 | result = flow.addFlow() |
| 1154 | assert_equal(result, True) |
| 1155 | log.info("flow number = %d is added",index+1) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1156 | if index % 200 == 0: |
| 1157 | cpu_usage = self.get_system_cpu_usage() |
| 1158 | log.info('CPU usage is %s for acl rule number %s'%(cpu_usage,index+1)) |
| 1159 | time.sleep(1) |
| 1160 | cpu_usage2 = self.get_system_cpu_usage() |
| 1161 | log.info('system cpu usage before flows added = %f, after %d flows added = %f'%(cpu_usage1,count,cpu_usage2)) |
| 1162 | df.callback(0) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1163 | reactor.callLater(0, scale_igmp_acl_flows, df) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1164 | return df |
| 1165 | |
| 1166 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1167 | def test_scale_adding_igmp_acl_and_flow_entries_and_simultaneously_toggling_app(self,igmp_groups=1300, flows_count=10000): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1168 | """ |
| 1169 | Test-Method: |
| 1170 | 1. Add igmp, acl and flow entries in onos |
| 1171 | 2. Send igmp joins for corresponding igmp entries |
| 1172 | 3. Send multicast data traffic to registered igmp groups |
| 1173 | 3. Verify onos forwards the traffic |
| 1174 | 4. Send traffic matching the flow entries |
| 1175 | 4. Verify onos forwards the traffic |
| 1176 | 5. Send traffic matching acl rules |
| 1177 | 6. Verify onos forwards the traffic |
| 1178 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1179 | df = defer.Deferred() |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1180 | def scale_igmp_acl_flows(df): |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1181 | cpu_usage1 = self.get_system_cpu_usage() |
| 1182 | def adding_igmp_entries(): |
| 1183 | OnosCtrl(self.igmp_app).activate() |
| 1184 | groups = self.generate_random_multicast_ip_addresses(count = igmp_groups) |
| 1185 | sources = self.generate_random_unicast_ip_addresses(count = igmp_groups) |
| 1186 | self.onos_ssm_table_load(groups,src_list=sources,flag=True) |
| 1187 | for index in range(igmp_groups): |
| 1188 | self.send_igmp_join(groups = [groups[index]], src_list = [sources[index]],record_type = IGMP_V3_GR_TYPE_INCLUDE, |
| 1189 | iface = self.V_INF1) |
| 1190 | status = self.verify_igmp_data_traffic(groups[index],intf=self.V_INF1,source=sources[index]) |
| 1191 | assert_equal(status, True) |
| 1192 | log_test.info('data received for group %s from source %s - %d'%(groups[index],sources[index],index)) |
| 1193 | def adding_flow_entries(): |
| 1194 | egress = 1 |
| 1195 | ingress = 2 |
| 1196 | egress_mac = '00:00:00:00:01:01' |
| 1197 | ingress_mac = '02:00:00:00:00:00' |
| 1198 | for index in range(flows_count): |
| 1199 | ingress_mac = self.next_mac(ingress_mac) |
| 1200 | flow = OnosFlowCtrl(deviceId = self.device_id, |
| 1201 | egressPort = egress + self.port_offset, |
| 1202 | ingressPort = ingress + self.port_offset, |
| 1203 | ethSrc = ingress_mac, |
| 1204 | ethDst = egress_mac) |
| 1205 | result = flow.addFlow() |
| 1206 | assert_equal(result, True) |
| 1207 | log.info("flow number = %d is added",index+1) |
| 1208 | def adding_acl_entries(): |
| 1209 | OnosCtrl(self.acl_app).activate() |
| 1210 | for index in range(flows_count): |
| 1211 | src_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1212 | dst_ip = self.generate_random_unicast_ip_addresses(count=1)[0]+'/32' |
| 1213 | dst_port = random.randint(1024,65535) |
| 1214 | 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)) |
| 1215 | status,code = acl_rule.adding_acl_rule('v4', srcIp=src_ip, dstIp = dst_ip, ipProto ='TCP', dstTpPort =dst_port, action = 'deny') |
| 1216 | assert_equal(status, True) |
| 1217 | igmp_thread = threading.Thread(target = adding_igmp_entries) |
| 1218 | flows_thread = threading.Thread(target = adding_flow_entries) |
| 1219 | acl_thread = threading.Thread(target = adding_acl_entries) |
| 1220 | igmp_thread.start() |
| 1221 | flows_thread.start() |
| 1222 | acl_thread.start() |
| 1223 | time.sleep(1) |
| 1224 | igmp_thread.join() |
| 1225 | flows_thread.join() |
| 1226 | acl_thread.join() |
| 1227 | cpu_usage2 = self.get_system_cpu_usage() |
| 1228 | OnosCtrl(self.igmp_app).deactivate() |
| 1229 | OnosCtrl(self.acl_app).deactivate() |
| 1230 | cpu_usage3 = self.get_system_cpu_usage() |
| 1231 | 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)) |
| 1232 | OnosCtrl(self.igmp_app).activate() |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1233 | OnosCtrl(self.acl_app).activate() |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1234 | df.callback(0) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1235 | reactor.callLater(0, scale_igmp_acl_flows, df) |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1236 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1237 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1238 | #tested with 100 routes on CiaB |
| 1239 | @deferred(1000) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1240 | def test_scale_for_vrouter_with_large_number_of_routes_and_peers(self): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1241 | """ |
| 1242 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1243 | 1. Add 100000 routes with 100 pairs in quagga(Change scale test number as per test requirement) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1244 | 2. Verify routes pushed to onos from quagga |
| 1245 | 3. Send traffic destined the routes added |
| 1246 | 3. Verify onos forwards the traffic |
| 1247 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1248 | scale().vrouter_setup() |
| 1249 | df = defer.Deferred() |
| 1250 | def scale_vrouter_routes(df): |
| 1251 | try: |
| 1252 | res = scale().vrouter_network_verify(10000, peers = 100) |
| 1253 | assert_equal(res, True) |
| 1254 | except Exception as error: |
| 1255 | log.info('Got Unexpected error %s'%error) |
| 1256 | raise |
| 1257 | df.callback(0) |
| 1258 | reactor.callLater(0, scale_vrouter_routes, df) |
| 1259 | return df |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1260 | |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1261 | #tested with 100 subscribers on CiaB |
| 1262 | @deferred(1800) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1263 | def test_scale_of_eap_tls_with_huge_number_of_sessions_using_diff_mac(self): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1264 | """ |
| 1265 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1266 | 1. Simulate eap authentication requests for 5000 users(Adjust user number as per requirement) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1267 | 2. Verify authentication is succes for all 5000 users |
| 1268 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1269 | OnosCtrl('org.opencord.aaa').activate() |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1270 | df = defer.Deferred() |
| 1271 | def eap_tls_5k_with_diff_mac(df): |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1272 | try: |
| 1273 | for i in xrange(5000): |
| 1274 | tls = TLSAuthTest(src_mac = 'random') |
| 1275 | tls.runTest() |
| 1276 | log_test.info('Authentication successfull for user %d'%i) |
| 1277 | except Exception as error: |
| 1278 | log.info('Got Unexpected error %s'%error) |
| 1279 | raise |
Anil Kumar Sanka | 8942c88 | 2017-07-07 17:05:11 +0000 | [diff] [blame] | 1280 | df.callback(0) |
| 1281 | reactor.callLater(0, eap_tls_5k_with_diff_mac, df) |
| 1282 | return df |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1283 | |
| 1284 | #tested with 100 subscribers on CiaB |
| 1285 | @deferred(1800) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1286 | def test_scale_of_eap_tls_with_huge_number_of_sessions_using_diff_mac_with_aaa_app_deactivation_and_activation(self): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1287 | """ |
| 1288 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1289 | 1. Simulate eap authentication requests for 5000 users(Adjust user number as per requirement) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1290 | 2. Verify authentication is succes for all 5000 users |
| 1291 | 3. Deactivate and activate the aaa app in onos |
| 1292 | 4. Simulate eap authentication requests for 5000 users |
| 1293 | 5. Verify authentication is succes for all 5000 users |
| 1294 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1295 | OnosCtrl('org.opencord.aaa').activate() |
| 1296 | df = defer.Deferred() |
| 1297 | def eap_tls_5k_with_diff_mac(df): |
| 1298 | try: |
| 1299 | for i in xrange(5000): |
| 1300 | tls = TLSAuthTest(src_mac = 'random') |
| 1301 | tls.runTest() |
| 1302 | log_test.info('Authentication successfull for user %d'%i) |
| 1303 | OnosCtrl('org.opencord.aaa').deactivate() |
| 1304 | time.sleep(2) |
| 1305 | OnosCtrl('org.opencord.aaa').activate() |
| 1306 | for i in xrange(100): |
| 1307 | tls = TLSAuthTest(src_mac = 'random') |
| 1308 | tls.runTest() |
| 1309 | log_test.info('Authentication successfull for user %d'%i) |
| 1310 | OnosCtrl('org.opencord.aaa').activate() |
| 1311 | except Exception as error: |
| 1312 | log.info('Got Unexpected error %s'%error) |
| 1313 | OnosCtrl('org.opencord.aaa').activate() |
| 1314 | raise |
| 1315 | df.callback(0) |
| 1316 | reactor.callLater(0, eap_tls_5k_with_diff_mac, df) |
| 1317 | return df |
| 1318 | |
| 1319 | #tested with 10 subscribers on CiaB |
| 1320 | @deferred(1800) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1321 | def test_scale_for_cord_subscribers_authentication_with_valid_and_invalid_certificates_and_channel_surfing(self): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1322 | """ |
| 1323 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1324 | 1. Simulate 5000 subscribers to get authentication access(Adjust cord subscribers according to test) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1325 | 2. Send igmp joins from all the subcribers |
| 1326 | 3. Verify multicast traffic received to all 5000 subscribers |
| 1327 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1328 | scale().subscriber_setup() |
| 1329 | df = defer.Deferred() |
| 1330 | def cordsub_auth_invalid_cert(df): |
| 1331 | num_subscribers = 2 |
| 1332 | num_channels = 1 |
| 1333 | try: |
| 1334 | test_status = scale().subscriber_join_verify(num_subscribers = num_subscribers, |
| 1335 | num_channels = num_channels, |
| 1336 | cbs = (scale().tls_invalid_cert, scale().dhcp_verify, scale().igmp_verify), |
| 1337 | port_list = scale().generate_port_list(num_subscribers, num_channels), negative_subscriber_auth = 'half') |
| 1338 | assert_equal(test_status, True) |
| 1339 | except Exception as error: |
| 1340 | log.info('Got Unexpected error %s'%error) |
| 1341 | raise |
| 1342 | finally: |
| 1343 | scale().subscriber_teardown() |
| 1344 | df.callback(0) |
| 1345 | reactor.callLater(0, cordsub_auth_invalid_cert, df) |
| 1346 | return df |
| 1347 | |
| 1348 | #tested with 10 subscribers on CiaB |
| 1349 | @deferred(1800) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1350 | def test_scale_for_cord_subscribers_with_igmp_join_and_jump_for_multiple_channels(self): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1351 | """ |
| 1352 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1353 | 1. Simulate 5000 subscribers(Adjust number as per test) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1354 | 2. Send igmp joins from all the subcribers |
| 1355 | 3. Verify multicast traffic received to all 5000 subscribers |
| 1356 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1357 | scale().subscriber_setup() |
| 1358 | df = defer.Deferred() |
| 1359 | def cordsub_igmp_join_jump(df): |
| 1360 | num_subscribers = 5000 |
| 1361 | num_channels = 1500 |
| 1362 | try: |
| 1363 | test_status = scale().subscriber_join_verify(num_subscribers = num_subscribers, |
| 1364 | num_channels = num_channels, |
| 1365 | cbs = (scale().tls_verify, scale().dhcp_jump_verify, scale().igmp_jump_verify), |
| 1366 | port_list = scale().generate_port_list(num_subscribers, num_channels), |
| 1367 | negative_subscriber_auth = 'all') |
| 1368 | assert_equal(test_status, True) |
| 1369 | except Exception as error: |
| 1370 | log.info('Got Unexpected error %s'%error) |
| 1371 | raise |
| 1372 | finally: |
| 1373 | scale().subscriber_teardown() |
| 1374 | df.callback(0) |
| 1375 | reactor.callLater(0, cordsub_igmp_join_jump, df) |
| 1376 | return df |
| 1377 | |
| 1378 | #tested with 10 subscribers on CiaB |
| 1379 | @deferred(1800) |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1380 | def test_scale_for_cord_subscribers_authentication_with_valid_and_non_ca_authorized_certificates_and_channel_surfing(self): |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1381 | """ |
| 1382 | Test-Method: |
Chetan Gaonker | 434b68c | 2017-08-04 17:10:03 +0000 | [diff] [blame] | 1383 | 1. Simulate 10000 subscribers to get authentication access(Adjust number as per test) |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1384 | 2. Send igmp joins from all the subcribers |
| 1385 | 3. Verify multicast traffic received to all 10000 subscribers |
| 1386 | """ |
Anil Kumar Sanka | fcb9a0f | 2017-07-22 00:24:35 +0000 | [diff] [blame] | 1387 | scale().subscriber_setup() |
| 1388 | df = defer.Deferred() |
| 1389 | def cordsub_auth_valid_cert(df): |
| 1390 | num_subscribers = 10000 |
| 1391 | num_channels = 1 |
| 1392 | try: |
| 1393 | test_status = scale().subscriber_join_verify(num_subscribers = num_subscribers, |
| 1394 | num_channels = num_channels, |
| 1395 | cbs = (scale().tls_non_ca_authrized_cert, scale().dhcp_verify, scale().igmp_verify), |
| 1396 | port_list = scale().generate_port_list(num_subscribers, num_channels), |
| 1397 | negative_subscriber_auth = 'onethird') |
| 1398 | assert_equal(test_status, True) |
| 1399 | except Exception as error: |
| 1400 | log.info('Got Unexpected error %s'%error) |
| 1401 | raise |
| 1402 | finally: |
| 1403 | scale().subscriber_teardown() |
| 1404 | df.callback(0) |
| 1405 | reactor.callLater(0, cordsub_auth_valid_cert, df) |
| 1406 | return df |
Anil Kumar Sanka | 35fc445 | 2017-07-27 00:39:10 +0000 | [diff] [blame] | 1407 | |