Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 1 | #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 | # |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 15 | import time |
| 16 | import os |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 17 | import sys |
| 18 | import json |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 19 | from nose.tools import * |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 20 | from twisted.internet import defer |
| 21 | from nose.twistedtools import reactor, deferred |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 22 | from CordTestUtils import * |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 23 | from OltConfig import OltConfig |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 24 | from onosclidriver import OnosCliDriver |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 25 | from SSHTestAgent import SSHTestAgent |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 26 | from CordLogger import CordLogger |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 27 | from VSGAccess import VSGAccess |
A R Karthick | 933f5b5 | 2017-03-27 15:27:16 -0700 | [diff] [blame] | 28 | from CordTestUtils import log_test as log |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 29 | from CordTestConfig import setup_module, running_on_ciab |
A.R Karthick | a9b594d | 2017-03-29 16:25:22 -0700 | [diff] [blame] | 30 | from OnosCtrl import OnosCtrl |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 31 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 32 | log.setLevel('INFO') |
| 33 | |
| 34 | class vsg_exchange(CordLogger): |
| 35 | ONOS_INSTANCES = 3 |
| 36 | V_INF1 = 'veth0' |
| 37 | device_id = 'of:' + get_mac() |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 38 | TEST_IP = '8.8.8.8' |
| 39 | HOST = "10.1.0.1" |
| 40 | USER = "vagrant" |
| 41 | PASS = "vagrant" |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 42 | head_node = os.getenv('HEAD_NODE', 'prod') |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 43 | HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 44 | test_path = os.path.dirname(os.path.realpath(__file__)) |
| 45 | olt_conf_file = os.path.join(test_path, '..', 'setup/olt_config.json') |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 46 | restApiXos = None |
A R Karthick | 0a4ca3a | 2017-03-30 09:36:53 -0700 | [diff] [blame] | 47 | subscriber_account_num = 200 |
| 48 | subscriber_s_tag = 304 |
| 49 | subscriber_c_tag = 304 |
| 50 | subscribers_per_s_tag = 8 |
| 51 | subscriber_map = {} |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 52 | subscriber_info = [] |
| 53 | volt_subscriber_info = [] |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 54 | restore_methods = [] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 55 | TIMEOUT=120 |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 56 | FABRIC_PORT_HEAD_NODE = 1 |
| 57 | FABRIC_PORT_COMPUTE_NODE = 2 |
| 58 | APP_NAME = 'org.ciena.xconnect' |
| 59 | APP_FILE = os.path.join(test_path, '..', 'apps/xconnect-1.0-SNAPSHOT.oar') |
A.R Karthick | 50f4d9a | 2017-04-20 16:44:19 -0700 | [diff] [blame] | 60 | NUM_SUBSCRIBERS = 5 |
A R Karthick | 0a4ca3a | 2017-03-30 09:36:53 -0700 | [diff] [blame] | 61 | |
| 62 | @classmethod |
| 63 | def getSubscriberCredentials(cls, subId): |
| 64 | """Generate our own account num, s_tag and c_tags""" |
| 65 | if subId in cls.subscriber_map: |
| 66 | return cls.subscriber_map[subId] |
| 67 | account_num = cls.subscriber_account_num |
| 68 | cls.subscriber_account_num += 1 |
| 69 | s_tag, c_tag = cls.subscriber_s_tag, cls.subscriber_c_tag |
| 70 | cls.subscriber_c_tag += 1 |
| 71 | if cls.subscriber_c_tag % cls.subscribers_per_s_tag == 0: |
| 72 | cls.subscriber_s_tag += 1 |
| 73 | cls.subscriber_map[subId] = account_num, s_tag, c_tag |
| 74 | return cls.subscriber_map[subId] |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 75 | |
| 76 | @classmethod |
A.R Karthick | a9b594d | 2017-03-29 16:25:22 -0700 | [diff] [blame] | 77 | def getXosCredentials(cls): |
| 78 | onos_cfg = OnosCtrl.get_config() |
| 79 | if onos_cfg is None: |
| 80 | return None |
| 81 | if 'apps' in onos_cfg and \ |
| 82 | 'org.opencord.vtn' in onos_cfg['apps'] and \ |
| 83 | 'cordvtn' in onos_cfg['apps']['org.opencord.vtn'] and \ |
| 84 | 'xos' in onos_cfg['apps']['org.opencord.vtn']['cordvtn']: |
| 85 | xos_cfg = onos_cfg['apps']['org.opencord.vtn']['cordvtn']['xos'] |
| 86 | endpoint = xos_cfg['endpoint'] |
| 87 | user = xos_cfg['user'] |
| 88 | password = xos_cfg['password'] |
| 89 | xos_endpoints = endpoint.split(':') |
| 90 | xos_host = xos_endpoints[1][len('//'):] |
| 91 | xos_port = xos_endpoints[2][:-1] |
| 92 | #log.info('xos_host: %s, port: %s, user: %s, password: %s' %(xos_host, xos_port, user, password)) |
| 93 | return dict(host = xos_host, port = xos_port, user = user, password = password) |
| 94 | |
| 95 | return None |
| 96 | |
| 97 | @classmethod |
A.R Karthick | 50f4d9a | 2017-04-20 16:44:19 -0700 | [diff] [blame] | 98 | def getSubscriberConfig(cls, num_subscribers): |
| 99 | features = { |
| 100 | 'cdn': True, |
| 101 | 'uplink_speed': 1000000000, |
| 102 | 'downlink_speed': 1000000000, |
| 103 | 'uverse': True, |
| 104 | 'status': 'enabled' |
| 105 | } |
| 106 | subscriber_map = [] |
| 107 | for i in xrange(num_subscribers): |
| 108 | subId = 'sub{}'.format(i) |
| 109 | account_num, _, _ = cls.getSubscriberCredentials(subId) |
| 110 | identity = { 'account_num' : str(account_num), |
| 111 | 'name' : 'My House {}'.format(i) |
| 112 | } |
| 113 | sub_info = { 'features' : features, |
| 114 | 'identity' : identity |
| 115 | } |
| 116 | subscriber_map.append(sub_info) |
| 117 | |
| 118 | return subscriber_map |
| 119 | |
| 120 | @classmethod |
| 121 | def getVoltSubscriberConfig(cls, num_subscribers): |
| 122 | voltSubscriberMap = [] |
| 123 | for i in xrange(num_subscribers): |
| 124 | subId = 'sub{}'.format(i) |
| 125 | account_num, s_tag, c_tag = cls.getSubscriberCredentials(subId) |
| 126 | voltSubscriberInfo = {} |
| 127 | voltSubscriberInfo['voltTenant'] = dict(s_tag = str(s_tag), |
| 128 | c_tag = str(c_tag), |
| 129 | subscriber = '') |
| 130 | voltSubscriberInfo['account_num'] = account_num |
| 131 | voltSubscriberMap.append(voltSubscriberInfo) |
| 132 | |
| 133 | return voltSubscriberMap |
| 134 | |
| 135 | @classmethod |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 136 | def setUpCordApi(cls): |
| 137 | our_path = os.path.dirname(os.path.realpath(__file__)) |
| 138 | cord_api_path = os.path.join(our_path, '..', 'cord-api') |
| 139 | framework_path = os.path.join(cord_api_path, 'Framework') |
| 140 | utils_path = os.path.join(framework_path, 'utils') |
| 141 | data_path = os.path.join(cord_api_path, 'Tests', 'data') |
| 142 | subscriber_cfg = os.path.join(data_path, 'Subscriber.json') |
| 143 | volt_tenant_cfg = os.path.join(data_path, 'VoltTenant.json') |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 144 | num_subscribers = max(cls.NUM_SUBSCRIBERS, 5) |
| 145 | cls.subscriber_info = cls.getSubscriberConfig(num_subscribers) |
| 146 | cls.volt_subscriber_info = cls.getVoltSubscriberConfig(num_subscribers) |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 147 | |
| 148 | sys.path.append(utils_path) |
| 149 | sys.path.append(framework_path) |
| 150 | from restApi import restApi |
| 151 | restApiXos = restApi() |
A.R Karthick | a9b594d | 2017-03-29 16:25:22 -0700 | [diff] [blame] | 152 | xos_credentials = cls.getXosCredentials() |
| 153 | if xos_credentials is None: |
| 154 | restApiXos.controllerIP = cls.HEAD_NODE |
| 155 | restApiXos.controllerPort = '9000' |
| 156 | else: |
| 157 | restApiXos.controllerIP = xos_credentials['host'] |
| 158 | restApiXos.controllerPort = xos_credentials['port'] |
| 159 | restApiXos.user = xos_credentials['user'] |
| 160 | restApiXos.password = xos_credentials['password'] |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 161 | cls.restApiXos = restApiXos |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 162 | |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 163 | @classmethod |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 164 | def getVoltId(cls, result, subId): |
| 165 | if type(result) is not type([]): |
| 166 | return None |
| 167 | for tenant in result: |
| 168 | if str(tenant['subscriber']) == str(subId): |
| 169 | return str(tenant['id']) |
| 170 | return None |
| 171 | |
| 172 | @classmethod |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 173 | def closeVCPEAccess(cls, volt_subscriber_info): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 174 | OnosCtrl.uninstall_app(cls.APP_NAME, onos_ip = cls.HEAD_NODE) |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 175 | |
| 176 | @classmethod |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 177 | def openVCPEAccess(cls, volt_subscriber_info): |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 178 | """ |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 179 | This code is used to configure leaf switch for head node access to compute node over fabric. |
| 180 | Care is to be taken to avoid overwriting existing/default vcpe flows. |
| 181 | The access is opened for generated subscriber info which should not overlap. |
| 182 | We target the fabric onos instance on head node. |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 183 | """ |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 184 | OnosCtrl.install_app(cls.APP_FILE, onos_ip = cls.HEAD_NODE) |
| 185 | time.sleep(2) |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 186 | s_tags = map(lambda tenant: int(tenant['voltTenant']['s_tag']), volt_subscriber_info) |
| 187 | #only get unique vlan tags |
| 188 | s_tags = list(set(s_tags)) |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 189 | devices = OnosCtrl.get_device_ids(controller = cls.HEAD_NODE) |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 190 | if devices: |
| 191 | device_config = {} |
| 192 | for device in devices: |
| 193 | device_config[device] = [] |
| 194 | for s_tag in s_tags: |
| 195 | xconnect_config = {'vlan': s_tag, 'ports' : [ cls.FABRIC_PORT_HEAD_NODE, cls.FABRIC_PORT_COMPUTE_NODE ] } |
| 196 | device_config[device].append(xconnect_config) |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 197 | |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 198 | cfg = { 'apps' : { 'org.ciena.xconnect' : { 'xconnectTestConfig' : device_config } } } |
| 199 | OnosCtrl.config(cfg, controller = cls.HEAD_NODE) |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 200 | |
| 201 | @classmethod |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 202 | def setUpClass(cls): |
| 203 | cls.controllers = get_controllers() |
| 204 | cls.controller = cls.controllers[0] |
| 205 | cls.cli = None |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 206 | cls.on_pod = running_on_pod() |
| 207 | cls.on_ciab = running_on_ciab() |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 208 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
| 209 | cls.vcpes = cls.olt.get_vcpes() |
| 210 | cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp') |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 211 | cls.vcpes_reserved = cls.olt.get_vcpes_by_type('reserved') |
| 212 | cls.dhcp_vcpes_reserved = [ 'vcpe{}.{}.{}'.format(i, cls.vcpes_reserved[i]['s_tag'], cls.vcpes_reserved[i]['c_tag']) |
| 213 | for i in xrange(len(cls.vcpes_reserved)) ] |
| 214 | cls.untagged_dhcp_vcpes_reserved = [ 'vcpe{}'.format(i) for i in xrange(len(cls.vcpes_reserved)) ] |
| 215 | cls.container_vcpes_reserved = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ] |
| 216 | vcpe_dhcp_reserved = None |
| 217 | vcpe_container_reserved = None |
| 218 | if cls.vcpes_reserved: |
| 219 | vcpe_dhcp_reserved = cls.dhcp_vcpes_reserved[0] |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 220 | if cls.on_pod is False: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 221 | vcpe_dhcp_reserved = cls.untagged_dhcp_vcpes_reserved[0] |
| 222 | vcpe_container_reserved = cls.container_vcpes_reserved[0] |
| 223 | |
| 224 | cls.vcpe_dhcp_reserved = vcpe_dhcp_reserved |
| 225 | cls.vcpe_container_reserved = vcpe_container_reserved |
| 226 | dhcp_vcpe_offset = len(cls.vcpes_reserved) |
A R Karthick | 927129c | 2017-04-25 14:08:02 -0700 | [diff] [blame] | 227 | cls.dhcp_vcpes = [ 'vcpe{}.{}.{}'.format(i+dhcp_vcpe_offset, cls.vcpes_dhcp[i]['s_tag'], cls.vcpes_dhcp[i]['c_tag']) |
| 228 | for i in xrange(len(cls.vcpes_dhcp)) ] |
| 229 | cls.untagged_dhcp_vcpes = [ 'vcpe{}'.format(i+dhcp_vcpe_offset) for i in xrange(len(cls.vcpes_dhcp)) ] |
| 230 | cls.container_vcpes = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_dhcp ] |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 231 | vcpe_dhcp = None |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 232 | vcpe_container = None |
| 233 | #cache the first dhcp vcpe in the class for quick testing |
| 234 | if cls.vcpes_dhcp: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 235 | vcpe_container = cls.container_vcpes[0] |
| 236 | vcpe_dhcp = cls.dhcp_vcpes[0] |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 237 | if cls.on_pod is False: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 238 | vcpe_dhcp = cls.untagged_dhcp_vcpes[0] |
| 239 | cls.vcpe_container = vcpe_container_reserved or vcpe_container |
| 240 | cls.vcpe_dhcp = vcpe_dhcp_reserved or vcpe_dhcp |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 241 | VSGAccess.setUp() |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 242 | cls.setUpCordApi() |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 243 | if cls.on_pod is True: |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 244 | cls.openVCPEAccess(cls.volt_subscriber_info) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 245 | |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 246 | @classmethod |
| 247 | def tearDownClass(cls): |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 248 | VSGAccess.tearDown() |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 249 | if cls.on_pod is True: |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 250 | cls.closeVCPEAccess(cls.volt_subscriber_info) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 251 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 252 | def cliEnter(self, controller = None): |
| 253 | retries = 0 |
| 254 | while retries < 30: |
| 255 | self.cli = OnosCliDriver(controller = controller, connect = True) |
| 256 | if self.cli.handle: |
| 257 | break |
| 258 | else: |
| 259 | retries += 1 |
| 260 | time.sleep(2) |
| 261 | |
| 262 | def cliExit(self): |
| 263 | self.cli.disconnect() |
| 264 | |
| 265 | def onos_shutdown(self, controller = None): |
| 266 | status = True |
| 267 | self.cliEnter(controller = controller) |
| 268 | try: |
| 269 | self.cli.shutdown(timeout = 10) |
| 270 | except: |
| 271 | log.info('Graceful shutdown of ONOS failed for controller: %s' %controller) |
| 272 | status = False |
| 273 | |
| 274 | self.cliExit() |
| 275 | return status |
| 276 | |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 277 | def log_set(self, level = None, app = 'org.onosproject'): |
| 278 | CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 279 | |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 280 | @classmethod |
| 281 | def get_dhcp(cls, vcpe, mgmt = 'eth0'): |
| 282 | """Get DHCP for vcpe interface saving management settings""" |
| 283 | |
| 284 | def put_dhcp(): |
| 285 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 286 | |
| 287 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 288 | if vcpe_ip is not None: |
| 289 | cls.restore_methods.append(put_dhcp) |
| 290 | return vcpe_ip |
| 291 | |
| 292 | @classmethod |
| 293 | def config_restore(cls): |
| 294 | """Restore the vsg test configuration on test case failures""" |
| 295 | for restore_method in cls.restore_methods: |
| 296 | restore_method() |
| 297 | |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 298 | def get_vsg_vcpe_pair(self): |
| 299 | vcpes = self.vcpes_dhcp |
| 300 | vcpe_containers = [] |
| 301 | vsg_vcpe = {} |
| 302 | for vcp in vcpes: |
| 303 | vcpe_container = 'vcpe-{}-{}'.format(vcp['s_tag'], vcp['c_tag']) |
| 304 | vcpe_containers.append(vcpe_container) |
| 305 | vsg = VSGAccess.get_vcpe_vsg(vcpe_container) |
| 306 | vsg_vcpe[vcpe_container]=str(vsg.get_ip()) |
| 307 | return vsg_vcpe |
| 308 | |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 309 | def get_vcpe_containers_and_interfaces(self): |
| 310 | vcpe_containers = {} |
| 311 | vcpe_interfaces = [] |
| 312 | vcpes = self.vcpes_dhcp |
| 313 | count = 0 |
| 314 | for vcpe in vcpes: |
| 315 | vcpe_intf = 'vcpe{}.{}.{}'.format(count,vcpe['s_tag'],vcpe['c_tag']) |
| 316 | vcpe_interfaces.append(vcpe_intf) |
| 317 | vcpe_container = 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) |
| 318 | vcpe_containers[vcpe_intf] = vcpe_container |
| 319 | count += 1 |
| 320 | log.info('vcpe interfaces are %s'%vcpe_interfaces) |
| 321 | log.info('vcpe containers are %s'%vcpe_containers) |
| 322 | return vcpe_interfaces,vcpe_containers |
| 323 | |
| 324 | def get_vcpe_interface_dhcp_ip(self,vcpe=None): |
| 325 | if not vcpe: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 326 | vcpe = self.vcpe_dhcp |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 327 | st, _ = getstatusoutput('dhclient {}'.format(vcpe)) |
| 328 | vcpe_ip = get_ip(vcpe) |
| 329 | return vcpe_ip |
| 330 | |
| 331 | def release_vcpe_interface_dhcp_ip(self,vcpe=None): |
| 332 | if not vcpe: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 333 | vcpe = self.vcpe_dhcp |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 334 | st, _ = getstatusoutput('dhclient {} -r'.format(vcpe)) |
| 335 | vcpe_ip = get_ip(vcpe) |
| 336 | assert_equal(vcpe_ip, None) |
| 337 | |
| 338 | def add_static_route_via_vcpe_interface(self, routes, vcpe=None,dhcp_ip=True): |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 339 | if not vcpe: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 340 | vcpe = self.vcpe_dhcp |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 341 | if dhcp_ip: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 342 | os.system('dhclient '+vcpe) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 343 | time.sleep(1) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 344 | for route in routes: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 345 | log.info('route is %s'%route) |
| 346 | cmd = 'ip route add ' + route + ' via 192.168.0.1 '+ 'dev ' + vcpe |
| 347 | cmds.append(cmd) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 348 | for cmd in cmds: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 349 | os.system(cmd) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 350 | return True |
| 351 | |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 352 | def del_static_route_via_vcpe_interface(self,routes,vcpe=None,dhcp_release=True): |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 353 | if not vcpe: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 354 | vcpe = self.vcpe_dhcp |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 355 | cmds = [] |
| 356 | for route in routes: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 357 | cmd = 'ip route del ' + route + ' via 192.168.0.1 ' + 'dev ' + vcpe |
| 358 | os.system(cmd) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 359 | if dhcp_release: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 360 | os.system('dhclient '+vcpe+' -r') |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 361 | return True |
| 362 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 363 | def test_vsg_health(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 364 | """ |
| 365 | Algo: |
| 366 | 1. Login to compute node VM |
| 367 | 2. Get all vSGs |
| 368 | 3. Ping to all vSGs |
| 369 | 4. Verifying Ping success |
| 370 | """ |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 371 | status = True |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 372 | if self.on_pod is True: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 373 | status = VSGAccess.health_check() |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 374 | assert_equal(status, True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 375 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 376 | def test_vsg_health_check(self, vsg_name='mysite_vsg-1', verify_status=True): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 377 | """ |
| 378 | Algo: |
| 379 | 1. If vsg name not specified, Get vsg corresponding to vcpe |
| 380 | 1. Login to compute mode VM |
| 381 | 3. Ping to the vSG |
| 382 | 4. Verifying Ping success |
| 383 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 384 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 385 | return |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 386 | if not vsg_name: |
| 387 | vcpe = self.vcpe_container |
| 388 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 389 | status = vsg.get_health() |
| 390 | assert_equal(status, verify_status) |
| 391 | else: |
| 392 | vsgs = VSGAccess.get_vsgs() |
| 393 | status = None |
| 394 | for vsg in vsgs: |
| 395 | if vsg.name == vsg_name: |
| 396 | status = vsg.get_health() |
| 397 | log.info('vsg health check status is %s'%status) |
| 398 | assert_equal(status,verify_status) |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 399 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 400 | @deferred(TIMEOUT) |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 401 | def test_vsg_for_vcpe(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 402 | """ |
| 403 | Algo: |
| 404 | 1. Get list of all compute nodes created using Openstack |
| 405 | 2. Login to compute mode VM |
| 406 | 3. Get all vSGs |
| 407 | 4. Verifying atleast one compute node and one vSG created |
| 408 | """ |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 409 | df = defer.Deferred() |
| 410 | def vsg_for_vcpe_df(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 411 | if self.on_pod is True: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 412 | vsgs = VSGAccess.get_vsgs() |
| 413 | compute_nodes = VSGAccess.get_compute_nodes() |
| 414 | time.sleep(14) |
| 415 | assert_not_equal(len(vsgs), 0) |
| 416 | assert_not_equal(len(compute_nodes), 0) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 417 | df.callback(0) |
| 418 | reactor.callLater(0,vsg_for_vcpe_df,df) |
| 419 | return df |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 420 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 421 | def test_vsg_for_login(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 422 | """ |
| 423 | Algo: |
| 424 | 1. Login to compute node VM |
| 425 | 2. Get all vSGs |
| 426 | 3. Verifying login to vSG is success |
| 427 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 428 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 429 | return |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 430 | vsgs = VSGAccess.get_vsgs() |
| 431 | vsg_access_status = map(lambda vsg: vsg.check_access(), vsgs) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 432 | status = filter(lambda st: st == False, vsg_access_status) |
| 433 | assert_equal(len(status), 0) |
| 434 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 435 | def test_vsg_for_default_route_through_testclient(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 436 | """ |
| 437 | Algo: |
| 438 | 1. Login to head node |
| 439 | 2. Verifying for default route in lxc test client |
| 440 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 441 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 442 | return |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 443 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 444 | cmd = "sudo lxc exec testclient -- route | grep default" |
| 445 | status, output = ssh_agent.run_cmd(cmd) |
| 446 | assert_equal(status, True) |
| 447 | |
| 448 | def test_vsg_for_external_connectivity_through_testclient(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 449 | """ |
| 450 | Algo: |
| 451 | 1. Login to head node |
| 452 | 2. On head node, executing ping to 8.8.8.8 from lxc test client |
| 453 | 3. Verifying for the ping success |
| 454 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 455 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 456 | return |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 457 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 458 | cmd = "lxc exec testclient -- ping -c 3 8.8.8.8" |
| 459 | status, output = ssh_agent.run_cmd(cmd) |
| 460 | assert_equal( status, True) |
| 461 | |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 462 | def vsg_for_external_connectivity(self, subscriber_index, reserved = False): |
| 463 | if reserved is True: |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 464 | if self.on_pod is True: |
| 465 | vcpe = self.dhcp_vcpes_reserved[subscriber_index] |
| 466 | else: |
| 467 | vcpe = self.untagged_dhcp_vcpes_reserved[subscriber_index] |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 468 | else: |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 469 | if self.on_pod is True: |
| 470 | vcpe = self.dhcp_vcpes[subscriber_index] |
| 471 | else: |
| 472 | vcpe = self.untagged_dhcp_vcpes[subscriber_index] |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 473 | mgmt = 'eth0' |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 474 | host = '8.8.8.8' |
| 475 | self.success = False |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 476 | assert_not_equal(vcpe, None) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 477 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 478 | assert_not_equal(vcpe_ip, None) |
| 479 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 480 | log.info('Sending icmp echo requests to external network 8.8.8.8') |
| 481 | st, _ = getstatusoutput('ping -c 3 8.8.8.8') |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 482 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 483 | assert_equal(st, 0) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 484 | |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 485 | def test_vsg_for_external_connectivity(self): |
| 486 | """ |
| 487 | Algo: |
| 488 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 489 | 2. Verifying vcpe interface gets dhcp IP |
| 490 | 3. Ping to 8.8.8.8 and Verifying ping should success |
| 491 | 4. Restoring management interface configuration in cord-tester |
| 492 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 493 | reserved = True |
| 494 | if self.on_pod: |
| 495 | reserved = self.on_ciab |
| 496 | self.vsg_for_external_connectivity(0, reserved = reserved) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 497 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 498 | def test_vsg_for_external_connectivity_to_google(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 499 | """ |
| 500 | Algo: |
| 501 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 502 | 2. Verifying vcpe interface gets dhcp IP |
| 503 | 3. Ping to www.google.com and Verifying ping should success |
| 504 | 4. Restoring management interface configuration in cord-tester |
| 505 | """ |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 506 | host = 'www.google.com' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 507 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 508 | mgmt = 'eth0' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 509 | assert_not_equal(vcpe, None) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 510 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 511 | assert_not_equal(vcpe_ip, None) |
| 512 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 513 | log.info('Sending icmp ping requests to %s' %host) |
| 514 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 515 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 516 | assert_equal(st, 0) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 517 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 518 | def test_vsg_for_external_connectivity_to_invalid_host(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 519 | """ |
| 520 | Algo: |
| 521 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 522 | 2. Verifying vcpe interface gets dhcp IP |
| 523 | 3. Ping to www.goglee.com and Verifying ping should not success |
| 524 | 4. Restoring management interface configuration in cord-tester |
| 525 | """ |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 526 | host = 'www.goglee.com' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 527 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 528 | mgmt = 'eth0' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 529 | assert_not_equal(vcpe, None) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 530 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 531 | assert_not_equal(vcpe_ip, None) |
| 532 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 533 | log.info('Sending icmp ping requests to non existent host %s' %host) |
| 534 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 535 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 536 | assert_not_equal(st, 0) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 537 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 538 | def test_vsg_for_external_connectivity_with_ttl_1(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 539 | """ |
| 540 | Algo: |
| 541 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 542 | 2. Verifying vcpe interface gets dhcp IP |
| 543 | 3. Ping to 8.8.8.8 with ttl set to 1 |
| 544 | 4. Verifying ping should not success |
| 545 | 5. Restoring management interface configuration in cord-tester |
| 546 | """ |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 547 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 548 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 549 | mgmt = 'eth0' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 550 | assert_not_equal(vcpe, None) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 551 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 552 | assert_not_equal(vcpe_ip, None) |
| 553 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 554 | log.info('Sending icmp ping requests to host %s with ttl 1' %host) |
| 555 | st, _ = getstatusoutput('ping -c 1 -t 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 556 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 557 | assert_not_equal(st, 0) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 558 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 559 | def test_vsg_for_external_connectivity_with_wan_interface_toggle_in_vcpe(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 560 | """ |
| 561 | Algo: |
| 562 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 563 | 2. Verifying vcpe interface gets dhcp IP |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 564 | 3. Ping to 8.8.8.8 and Verifying ping succeeds |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 565 | 4. Now down the WAN interface of vcpe |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 566 | 5. Ping to 8.8.8.8 and Verifying ping fails |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 567 | 6. Now Up the WAN interface of vcpe |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 568 | 7. Ping to 8.8.8.8 and Verifying ping succeeds |
| 569 | 8. Restoring management interface configuration in cord-tester |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 570 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 571 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 572 | return |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 573 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 574 | mgmt = 'eth0' |
| 575 | vcpe = self.vcpe_container |
| 576 | assert_not_equal(vcpe, None) |
| 577 | assert_not_equal(self.vcpe_dhcp, None) |
| 578 | #first get dhcp on the vcpe interface |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 579 | vcpe_ip = VSGAccess.vcpe_get_dhcp(self.vcpe_dhcp, mgmt = mgmt) |
| 580 | assert_not_equal(vcpe_ip, None) |
| 581 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp)) |
| 582 | log.info('Sending ICMP pings to host %s' %(host)) |
| 583 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 584 | if st != 0: |
| 585 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 586 | assert_equal(st, 0) |
| 587 | #bring down the wan interface and check again |
| 588 | st = VSGAccess.vcpe_wan_down(vcpe) |
| 589 | if st is False: |
| 590 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 591 | assert_equal(st, True) |
| 592 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 593 | if st == 0: |
| 594 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 595 | assert_not_equal(st, 0) |
| 596 | st = VSGAccess.vcpe_wan_up(vcpe) |
| 597 | if st is False: |
| 598 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 599 | assert_equal(st, True) |
| 600 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 601 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 602 | assert_equal(st, 0) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 603 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 604 | def test_vsg_for_external_connectivity_with_lan_interface_toggle_in_vcpe(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 605 | """ |
| 606 | Algo: |
| 607 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 608 | 2. Verifying vcpe interface gets dhcp IP |
| 609 | 3. Ping to 8.8.8.8 and Verifying ping should success |
| 610 | 4. Now down the LAN interface of vcpe |
| 611 | 5. Ping to 8.8.8.8 and Verifying ping should not success |
| 612 | 6. Now Up the LAN interface of vcpe |
| 613 | 7. Ping to 8.8.8.8 and Verifying ping should success |
| 614 | 8. Restoring management interface configuration in cord-tester |
| 615 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 616 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 617 | return |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 618 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 619 | mgmt = 'eth0' |
| 620 | vcpe = self.vcpe_container |
| 621 | assert_not_equal(vcpe, None) |
| 622 | assert_not_equal(self.vcpe_dhcp, None) |
| 623 | #first get dhcp on the vcpe interface |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 624 | vcpe_ip = VSGAccess.vcpe_get_dhcp(self.vcpe_dhcp, mgmt = mgmt) |
| 625 | assert_not_equal(vcpe_ip, None) |
| 626 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp)) |
| 627 | log.info('Sending ICMP pings to host %s' %(host)) |
| 628 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 629 | if st != 0: |
| 630 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 631 | assert_equal(st, 0) |
| 632 | #bring down the lan interface and check again |
| 633 | st = VSGAccess.vcpe_lan_down(vcpe) |
| 634 | if st is False: |
| 635 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 636 | assert_equal(st, True) |
| 637 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 638 | if st == 0: |
| 639 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 640 | assert_not_equal(st, 0) |
| 641 | st = VSGAccess.vcpe_lan_up(vcpe) |
| 642 | if st is False: |
| 643 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 644 | assert_equal(st, True) |
| 645 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 646 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 647 | assert_equal(st, 0) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 648 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 649 | @deferred(TIMEOUT) |
| 650 | def test_vsg_for_external_connectivity_with_vcpe_container_paused(self,vcpe_name=None,vcpe_intf=None): |
| 651 | """ |
| 652 | Algo: |
| 653 | 1. Get vSG corresponding to vcpe |
| 654 | 2. Get dhcp ip to vcpe interface |
| 655 | 3. Add static route to destination route in test container |
| 656 | 4. From test container ping to destination route and verify ping success |
| 657 | 5. Login to compute node and execute command to pause vcpe container |
| 658 | 6. From test container ping to destination route and verify ping success |
| 659 | """ |
| 660 | if not vcpe_name: |
| 661 | vcpe_name = self.vcpe_container |
| 662 | if not vcpe_intf: |
| 663 | vcpe_intf = self.vcpe_dhcp |
| 664 | df = defer.Deferred() |
| 665 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 666 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 667 | df.callback(0) |
| 668 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 669 | host = '8.8.8.8' |
| 670 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 671 | try: |
| 672 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 673 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 674 | assert_equal(st, False) |
| 675 | st, _ = vsg.run_cmd('sudo docker pause {}'.format(vcpe_name)) |
| 676 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 677 | assert_equal(st, False) |
| 678 | finally: |
| 679 | vsg.run_cmd('sudo docker unpause'.format(vcpe_name)) |
| 680 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 681 | df.callback(0) |
| 682 | reactor.callLater(0, vcpe_firewall, df) |
| 683 | return df |
| 684 | |
| 685 | @deferred(TIMEOUT) |
| 686 | def test_vsg_firewall_with_deny_destination_ip(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 687 | """ |
| 688 | Algo: |
| 689 | 1. Get vSG corresponding to vcpe |
| 690 | 2. Login to compute node |
| 691 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 692 | 4. From cord-tester ping to the denied IP address |
| 693 | 5. Verifying that ping should not be successful |
| 694 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 695 | if not vcpe_name: |
| 696 | vcpe_name = self.vcpe_container |
| 697 | if not vcpe_intf: |
| 698 | vcpe_intf = self.vcpe_dhcp |
| 699 | df = defer.Deferred() |
| 700 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 701 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 702 | df.callback(0) |
| 703 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 704 | host = '8.8.8.8' |
| 705 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 706 | try: |
| 707 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 708 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 709 | assert_equal(st, False) |
| 710 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 711 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 712 | assert_equal(st, True) |
| 713 | finally: |
| 714 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 715 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 716 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 717 | df.callback(0) |
| 718 | reactor.callLater(0, vcpe_firewall, df) |
| 719 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 720 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 721 | @deferred(TIMEOUT) |
| 722 | def test_vsg_firewall_with_rule_add_and_delete_dest_ip(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 723 | """ |
| 724 | Algo: |
| 725 | 1. Get vSG corresponding to vcpe |
| 726 | 2. Login to compute node |
| 727 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 728 | 4. From cord-tester ping to the denied IP address |
| 729 | 5. Verifying that ping should not be successful |
| 730 | 6. Delete the iptable rule in vcpe |
| 731 | 7. From cord-tester ping to the denied IP address |
| 732 | 8. Verifying the ping should success |
| 733 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 734 | if not vcpe_name: |
| 735 | vcpe_name = self.vcpe_container |
| 736 | if not vcpe_intf: |
| 737 | vcpe_intf = self.vcpe_dhcp |
| 738 | df = defer.Deferred() |
| 739 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 740 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 741 | df.callback(0) |
| 742 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 743 | host = '8.8.8.8' |
| 744 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 745 | try: |
| 746 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 747 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 748 | assert_equal(st, False) |
| 749 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 750 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 751 | assert_equal(st, True) |
| 752 | st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 753 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 754 | assert_equal(st, False) |
| 755 | finally: |
| 756 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 757 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 758 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 759 | df.callback(0) |
| 760 | reactor.callLater(0, vcpe_firewall, df) |
| 761 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 762 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 763 | @deferred(TIMEOUT) |
| 764 | def test_vsg_firewall_verifying_reachability_for_non_blocked_dest_ip(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 765 | """ |
| 766 | Algo: |
| 767 | 1. Get vSG corresponding to vcpe |
| 768 | 2. Login to compute node |
| 769 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 770 | 4. From cord-tester ping to the denied IP address |
| 771 | 5. Verifying that ping should not be successful |
| 772 | 6. From cord-tester ping to the denied IP address other than the denied one |
| 773 | 7. Verifying the ping should success |
| 774 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 775 | if not vcpe_name: |
| 776 | vcpe_name = self.vcpe_container |
| 777 | if not vcpe_intf: |
| 778 | vcpe_intf = self.vcpe_dhcp |
| 779 | df = defer.Deferred() |
| 780 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 781 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 782 | df.callback(0) |
| 783 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 784 | host1 = '8.8.8.8' |
| 785 | host2 = '204.79.197.203' |
| 786 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 787 | try: |
| 788 | self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
| 789 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 790 | assert_equal(st, False) |
| 791 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 792 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 793 | assert_equal(st, True) |
| 794 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 795 | assert_equal(st,False) |
| 796 | finally: |
| 797 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 798 | self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
| 799 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 800 | df.callback(0) |
| 801 | reactor.callLater(0, vcpe_firewall, df) |
| 802 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 803 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 804 | @deferred(TIMEOUT) |
| 805 | def test_vsg_firewall_appending_rules_with_deny_dest_ip(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 806 | """ |
| 807 | Algo: |
| 808 | 1. Get vSG corresponding to vcpe |
| 809 | 2. Login to compute node |
| 810 | 3. Execute iptable command on vcpe from compute node to deny a destination IP1 |
| 811 | 4. From cord-tester ping to the denied IP address IP1 |
| 812 | 5. Verifying that ping should not be successful |
| 813 | 6. Execute iptable command on vcpe from compute node to deny a destination IP2 |
| 814 | 6. From cord-tester ping to the denied IP address IP2 |
| 815 | 7. Verifying that ping should not be successful |
| 816 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 817 | if not vcpe_name: |
| 818 | vcpe_name = self.vcpe_container |
| 819 | if not vcpe_intf: |
| 820 | vcpe_intf = self.vcpe_dhcp |
| 821 | df = defer.Deferred() |
| 822 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 823 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 824 | df.callback(0) |
| 825 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 826 | host1 = '8.8.8.8' |
| 827 | host2 = '204.79.197.203' |
| 828 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 829 | try: |
| 830 | self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
| 831 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 832 | assert_equal(st, False) |
| 833 | st,_ = vsg.run_cmd('sudo docker exec {} iptables -F FORWARD'.format(vcpe_name)) |
| 834 | time.sleep(2) |
| 835 | st,_ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 836 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 837 | assert_equal(st, True) |
| 838 | st, out = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 839 | log.info('host2 ping output is %s'%out) |
| 840 | assert_equal(st, False) |
| 841 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -A FORWARD -d {} -j DROP'.format(vcpe_name,host2)) |
| 842 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 843 | assert_equal(st,True) |
| 844 | finally: |
| 845 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 846 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2)) |
| 847 | self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
| 848 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 849 | df.callback(0) |
| 850 | reactor.callLater(0, vcpe_firewall, df) |
| 851 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 852 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 853 | @deferred(TIMEOUT) |
| 854 | def test_vsg_firewall_removing_one_rule_denying_dest_ip(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 855 | """ |
| 856 | Algo: |
| 857 | 1. Get vSG corresponding to vcpe |
| 858 | 2. Login to compute node |
| 859 | 3. Execute iptable command on vcpe from compute node to deny a destination IP1 |
| 860 | 4. Execute iptable command on vcpe from compute node to deny a destination IP2 |
| 861 | 5. From cord-tester ping to the denied IP address IP1 |
| 862 | 6. Verifying that ping should not be successful |
| 863 | 7. From cord-tester ping to the denied IP address IP2 |
| 864 | 8. Verifying that ping should not be successful |
| 865 | 9. Execute iptable command on vcpe from compute node to remove deny a destination IP2 rule |
| 866 | 10. From cord-tester ping to the denied IP address IP2 |
| 867 | 11. Verifying the ping should success |
| 868 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 869 | if not vcpe_name: |
| 870 | vcpe_name = self.vcpe_container |
| 871 | if not vcpe_intf: |
| 872 | vcpe_intf = self.vcpe_dhcp |
| 873 | df = defer.Deferred() |
| 874 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 875 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 876 | df.callback(0) |
| 877 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 878 | host1 = '8.8.8.8' |
| 879 | host2 = '204.79.197.203' |
| 880 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 881 | try: |
| 882 | self.add_static_route_via_vcpe_interface([host1,host2],vcpe=self.vcpe_dhcp) |
| 883 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 884 | assert_equal(st, False) |
| 885 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 886 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host2)) |
| 887 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 888 | assert_equal(st, True) |
| 889 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 890 | assert_equal(st,True) |
| 891 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2)) |
| 892 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 893 | assert_equal(st,False) |
| 894 | finally: |
| 895 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 896 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2)) |
| 897 | self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
| 898 | log.info('restarting vcpe container') |
| 899 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 900 | df.callback(0) |
| 901 | reactor.callLater(0, vcpe_firewall, df) |
| 902 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 903 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 904 | @deferred(TIMEOUT) |
| 905 | def test_vsg_firewall_changing_rule_id_deny_dest_ip(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 906 | """ |
| 907 | Algo: |
| 908 | 1. Get vSG corresponding to vcpe |
| 909 | 2. Login to compute node |
| 910 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 911 | 5. From cord-tester ping to the denied IP address IP1 |
| 912 | 6. Verifying that ping should not be successful |
| 913 | 9. Execute iptable command on vcpe from compute node to change the rule ID to 2 to deny the same destination IP |
| 914 | 10. From cord-tester ping to the denied IP address IP |
| 915 | 11. Verifying that ping should not be successful |
| 916 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 917 | if not vcpe_name: |
| 918 | vcpe_name = self.vcpe_container |
| 919 | if not vcpe_intf: |
| 920 | vcpe_intf = self.vcpe_dhcp |
| 921 | df = defer.Deferred() |
| 922 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 923 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 924 | df.callback(0) |
| 925 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 926 | host = '8.8.8.8' |
| 927 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 928 | try: |
| 929 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 930 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 931 | assert_equal(st, False) |
| 932 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 933 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 934 | assert_equal(st, True) |
| 935 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP '.format(vcpe_name,host)) |
| 936 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 937 | assert_equal(st,True) |
| 938 | finally: |
| 939 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 940 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 941 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 942 | df.callback(0) |
| 943 | reactor.callLater(0, vcpe_firewall, df) |
| 944 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 945 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 946 | @deferred(TIMEOUT) |
| 947 | def test_vsg_firewall_changing_deny_rule_to_accept_dest_ip(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 948 | """ |
| 949 | Algo: |
| 950 | 1. Get vSG corresponding to vcpe |
| 951 | 2. Login to compute node |
| 952 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 953 | 5. From cord-tester ping to the denied IP address IP1 |
| 954 | 6. Verifying that ping should not be successful |
| 955 | 9. Execute iptable command on vcpe from compute node to accept the same destination IP |
| 956 | 10. From cord-tester ping to the accepted IP |
| 957 | 11. Verifying the ping should success |
| 958 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 959 | if not vcpe_name: |
| 960 | vcpe_name = self.vcpe_container |
| 961 | if not vcpe_intf: |
| 962 | vcpe_intf = self.vcpe_dhcp |
| 963 | df = defer.Deferred() |
| 964 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 965 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 966 | df.callback(0) |
| 967 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 968 | host = '8.8.8.8' |
| 969 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 970 | try: |
| 971 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 972 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 973 | assert_equal(st, False) |
| 974 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 975 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 976 | assert_equal(st, True) |
| 977 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -d {} -j ACCEPT'.format(vcpe_name,host)) |
| 978 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 979 | assert_equal(st,False) |
| 980 | finally: |
| 981 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 982 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j ACCEPT'.format(vcpe_name,host)) |
| 983 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 984 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 985 | df.callback(0) |
| 986 | reactor.callLater(0, vcpe_firewall, df) |
| 987 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 988 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 989 | @deferred(TIMEOUT) #Fail |
| 990 | def test_vsg_firewall_denying_destination_network(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 991 | """ |
| 992 | Algo: |
| 993 | 1. Get vSG corresponding to vcpe |
| 994 | 2. Login to compute node |
| 995 | 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet |
| 996 | 4. From cord-tester ping to the denied IP address IP1 in the denied subnet |
| 997 | 5. Verifying that ping should not be successful |
| 998 | 6. From cord-tester ping to the denied IP address IP2 in the denied subnet |
| 999 | 7. Verifying that ping should not be successful |
| 1000 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1001 | if not vcpe_name: |
| 1002 | vcpe_name = self.vcpe_container |
| 1003 | if not vcpe_intf: |
| 1004 | vcpe_intf = self.vcpe_dhcp |
| 1005 | df = defer.Deferred() |
| 1006 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1007 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1008 | df.callback(0) |
| 1009 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1010 | network = '204.79.197.192/28' |
| 1011 | host1 = '204.79.197.203' |
| 1012 | host2 = '204.79.197.210' |
| 1013 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1014 | try: |
| 1015 | self.add_static_route_via_vcpe_interface([host1,host2],vcpe=self.vcpe_dhcp) |
| 1016 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1017 | assert_equal(st, False) |
| 1018 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network)) |
| 1019 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1020 | assert_equal(st, True) |
| 1021 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1022 | assert_equal(st,False) |
| 1023 | finally: |
| 1024 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network)) |
| 1025 | self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
| 1026 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1027 | df.callback(0) |
| 1028 | reactor.callLater(0, vcpe_firewall, df) |
| 1029 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1030 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1031 | @deferred(TIMEOUT) |
| 1032 | def test_vsg_firewall_denying_destination_network_subnet_modification(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1033 | """ |
| 1034 | Algo: |
| 1035 | 1. Get vSG corresponding to vcpe |
| 1036 | 2. Login to compute node |
| 1037 | 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet |
| 1038 | 4. From cord-tester ping to the denied IP address IP1 in the denied subnet |
| 1039 | 5. Verifying that ping should not be successful |
| 1040 | 6. From cord-tester ping to the denied IP address IP2 in the denied subnet |
| 1041 | 7. Verifying that ping should not be successful |
| 1042 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1043 | if not vcpe_name: |
| 1044 | vcpe_name = self.vcpe_container |
| 1045 | if not vcpe_intf: |
| 1046 | vcpe_intf = self.vcpe_dhcp |
| 1047 | df = defer.Deferred() |
| 1048 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1049 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1050 | df.callback(0) |
| 1051 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1052 | network1 = '204.79.197.192/28' |
| 1053 | network2 = '204.79.197.192/27' |
| 1054 | host1 = '204.79.197.203' |
| 1055 | host2 = '204.79.197.210' |
| 1056 | host3 = '204.79.197.224' |
| 1057 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1058 | try: |
| 1059 | self.add_static_route_via_vcpe_interface([host1,host2,host3],vcpe=self.vcpe_dhcp) |
| 1060 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1061 | assert_equal(st, False) |
| 1062 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network1)) |
| 1063 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1064 | assert_equal(st, True) |
| 1065 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1066 | assert_equal(st,False) |
| 1067 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,network2)) |
| 1068 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1069 | assert_equal(st, True) |
| 1070 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1071 | assert_equal(st, True) |
| 1072 | st, _ = getstatusoutput('ping -c 1 {}'.format(host3)) |
| 1073 | assert_equal(st, False) |
| 1074 | finally: |
| 1075 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network1)) |
| 1076 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network2)) |
| 1077 | self.del_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf) |
| 1078 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1079 | df.callback(0) |
| 1080 | reactor.callLater(0, vcpe_firewall, df) |
| 1081 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1082 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1083 | @deferred(TIMEOUT) |
| 1084 | def test_vsg_firewall_with_deny_source_ip(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1085 | """ |
| 1086 | Algo: |
| 1087 | 1. Get vSG corresponding to vcpe |
| 1088 | 2. Login to compute node |
| 1089 | 3. Execute iptable command on vcpe from compute node to deny a source IP |
| 1090 | 4. From cord-tester ping to 8.8.8.8 from the denied IP |
| 1091 | 5. Verifying that ping should not be successful |
| 1092 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1093 | if not vcpe_name: |
| 1094 | vcpe_name = self.vcpe_container |
| 1095 | if not vcpe_intf: |
| 1096 | vcpe_intf = self.vcpe_dhcp |
| 1097 | df = defer.Deferred() |
| 1098 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1099 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1100 | df.callback(0) |
| 1101 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1102 | host = '8.8.8.8' |
| 1103 | #source_ip = get_ip(self.vcpe_dhcp) |
| 1104 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1105 | try: |
| 1106 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1107 | source_ip = get_ip(self.vcpe_dhcp) |
| 1108 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1109 | assert_equal(st, False) |
| 1110 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1111 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1112 | assert_equal(st, True) |
| 1113 | finally: |
| 1114 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1115 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1116 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1117 | df.callback(0) |
| 1118 | reactor.callLater(0, vcpe_firewall, df) |
| 1119 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1120 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1121 | @deferred(TIMEOUT) |
| 1122 | def test_vsg_firewall_rule_with_add_and_delete_deny_source_ip(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1123 | """ |
| 1124 | Algo: |
| 1125 | 1. Get vSG corresponding to vcpe |
| 1126 | 2. Login to compute node |
| 1127 | 3. Execute iptable command on vcpe from compute node to deny a source IP |
| 1128 | 4. From cord-tester ping to 8.8.8.8 from the denied IP |
| 1129 | 5. Verifying that ping should not be successful |
| 1130 | 6. Delete the iptable rule in vcpe |
| 1131 | 7. From cord-tester ping to 8.8.8.8 from the denied IP |
| 1132 | 8. Verifying the ping should success |
| 1133 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1134 | if not vcpe_name: |
| 1135 | vcpe_name = self.vcpe_container |
| 1136 | if not vcpe_intf: |
| 1137 | vcpe_intf = self.vcpe_dhcp |
| 1138 | df = defer.Deferred() |
| 1139 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1140 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1141 | df.callback(0) |
| 1142 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1143 | host = '8.8.8.8' |
| 1144 | source_ip = get_ip(self.vcpe_dhcp) |
| 1145 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1146 | try: |
| 1147 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1148 | source_ip = get_ip(self.vcpe_dhcp) |
| 1149 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1150 | assert_equal(st, False) |
| 1151 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1152 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1153 | assert_equal(st, True) |
| 1154 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1155 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1156 | assert_equal(st, False) |
| 1157 | finally: |
| 1158 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1159 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1160 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1161 | df.callback(0) |
| 1162 | reactor.callLater(0, vcpe_firewall, df) |
| 1163 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1164 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1165 | @deferred(TIMEOUT) |
| 1166 | def test_vsg_firewall_rule_with_deny_icmp_protocol_echo_requests_type(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1167 | """ |
| 1168 | Algo: |
| 1169 | 1. Get vSG corresponding to vcpe |
| 1170 | 2. Login to compute node |
| 1171 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets |
| 1172 | 4. From cord-tester ping to 8.8.8.8 |
| 1173 | 5. Verifying that ping should not be successful |
| 1174 | 6. Delete the iptable rule |
| 1175 | 7. From cord-tester ping to 8.8.8.8 |
| 1176 | 8. Verifying the ping should success |
| 1177 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1178 | if not vcpe_name: |
| 1179 | vcpe_name = self.vcpe_container |
| 1180 | if not vcpe_intf: |
| 1181 | vcpe_intf = self.vcpe_dhcp |
| 1182 | df = defer.Deferred() |
| 1183 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1184 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1185 | df.callback(0) |
| 1186 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1187 | host = '8.8.8.8' |
| 1188 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1189 | try: |
| 1190 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1191 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1192 | assert_equal(st, False) |
| 1193 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1194 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1195 | assert_equal(st, True) |
| 1196 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1197 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1198 | assert_equal(st, False) |
| 1199 | finally: |
| 1200 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1201 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1202 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1203 | df.callback(0) |
| 1204 | reactor.callLater(0, vcpe_firewall, df) |
| 1205 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1206 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1207 | @deferred(TIMEOUT) |
| 1208 | def test_vsg_firewall_rule_with_deny_icmp_protocol_echo_reply_type(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1209 | """ |
| 1210 | Algo: |
| 1211 | 1. Get vSG corresponding to vcpe |
| 1212 | 2. Login to compute node |
| 1213 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets |
| 1214 | 4. From cord-tester ping to 8.8.8.8 |
| 1215 | 5. Verifying that ping should not be successful |
| 1216 | 6. Delete the iptable rule |
| 1217 | 7. From cord-tester ping to 8.8.8.8 |
| 1218 | 8. Verifying the ping should success |
| 1219 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1220 | if not vcpe_name: |
| 1221 | vcpe_name = self.vcpe_container |
| 1222 | if not vcpe_intf: |
| 1223 | vcpe_intf = self.vcpe_dhcp |
| 1224 | df = defer.Deferred() |
| 1225 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1226 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1227 | df.callback(0) |
| 1228 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1229 | host = '8.8.8.8' |
| 1230 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1231 | try: |
| 1232 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1233 | st, _ = getstatusoutput('ping -c 1 {}'.format('8.8.8.8')) |
| 1234 | assert_equal(st, False) |
| 1235 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1236 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1237 | assert_equal(st, True) |
| 1238 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1239 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1240 | assert_equal(st,False) |
| 1241 | finally: |
| 1242 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1243 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1244 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1245 | df.callback(0) |
| 1246 | reactor.callLater(0, vcpe_firewall, df) |
| 1247 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1248 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1249 | @deferred(TIMEOUT) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 1250 | def test_vsg_firewall_changing_deny_rule_to_accept_rule_with_icmp_protocol_echo_requests_type(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1251 | """ |
| 1252 | Algo: |
| 1253 | 1. Get vSG corresponding to vcpe |
| 1254 | 2. Login to compute node |
| 1255 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets |
| 1256 | 4. From cord-tester ping to 8.8.8.8 |
| 1257 | 5. Verifying that ping should not be successful |
| 1258 | 6. Insert another rule to accept the icmp-echo requests protocol packets |
| 1259 | 7. From cord-tester ping to 8.8.8.8 |
| 1260 | 8. Verifying the ping should success |
| 1261 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1262 | if not vcpe_name: |
| 1263 | vcpe_name = self.vcpe_container |
| 1264 | if not vcpe_intf: |
| 1265 | vcpe_intf = self.vcpe_dhcp |
| 1266 | df = defer.Deferred() |
| 1267 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1268 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1269 | df.callback(0) |
| 1270 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1271 | host = '8.8.8.8' |
| 1272 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1273 | try: |
| 1274 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1275 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1276 | assert_equal(st, False) |
| 1277 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1278 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1279 | assert_equal(st, True) |
| 1280 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name)) |
| 1281 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1282 | assert_equal(st,False) |
| 1283 | finally: |
| 1284 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1285 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name)) |
| 1286 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1287 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1288 | df.callback(0) |
| 1289 | reactor.callLater(0, vcpe_firewall, df) |
| 1290 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1291 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1292 | @deferred(TIMEOUT) |
| 1293 | def test_vsg_firewall_changing_deny_rule_to_accept_rule_with_icmp_protocol_echo_reply_type(self,vcpe_name=None,vcpe_intf=None): |
| 1294 | """ |
| 1295 | Algo: |
| 1296 | 1. Get vSG corresponding to vcpe |
| 1297 | 2. Login to compute node |
| 1298 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets |
| 1299 | 4. From cord-tester ping to 8.8.8.8 |
| 1300 | 5. Verifying the ping should not success |
| 1301 | 6. Insert another rule to accept the icmp-echo requests protocol packets |
| 1302 | 7. From cord-tester ping to 8.8.8.8 |
| 1303 | 8. Verifying the ping should success |
| 1304 | """ |
| 1305 | if not vcpe_name: |
| 1306 | vcpe_name = self.vcpe_container |
| 1307 | if not vcpe_intf: |
| 1308 | vcpe_intf = self.vcpe_dhcp |
| 1309 | df = defer.Deferred() |
| 1310 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1311 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1312 | df.callback(0) |
| 1313 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1314 | host = '8.8.8.8' |
| 1315 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1316 | try: |
| 1317 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1318 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1319 | assert_equal(st, False) |
| 1320 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1321 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1322 | assert_equal(st, True) |
| 1323 | st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name)) |
| 1324 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1325 | assert_equal(st,False) |
| 1326 | finally: |
| 1327 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1328 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name)) |
| 1329 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1330 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1331 | df.callback(0) |
| 1332 | reactor.callLater(0, vcpe_firewall, df) |
| 1333 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1334 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1335 | @deferred(TIMEOUT) |
| 1336 | def test_vsg_firewall_for_deny_icmp_protocol(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1337 | """ |
| 1338 | Algo: |
| 1339 | 1. Get vSG corresponding to vcpe |
| 1340 | 2. Login to compute node |
| 1341 | 3. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 1342 | 4. From cord-tester ping to 8.8.8.8 |
| 1343 | 5. Verifying that ping should not be successful |
| 1344 | 6. Delete the iptable rule |
| 1345 | 7. From cord-tester ping to 8.8.8.8 |
| 1346 | 8. Verifying the ping should success |
| 1347 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1348 | if not vcpe_name: |
| 1349 | vcpe_name = self.vcpe_container |
| 1350 | if not vcpe_intf: |
| 1351 | vcpe_intf = self.vcpe_dhcp |
| 1352 | df = defer.Deferred() |
| 1353 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1354 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1355 | df.callback(0) |
| 1356 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1357 | host = '8.8.8.8' |
| 1358 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1359 | try: |
| 1360 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1361 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1362 | assert_equal(st, False) |
| 1363 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1364 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1365 | assert_equal(st, True) |
| 1366 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1367 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1368 | assert_equal(st,False) |
| 1369 | finally: |
| 1370 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1371 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1372 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1373 | df.callback(0) |
| 1374 | reactor.callLater(0, vcpe_firewall, df) |
| 1375 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1376 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1377 | @deferred(TIMEOUT) |
| 1378 | def test_vsg_firewall_rule_deny_icmp_protocol_and_destination_ip(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1379 | """ |
| 1380 | Algo: |
| 1381 | 1. Get vSG corresponding to vcpe |
| 1382 | 2. Login to compute node |
| 1383 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 1384 | 4. From cord-tester ping to 8.8.8.8 |
| 1385 | 5. Verifying that ping should not be successful |
| 1386 | 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 1387 | 7. From cord-tester ping to 8.8.8.8 |
| 1388 | 8. Verifying the ping should success |
| 1389 | 9. Delete the rule added in step 3 |
| 1390 | 10. From cord-tester ping to 8.8.8.8 |
| 1391 | 11. Verifying that ping should not be successful |
| 1392 | 12. Delete the rule added in step 6 |
| 1393 | 13. From cord-tester ping to 8.8.8.8 |
| 1394 | 14. Verifying the ping should success |
| 1395 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1396 | if not vcpe_name: |
| 1397 | vcpe_name = self.vcpe_container |
| 1398 | if not vcpe_intf: |
| 1399 | vcpe_intf = self.vcpe_dhcp |
| 1400 | df = defer.Deferred() |
| 1401 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1402 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1403 | df.callback(0) |
| 1404 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1405 | host = '8.8.8.8' |
| 1406 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1407 | try: |
| 1408 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1409 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1410 | assert_equal(st, False) |
| 1411 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1412 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1413 | assert_equal(st, True) |
| 1414 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1415 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1416 | assert_equal(st, True) |
| 1417 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1418 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1419 | assert_equal(st, True) |
| 1420 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1421 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1422 | assert_equal(st,False) |
| 1423 | finally: |
| 1424 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1425 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1426 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1427 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1428 | df.callback(0) |
| 1429 | reactor.callLater(0, vcpe_firewall, df) |
| 1430 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1431 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1432 | @deferred(TIMEOUT) #Fail |
| 1433 | def test_vsg_firewall_flushing_all_configured_rules(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1434 | """ |
| 1435 | Algo: |
| 1436 | 1. Get vSG corresponding to vcpe |
| 1437 | 2. Login to compute node |
| 1438 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 1439 | 4. From cord-tester ping to 8.8.8.8 |
| 1440 | 5. Verifying that ping should not be successful |
| 1441 | 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 1442 | 7. From cord-tester ping to 8.8.8.8 |
| 1443 | 8. Verifying the ping should success |
| 1444 | 9. Flush all the iptable rules configuraed in vcpe |
| 1445 | 10. Delete the rule added in step 6 |
| 1446 | 11. From cord-tester ping to 8.8.8.8 |
| 1447 | 12. Verifying the ping should success |
| 1448 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1449 | if not vcpe_name: |
| 1450 | vcpe_name = self.vcpe_container |
| 1451 | if not vcpe_intf: |
| 1452 | vcpe_intf = self.vcpe_dhcp |
| 1453 | df = defer.Deferred() |
| 1454 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1455 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1456 | df.callback(0) |
| 1457 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1458 | host = '8.8.8.8' |
| 1459 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1460 | try: |
| 1461 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1462 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1463 | assert_equal(st, False) |
| 1464 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1465 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1466 | assert_equal(st, True) |
| 1467 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1468 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1469 | assert_equal(st, True) |
| 1470 | st,output = vsg.run_cmd('sudo docker exec {} iptables -F FORWARD'.format(vcpe_name)) |
| 1471 | time.sleep(1) |
| 1472 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1473 | assert_equal(st, False) |
| 1474 | finally: |
| 1475 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1476 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1477 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1478 | df.callback(0) |
| 1479 | reactor.callLater(0, vcpe_firewall, df) |
| 1480 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1481 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1482 | @deferred(TIMEOUT) |
| 1483 | def test_vsg_firewall_deny_all_ipv4_traffic(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1484 | """ |
| 1485 | Algo: |
| 1486 | 1. Get vSG corresponding to vcpe |
| 1487 | 2. Login to compute node |
| 1488 | 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic |
| 1489 | 4. From cord-tester ping to 8.8.8.8 |
| 1490 | 5. Verifying that ping should not be successful |
| 1491 | 6. Delete the iptable rule added |
| 1492 | 7. From cord-tester ping to 8.8.8.8 |
| 1493 | 8. Verifying the ping should success |
| 1494 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1495 | if not vcpe_name: |
| 1496 | vcpe_name = self.vcpe_container |
| 1497 | if not vcpe_intf: |
| 1498 | vcpe_intf = self.vcpe_dhcp |
| 1499 | df = defer.Deferred() |
| 1500 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1501 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1502 | df.callback(0) |
| 1503 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1504 | host = '8.8.8.8' |
| 1505 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1506 | try: |
| 1507 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1508 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1509 | assert_equal(st, False) |
| 1510 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1511 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1512 | assert_equal(st, True) |
| 1513 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1514 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1515 | assert_equal(st, False) |
| 1516 | finally: |
| 1517 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1518 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1519 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1520 | df.callback(0) |
| 1521 | reactor.callLater(0, vcpe_firewall, df) |
| 1522 | return df |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1523 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1524 | @deferred(TIMEOUT) |
| 1525 | def test_vsg_firewall_replacing_deny_rule_to_accept_rule_ipv4_traffic(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1526 | """ |
| 1527 | Algo: |
| 1528 | 1. Get vSG corresponding to vcpe |
| 1529 | 2. Login to compute node |
| 1530 | 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic |
| 1531 | 4. From cord-tester ping to 8.8.8.8 |
| 1532 | 5. Verifying that ping should not be successful |
| 1533 | 6. Replace the deny rule added in step 3 with accept rule |
| 1534 | 7. From cord-tester ping to 8.8.8.8 |
| 1535 | 8. Verifying the ping should success |
| 1536 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1537 | if not vcpe_name: |
| 1538 | vcpe_name = self.vcpe_container |
| 1539 | if not vcpe_intf: |
| 1540 | vcpe_intf = self.vcpe_dhcp |
| 1541 | df = defer.Deferred() |
| 1542 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1543 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1544 | df.callback(0) |
| 1545 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1546 | host = '8.8.8.8' |
| 1547 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1548 | try: |
| 1549 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1550 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1551 | assert_equal(st, False) |
| 1552 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1553 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1554 | assert_equal(st, True) |
| 1555 | st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -4 -j ACCEPT'.format(vcpe_name)) |
| 1556 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1557 | assert_equal(st, False) |
| 1558 | finally: |
| 1559 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1560 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1561 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1562 | df.callback(0) |
| 1563 | reactor.callLater(0, vcpe_firewall, df) |
| 1564 | return df |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1565 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1566 | @deferred(TIMEOUT) |
| 1567 | def test_vsg_firewall_deny_all_traffic_coming_on_lan_interface_in_vcpe(self,vcpe_name=None,vcpe_intf=None): |
| 1568 | """ |
| 1569 | Algo: |
| 1570 | 1. Get vSG corresponding to vcpe |
| 1571 | 2. Login to compute node |
| 1572 | 3. Execute iptable command on vcpe from compute node to deny all the traffic coming on lan interface inside vcpe container |
| 1573 | 4. From cord-tester ping to 8.8.8.8 |
| 1574 | 5. Verifying the ping should not success |
| 1575 | 6. Delete the iptable rule added |
| 1576 | 7. From cord-tester ping to 8.8.8.8 |
| 1577 | 8. Verifying the ping should success |
| 1578 | """ |
| 1579 | if not vcpe_name: |
| 1580 | vcpe_name = self.vcpe_container |
| 1581 | if not vcpe_intf: |
| 1582 | vcpe_intf = self.vcpe_dhcp |
| 1583 | df = defer.Deferred() |
| 1584 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1585 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1586 | df.callback(0) |
| 1587 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1588 | host = '8.8.8.8' |
| 1589 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1590 | try: |
| 1591 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1592 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1593 | assert_equal(st, False) |
| 1594 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -j DROP'.format(vcpe_name)) |
| 1595 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1596 | assert_equal(st, True) |
| 1597 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name)) |
| 1598 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1599 | assert_equal(st, False) |
| 1600 | finally: |
| 1601 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name)) |
| 1602 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1603 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1604 | df.callback(0) |
| 1605 | reactor.callLater(0, vcpe_firewall, df) |
| 1606 | return df |
| 1607 | |
| 1608 | @deferred(TIMEOUT) |
| 1609 | def test_vsg_firewall_deny_all_traffic_going_out_of_wan_interface_in_vcpe(self,vcpe_name=None,vcpe_intf=None): |
| 1610 | """ |
| 1611 | Algo: |
| 1612 | 1. Get vSG corresponding to vcpe |
| 1613 | 2. Login to compute node |
| 1614 | 3. Execute iptable command on vcpe from compute node to deny all the traffic going out of wan interface inside vcpe container |
| 1615 | 4. From cord-tester ping to 8.8.8.8 |
| 1616 | 5. Verifying the ping should not success |
| 1617 | 6. Delete the iptable rule added |
| 1618 | 7. From cord-tester ping to 8.8.8.8 |
| 1619 | 8. Verifying the ping should success |
| 1620 | """ |
| 1621 | if not vcpe_name: |
| 1622 | vcpe_name = self.vcpe_container |
| 1623 | if not vcpe_intf: |
| 1624 | vcpe_intf = self.vcpe_dhcp |
| 1625 | df = defer.Deferred() |
| 1626 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1627 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1628 | df.callback(0) |
| 1629 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1630 | host = '8.8.8.8' |
| 1631 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1632 | try: |
| 1633 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1634 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1635 | assert_equal(st, False) |
| 1636 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -o eth0 -j DROP'.format(vcpe_name)) |
| 1637 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1638 | assert_equal(st, True) |
| 1639 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name)) |
| 1640 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1641 | assert_equal(st, False) |
| 1642 | finally: |
| 1643 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name)) |
| 1644 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1645 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1646 | df.callback(0) |
| 1647 | reactor.callLater(0, vcpe_firewall, df) |
| 1648 | return df |
| 1649 | |
| 1650 | @deferred(TIMEOUT) |
| 1651 | def test_vsg_firewall_deny_all_traffic_from_lan_to_wan_in_vcpe(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1652 | """ |
| 1653 | Algo: |
| 1654 | 1. Get vSG corresponding to vcpe |
| 1655 | 2. Login to compute node |
| 1656 | 3. Execute iptable command on vcpe from compute node to deny all the traffic from lan to wan interface in vcpe |
| 1657 | 4. From cord-tester ping to 8.8.8.8 |
| 1658 | 5. Verifying that ping should not be successful |
| 1659 | 6. Delete the iptable rule added |
| 1660 | 7. From cord-tester ping to 8.8.8.8 |
| 1661 | 8. Verifying the ping should success |
| 1662 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1663 | if not vcpe_name: |
| 1664 | vcpe_name = self.vcpe_container |
| 1665 | if not vcpe_intf: |
| 1666 | vcpe_intf = self.vcpe_dhcp |
| 1667 | df = defer.Deferred() |
| 1668 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1669 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1670 | df.callback(0) |
| 1671 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1672 | host = '8.8.8.8' |
| 1673 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1674 | try: |
| 1675 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1676 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1677 | assert_equal(st, False) |
| 1678 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name)) |
| 1679 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1680 | assert_equal(st, True) |
| 1681 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name)) |
| 1682 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1683 | assert_equal(st, False) |
| 1684 | finally: |
| 1685 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name)) |
| 1686 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1687 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1688 | df.callback(0) |
| 1689 | reactor.callLater(0, vcpe_firewall, df) |
| 1690 | return df |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1691 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1692 | #this test case needs modification.default route should be vcpe interface to run this test case |
| 1693 | @deferred(TIMEOUT) |
| 1694 | def test_vsg_firewall_deny_all_dns_traffic(self,vcpe_name=None,vcpe_intf=None): |
| 1695 | """ |
| 1696 | Algo: |
| 1697 | 1. Get vSG corresponding to vcpe |
| 1698 | 2. Login to compute node |
| 1699 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 1700 | 4. From cord-tester ping to www.google.com |
| 1701 | 5. Verifying the ping should not success |
| 1702 | 6. Delete the iptable rule added |
| 1703 | 7. From cord-tester ping to www.google.com |
| 1704 | 8. Verifying the ping should success |
| 1705 | """ |
| 1706 | if not vcpe_name: |
| 1707 | vcpe_name = self.vcpe_container |
| 1708 | if not vcpe_intf: |
| 1709 | vcpe_intf = self.vcpe_dhcp |
| 1710 | df = defer.Deferred() |
| 1711 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1712 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1713 | df.callback(0) |
| 1714 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1715 | host = 'www.msn.com' |
| 1716 | host_ip = '131.253.33.203' |
| 1717 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1718 | try: |
| 1719 | self.add_static_route_via_vcpe_interface([host_ip],vcpe=self.vcpe_dhcp) |
| 1720 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1721 | assert_equal(st, False) |
| 1722 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name)) |
| 1723 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1724 | assert_equal(st, True) |
| 1725 | st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p udp --dport 53 -j ACCEPT'.format(vcpe_name)) |
| 1726 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1727 | assert_equal(st, False) |
| 1728 | finally: |
| 1729 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name)) |
| 1730 | self.del_static_route_via_vcpe_interface([host_ip],vcpe=vcpe_intf) |
| 1731 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1732 | df.callback(0) |
| 1733 | reactor.callLater(0, vcpe_firewall, df) |
| 1734 | return df |
| 1735 | |
| 1736 | @deferred(TIMEOUT) |
| 1737 | def test_vsg_firewall_deny_all_ipv4_traffic_vcpe_container_restart(self,vcpe_name=None,vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1738 | """ |
| 1739 | Algo: |
| 1740 | 1. Get vSG corresponding to vcpe |
| 1741 | 2. Login to compute node |
| 1742 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 1743 | 4. From cord-tester ping to www.google.com |
| 1744 | 5. Verifying that ping should not be successful |
| 1745 | 6. Delete the iptable rule added |
| 1746 | 7. From cord-tester ping to www.google.com |
| 1747 | 8. Verifying the ping should success |
| 1748 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1749 | if not vcpe_name: |
| 1750 | vcpe_name = self.vcpe_container |
| 1751 | if not vcpe_intf: |
| 1752 | vcpe_intf = self.vcpe_dhcp |
| 1753 | df = defer.Deferred() |
| 1754 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1755 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1756 | df.callback(0) |
| 1757 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1758 | host = '8.8.8.8' |
| 1759 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1760 | try: |
| 1761 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1762 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1763 | assert_equal(st, False) |
| 1764 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1765 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1766 | assert_equal(st, True) |
| 1767 | st,output = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1768 | time.sleep(3) |
| 1769 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1770 | assert_equal(st, False) |
| 1771 | finally: |
| 1772 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1773 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1774 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1775 | df.callback(0) |
| 1776 | reactor.callLater(0, vcpe_firewall, df) |
| 1777 | return df |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1778 | |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 1779 | @deferred(TIMEOUT) |
| 1780 | def test_vsg_dnat_modifying_destination_ip(self,vcpe_name=None,vcpe_intf=None): |
| 1781 | """ |
| 1782 | Algo: |
| 1783 | 1. Get vSG corresponding to vcpe |
| 1784 | 2. Login to compute node |
| 1785 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 1786 | 4. From cord-tester ping to www.google.com |
| 1787 | 5. Verifying the ping should not success |
| 1788 | 6. Delete the iptable rule added |
| 1789 | 7. From cord-tester ping to www.google.com |
| 1790 | 8. Verifying the ping should success |
| 1791 | """ |
| 1792 | if not vcpe_name: |
| 1793 | vcpe_name = self.vcpe_container |
| 1794 | if not vcpe_intf: |
| 1795 | vcpe_intf = self.vcpe_dhcp |
| 1796 | df = defer.Deferred() |
| 1797 | def vcpe_firewall(df): |
| 1798 | host = '8.8.8.8' |
| 1799 | dst_ip = '123.123.123.123' |
| 1800 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1801 | try: |
| 1802 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1803 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1804 | assert_equal(st, False) |
| 1805 | st,output = vsg.run_cmd('sudo docker exec {} iptables -t nat -A PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip)) |
| 1806 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1807 | assert_equal(st, True) |
| 1808 | finally: |
| 1809 | vsg.run_cmd('sudo docker exec {} iptables -t nat -D PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip)) |
| 1810 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1811 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1812 | df.callback(0) |
| 1813 | reactor.callLater(0,vcpe_firewall,df) |
| 1814 | return df |
| 1815 | |
| 1816 | @deferred(TIMEOUT) |
| 1817 | def test_vsg_dnat_modifying_destination_ip_and_delete(self,vcpe_name=None,vcpe_intf=None): |
| 1818 | """ |
| 1819 | Algo: |
| 1820 | 1. Get vSG corresponding to vcpe |
| 1821 | 2. Login to compute node |
| 1822 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 1823 | 4. From cord-tester ping to www.google.com |
| 1824 | 5. Verifying the ping should not success |
| 1825 | 6. Delete the iptable rule added |
| 1826 | 7. From cord-tester ping to www.google.com |
| 1827 | 8. Verifying the ping should success |
| 1828 | """ |
| 1829 | if not vcpe_name: |
| 1830 | vcpe_name = self.vcpe_container |
| 1831 | if not vcpe_intf: |
| 1832 | vcpe_intf = self.vcpe_dhcp |
| 1833 | df = defer.Deferred() |
| 1834 | def vcpe_firewall(df): |
| 1835 | host = '8.8.8.8' |
| 1836 | dst_ip = '123.123.123.123' |
| 1837 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1838 | try: |
| 1839 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1840 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1841 | assert_equal(st, False) |
| 1842 | st,output = vsg.run_cmd('sudo docker exec {} iptables -t nat -A PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip)) |
| 1843 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1844 | assert_equal(st, True) |
| 1845 | st,output = vsg.run_cmd('sudo docker exec {} iptables -t nat -A PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip)) |
| 1846 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1847 | assert_equal(st, False) |
| 1848 | finally: |
| 1849 | vsg.run_cmd('sudo docker exec {} iptables -t nat -D PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip)) |
| 1850 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1851 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1852 | df.callback(0) |
| 1853 | reactor.callLater(0,vcpe_firewall,df) |
| 1854 | return df |
| 1855 | |
| 1856 | @deferred(TIMEOUT) |
| 1857 | def test_vsg_dnat_change_modifying_destination_ip_address(self,vcpe_name=None,vcpe_intf=None): |
| 1858 | """ |
| 1859 | Algo: |
| 1860 | 1. Get vSG corresponding to vcpe |
| 1861 | 2. Login to compute node |
| 1862 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 1863 | 4. From cord-tester ping to www.google.com |
| 1864 | 5. Verifying the ping should not success |
| 1865 | 6. Delete the iptable rule added |
| 1866 | 7. From cord-tester ping to www.google.com |
| 1867 | 8. Verifying the ping should success |
| 1868 | """ |
| 1869 | if not vcpe_name: |
| 1870 | vcpe_name = self.vcpe_container |
| 1871 | if not vcpe_intf: |
| 1872 | vcpe_intf = self.vcpe_dhcp |
| 1873 | df = defer.Deferred() |
| 1874 | def vcpe_firewall(df): |
| 1875 | host = '8.8.8.8' |
| 1876 | dst_ip = '123.123.123.123' |
| 1877 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1878 | try: |
| 1879 | self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp) |
| 1880 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1881 | assert_equal(st, False) |
| 1882 | st,output = vsg.run_cmd('sudo docker exec {} iptables -t nat -A PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip)) |
| 1883 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1884 | assert_equal(st, True) |
| 1885 | st,output = vsg.run_cmd('sudo docker exec {} iptables -t nat -R PREROUTING 1 -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,host)) |
| 1886 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1887 | assert_equal(st, False) |
| 1888 | finally: |
| 1889 | vsg.run_cmd('sudo docker exec {} iptables -t nat -D PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip)) |
| 1890 | vsg.run_cmd('sudo docker exec {} iptables -t nat -D PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,host)) |
| 1891 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1892 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1893 | df.callback(0) |
| 1894 | reactor.callLater(0,vcpe_firewall,df) |
| 1895 | return df |
| 1896 | |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 1897 | def vsg_xos_subscriber_create(self, index): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1898 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1899 | return |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 1900 | subscriber_info = self.subscriber_info[index] |
| 1901 | volt_subscriber_info = self.volt_subscriber_info[index] |
A R Karthick | d0b0679 | 2017-04-25 15:11:23 -0700 | [diff] [blame] | 1902 | s_tag = int(volt_subscriber_info['voltTenant']['s_tag']) |
| 1903 | c_tag = int(volt_subscriber_info['voltTenant']['c_tag']) |
| 1904 | vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag) |
| 1905 | log.info('Creating tenant with s_tag: %d, c_tag: %d' %(s_tag, c_tag)) |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 1906 | subId = '' |
| 1907 | try: |
| 1908 | result = self.restApiXos.ApiPost('TENANT_SUBSCRIBER', subscriber_info) |
| 1909 | assert_equal(result, True) |
| 1910 | result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 1911 | assert_not_equal(result, None) |
| 1912 | subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num']) |
| 1913 | assert_not_equal(subId, '0') |
| 1914 | log.info('Subscriber ID for account num %d = %s' %(volt_subscriber_info['account_num'], subId)) |
| 1915 | volt_tenant = volt_subscriber_info['voltTenant'] |
| 1916 | #update the subscriber id in the tenant info before making the rest |
| 1917 | volt_tenant['subscriber'] = subId |
| 1918 | result = self.restApiXos.ApiPost('TENANT_VOLT', volt_tenant) |
| 1919 | assert_equal(result, True) |
| 1920 | #if the vsg instance was already instantiated, then reduce delay |
| 1921 | if c_tag % self.subscribers_per_s_tag == 0: |
| 1922 | delay = 350 |
| 1923 | else: |
| 1924 | delay = 90 |
| 1925 | log.info('Delaying %d seconds for the VCPE to be provisioned' %(delay)) |
| 1926 | time.sleep(delay) |
| 1927 | log.info('Testing for external connectivity to VCPE %s' %(vcpe)) |
| 1928 | self.vsg_for_external_connectivity(index) |
| 1929 | finally: |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 1930 | return subId |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 1931 | |
| 1932 | def vsg_xos_subscriber_delete(self, index, subId = ''): |
| 1933 | if self.on_pod is False: |
| 1934 | return |
| 1935 | subscriber_info = self.subscriber_info[index] |
| 1936 | volt_subscriber_info = self.volt_subscriber_info[index] |
| 1937 | s_tag = int(volt_subscriber_info['voltTenant']['s_tag']) |
| 1938 | c_tag = int(volt_subscriber_info['voltTenant']['c_tag']) |
| 1939 | vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag) |
| 1940 | log.info('Deleting tenant with s_tag: %d, c_tag: %d' %(s_tag, c_tag)) |
| 1941 | if not subId: |
| 1942 | #get the subscriber id first |
| 1943 | result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 1944 | assert_not_equal(result, None) |
| 1945 | subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num']) |
| 1946 | assert_not_equal(subId, '0') |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 1947 | #get the volt id for the subscriber |
| 1948 | result = self.restApiXos.ApiGet('TENANT_VOLT') |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 1949 | assert_not_equal(result, None) |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 1950 | voltId = self.getVoltId(result, subId) |
| 1951 | assert_not_equal(voltId, None) |
A R Karthick | a385cea | 2017-04-26 10:12:43 -0700 | [diff] [blame] | 1952 | log.info('Deleting subscriber ID %s for account num %d' %(subId, volt_subscriber_info['account_num'])) |
| 1953 | status = self.restApiXos.ApiDelete('TENANT_SUBSCRIBER', subId) |
| 1954 | assert_equal(status, True) |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 1955 | #Delete the tenant |
| 1956 | log.info('Deleting VOLT Tenant ID %s for subscriber %s' %(voltId, subId)) |
A R Karthick | 7694487 | 2017-04-26 10:21:37 -0700 | [diff] [blame] | 1957 | self.restApiXos.ApiDelete('TENANT_VOLT', voltId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 1958 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 1959 | def vsg_xos_subscriber_id(self, index): |
| 1960 | volt_subscriber_info = self.volt_subscriber_info[index] |
| 1961 | result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 1962 | assert_not_equal(result, None) |
| 1963 | subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num']) |
| 1964 | return subId |
| 1965 | |
| 1966 | def test_vsg_xos_subscriber_create_all(self): |
| 1967 | for index in xrange(len(self.subscriber_info)): |
| 1968 | #check if the index exists |
| 1969 | subId = self.vsg_xos_subscriber_id(index) |
| 1970 | if subId and subId != '0': |
| 1971 | self.vsg_xos_subscriber_delete(index, subId = subId) |
| 1972 | subId = self.vsg_xos_subscriber_create(index) |
| 1973 | log.info('Created Subscriber %s' %(subId)) |
| 1974 | |
| 1975 | def test_vsg_xos_subscriber_delete_all(self): |
| 1976 | for index in xrange(len(self.subscriber_info)): |
| 1977 | subId = self.vsg_xos_subscriber_id(index) |
| 1978 | if subId and subId != '0': |
| 1979 | self.vsg_xos_subscriber_delete(index, subId = subId) |
| 1980 | |
| 1981 | def test_vsg_xos_subscriber_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 1982 | subId = self.vsg_xos_subscriber_create(0) |
| 1983 | if subId and subId != '0': |
| 1984 | self.vsg_xos_subscriber_delete(0, subId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 1985 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 1986 | def test_vsg_xos_subscriber_2_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 1987 | subId = self.vsg_xos_subscriber_create(1) |
| 1988 | if subId and subId != '0': |
| 1989 | self.vsg_xos_subscriber_delete(1, subId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 1990 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 1991 | def test_vsg_xos_subscriber_3_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 1992 | subId = self.vsg_xos_subscriber_create(2) |
| 1993 | if subId and subId != '0': |
| 1994 | self.vsg_xos_subscriber_delete(2, subId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 1995 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 1996 | def test_vsg_xos_subscriber_4_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 1997 | subId = self.vsg_xos_subscriber_create(3) |
| 1998 | if subId and subId != '0': |
| 1999 | self.vsg_xos_subscriber_delete(3, subId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 2000 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 2001 | def test_vsg_xos_subscriber_5_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 2002 | subId = self.vsg_xos_subscriber_create(4) |
| 2003 | if subId and subId != '0': |
| 2004 | self.vsg_xos_subscriber_delete(4, subId) |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 2005 | |
Chetan Gaonker | 4cff443 | 2017-05-01 17:56:56 +0000 | [diff] [blame] | 2006 | def test_vsg_multiple_subscribers_for_same_vcpe_instace(self): |
| 2007 | vcpe_intfs,containers = self.get_vcpe_containers_and_interfaces() |
| 2008 | for vcpe in vcpe_intfs: |
| 2009 | vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 2010 | assert_not_equal(vcpe_ip,None) |
| 2011 | for vcpe in vcpe_intfs: |
| 2012 | self.release_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 2013 | |
| 2014 | def test_vsg_multiple_subscribers_for_same_vcpe_instance_ping_to_external_connectivity(self): |
| 2015 | host = '8.8.8.8' |
| 2016 | vcpe_intfs, containers = self.get_vcpe_containers_and_interfaces() |
| 2017 | for vcpe in vcpe_intfs: |
| 2018 | vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 2019 | assert_not_equal(vcpe_ip,None) |
| 2020 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_ip=False) |
| 2021 | st, _ = getstatusoutput('ping -I {} -c 3 {}'.format(vcpe,host)) |
| 2022 | assert_equal(st, 0) |
| 2023 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_release=False) |
| 2024 | for vcpe in vcpe_intfs: |
| 2025 | self.release_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 2026 | |
| 2027 | def test_vsg_vcpe_interface_gets_dhcp_ip_after_interface_toggle(self): |
| 2028 | vcpe_intfs,containers = self.get_vcpe_containers_and_interfaces() |
| 2029 | for vcpe in vcpe_intfs: |
| 2030 | vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 2031 | assert_not_equal(vcpe_ip,None) |
| 2032 | os.system('ifconfig {} down'.format(vcpe)) |
| 2033 | time.sleep(1) |
| 2034 | os.system('ifconfig {} up'.format(vcpe)) |
| 2035 | time.sleep(1) |
| 2036 | vcpe_ip2 = get_ip(vcpe) |
| 2037 | assert_equal(vcpe_ip2,vcpe_ip) |
| 2038 | for vcpe in vcpe_intfs: |
| 2039 | self.release_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 2040 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 2041 | def test_vsg_for_dns_service(self): |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2042 | """ |
| 2043 | Algo: |
| 2044 | 1. Create a test client in Prod VM |
| 2045 | 2. Create a vCPE container in vSG VM inside compute Node |
| 2046 | 3. Ensure vSG VM and vCPE container created properly |
| 2047 | 4. Enable dns service in vCPE ( if not by default ) |
| 2048 | 5. Send ping request from test client to valid domain address say, 'www.google'com |
| 2049 | 6. Verify that dns should resolve ping should success |
| 2050 | 7. Now send ping request to invalid domain address say 'www.invalidaddress'.com' |
| 2051 | 8. Verify that dns resolve should fail and hence ping |
| 2052 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2053 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2054 | def test_vsg_for_10_subscribers_for_same_service(self): |
| 2055 | """ |
| 2056 | Algo: |
| 2057 | 1.Create a vSG VM in compute node |
| 2058 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 2059 | 3.Ensure vSG VM and vCPE container created properly |
| 2060 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP |
| 2061 | 5.Verify that ping success for all 10 subscribers |
| 2062 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2063 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2064 | def test_vsg_for_10_subscribers_for_same_service_ping_invalid_ip(self): |
| 2065 | """ |
| 2066 | Algo: |
| 2067 | 1.Create a vSG VM in compute Node |
| 2068 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 2069 | 3.Ensure vSG VM and vCPE container created properly |
| 2070 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP |
| 2071 | 5.Verify that ping fails for all 10 subscribers |
| 2072 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2073 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2074 | def test_vsg_for_10_subscribers_for_same_service_ping_valid_and_invalid_ip(self): |
| 2075 | """ |
| 2076 | Algo: |
| 2077 | 1.Create a vSG VM in VM |
| 2078 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 2079 | 3.Ensure vSG VM and vCPE container created properly |
| 2080 | 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP |
| 2081 | 5.Verify that ping success for all 5 subscribers |
| 2082 | 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP |
| 2083 | 7.Verify that ping fails for all 5 subscribers |
| 2084 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2085 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2086 | def test_vsg_for_100_subscribers_for_same_service(self): |
| 2087 | """ |
| 2088 | Algo: |
| 2089 | 1.Create a vSG VM in compute node |
| 2090 | 2.Create 100 vCPE containers for 100 subscribers, in vSG VM |
| 2091 | 3.Ensure vSG VM and vCPE container created properly |
| 2092 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP |
| 2093 | 5.Verify that ping success for all 100 subscribers |
| 2094 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2095 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2096 | def test_vsg_for_100_subscribers_for_same_service_ping_invalid_ip(self): |
| 2097 | """ |
| 2098 | Algo: |
| 2099 | 1.Create a vSG VM in compute Node |
| 2100 | 2.Create 10 vCPE containers for 100 subscribers, in vSG VM |
| 2101 | 3.Ensure vSG VM and vCPE container created properly |
| 2102 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP |
| 2103 | 5.Verify that ping fails for all 100 subscribers |
| 2104 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2105 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2106 | def test_vsg_for_100_subscribers_for_same_service_ping_valid_and_invalid_ip(self): |
| 2107 | """ |
| 2108 | Algo: |
| 2109 | 1.Create a vSG VM in VM |
| 2110 | 2.Create 10 vCPE containers for 100 subscribers, in vSG VM |
| 2111 | 3.Ensure vSG VM and vCPE container created properly |
| 2112 | 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP |
| 2113 | 5.Verify that ping success for all 5 subscribers |
| 2114 | 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP |
| 2115 | 7.Verify that ping fails for all 5 subscribers |
| 2116 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2117 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2118 | def test_vsg_for_packet_received_with_invalid_ip_fields(self): |
| 2119 | """ |
| 2120 | Algo: |
| 2121 | 1.Create a vSG VM in compute node |
| 2122 | 2.Create a vCPE container in vSG VM |
| 2123 | 3.Ensure vSG VM and vCPE container created properly |
| 2124 | 4.From subscriber, send a ping packet with invalid ip fields |
| 2125 | 5.Verify that vSG drops the packet |
| 2126 | 6.Verify ping fails |
| 2127 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2128 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2129 | def test_vsg_for_packet_received_with_invalid_mac_fields(self): |
| 2130 | """ |
| 2131 | Algo: |
| 2132 | 1.Create a vSG VM in compute node |
| 2133 | 2.Create a vCPE container in vSG VM |
| 2134 | 3.Ensure vSG VM and vCPE container created properly |
| 2135 | 4.From subscriber, send a ping packet with invalid mac fields |
| 2136 | 5.Verify that vSG drops the packet |
| 2137 | 6.Verify ping fails |
| 2138 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2139 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2140 | def test_vsg_for_vlan_id_mismatch_in_stag(self): |
| 2141 | """ |
| 2142 | Algo: |
| 2143 | 1.Create a vSG VM in compute Node |
| 2144 | 2.Create a vCPE container in vSG VM |
| 2145 | 3.Ensure vSG VM and vCPE container created properly |
| 2146 | 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag |
| 2147 | 5.Verify that ping fails as the packet drops at VM entry |
| 2148 | 6.Repeat step 4 with correct s-tag |
| 2149 | 7.Verify that ping success |
| 2150 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2151 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2152 | def test_vsg_for_vlan_id_mismatch_in_ctag(self): |
| 2153 | """ |
| 2154 | Algo: |
| 2155 | 1.Create a vSG VM in compute node |
| 2156 | 2.Create a vCPE container in vSG VM |
| 2157 | 3.Ensure vSG VM and vCPE container created properly |
| 2158 | 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag |
| 2159 | 5.Verify that ping fails as the packet drops at vCPE container entry |
| 2160 | 6.Repeat step 4 with valid s-tag and c-tag |
| 2161 | 7.Verify that ping success |
| 2162 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2163 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2164 | def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self): |
| 2165 | """ |
| 2166 | Algo: |
| 2167 | 1.Create two vSG VMs in compute node |
| 2168 | 2.Create a vCPE container in each vSG VM |
| 2169 | 3.Ensure vSG VM and vCPE container created properly |
| 2170 | 4.From subscriber one, send ping request with valid s and c tags |
| 2171 | 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags |
| 2172 | 6.Verify that ping success for only subscriber one and fails for two. |
| 2173 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2174 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2175 | def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self): |
| 2176 | """ |
| 2177 | Algo: |
| 2178 | 1.Create a vSG VM in compute node |
| 2179 | 2.Create two vCPE containers in vSG VM |
| 2180 | 3.Ensure vSG VM and vCPE container created properly |
| 2181 | 4.From subscriber one, send ping request with valid s and c tags |
| 2182 | 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag |
| 2183 | 6.Verify that ping success for only subscriber one and fails for two |
| 2184 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2185 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2186 | def test_vsg_for_out_of_range_vlanid_in_ctag(self): |
| 2187 | """ |
| 2188 | Algo: |
| 2189 | 1.Create a vSG VM in compute node |
| 2190 | 2.Create a vCPE container in vSG VM |
| 2191 | 3.Ensure vSG VM and vCPE container created properly |
| 2192 | 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 ) |
| 2193 | 4.Verify that ping fails as the ping packets drops at vCPE container entry |
| 2194 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2195 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2196 | def test_vsg_for_out_of_range_vlanid_in_stag(self): |
| 2197 | """ |
| 2198 | Algo: |
| 2199 | 1.Create a vSG VM in compute node |
| 2200 | 2.Create a vCPE container in vSG VM |
| 2201 | 3.Ensure vSG VM and vCPE container created properly |
| 2202 | 2.From subscriber, send ping request with vlan id in s-tag is an out of range value ( like 0,4097 ), with valid c-tag |
| 2203 | 4.Verify that ping fails as the ping packets drops at vSG VM entry |
| 2204 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2205 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2206 | def test_vsg_without_creating_vcpe_instance(self): |
| 2207 | """ |
| 2208 | Algo: |
| 2209 | 1.Create a vSG VM in compute Node |
| 2210 | 2.Ensure vSG VM created properly |
| 2211 | 3.Do not create vCPE container inside vSG VM |
| 2212 | 4.From a subscriber, send ping to external valid IP |
| 2213 | 5.Verify that ping fails as the ping packet drops at vSG VM entry itself. |
| 2214 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2215 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2216 | def test_vsg_for_remove_vcpe_instance(self): |
| 2217 | """ |
| 2218 | Algo: |
| 2219 | 1.Create a vSG VM in compute node |
| 2220 | 2.Create a vCPE container in vSG VM |
| 2221 | 3.Ensure vSG VM and vCPE container created properly |
| 2222 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 2223 | 5.Verify that ping success |
| 2224 | 6.Verify ping success flows in OvS switch in compute node |
| 2225 | 7.Now remove the vCPE container in vSG VM |
| 2226 | 8.Ensure that the container removed properly |
| 2227 | 9.Repeat step 4 |
| 2228 | 10.Verify that now, ping fails |
| 2229 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2230 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2231 | def test_vsg_for_restart_vcpe_instance(self): |
| 2232 | """ |
| 2233 | Algo: |
| 2234 | 1.Create a vSG VM in compute node |
| 2235 | 2.Create a vCPE container in vSG VM |
| 2236 | 3.Ensure vSG VM and vCPE container created properly |
| 2237 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 2238 | 5.Verify that ping success |
| 2239 | 6.Verify ping success flows in OvS switch in compute node |
| 2240 | 7.Now restart the vCPE container in vSG VM |
| 2241 | 8.Ensure that the container came up after restart |
| 2242 | 9.Repeat step 4 |
| 2243 | 10.Verify that now,ping gets success and flows added in OvS |
| 2244 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2245 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2246 | def test_vsg_for_restart_vsg_vm(self): |
| 2247 | """ |
| 2248 | Algo: |
| 2249 | 1.Create a vSG VM in compute node |
| 2250 | 2.Create a vCPE container in vSG VM |
| 2251 | 3.Ensure vSG VM and vCPE container created properly |
| 2252 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 2253 | 5.Verify that ping success |
| 2254 | 6.Verify ping success flows in OvS switch in compute node |
| 2255 | 7.Now restart the vSG VM |
| 2256 | 8.Ensure that the vSG comes up properly after restart |
| 2257 | 9.Verify that vCPE container comes up after vSG restart |
| 2258 | 10.Repeat step 4 |
| 2259 | 11.Verify that now,ping gets success and flows added in OvS |
| 2260 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2261 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2262 | def test_vsg_for_pause_vcpe_instance(self): |
| 2263 | """ |
| 2264 | Algo: |
| 2265 | 1.Create a vSG VM in compute node |
| 2266 | 2.Create a vCPE container in vSG VM |
| 2267 | 3.Ensure vSG VM and vCPE container created properly |
| 2268 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 2269 | 5.Verify that ping success |
| 2270 | 6.Verify ping success flows in OvS switch in compute node |
| 2271 | 7.Now pause vCPE container in vSG VM for a while |
| 2272 | 8.Ensure that the container state is pause |
| 2273 | 9.Repeat step 4 |
| 2274 | 10.Verify that now,ping fails now and verify flows in OvS |
| 2275 | 11.Now resume the container |
| 2276 | 12.Now repeat step 4 again |
| 2277 | 13.Verify that now, ping gets success |
| 2278 | 14.Verify ping success flows in OvS |
| 2279 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2280 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2281 | def test_vsg_for_extract_all_compute_stats_from_all_vcpe_containers(self): |
| 2282 | """ |
| 2283 | Algo: |
| 2284 | 1.Create a vSG VM in compute node |
| 2285 | 2.Create 10 vCPE containers in VM |
| 2286 | 3.Ensure vSG VM and vCPE containers created properly |
| 2287 | 4.Login to all vCPE containers |
| 2288 | 4.Get all compute stats from all vCPE containers |
| 2289 | 5.Verify the stats # verification method need to add |
| 2290 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2291 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2292 | def test_vsg_for_extract_dns_stats_from_all_vcpe_containers(self): |
| 2293 | """ |
| 2294 | Algo: |
| 2295 | 1.Create a vSG VM in compute node |
| 2296 | 2.Create 10 vCPE containers in VM |
| 2297 | 3.Ensure vSG VM and vCPE containers created properly |
| 2298 | 4.From 10 subscribers, send ping to valid and invalid dns hosts |
| 2299 | 5.Verify dns resolves and ping success for valid dns hosts |
| 2300 | 6.Verify ping fails for invalid dns hosts |
| 2301 | 7.Verify dns host name resolve flows in OvS |
| 2302 | 8.Login to all 10 vCPE containers |
| 2303 | 9.Extract all dns stats |
| 2304 | 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios |
| 2305 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2306 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2307 | def test_vsg_for_subscriber_access_two_vsg_services(self): |
| 2308 | """ |
| 2309 | # Intention is to verify if subscriber can reach internet via two vSG VMs |
| 2310 | Algo: |
| 2311 | 1.Create two vSG VMs for two services in compute node |
| 2312 | 2.Create one vCPE container in each VM for one subscriber |
| 2313 | 3.Ensure VMs and containers created properly |
| 2314 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 2315 | 5.Verify ping gets success |
| 2316 | 6.Verify ping success flows in OvS |
| 2317 | 7.Now repeat step 4 with stag corresponds to vSG-2 VM |
| 2318 | 8.Verify that ping again success |
| 2319 | 9.Verify ping success flows in OvS |
| 2320 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2321 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2322 | def test_vsg_for_subscriber_access_service2_if_service1_goes_down(self): |
| 2323 | """ |
| 2324 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down |
| 2325 | Algo: |
| 2326 | 1.Create two vSG VMs for two services in compute node |
| 2327 | 2.Create one vCPE container in each VM for one subscriber |
| 2328 | 3.Ensure VMs and containers created properly |
| 2329 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 2330 | 5.Verify ping gets success |
| 2331 | 6.Verify ping success flows in OvS |
| 2332 | 7.Down the vSG-1 VM |
| 2333 | 8.Now repeat step 4 |
| 2334 | 9.Verify that ping fails as vSG-1 is down |
| 2335 | 10.Repeat step 4 with stag corresponding to vSG-2 |
| 2336 | 9.Verify ping success and flows added in OvS |
| 2337 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2338 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2339 | def test_vsg_for_subscriber_access_service2_if_service1_goes_restart(self): |
| 2340 | """ |
| 2341 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts |
| 2342 | Algo: |
| 2343 | 1.Create two vSG VMs for two services in compute node |
| 2344 | 2.Create one vCPE container in each VM for one subscriber |
| 2345 | 3.Ensure VMs and containers created properly |
| 2346 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 2347 | 5.Verify ping gets success |
| 2348 | 6.Verify ping success flows added in OvS |
| 2349 | 7.Now restart vSG-1 VM |
| 2350 | 8.Now repeat step 4 while vSG-1 VM restarts |
| 2351 | 9.Verify that ping fails as vSG-1 is restarting |
| 2352 | 10.Repeat step 4 with stag corresponding to vSG-2 while vSG-1 VM restarts |
| 2353 | 11.Verify ping success and flows added in OvS |
| 2354 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2355 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2356 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_goes_down(self): |
| 2357 | """ |
| 2358 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down |
| 2359 | Algo: |
| 2360 | 1.Create a vSG VM in compute node |
| 2361 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 2362 | 3.Ensure VM and containers created properly |
| 2363 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 2364 | 5.Verify ping gets success |
| 2365 | 6.Verify ping success flows added in OvS |
| 2366 | 7.Now stop vCPE-1 container |
| 2367 | 8.Now repeat step 4 |
| 2368 | 9.Verify that ping fails as vCPE-1 container is down |
| 2369 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container |
| 2370 | 11.Verify ping success and flows added in OvS |
| 2371 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2372 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2373 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_restart(self): |
| 2374 | """ |
| 2375 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts |
| 2376 | Algo: |
| 2377 | 1.Create a vSG VM in compute node |
| 2378 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 2379 | 3.Ensure VM and containers created properly |
| 2380 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 2381 | 5.Verify ping gets success |
| 2382 | 6.Verify ping success flows added in OvS |
| 2383 | 7.Now restart vCPE-1 container |
| 2384 | 8.Now repeat step 4 while vCPE-1 restarts |
| 2385 | 9.Verify that ping fails as vCPE-1 container is restarts |
| 2386 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 restarts |
| 2387 | 11..Verify ping success and flows added in OvS |
| 2388 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2389 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2390 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_pause(self): |
| 2391 | """ |
| 2392 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 paused |
| 2393 | Algo: |
| 2394 | 1.Create a vSG VM in compute node |
| 2395 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 2396 | 3.Ensure VM and containers created properly |
| 2397 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 2398 | 5.Verify ping gets success |
| 2399 | 6.Verify ping success flows added in OvS |
| 2400 | 7.Now pause vCPE-1 container |
| 2401 | 8.Now repeat step 4 while vCPE-1 in pause state |
| 2402 | 9.Verify that ping fails as vCPE-1 container in pause state |
| 2403 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 in pause state |
| 2404 | 11.Verify ping success and flows added in OvS |
| 2405 | """ |
| 2406 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_removed(self): |
| 2407 | """ |
| 2408 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 removed |
| 2409 | Algo: |
| 2410 | 1.Create a vSG VM in compute node |
| 2411 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 2412 | 3.Ensure VM and containers created properly |
| 2413 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 2414 | 5.Verify ping gets success |
| 2415 | 6.Verify ping success flows added in OvS |
| 2416 | 7.Now remove vCPE-1 container |
| 2417 | 8.Now repeat step 4 |
| 2418 | 9.Verify that ping fails as vCPE-1 container removed |
| 2419 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container |
| 2420 | 11.Verify ping success and flows added in OvS |
| 2421 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2422 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2423 | def test_vsg_for_vcpe_instance_removed_and_added_again(self): |
| 2424 | """ |
| 2425 | Algo: |
| 2426 | 1.Create a vSG VM in compute node |
| 2427 | 2.Create a vCPE container in vSG VM |
| 2428 | 3.Ensure VM and containers created properly |
| 2429 | 4.From subscriber end, send ping to public IP |
| 2430 | 5.Verify ping gets success |
| 2431 | 6.Verify ping success flows added in OvS |
| 2432 | 7.Now remove vCPE container in vSG VM |
| 2433 | 8.Now repeat step 4 |
| 2434 | 9.Verify that ping fails as vCPE container removed |
| 2435 | 10.Create the vCPE container again for the same subscriber |
| 2436 | 11.Ensure that vCPE created now |
| 2437 | 12.Now repeat step 4 |
| 2438 | 13.Verify ping success and flows added in OvS |
| 2439 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 2440 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 2441 | def test_vsg_for_vsg_vm_removed_and_added_again(self): |
| 2442 | """ |
| 2443 | Algo: |
| 2444 | 1.Create a vSG VM in compute node |
| 2445 | 2.Create a vCPE container in vSG VM |
| 2446 | 3.Ensure VM and containers created properly |
| 2447 | 4.From subscriber end, send ping to public IP |
| 2448 | 5.Verify ping gets success |
| 2449 | 6.Verify ping success flows added in OvS |
| 2450 | 7.Now remove vSG VM |
| 2451 | 8.Now repeat step 4 |
| 2452 | 9.Verify that ping fails as vSG VM not exists |
| 2453 | 10.Create the vSG VM and vCPE container in VM again |
| 2454 | 11.Ensure that vSG and vCPE created |
| 2455 | 12.Now repeat step 4 |
| 2456 | 13.Verify ping success and flows added in OvS |
| 2457 | """ |
| 2458 | |
| 2459 | #Test vSG - Subscriber Configuration |
| 2460 | def test_vsg_for_configuring_new_subscriber_in_vcpe(self): |
| 2461 | """ |
| 2462 | Algo: |
| 2463 | 1.Create a vSG VM in compute node |
| 2464 | 2.Create a vCPE container in vSG VM |
| 2465 | 3.Ensure VM and containers created properly |
| 2466 | 4.Configure a subscriber in XOS and assign a service id |
| 2467 | 5.Set the admin privileges to the subscriber |
| 2468 | 6.Verify subscriber configuration is success |
| 2469 | """ |
| 2470 | def test_vsg_for_adding_subscriber_devices_in_vcpe(self): |
| 2471 | """ |
| 2472 | Algo: |
| 2473 | 1.Create a vSG VM in compute node |
| 2474 | 2.Create a vCPE container in vSG VM |
| 2475 | 3.Ensure VM and containers created properly |
| 2476 | 4.Configure a subscriber in XOS and assign a service id |
| 2477 | 5.Verify subscriber successfully configured in vCPE |
| 2478 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 2479 | 7.Verify all devices ( Macs ) added successfully |
| 2480 | """ |
| 2481 | def test_vsg_for_removing_subscriber_devices_in_vcpe(self): |
| 2482 | """ |
| 2483 | Algo: |
| 2484 | 1.Create a vSG VM in compute node |
| 2485 | 2.Create a vCPE container in vSG VM |
| 2486 | 3.Ensure VM and containers created properly |
| 2487 | 4.Configure a subscriber in XOS and assign a service id |
| 2488 | 5.Verify subscriber successfully configured |
| 2489 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 2490 | 7.Verify all devices ( Macs ) added successfully |
| 2491 | 8.Now remove All the added devices in XOS |
| 2492 | 9.Verify all the devices removed |
| 2493 | """ |
| 2494 | def test_vsg_for_modify_subscriber_devices_in_vcpe(self): |
| 2495 | """ |
| 2496 | Algo: |
| 2497 | 1.Create a vSG VM in compute node |
| 2498 | 2.Create a vCPE container in vSG VM |
| 2499 | 3.Ensure VM and containers created properly |
| 2500 | 4.Configure a user in XOS and assign a service id |
| 2501 | 5.Verify subscriber successfully configured in vCPE. |
| 2502 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 2503 | 7.Verify all devices ( Macs ) added successfully |
| 2504 | 8.Now remove few devices in XOS |
| 2505 | 9.Verify devices removed successfully |
| 2506 | 10.Now add few additional devices in XOS under the same subscriber admin group |
| 2507 | 11.Verify newly added devices successfully added |
| 2508 | """ |
| 2509 | def test_vsg_for_vcpe_login_fails_with_incorrect_subscriber_credentials(self): |
| 2510 | """ |
| 2511 | Algo: |
| 2512 | 1.Create a vSG VM in compute node |
| 2513 | 2.Create a vCPE container in vSG VM |
| 2514 | 3.Ensure VM and containers created properly |
| 2515 | 4.Configure a subscriber in XOS and assign a service id |
| 2516 | 5.Verify subscriber successfully configured |
| 2517 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 2518 | 7.Verify all devices ( Macs ) added successfully |
| 2519 | 8.Login vCPE with credentials with which subscriber configured |
| 2520 | 9.Verify subscriber successfully logged in |
| 2521 | 10.Logout and login again with incorrect credentials ( either user name or password ) |
| 2522 | 11.Verify login attempt to vCPE fails wtih incorrect credentials |
| 2523 | """ |
| 2524 | def test_vsg_for_subscriber_configuration_in_vcpe_retain_after_vcpe_restart(self): |
| 2525 | """ |
| 2526 | Algo: |
| 2527 | 1.Create a vSG VM in compute node |
| 2528 | 2.Create a vCPE container in vSG VM |
| 2529 | 3.Ensure VM and containers created properly |
| 2530 | 4.Configure a subscriber in XOS and assign a service id |
| 2531 | 5.Verify subscriber successfully configured |
| 2532 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 2533 | 7.Verify all devices ( Macs ) added successfully |
| 2534 | 8.Restart vCPE ( locate backup config path while restart ) |
| 2535 | 9.Verify subscriber details in vCPE after restart should be same as before the restart |
| 2536 | """ |
| 2537 | def test_vsg_for_create_multiple_vcpe_instances_and_configure_subscriber_in_each_instance(self): |
| 2538 | """ |
| 2539 | Algo: |
| 2540 | 1.Create a vSG VM in compute node |
| 2541 | 2.Create 2 vCPE containers in vSG VM |
| 2542 | 3.Ensure VM and containers created properly |
| 2543 | 4.Configure a subscriber in XOS for each vCPE instance and assign a service id |
| 2544 | 5.Verify subscribers successfully configured |
| 2545 | 6.Now login vCPE-2 with subscriber-1 credentials |
| 2546 | 7.Verify login fails |
| 2547 | 8.Now login vCPE-1 with subscriber-2 credentials |
| 2548 | 9.Verify login fails |
| 2549 | 10.Now login vCPE-1 with subscriber-1 and vCPE-2 with subscriber-2 credentials |
| 2550 | 11.Verify that both the subscribers able to login to their respective vCPE containers |
| 2551 | """ |
| 2552 | def test_vsg_for_same_subscriber_can_be_configured_for_multiple_services(self): |
| 2553 | """ |
| 2554 | Algo: |
| 2555 | 1.Create 2 vSG VMs in compute node |
| 2556 | 2.Create a vCPE container in each vSG VM |
| 2557 | 3.Ensure VMs and containers created properly |
| 2558 | 4.Configure same subscriber in XOS for each vCPE instance and assign a service id |
| 2559 | 5.Verify subscriber successfully configured |
| 2560 | 6.Now login vCPE-1 with subscriber credentials |
| 2561 | 7.Verify login success |
| 2562 | 8.Now login vCPE-2 with the same subscriber credentials |
| 2563 | 9.Verify login success |
| 2564 | """ |
| 2565 | |
| 2566 | #Test Example Service |
| 2567 | def test_vsg_for_subcriber_avail_example_service_running_in_apache_server(self): |
| 2568 | """ |
| 2569 | Algo: |
| 2570 | 1.Create a vSG VM in compute node |
| 2571 | 2.Create a vCPE container in each vSG VM |
| 2572 | 3.Ensure VM and container created properly |
| 2573 | 4.Configure a subscriber in XOS for the vCPE instance and assign a service id |
| 2574 | 5.On-board an example service into cord pod |
| 2575 | 6.Create a VM in compute node and run the example service ( Apache server ) |
| 2576 | 7.Configure the example service with service specific and subscriber specific messages |
| 2577 | 8.Verify example service on-boarded successfully |
| 2578 | 9.Verify example service running in VM |
| 2579 | 10.Run a curl command from subscriber to reach example service |
| 2580 | 11.Verify subscriber can successfully reach example service via vSG |
| 2581 | 12.Verify that service specific and subscriber specific messages |
| 2582 | """ |
| 2583 | def test_vsg_for_subcriber_avail_example_service_running_in_apache_server_after_service_restart(self): |
| 2584 | """ |
| 2585 | Algo: |
| 2586 | 1.Create a vSG VM in compute node |
| 2587 | 2.Create a vCPE container in each vSG VM |
| 2588 | 3.Ensure VM and container created properly |
| 2589 | 4.Configure a subscriber in XOS for the vCPE instance and assign a service id |
| 2590 | 5.On-board an example service into cord pod |
| 2591 | 6.Create a VM in compute node and run the example service ( Apache server ) |
| 2592 | 7.Configure the example service with service specific and subscriber specific messages |
| 2593 | 8.Verify example service on-boarded successfully |
| 2594 | 9.Verify example service running in VM |
| 2595 | 10.Run a curl command from subscriber to reach example service |
| 2596 | 11.Verify subscriber can successfully reach example service via vSG |
| 2597 | 12.Verify that service specific and subscriber specific messages |
| 2598 | 13.Restart example service running in VM |
| 2599 | 14.Repeat step 10 |
| 2600 | 15.Verify the same results as mentioned in steps 11, 12 |
| 2601 | """ |
| 2602 | |
| 2603 | #vCPE Firewall Functionality |
| 2604 | def test_vsg_firewall_for_creating_acl_rule_based_on_source_ip(self): |
| 2605 | """ |
| 2606 | Algo: |
| 2607 | 1.Create a vSG VM in compute node |
| 2608 | 2.Create vCPE container in the VM |
| 2609 | 3.Ensure vSG VM and vCPE container created properly |
| 2610 | 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP |
| 2611 | 5.Bound the acl rule to WAN interface of vCPE |
| 2612 | 6.Verify configuration in vCPE is success |
| 2613 | 8.Verify flows added in OvS |
| 2614 | """ |
| 2615 | def test_vsg_firewall_for_creating_acl_rule_based_on_destination_ip(self): |
| 2616 | """ |
| 2617 | Algo: |
| 2618 | 1.Create a vSG VM in compute node |
| 2619 | 2.Create vCPE container in the VM |
| 2620 | 3.Ensure vSG VM and vCPE container created properly |
| 2621 | 4.Configure ac acl rule in vCPE to deny IP traffic to a destination ip |
| 2622 | 5.Bound the acl rule to WAN interface of vCPE |
| 2623 | 6.Verify configuration in vCPE is success |
| 2624 | 8.Verify flows added in OvS |
| 2625 | """ |
| 2626 | def test_vsg_firewall_for_acl_deny_rule_based_on_source_ip_traffic(self): |
| 2627 | """ |
| 2628 | Algo: |
| 2629 | 1.Create a vSG VM in compute node |
| 2630 | 2.Create vCPE container in the VM |
| 2631 | 3.Ensure vSG VM and vCPE container created properly |
| 2632 | 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP |
| 2633 | 5.Bound the acl rule to WAN interface of vCPE |
| 2634 | 6.From subscriber, send ping to the denied IP address |
| 2635 | 7.Verify that ping fails as vCPE denies ping response |
| 2636 | 8.Verify flows added in OvS |
| 2637 | """ |
| 2638 | def test_vsg_firewall_for_acl_deny_rule_based_on_destination_ip_traffic(self): |
| 2639 | """ |
| 2640 | Algo: |
| 2641 | 1.Create a vSG VM in compute node |
| 2642 | 2.Create vCPE container in the VM |
| 2643 | 3.Ensure vSG VM and vCPE container created properly |
| 2644 | 4.Configure ac acl rule in vCPE to deny IP traffic to a destination IP |
| 2645 | 5.Bound the acl rule to WAN interface of vCPE |
| 2646 | 6.From subscriber, send ping to the denied IP address |
| 2647 | 7.Verify that ping fails as vCPE drops the ping request at WAN interface |
| 2648 | 8.Verify flows added in OvS |
| 2649 | """ |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 2650 | |
| 2651 | def test_vsg_dnsmasq(self): |
| 2652 | pass |
| 2653 | |
| 2654 | def test_vsg_with_external_parental_control_family_shield_for_filter(self): |
| 2655 | pass |
| 2656 | |
| 2657 | def test_vsg_with_external_parental_control_with_answerx(self): |
| 2658 | pass |
| 2659 | |
| 2660 | def test_vsg_for_subscriber_upstream_bandwidth(self): |
| 2661 | pass |
| 2662 | |
| 2663 | def test_vsg_for_subscriber_downstream_bandwidth(self): |
| 2664 | pass |
| 2665 | |
| 2666 | def test_vsg_for_diagnostic_run_of_traceroute(self): |
| 2667 | pass |
| 2668 | |
| 2669 | def test_vsg_for_diagnostic_run_of_tcpdump(self): |
| 2670 | pass |
| 2671 | |
| 2672 | def test_vsg_for_iptable_rules(self): |
| 2673 | pass |
| 2674 | |
| 2675 | def test_vsg_for_iptables_with_neutron(self): |
| 2676 | pass |