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 | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 19 | import requests |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 20 | from nose.tools import * |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 21 | from twisted.internet import defer |
| 22 | from nose.twistedtools import reactor, deferred |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 23 | from CordTestUtils import * |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 24 | from OltConfig import OltConfig |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 25 | from onosclidriver import OnosCliDriver |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 26 | from SSHTestAgent import SSHTestAgent |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 27 | from CordLogger import CordLogger |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 28 | from VSGAccess import VSGAccess |
A R Karthick | 933f5b5 | 2017-03-27 15:27:16 -0700 | [diff] [blame] | 29 | from CordTestUtils import log_test as log |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 30 | from CordTestConfig import setup_module, running_on_ciab |
A.R Karthick | a9b594d | 2017-03-29 16:25:22 -0700 | [diff] [blame] | 31 | from OnosCtrl import OnosCtrl |
A R Karthick | b608d40 | 2017-06-02 11:48:41 -0700 | [diff] [blame] | 32 | from CordContainer import Onos |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 33 | log.setLevel('INFO') |
| 34 | |
| 35 | class vsg_exchange(CordLogger): |
| 36 | ONOS_INSTANCES = 3 |
| 37 | V_INF1 = 'veth0' |
| 38 | device_id = 'of:' + get_mac() |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 39 | TEST_IP = '8.8.8.8' |
| 40 | HOST = "10.1.0.1" |
| 41 | USER = "vagrant" |
| 42 | PASS = "vagrant" |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 43 | head_node = os.getenv('HEAD_NODE', 'prod') |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 44 | 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] | 45 | test_path = os.path.dirname(os.path.realpath(__file__)) |
A.R Karthick | 5968e0d | 2017-05-16 14:50:46 -0700 | [diff] [blame] | 46 | olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config.json')) |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 47 | restApiXos = None |
A R Karthick | 0a4ca3a | 2017-03-30 09:36:53 -0700 | [diff] [blame] | 48 | subscriber_account_num = 200 |
| 49 | subscriber_s_tag = 304 |
| 50 | subscriber_c_tag = 304 |
| 51 | subscribers_per_s_tag = 8 |
| 52 | subscriber_map = {} |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 53 | subscriber_info = [] |
| 54 | volt_subscriber_info = [] |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 55 | restore_methods = [] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 56 | TIMEOUT=120 |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 57 | FABRIC_PORT_HEAD_NODE = 1 |
| 58 | FABRIC_PORT_COMPUTE_NODE = 2 |
| 59 | APP_NAME = 'org.ciena.xconnect' |
| 60 | 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] | 61 | NUM_SUBSCRIBERS = 5 |
A R Karthick | 0a4ca3a | 2017-03-30 09:36:53 -0700 | [diff] [blame] | 62 | |
| 63 | @classmethod |
| 64 | def getSubscriberCredentials(cls, subId): |
| 65 | """Generate our own account num, s_tag and c_tags""" |
| 66 | if subId in cls.subscriber_map: |
| 67 | return cls.subscriber_map[subId] |
| 68 | account_num = cls.subscriber_account_num |
| 69 | cls.subscriber_account_num += 1 |
| 70 | s_tag, c_tag = cls.subscriber_s_tag, cls.subscriber_c_tag |
| 71 | cls.subscriber_c_tag += 1 |
| 72 | if cls.subscriber_c_tag % cls.subscribers_per_s_tag == 0: |
| 73 | cls.subscriber_s_tag += 1 |
| 74 | cls.subscriber_map[subId] = account_num, s_tag, c_tag |
| 75 | return cls.subscriber_map[subId] |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 76 | |
| 77 | @classmethod |
A.R Karthick | a9b594d | 2017-03-29 16:25:22 -0700 | [diff] [blame] | 78 | def getXosCredentials(cls): |
| 79 | onos_cfg = OnosCtrl.get_config() |
| 80 | if onos_cfg is None: |
| 81 | return None |
| 82 | if 'apps' in onos_cfg and \ |
| 83 | 'org.opencord.vtn' in onos_cfg['apps'] and \ |
| 84 | 'cordvtn' in onos_cfg['apps']['org.opencord.vtn'] and \ |
| 85 | 'xos' in onos_cfg['apps']['org.opencord.vtn']['cordvtn']: |
| 86 | xos_cfg = onos_cfg['apps']['org.opencord.vtn']['cordvtn']['xos'] |
| 87 | endpoint = xos_cfg['endpoint'] |
| 88 | user = xos_cfg['user'] |
| 89 | password = xos_cfg['password'] |
| 90 | xos_endpoints = endpoint.split(':') |
| 91 | xos_host = xos_endpoints[1][len('//'):] |
| 92 | xos_port = xos_endpoints[2][:-1] |
| 93 | #log.info('xos_host: %s, port: %s, user: %s, password: %s' %(xos_host, xos_port, user, password)) |
| 94 | return dict(host = xos_host, port = xos_port, user = user, password = password) |
| 95 | |
| 96 | return None |
| 97 | |
| 98 | @classmethod |
A.R Karthick | 50f4d9a | 2017-04-20 16:44:19 -0700 | [diff] [blame] | 99 | def getSubscriberConfig(cls, num_subscribers): |
| 100 | features = { |
| 101 | 'cdn': True, |
| 102 | 'uplink_speed': 1000000000, |
| 103 | 'downlink_speed': 1000000000, |
| 104 | 'uverse': True, |
| 105 | 'status': 'enabled' |
| 106 | } |
| 107 | subscriber_map = [] |
| 108 | for i in xrange(num_subscribers): |
| 109 | subId = 'sub{}'.format(i) |
| 110 | account_num, _, _ = cls.getSubscriberCredentials(subId) |
| 111 | identity = { 'account_num' : str(account_num), |
| 112 | 'name' : 'My House {}'.format(i) |
| 113 | } |
| 114 | sub_info = { 'features' : features, |
| 115 | 'identity' : identity |
| 116 | } |
| 117 | subscriber_map.append(sub_info) |
| 118 | |
| 119 | return subscriber_map |
| 120 | |
| 121 | @classmethod |
| 122 | def getVoltSubscriberConfig(cls, num_subscribers): |
| 123 | voltSubscriberMap = [] |
| 124 | for i in xrange(num_subscribers): |
| 125 | subId = 'sub{}'.format(i) |
| 126 | account_num, s_tag, c_tag = cls.getSubscriberCredentials(subId) |
| 127 | voltSubscriberInfo = {} |
| 128 | voltSubscriberInfo['voltTenant'] = dict(s_tag = str(s_tag), |
| 129 | c_tag = str(c_tag), |
| 130 | subscriber = '') |
| 131 | voltSubscriberInfo['account_num'] = account_num |
| 132 | voltSubscriberMap.append(voltSubscriberInfo) |
| 133 | |
| 134 | return voltSubscriberMap |
| 135 | |
| 136 | @classmethod |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 137 | def setUpCordApi(cls): |
| 138 | our_path = os.path.dirname(os.path.realpath(__file__)) |
| 139 | cord_api_path = os.path.join(our_path, '..', 'cord-api') |
| 140 | framework_path = os.path.join(cord_api_path, 'Framework') |
| 141 | utils_path = os.path.join(framework_path, 'utils') |
| 142 | data_path = os.path.join(cord_api_path, 'Tests', 'data') |
| 143 | subscriber_cfg = os.path.join(data_path, 'Subscriber.json') |
| 144 | volt_tenant_cfg = os.path.join(data_path, 'VoltTenant.json') |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 145 | num_subscribers = max(cls.NUM_SUBSCRIBERS, 5) |
| 146 | cls.subscriber_info = cls.getSubscriberConfig(num_subscribers) |
| 147 | cls.volt_subscriber_info = cls.getVoltSubscriberConfig(num_subscribers) |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 148 | |
| 149 | sys.path.append(utils_path) |
| 150 | sys.path.append(framework_path) |
| 151 | from restApi import restApi |
| 152 | restApiXos = restApi() |
A.R Karthick | a9b594d | 2017-03-29 16:25:22 -0700 | [diff] [blame] | 153 | xos_credentials = cls.getXosCredentials() |
| 154 | if xos_credentials is None: |
| 155 | restApiXos.controllerIP = cls.HEAD_NODE |
| 156 | restApiXos.controllerPort = '9000' |
| 157 | else: |
| 158 | restApiXos.controllerIP = xos_credentials['host'] |
| 159 | restApiXos.controllerPort = xos_credentials['port'] |
| 160 | restApiXos.user = xos_credentials['user'] |
| 161 | restApiXos.password = xos_credentials['password'] |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 162 | cls.restApiXos = restApiXos |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 163 | |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 164 | @classmethod |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 165 | def getVoltId(cls, result, subId): |
| 166 | if type(result) is not type([]): |
| 167 | return None |
| 168 | for tenant in result: |
| 169 | if str(tenant['subscriber']) == str(subId): |
| 170 | return str(tenant['id']) |
| 171 | return None |
| 172 | |
| 173 | @classmethod |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 174 | def closeVCPEAccess(cls, volt_subscriber_info): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 175 | OnosCtrl.uninstall_app(cls.APP_NAME, onos_ip = cls.HEAD_NODE) |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 176 | |
| 177 | @classmethod |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 178 | def openVCPEAccess(cls, volt_subscriber_info): |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 179 | """ |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 180 | This code is used to configure leaf switch for head node access to compute node over fabric. |
| 181 | Care is to be taken to avoid overwriting existing/default vcpe flows. |
| 182 | The access is opened for generated subscriber info which should not overlap. |
| 183 | We target the fabric onos instance on head node. |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 184 | """ |
A R Karthick | b608d40 | 2017-06-02 11:48:41 -0700 | [diff] [blame] | 185 | version = Onos.getVersion(onos_ip = cls.HEAD_NODE) |
| 186 | app_version = '1.0-SNAPSHOT' |
| 187 | major = int(version.split('.')[0]) |
| 188 | minor = int(version.split('.')[1]) |
| 189 | if major > 1: |
| 190 | app_version = '2.0-SNAPSHOT' |
| 191 | elif major == 1 and minor > 10: |
| 192 | app_version = '2.0-SNAPSHOT' |
| 193 | cls.APP_FILE = os.path.join(cls.test_path, '..', 'apps/xconnect-{}.oar'.format(app_version)) |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 194 | OnosCtrl.install_app(cls.APP_FILE, onos_ip = cls.HEAD_NODE) |
| 195 | time.sleep(2) |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 196 | s_tags = map(lambda tenant: int(tenant['voltTenant']['s_tag']), volt_subscriber_info) |
| 197 | #only get unique vlan tags |
| 198 | s_tags = list(set(s_tags)) |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 199 | devices = OnosCtrl.get_device_ids(controller = cls.HEAD_NODE) |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 200 | if devices: |
| 201 | device_config = {} |
| 202 | for device in devices: |
| 203 | device_config[device] = [] |
| 204 | for s_tag in s_tags: |
| 205 | xconnect_config = {'vlan': s_tag, 'ports' : [ cls.FABRIC_PORT_HEAD_NODE, cls.FABRIC_PORT_COMPUTE_NODE ] } |
| 206 | device_config[device].append(xconnect_config) |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 207 | |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 208 | cfg = { 'apps' : { 'org.ciena.xconnect' : { 'xconnectTestConfig' : device_config } } } |
| 209 | OnosCtrl.config(cfg, controller = cls.HEAD_NODE) |
A.R Karthick | b145da8 | 2017-04-20 14:45:43 -0700 | [diff] [blame] | 210 | |
| 211 | @classmethod |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 212 | def setUpClass(cls): |
| 213 | cls.controllers = get_controllers() |
| 214 | cls.controller = cls.controllers[0] |
| 215 | cls.cli = None |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 216 | cls.on_pod = running_on_pod() |
| 217 | cls.on_ciab = running_on_ciab() |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 218 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
| 219 | cls.vcpes = cls.olt.get_vcpes() |
| 220 | cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp') |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 221 | cls.vcpes_reserved = cls.olt.get_vcpes_by_type('reserved') |
| 222 | cls.dhcp_vcpes_reserved = [ 'vcpe{}.{}.{}'.format(i, cls.vcpes_reserved[i]['s_tag'], cls.vcpes_reserved[i]['c_tag']) |
| 223 | for i in xrange(len(cls.vcpes_reserved)) ] |
| 224 | cls.untagged_dhcp_vcpes_reserved = [ 'vcpe{}'.format(i) for i in xrange(len(cls.vcpes_reserved)) ] |
| 225 | cls.container_vcpes_reserved = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ] |
| 226 | vcpe_dhcp_reserved = None |
| 227 | vcpe_container_reserved = None |
| 228 | if cls.vcpes_reserved: |
| 229 | vcpe_dhcp_reserved = cls.dhcp_vcpes_reserved[0] |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 230 | if cls.on_pod is False: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 231 | vcpe_dhcp_reserved = cls.untagged_dhcp_vcpes_reserved[0] |
| 232 | vcpe_container_reserved = cls.container_vcpes_reserved[0] |
| 233 | |
| 234 | cls.vcpe_dhcp_reserved = vcpe_dhcp_reserved |
| 235 | cls.vcpe_container_reserved = vcpe_container_reserved |
| 236 | dhcp_vcpe_offset = len(cls.vcpes_reserved) |
A R Karthick | 927129c | 2017-04-25 14:08:02 -0700 | [diff] [blame] | 237 | cls.dhcp_vcpes = [ 'vcpe{}.{}.{}'.format(i+dhcp_vcpe_offset, cls.vcpes_dhcp[i]['s_tag'], cls.vcpes_dhcp[i]['c_tag']) |
| 238 | for i in xrange(len(cls.vcpes_dhcp)) ] |
| 239 | cls.untagged_dhcp_vcpes = [ 'vcpe{}'.format(i+dhcp_vcpe_offset) for i in xrange(len(cls.vcpes_dhcp)) ] |
| 240 | 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] | 241 | vcpe_dhcp = None |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 242 | vcpe_container = None |
| 243 | #cache the first dhcp vcpe in the class for quick testing |
| 244 | if cls.vcpes_dhcp: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 245 | vcpe_container = cls.container_vcpes[0] |
| 246 | vcpe_dhcp = cls.dhcp_vcpes[0] |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 247 | if cls.on_pod is False: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 248 | vcpe_dhcp = cls.untagged_dhcp_vcpes[0] |
| 249 | cls.vcpe_container = vcpe_container_reserved or vcpe_container |
| 250 | cls.vcpe_dhcp = vcpe_dhcp_reserved or vcpe_dhcp |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 251 | VSGAccess.setUp() |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 252 | cls.setUpCordApi() |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 253 | if cls.on_pod is True: |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 254 | cls.openVCPEAccess(cls.volt_subscriber_info) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 255 | |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 256 | @classmethod |
| 257 | def tearDownClass(cls): |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 258 | VSGAccess.tearDown() |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 259 | if cls.on_pod is True: |
A R Karthick | b0cec7c | 2017-04-21 10:42:54 -0700 | [diff] [blame] | 260 | cls.closeVCPEAccess(cls.volt_subscriber_info) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 261 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 262 | def onos_shutdown(self, controller = None): |
| 263 | status = True |
A R Karthick | b608d40 | 2017-06-02 11:48:41 -0700 | [diff] [blame] | 264 | cli = Onos.cliEnter(onos_ip = controller) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 265 | try: |
A R Karthick | b608d40 | 2017-06-02 11:48:41 -0700 | [diff] [blame] | 266 | cli.shutdown(timeout = 10) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 267 | except: |
| 268 | log.info('Graceful shutdown of ONOS failed for controller: %s' %controller) |
| 269 | status = False |
| 270 | |
A R Karthick | b608d40 | 2017-06-02 11:48:41 -0700 | [diff] [blame] | 271 | Onos.cliExit(cli) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 272 | return status |
| 273 | |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 274 | def log_set(self, level = None, app = 'org.onosproject'): |
| 275 | CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 276 | |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 277 | @classmethod |
| 278 | def get_dhcp(cls, vcpe, mgmt = 'eth0'): |
| 279 | """Get DHCP for vcpe interface saving management settings""" |
| 280 | |
| 281 | def put_dhcp(): |
| 282 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 283 | |
| 284 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 285 | if vcpe_ip is not None: |
| 286 | cls.restore_methods.append(put_dhcp) |
| 287 | return vcpe_ip |
| 288 | |
| 289 | @classmethod |
| 290 | def config_restore(cls): |
| 291 | """Restore the vsg test configuration on test case failures""" |
| 292 | for restore_method in cls.restore_methods: |
| 293 | restore_method() |
| 294 | |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 295 | def get_vsg_vcpe_pair(self): |
| 296 | vcpes = self.vcpes_dhcp |
| 297 | vcpe_containers = [] |
| 298 | vsg_vcpe = {} |
| 299 | for vcp in vcpes: |
| 300 | vcpe_container = 'vcpe-{}-{}'.format(vcp['s_tag'], vcp['c_tag']) |
| 301 | vcpe_containers.append(vcpe_container) |
| 302 | vsg = VSGAccess.get_vcpe_vsg(vcpe_container) |
| 303 | vsg_vcpe[vcpe_container]=str(vsg.get_ip()) |
| 304 | return vsg_vcpe |
| 305 | |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 306 | def get_vcpe_containers_and_interfaces(self): |
| 307 | vcpe_containers = {} |
| 308 | vcpe_interfaces = [] |
| 309 | vcpes = self.vcpes_dhcp |
| 310 | count = 0 |
| 311 | for vcpe in vcpes: |
| 312 | vcpe_intf = 'vcpe{}.{}.{}'.format(count,vcpe['s_tag'],vcpe['c_tag']) |
| 313 | vcpe_interfaces.append(vcpe_intf) |
| 314 | vcpe_container = 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) |
| 315 | vcpe_containers[vcpe_intf] = vcpe_container |
| 316 | count += 1 |
| 317 | log.info('vcpe interfaces are %s'%vcpe_interfaces) |
| 318 | log.info('vcpe containers are %s'%vcpe_containers) |
| 319 | return vcpe_interfaces,vcpe_containers |
| 320 | |
| 321 | def get_vcpe_interface_dhcp_ip(self,vcpe=None): |
| 322 | if not vcpe: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 323 | vcpe = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 324 | st, _ = getstatusoutput('dhclient {}'.format(vcpe)) |
| 325 | vcpe_ip = get_ip(vcpe) |
| 326 | return vcpe_ip |
| 327 | |
| 328 | def release_vcpe_interface_dhcp_ip(self,vcpe=None): |
| 329 | if not vcpe: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 330 | vcpe = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 331 | st, _ = getstatusoutput('dhclient {} -r'.format(vcpe)) |
| 332 | vcpe_ip = get_ip(vcpe) |
| 333 | assert_equal(vcpe_ip, None) |
| 334 | |
| 335 | 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] | 336 | if not vcpe: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 337 | vcpe = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 338 | if dhcp_ip: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 339 | os.system('dhclient '+vcpe) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 340 | time.sleep(1) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 341 | for route in routes: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 342 | log.info('route is %s'%route) |
| 343 | cmd = 'ip route add ' + route + ' via 192.168.0.1 '+ 'dev ' + vcpe |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 344 | os.system(cmd) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 345 | return True |
| 346 | |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 347 | 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] | 348 | if not vcpe: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 349 | vcpe = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 350 | cmds = [] |
| 351 | for route in routes: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 352 | cmd = 'ip route del ' + route + ' via 192.168.0.1 ' + 'dev ' + vcpe |
| 353 | os.system(cmd) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 354 | if dhcp_release: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 355 | os.system('dhclient '+vcpe+' -r') |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 356 | return True |
| 357 | |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 358 | def vsg_for_external_connectivity(self, subscriber_index, reserved = False): |
| 359 | if reserved is True: |
| 360 | if self.on_pod is True: |
| 361 | vcpe = self.dhcp_vcpes_reserved[subscriber_index] |
| 362 | else: |
| 363 | vcpe = self.untagged_dhcp_vcpes_reserved[subscriber_index] |
| 364 | else: |
| 365 | if self.on_pod is True: |
| 366 | vcpe = self.dhcp_vcpes[subscriber_index] |
| 367 | else: |
| 368 | vcpe = self.untagged_dhcp_vcpes[subscriber_index] |
| 369 | mgmt = 'eth0' |
| 370 | host = '8.8.8.8' |
| 371 | self.success = False |
| 372 | assert_not_equal(vcpe, None) |
| 373 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 374 | assert_not_equal(vcpe_ip, None) |
| 375 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 376 | log.info('Sending icmp echo requests to external network 8.8.8.8') |
| 377 | st, _ = getstatusoutput('ping -c 3 8.8.8.8') |
| 378 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 379 | assert_equal(st, 0) |
| 380 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 381 | def get_vsg_health_check(self, vsg_name=None): |
| 382 | if self.on_pod is False: |
| 383 | return |
| 384 | if vsg_name is None: |
| 385 | vcpe = self.container_vcpes_reserved[0] |
| 386 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 387 | status = vsg.get_health() |
| 388 | return status |
| 389 | else: |
| 390 | vsgs = VSGAccess.get_vsgs() |
| 391 | for vsg in vsgs: |
| 392 | if vsg.name == vsg_name: |
| 393 | status = vsg.get_health() |
| 394 | return status |
| 395 | return None |
| 396 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 397 | def test_vsg_health(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 398 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 399 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 400 | 1. Login to compute node VM |
| 401 | 2. Get all vSGs |
| 402 | 3. Ping to all vSGs |
| 403 | 4. Verifying Ping success |
| 404 | """ |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 405 | status = True |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 406 | if self.on_pod is True: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 407 | status = VSGAccess.health_check() |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 408 | assert_equal(status, True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 409 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 410 | def test_vsg_health_check(self, vsg_name=None, verify_status=True): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 411 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 412 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 413 | 1. If vsg name not specified, Get vsg corresponding to vcpe |
| 414 | 1. Login to compute mode VM |
| 415 | 3. Ping to the vSG |
| 416 | 4. Verifying Ping success |
| 417 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 418 | st = self.get_vsg_health_check(vsg_name=vsg_name) |
| 419 | assert_equal(st,verify_status) |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 420 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 421 | @deferred(30) |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 422 | def test_vsg_for_vcpe(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 423 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 424 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 425 | 1. Get list of all compute nodes created using Openstack |
| 426 | 2. Login to compute mode VM |
| 427 | 3. Get all vSGs |
| 428 | 4. Verifying atleast one compute node and one vSG created |
| 429 | """ |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 430 | df = defer.Deferred() |
| 431 | def vsg_for_vcpe_df(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 432 | if self.on_pod is True: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 433 | vsgs = VSGAccess.get_vsgs() |
| 434 | compute_nodes = VSGAccess.get_compute_nodes() |
| 435 | time.sleep(14) |
| 436 | assert_not_equal(len(vsgs), 0) |
| 437 | assert_not_equal(len(compute_nodes), 0) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 438 | df.callback(0) |
| 439 | reactor.callLater(0,vsg_for_vcpe_df,df) |
| 440 | return df |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 441 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 442 | def test_vsg_for_login(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 443 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 444 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 445 | 1. Login to compute node VM |
| 446 | 2. Get all vSGs |
| 447 | 3. Verifying login to vSG is success |
| 448 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 449 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 450 | return |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 451 | vsgs = VSGAccess.get_vsgs() |
| 452 | vsg_access_status = map(lambda vsg: vsg.check_access(), vsgs) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 453 | status = filter(lambda st: st == False, vsg_access_status) |
| 454 | assert_equal(len(status), 0) |
| 455 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 456 | def test_vsg_for_default_route_through_testclient(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 457 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 458 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 459 | 1. Login to head node |
| 460 | 2. Verifying for default route in lxc test client |
| 461 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 462 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 463 | return |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 464 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 465 | cmd = "sudo lxc exec testclient -- route | grep default" |
| 466 | status, output = ssh_agent.run_cmd(cmd) |
| 467 | assert_equal(status, True) |
| 468 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 469 | @deferred(30) |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 470 | def test_vsg_for_external_connectivity_through_testclient(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 471 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 472 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 473 | 1. Login to head node |
| 474 | 2. On head node, executing ping to 8.8.8.8 from lxc test client |
| 475 | 3. Verifying for the ping success |
| 476 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 477 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 478 | return |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 479 | df = defer.Deferred() |
| 480 | def test_external_connectivity(df): |
| 481 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 482 | cmd = "sudo lxc exec testclient -- ping -c 3 8.8.8.8" |
| 483 | status, output = ssh_agent.run_cmd(cmd) |
| 484 | assert_equal( status, True) |
| 485 | df.callback(0) |
| 486 | reactor.callLater(0,test_external_connectivity,df) |
| 487 | return df |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 488 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 489 | @deferred(30) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 490 | def test_vsg_for_external_connectivity(self): |
| 491 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 492 | Test Method: |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 493 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 494 | 2. Verifying vcpe interface gets dhcp IP |
| 495 | 3. Ping to 8.8.8.8 and Verifying ping should success |
| 496 | 4. Restoring management interface configuration in cord-tester |
| 497 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 498 | reserved = True |
| 499 | if self.on_pod: |
| 500 | reserved = self.on_ciab |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 501 | df = defer.Deferred() |
| 502 | def test_external_connectivity(df): |
| 503 | self.vsg_for_external_connectivity(0, reserved = reserved) |
| 504 | df.callback(0) |
| 505 | reactor.callLater(0,test_external_connectivity,df) |
| 506 | return df |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 507 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 508 | @deferred(30) |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 509 | def test_vsg_for_external_connectivity_to_google(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 510 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 511 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 512 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 513 | 2. Verifying vcpe interface gets dhcp IP |
| 514 | 3. Ping to www.google.com and Verifying ping should success |
| 515 | 4. Restoring management interface configuration in cord-tester |
| 516 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 517 | df = defer.Deferred() |
| 518 | def test_external_connectivity(df): |
| 519 | host = 'www.google.com' |
| 520 | vcpe = self.dhcp_vcpes_reserved[0] |
| 521 | mgmt = 'eth0' |
| 522 | assert_not_equal(vcpe, None) |
| 523 | try: |
| 524 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 525 | assert_not_equal(vcpe_ip, None) |
| 526 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 527 | log.info('Sending icmp ping requests to %s' %host) |
| 528 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 529 | assert_equal(st, 0) |
| 530 | except Exception as error: |
| 531 | log.info('Got Unexpected error %s'%error) |
| 532 | raise |
| 533 | finally: |
| 534 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 535 | df.callback(0) |
| 536 | reactor.callLater(0,test_external_connectivity,df) |
| 537 | return df |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 538 | |
A R Karthick | b261805 | 2017-05-10 09:23:22 -0700 | [diff] [blame] | 539 | def retrieve_content_from_host_to_validate_path_mtu(self, host): |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 540 | vcpe = self.dhcp_vcpes_reserved[0] |
A R Karthick | b261805 | 2017-05-10 09:23:22 -0700 | [diff] [blame] | 541 | mgmt = 'eth0' |
| 542 | assert_not_equal(vcpe, None) |
| 543 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 544 | assert_not_equal(vcpe_ip, None) |
| 545 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 546 | log.info('Initiating get requests to %s' %host) |
| 547 | r = requests.get('http://{}'.format(host)) |
| 548 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 549 | return r.status_code |
| 550 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 551 | @deferred(30) |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 552 | def test_vsg_to_retrieve_content_from_google_to_validate_path_mtu(self): |
| 553 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 554 | Test Method: |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 555 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 556 | 2. Verifying vcpe interface gets dhcp IP |
| 557 | 3. Retrieve contents from www.google.com and Verify response status is 200 ok. |
| 558 | 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework. |
| 559 | (Based on website response, size differs, needs check on MTU) |
| 560 | 4. Restoring management interface configuration in cord-tester |
| 561 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 562 | df = defer.Deferred() |
| 563 | def test_external_connectivity(df): |
| 564 | status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.google.com') |
| 565 | assert_equal(status_code, 200) |
| 566 | df.callback(0) |
| 567 | reactor.callLater(0,test_external_connectivity,df) |
| 568 | return df |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 569 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 570 | @deferred(30) |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 571 | def test_vsg_to_retrieve_content_from_rediff_to_validate_path_mtu(self): |
| 572 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 573 | Test Method: |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 574 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 575 | 2. Verifying vcpe interface gets dhcp IP |
| 576 | 3. Retrieve contents from www.rediff.com and Verify response status is 200 ok. |
| 577 | 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework. |
| 578 | (Based on website response, size differs, needs check on MTU) |
| 579 | 4. Restoring management interface configuration in cord-tester |
| 580 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 581 | df = defer.Deferred() |
| 582 | def test_external_connectivity(df): |
| 583 | status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.rediff.com') |
| 584 | assert_equal(status_code, 200) |
| 585 | df.callback(0) |
| 586 | reactor.callLater(0,test_external_connectivity,df) |
| 587 | return df |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 588 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 589 | @deferred(30) |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 590 | def test_vsg_to_retrieve_content_from_yahoo_to_validate_path_mtu(self): |
| 591 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 592 | Test Method: |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 593 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 594 | 2. Verifying vcpe interface gets dhcp IP |
| 595 | 3. Retrieve contents from www.yahoo.com and Verify response status is 200 ok. |
| 596 | 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework. |
| 597 | (Based on website response, size differs, needs check on MTU) |
| 598 | 4. Restoring management interface configuration in cord-tester |
| 599 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 600 | df = defer.Deferred() |
| 601 | def test_external_connectivity(df): |
| 602 | status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.yahoo.com') |
| 603 | assert_equal(status_code, 200) |
| 604 | df.callback(0) |
| 605 | reactor.callLater(0,test_external_connectivity,df) |
| 606 | return df |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 607 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 608 | @deferred(30) |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 609 | def test_vsg_to_retrieve_content_from_facebook_to_validate_path_mtu(self): |
| 610 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 611 | Test Method: |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 612 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 613 | 2. Verifying vcpe interface gets dhcp IP |
| 614 | 3. Retrieve contents from www.facebook.com and Verify response status is 200 ok. |
| 615 | 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework. |
| 616 | (Based on website response, size differs, needs check on MTU) |
| 617 | 4. Restoring management interface configuration in cord-tester |
| 618 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 619 | df = defer.Deferred() |
| 620 | def test_external_connectivity(df): |
| 621 | status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.facebook.com') |
| 622 | assert_equal(status_code, 200) |
| 623 | df.callback(0) |
| 624 | reactor.callLater(0,test_external_connectivity,df) |
| 625 | return df |
Chetan Gaonker | 0bf7631 | 2017-05-09 16:48:10 +0000 | [diff] [blame] | 626 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 627 | |
| 628 | @deferred(30) |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 629 | def test_vsg_for_external_connectivity_to_invalid_host(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 630 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 631 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 632 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 633 | 2. Verifying vcpe interface gets dhcp IP |
| 634 | 3. Ping to www.goglee.com and Verifying ping should not success |
| 635 | 4. Restoring management interface configuration in cord-tester |
| 636 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 637 | df = defer.Deferred() |
| 638 | def test_external_connectivity(df): |
| 639 | host = 'www.goglee.com' |
| 640 | vcpe = self.dhcp_vcpes_reserved[0] |
| 641 | mgmt = 'eth0' |
| 642 | assert_not_equal(vcpe, None) |
| 643 | try: |
| 644 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 645 | assert_not_equal(vcpe_ip, None) |
| 646 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 647 | log.info('Sending icmp ping requests to non existent host %s' %host) |
| 648 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 649 | assert_not_equal(st, 0) |
| 650 | except Exception as error: |
| 651 | log.info('Got Unexpected error %s'%error) |
| 652 | raise |
| 653 | finally: |
| 654 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 655 | df.callback(0) |
| 656 | reactor.callLater(0,test_external_connectivity,df) |
| 657 | return df |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 658 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 659 | @deferred(30) |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 660 | def test_vsg_for_external_connectivity_with_ttl_1(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 661 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 662 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 663 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 664 | 2. Verifying vcpe interface gets dhcp IP |
| 665 | 3. Ping to 8.8.8.8 with ttl set to 1 |
| 666 | 4. Verifying ping should not success |
| 667 | 5. Restoring management interface configuration in cord-tester |
| 668 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 669 | df = defer.Deferred() |
| 670 | def test_external_connectivity(df): |
| 671 | host = '8.8.8.8' |
| 672 | vcpe = self.dhcp_vcpes_reserved[0] |
| 673 | mgmt = 'eth0' |
| 674 | assert_not_equal(vcpe, None) |
| 675 | try: |
| 676 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 677 | assert_not_equal(vcpe_ip, None) |
| 678 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 679 | log.info('Sending icmp ping requests to host %s with ttl 1' %host) |
| 680 | st, _ = getstatusoutput('ping -c 1 -t 1 {}'.format(host)) |
| 681 | assert_not_equal(st, 0) |
| 682 | except Exception as error: |
| 683 | log.info('Got Unexpected error %s'%error) |
| 684 | raise |
| 685 | finally: |
| 686 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 687 | df.callback(0) |
| 688 | reactor.callLater(0,test_external_connectivity,df) |
| 689 | return df |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 690 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 691 | @deferred(60) |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 692 | 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] | 693 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 694 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 695 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 696 | 2. Verifying vcpe interface gets dhcp IP |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 697 | 3. Ping to 8.8.8.8 and Verifying ping succeeds |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 698 | 4. Now down the WAN interface of vcpe |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 699 | 5. Ping to 8.8.8.8 and Verifying ping fails |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 700 | 6. Now Up the WAN interface of vcpe |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 701 | 7. Ping to 8.8.8.8 and Verifying ping succeeds |
| 702 | 8. Restoring management interface configuration in cord-tester |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 703 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 704 | df = defer.Deferred() |
| 705 | def test_external_connectivity(df): |
| 706 | if self.on_pod is False: |
| 707 | return |
| 708 | host = '8.8.8.8' |
| 709 | mgmt = 'eth0' |
| 710 | vcpe = self.dhcp_vcpes_reserved[0] |
| 711 | vcpe_name = self.container_vcpes_reserved[0] |
| 712 | assert_not_equal(vcpe_name, None) |
| 713 | assert_not_equal(vcpe, None) |
| 714 | #first get dhcp on the vcpe interface |
| 715 | try: |
| 716 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 717 | assert_not_equal(vcpe_ip, None) |
| 718 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 719 | log.info('Sending ICMP pings to host %s' %(host)) |
| 720 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 721 | if st != 0: |
| 722 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 723 | assert_equal(st, 0) |
| 724 | #bring down the wan interface and check again |
| 725 | st = VSGAccess.vcpe_wan_down(vcpe_name) |
| 726 | if st is False: |
| 727 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 728 | assert_equal(st, True) |
| 729 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 730 | if st == 0: |
| 731 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 732 | assert_not_equal(st, 0) |
| 733 | st = VSGAccess.vcpe_wan_up(vcpe_name) |
| 734 | if st is False: |
| 735 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 736 | assert_equal(st, True) |
| 737 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 738 | assert_equal(st, 0) |
| 739 | except Exception as error: |
| 740 | log.info('Got Unexpected error %s'%error) |
| 741 | raise |
| 742 | finally: |
| 743 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 744 | df.callback(0) |
| 745 | reactor.callLater(0,test_external_connectivity,df) |
| 746 | return df |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 747 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 748 | @deferred(60) |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 749 | 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] | 750 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 751 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 752 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 753 | 2. Verifying vcpe interface gets dhcp IP |
| 754 | 3. Ping to 8.8.8.8 and Verifying ping should success |
| 755 | 4. Now down the LAN interface of vcpe |
| 756 | 5. Ping to 8.8.8.8 and Verifying ping should not success |
| 757 | 6. Now Up the LAN interface of vcpe |
| 758 | 7. Ping to 8.8.8.8 and Verifying ping should success |
| 759 | 8. Restoring management interface configuration in cord-tester |
| 760 | """ |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 761 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 762 | return |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 763 | df = defer.Deferred() |
| 764 | def test_external_connectivity(df): |
| 765 | host = '8.8.8.8' |
| 766 | mgmt = 'eth0' |
| 767 | vcpe = self.dhcp_vcpes_reserved[0] |
| 768 | vcpe_name = self.container_vcpes_reserved[0] |
| 769 | assert_not_equal(vcpe, None) |
| 770 | assert_not_equal(vcpe_name, None) |
| 771 | #first get dhcp on the vcpe interface |
| 772 | try: |
| 773 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 774 | assert_not_equal(vcpe_ip, None) |
| 775 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 776 | log.info('Sending ICMP pings to host %s' %(host)) |
| 777 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 778 | if st != 0: |
| 779 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 780 | assert_equal(st, 0) |
| 781 | #bring down the lan interface and check again |
| 782 | st = VSGAccess.vcpe_lan_down(vcpe_name) |
| 783 | if st is False: |
| 784 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 785 | assert_equal(st, True) |
| 786 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 787 | if st == 0: |
| 788 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 789 | assert_not_equal(st, 0) |
| 790 | st = VSGAccess.vcpe_lan_up(vcpe_name) |
| 791 | if st is False: |
| 792 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 793 | assert_equal(st, True) |
| 794 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 795 | assert_equal(st, 0) |
| 796 | except Exception as error: |
| 797 | log.info('Got Unexpected error %s'%error) |
| 798 | raise |
| 799 | finally: |
| 800 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 801 | df.callback(0) |
| 802 | reactor.callLater(0,test_external_connectivity,df) |
| 803 | return df |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 804 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 805 | @deferred(120) |
Chetan Gaonker | fe1048f | 2017-06-13 20:16:25 +0000 | [diff] [blame] | 806 | def test_vsg_multiple_subscribers_for_same_vcpe_instance(self): |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 807 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 808 | Test Method: |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 809 | 1. Create a vcpe instance |
| 810 | 2. Create multiple vcpe interfaces in cord-tester with same s-tag and c-tag to access vcpe instance |
| 811 | 3. Verify all the interfaces gets dhcp IP in same subnet |
| 812 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 813 | df = defer.Deferred() |
| 814 | def test_external_connectivity(df): |
| 815 | vcpe_intfs,containers = self.get_vcpe_containers_and_interfaces() |
| 816 | for vcpe in vcpe_intfs: |
| 817 | vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 818 | assert_not_equal(vcpe_ip,None) |
| 819 | for vcpe in vcpe_intfs: |
| 820 | self.release_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 821 | df.callback(0) |
| 822 | reactor.callLater(0,test_external_connectivity,df) |
| 823 | return df |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 824 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 825 | @deferred(120) |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 826 | def test_vsg_for_multiple_subscribers_with_same_vcpe_instance_and_validate_external_connectivity(self): |
| 827 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 828 | Test Method: |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 829 | 1. Create a vcpe instance |
| 830 | 2. Create multiple vcpe interfaces in cord-tester with same s-tag and c-tag to access vcpe instance |
| 831 | 3. Verify all the interfaces gets dhcp IP in same subnet |
| 832 | 4. From cord-tester ping to external with vcpe interface option |
| 833 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 834 | df = defer.Deferred() |
| 835 | def test_external_connectivity(df): |
| 836 | host = '8.8.8.8' |
| 837 | vcpe_intfs, containers = self.get_vcpe_containers_and_interfaces() |
| 838 | try: |
| 839 | for vcpe in vcpe_intfs: |
| 840 | vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 841 | assert_not_equal(vcpe_ip,None) |
| 842 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_ip=False) |
| 843 | st, _ = getstatusoutput('ping -I {} -c 3 {}'.format(vcpe,host)) |
| 844 | assert_equal(st, 0) |
| 845 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_release=False) |
| 846 | except Exception as error: |
| 847 | log.info('Got Unexpected error %s'%error) |
| 848 | raise |
| 849 | finally: |
| 850 | for vcpe in vcpe_intfs: |
| 851 | self.release_vcpe_interface_dhcp_ip(vcpe=vcpe) |
| 852 | df.callback(0) |
| 853 | reactor.callLater(0,test_external_connectivity,df) |
| 854 | return df |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 855 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 856 | @deferred(30) |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 857 | def test_vsg_vcpe_interface_and_validate_dhcp_ip_after_interface_toggle(self): |
| 858 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 859 | Test Method: |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 860 | 1. Create a vcpe instance |
| 861 | 2. Create a vcpe interface in cord-tester |
| 862 | 3. Verify the interface gets dhcp IP |
| 863 | 4. Toggle the interface |
| 864 | 5. Verify the interface gets dhcp IP |
| 865 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 866 | df = defer.Deferred() |
| 867 | def test_external_connectivity(df): |
| 868 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
| 869 | host = '8.8.8.8' |
| 870 | try: |
| 871 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 872 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 873 | assert_equal(st, 0) |
| 874 | os.system('ifconfig {} down'.format(vcpe_intf)) |
| 875 | time.sleep(1) |
| 876 | os.system('ifconfig {} up'.format(vcpe_intf)) |
| 877 | time.sleep(1) |
| 878 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 879 | assert_equal(st, 0) |
| 880 | except Exception as error: |
| 881 | log.info('Got Unexpected error %s'%error) |
| 882 | raise |
| 883 | finally: |
| 884 | self.del_static_route_via_vcpe_interface([host], vcpe=vcpe_intf) |
| 885 | df.callback(0) |
| 886 | reactor.callLater(0,test_external_connectivity,df) |
| 887 | return df |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 888 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 889 | @deferred(TIMEOUT) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 890 | def test_vsg_for_external_connectivity_after_restarting_vcpe_instance(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 891 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 892 | Test Method: |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 893 | 1. Get vSG corresponding to vcpe |
| 894 | 2. Get dhcp ip to vcpe interface |
| 895 | 3. Add static route to destination route in test container |
| 896 | 4. From test container ping to destination route and verify ping success |
| 897 | 5. Login to compute node and execute command to pause vcpe container |
| 898 | 6. From test container ping to destination route and verify ping success |
| 899 | """ |
| 900 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 901 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 902 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 903 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 904 | df = defer.Deferred() |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 905 | def test_external_connectivity(df): |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 906 | if self.on_pod is False: |
| 907 | df.callback(0) |
| 908 | return |
| 909 | host = '8.8.8.8' |
| 910 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 911 | try: |
| 912 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 913 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 914 | assert_equal(st, False) |
| 915 | st, _ = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 916 | clock = 0 |
| 917 | status = False |
| 918 | while(clock <= 20): |
| 919 | time.sleep(5) |
| 920 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 921 | if st == False: |
| 922 | status = True |
| 923 | break |
| 924 | clock += 5 |
| 925 | assert_equal(status, True) |
| 926 | except Exception as error: |
| 927 | log.info('Got Unexpected error %s'%error) |
| 928 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 929 | raise |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 930 | finally: |
| 931 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 932 | df.callback(0) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 933 | reactor.callLater(0, test_external_connectivity, df) |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 934 | return df |
| 935 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 936 | @nottest #Setup getting distrubed if vSG VM restart |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 937 | @deferred(TIMEOUT) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 938 | def test_vsg_for_external_connectivity_after_restarting_vsg_vm(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 939 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 940 | Test Method: |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 941 | 1. Get vSG corresponding to vcpe |
| 942 | 2. Get dhcp ip to vcpe interface |
| 943 | 3. Add static route to destination route in test container |
| 944 | 4. From test container ping to destination route and verify ping success |
| 945 | 5. Login to compute node and execute command to pause vcpe container |
| 946 | 6. From test container ping to destination route and verify ping success |
| 947 | """ |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 948 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 949 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 950 | df = defer.Deferred() |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 951 | def test_external_connectivity(df): |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 952 | if self.on_pod is False: |
| 953 | df.callback(0) |
| 954 | return |
| 955 | host = '8.8.8.8' |
| 956 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 957 | try: |
| 958 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 959 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 960 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 961 | vsg.reboot() |
| 962 | clock = 0 |
| 963 | status = False |
| 964 | while(clock <= 30): |
| 965 | time.sleep(5) |
| 966 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 967 | if st == False: |
| 968 | status = True |
| 969 | break |
| 970 | clock += 5 |
| 971 | assert_equal(status, True) |
| 972 | except Exception as error: |
| 973 | log.info('Got Unexpected error %s'%error) |
| 974 | vsg.reboot() |
| 975 | raise |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 976 | finally: |
| 977 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 978 | df.callback(0) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 979 | reactor.callLater(0, test_external_connectivity, df) |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 980 | return df |
| 981 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 982 | @deferred(60) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 983 | def test_vsg_for_external_connectivity_with_vcpe_container_paused(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 984 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 985 | Test Method: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 986 | 1. Get vSG corresponding to vcpe |
| 987 | 2. Get dhcp ip to vcpe interface |
| 988 | 3. Add static route to destination route in test container |
| 989 | 4. From test container ping to destination route and verify ping success |
| 990 | 5. Login to compute node and execute command to pause vcpe container |
| 991 | 6. From test container ping to destination route and verify ping success |
| 992 | """ |
| 993 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 994 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 995 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 996 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 997 | df = defer.Deferred() |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 998 | def test_external_connectivity(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 999 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1000 | df.callback(0) |
| 1001 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1002 | host = '8.8.8.8' |
| 1003 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1004 | try: |
| 1005 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1006 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1007 | assert_equal(st, False) |
| 1008 | st, _ = vsg.run_cmd('sudo docker pause {}'.format(vcpe_name)) |
| 1009 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1010 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1011 | vsg.run_cmd('sudo docker unpause {}'.format(vcpe_name)) |
| 1012 | except Exception as error: |
| 1013 | log.info('Got Unexpected error %s'%error) |
| 1014 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1015 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1016 | finally: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1017 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1018 | df.callback(0) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1019 | reactor.callLater(0, test_external_connectivity, df) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1020 | return df |
| 1021 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1022 | @deferred(30) |
| 1023 | def test_vsg_firewall_with_deny_destination_ip_set(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1024 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1025 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1026 | 1. Get vSG corresponding to vcpe |
| 1027 | 2. Login to compute node |
| 1028 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 1029 | 4. From cord-tester ping to the denied IP address |
| 1030 | 5. Verifying that ping should not be successful |
| 1031 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1032 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1033 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1034 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1035 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1036 | df = defer.Deferred() |
| 1037 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1038 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1039 | df.callback(0) |
| 1040 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1041 | host = '8.8.8.8' |
| 1042 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1043 | try: |
| 1044 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1045 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1046 | assert_equal(st, False) |
| 1047 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1048 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1049 | assert_equal(st, True) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1050 | except Exception as error: |
| 1051 | log.info('Got Unexpected error %s'%error) |
| 1052 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1053 | finally: |
| 1054 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1055 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1056 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1057 | df.callback(0) |
| 1058 | reactor.callLater(0, vcpe_firewall, df) |
| 1059 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1060 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1061 | @deferred(60) |
| 1062 | def test_vsg_firewall_with_rule_to_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] | 1063 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1064 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1065 | 1. Get vSG corresponding to vcpe |
| 1066 | 2. Login to compute node |
| 1067 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 1068 | 4. From cord-tester ping to the denied IP address |
| 1069 | 5. Verifying that ping should not be successful |
| 1070 | 6. Delete the iptable rule in vcpe |
| 1071 | 7. From cord-tester ping to the denied IP address |
| 1072 | 8. Verifying the ping should success |
| 1073 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1074 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1075 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1076 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1077 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1078 | df = defer.Deferred() |
| 1079 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1080 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1081 | df.callback(0) |
| 1082 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1083 | host = '8.8.8.8' |
| 1084 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1085 | try: |
| 1086 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1087 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1088 | assert_equal(st, False) |
| 1089 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1090 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1091 | assert_equal(st, True) |
| 1092 | st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1093 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1094 | assert_equal(st, False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1095 | except Exception as error: |
| 1096 | log.info('Got Unexpected error %s'%error) |
| 1097 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1098 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1099 | finally: |
| 1100 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1101 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1102 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1103 | df.callback(0) |
| 1104 | reactor.callLater(0, vcpe_firewall, df) |
| 1105 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1106 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1107 | @deferred(40) |
| 1108 | 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] | 1109 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1110 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1111 | 1. Get vSG corresponding to vcpe |
| 1112 | 2. Login to compute node |
| 1113 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 1114 | 4. From cord-tester ping to the denied IP address |
| 1115 | 5. Verifying that ping should not be successful |
| 1116 | 6. From cord-tester ping to the denied IP address other than the denied one |
| 1117 | 7. Verifying the ping should success |
| 1118 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1119 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1120 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1121 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1122 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1123 | df = defer.Deferred() |
| 1124 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1125 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1126 | df.callback(0) |
| 1127 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1128 | host1 = '8.8.8.8' |
| 1129 | host2 = '204.79.197.203' |
| 1130 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1131 | try: |
| 1132 | self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
| 1133 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1134 | assert_equal(st, False) |
| 1135 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 1136 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1137 | assert_equal(st, True) |
| 1138 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1139 | assert_equal(st,False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1140 | except Exception as error: |
| 1141 | log.info('Got Unexpected error %s'%error) |
| 1142 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1143 | finally: |
| 1144 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 1145 | self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1146 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1147 | df.callback(0) |
| 1148 | reactor.callLater(0, vcpe_firewall, df) |
| 1149 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1150 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1151 | @deferred(60) |
| 1152 | 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] | 1153 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1154 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1155 | 1. Get vSG corresponding to vcpe |
| 1156 | 2. Login to compute node |
| 1157 | 3. Execute iptable command on vcpe from compute node to deny a destination IP1 |
| 1158 | 4. From cord-tester ping to the denied IP address IP1 |
| 1159 | 5. Verifying that ping should not be successful |
| 1160 | 6. Execute iptable command on vcpe from compute node to deny a destination IP2 |
| 1161 | 6. From cord-tester ping to the denied IP address IP2 |
| 1162 | 7. Verifying that ping should not be successful |
| 1163 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1164 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1165 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1166 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1167 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1168 | df = defer.Deferred() |
| 1169 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1170 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1171 | df.callback(0) |
| 1172 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1173 | host1 = '8.8.8.8' |
| 1174 | host2 = '204.79.197.203' |
| 1175 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1176 | try: |
| 1177 | self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
| 1178 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1179 | assert_equal(st, False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1180 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1181 | assert_equal(st, False) |
| 1182 | st,_ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 1183 | time.sleep(1) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1184 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1185 | assert_equal(st, True) |
| 1186 | st, out = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1187 | log.info('host2 ping output is %s'%out) |
| 1188 | assert_equal(st, False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1189 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,host2)) |
| 1190 | time.sleep(1) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1191 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1192 | assert_equal(st,True) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1193 | except Exception as error: |
| 1194 | log.info('Got Unexpected error %s'%error) |
| 1195 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1196 | finally: |
| 1197 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 1198 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2)) |
| 1199 | self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1200 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1201 | df.callback(0) |
| 1202 | reactor.callLater(0, vcpe_firewall, df) |
| 1203 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1204 | |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1205 | @deferred(TIMEOUT) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1206 | 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] | 1207 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1208 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1209 | 1. Get vSG corresponding to vcpe |
| 1210 | 2. Login to compute node |
| 1211 | 3. Execute iptable command on vcpe from compute node to deny a destination IP1 |
| 1212 | 4. Execute iptable command on vcpe from compute node to deny a destination IP2 |
| 1213 | 5. From cord-tester ping to the denied IP address IP1 |
| 1214 | 6. Verifying that ping should not be successful |
| 1215 | 7. From cord-tester ping to the denied IP address IP2 |
| 1216 | 8. Verifying that ping should not be successful |
| 1217 | 9. Execute iptable command on vcpe from compute node to remove deny a destination IP2 rule |
| 1218 | 10. From cord-tester ping to the denied IP address IP2 |
| 1219 | 11. Verifying the ping should success |
| 1220 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1221 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1222 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1223 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1224 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1225 | df = defer.Deferred() |
| 1226 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1227 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1228 | df.callback(0) |
| 1229 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1230 | host1 = '8.8.8.8' |
| 1231 | host2 = '204.79.197.203' |
| 1232 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1233 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1234 | self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1235 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1236 | assert_equal(st, False) |
| 1237 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 1238 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host2)) |
| 1239 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1240 | assert_equal(st, True) |
| 1241 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1242 | assert_equal(st,True) |
| 1243 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2)) |
| 1244 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1245 | assert_equal(st,False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1246 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1247 | assert_equal(st, True) |
| 1248 | except Exception as error: |
| 1249 | log.info('Got Unexpected error %s'%error) |
| 1250 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1251 | finally: |
| 1252 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1)) |
| 1253 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2)) |
| 1254 | self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1255 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1256 | df.callback(0) |
| 1257 | reactor.callLater(0, vcpe_firewall, df) |
| 1258 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1259 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1260 | @deferred(60) |
| 1261 | 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] | 1262 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1263 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1264 | 1. Get vSG corresponding to vcpe |
| 1265 | 2. Login to compute node |
| 1266 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 1267 | 5. From cord-tester ping to the denied IP address IP1 |
| 1268 | 6. Verifying that ping should not be successful |
| 1269 | 9. Execute iptable command on vcpe from compute node to change the rule ID to 2 to deny the same destination IP |
| 1270 | 10. From cord-tester ping to the denied IP address IP |
| 1271 | 11. Verifying that ping should not be successful |
| 1272 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1273 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1274 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1275 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1276 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1277 | df = defer.Deferred() |
| 1278 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1279 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1280 | df.callback(0) |
| 1281 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1282 | host = '8.8.8.8' |
| 1283 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1284 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1285 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1286 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1287 | assert_equal(st, False) |
| 1288 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1289 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1290 | assert_equal(st, True) |
| 1291 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP '.format(vcpe_name,host)) |
| 1292 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1293 | assert_equal(st,True) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1294 | except Exception as error: |
| 1295 | log.info('Got Unexpected error %s'%error) |
| 1296 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1297 | finally: |
| 1298 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1299 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1300 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1301 | df.callback(0) |
| 1302 | reactor.callLater(0, vcpe_firewall, df) |
| 1303 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1304 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1305 | @deferred(50) |
| 1306 | 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] | 1307 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1308 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1309 | 1. Get vSG corresponding to vcpe |
| 1310 | 2. Login to compute node |
| 1311 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 1312 | 5. From cord-tester ping to the denied IP address IP1 |
| 1313 | 6. Verifying that ping should not be successful |
| 1314 | 9. Execute iptable command on vcpe from compute node to accept the same destination IP |
| 1315 | 10. From cord-tester ping to the accepted IP |
| 1316 | 11. Verifying the ping should success |
| 1317 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1318 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1319 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1320 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1321 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1322 | df = defer.Deferred() |
| 1323 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1324 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1325 | df.callback(0) |
| 1326 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1327 | host = '8.8.8.8' |
| 1328 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1329 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1330 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1331 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1332 | assert_equal(st, False) |
| 1333 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1334 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1335 | assert_equal(st, True) |
| 1336 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -d {} -j ACCEPT'.format(vcpe_name,host)) |
| 1337 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1338 | assert_equal(st,False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1339 | except Exception as error: |
| 1340 | log.info('Got Unexpected error %s'%error) |
| 1341 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1342 | finally: |
| 1343 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1344 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j ACCEPT'.format(vcpe_name,host)) |
| 1345 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1346 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1347 | df.callback(0) |
| 1348 | reactor.callLater(0, vcpe_firewall, df) |
| 1349 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1350 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1351 | @deferred(60) |
| 1352 | 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] | 1353 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1354 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1355 | 1. Get vSG corresponding to vcpe |
| 1356 | 2. Login to compute node |
| 1357 | 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet |
| 1358 | 4. From cord-tester ping to the denied IP address IP1 in the denied subnet |
| 1359 | 5. Verifying that ping should not be successful |
| 1360 | 6. From cord-tester ping to the denied IP address IP2 in the denied subnet |
| 1361 | 7. Verifying that ping should not be successful |
| 1362 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1363 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1364 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1365 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1366 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1367 | df = defer.Deferred() |
| 1368 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1369 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1370 | df.callback(0) |
| 1371 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1372 | network = '204.79.197.192/28' |
| 1373 | host1 = '204.79.197.203' |
| 1374 | host2 = '204.79.197.210' |
| 1375 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1376 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1377 | self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1378 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1379 | assert_equal(st, False) |
| 1380 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network)) |
| 1381 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1382 | assert_equal(st, True) |
| 1383 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1384 | assert_equal(st,False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1385 | except Exception as error: |
| 1386 | log.info('Got Unexpected error %s'%error) |
| 1387 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1388 | finally: |
| 1389 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network)) |
| 1390 | self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1391 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1392 | df.callback(0) |
| 1393 | reactor.callLater(0, vcpe_firewall, df) |
| 1394 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1395 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1396 | @deferred(60) |
| 1397 | 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] | 1398 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1399 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1400 | 1. Get vSG corresponding to vcpe |
| 1401 | 2. Login to compute node |
| 1402 | 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet |
| 1403 | 4. From cord-tester ping to the denied IP address IP1 in the denied subnet |
| 1404 | 5. Verifying that ping should not be successful |
| 1405 | 6. From cord-tester ping to the denied IP address IP2 in the denied subnet |
| 1406 | 7. Verifying that ping should not be successful |
| 1407 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1408 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1409 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1410 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1411 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1412 | df = defer.Deferred() |
| 1413 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1414 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1415 | df.callback(0) |
| 1416 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1417 | network1 = '204.79.197.192/28' |
| 1418 | network2 = '204.79.197.192/27' |
| 1419 | host1 = '204.79.197.203' |
| 1420 | host2 = '204.79.197.210' |
| 1421 | host3 = '204.79.197.224' |
| 1422 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1423 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1424 | self.add_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1425 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1426 | assert_equal(st, False) |
| 1427 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network1)) |
| 1428 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1429 | assert_equal(st, True) |
| 1430 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1431 | assert_equal(st,False) |
| 1432 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,network2)) |
| 1433 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 1434 | assert_equal(st, True) |
| 1435 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 1436 | assert_equal(st, True) |
| 1437 | st, _ = getstatusoutput('ping -c 1 {}'.format(host3)) |
| 1438 | assert_equal(st, False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1439 | except Exception as error: |
| 1440 | log.info('Got Unexpected error %s'%error) |
| 1441 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1442 | finally: |
| 1443 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network1)) |
| 1444 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network2)) |
| 1445 | self.del_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1446 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1447 | df.callback(0) |
| 1448 | reactor.callLater(0, vcpe_firewall, df) |
| 1449 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1450 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1451 | @deferred(40) |
| 1452 | 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] | 1453 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1454 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1455 | 1. Get vSG corresponding to vcpe |
| 1456 | 2. Login to compute node |
| 1457 | 3. Execute iptable command on vcpe from compute node to deny a source IP |
| 1458 | 4. From cord-tester ping to 8.8.8.8 from the denied IP |
| 1459 | 5. Verifying that ping should not be successful |
| 1460 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1461 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1462 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1463 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1464 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1465 | df = defer.Deferred() |
| 1466 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1467 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1468 | df.callback(0) |
| 1469 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1470 | host = '8.8.8.8' |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1471 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1472 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1473 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1474 | source_ip = get_ip(vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1475 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1476 | assert_equal(st, False) |
| 1477 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1478 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1479 | assert_equal(st, True) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1480 | except Exception as error: |
| 1481 | log.info('Got Unexpected error %s'%error) |
| 1482 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1483 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1484 | finally: |
| 1485 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1486 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1487 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1488 | df.callback(0) |
| 1489 | reactor.callLater(0, vcpe_firewall, df) |
| 1490 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1491 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1492 | @deferred(40) |
| 1493 | 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] | 1494 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1495 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1496 | 1. Get vSG corresponding to vcpe |
| 1497 | 2. Login to compute node |
| 1498 | 3. Execute iptable command on vcpe from compute node to deny a source IP |
| 1499 | 4. From cord-tester ping to 8.8.8.8 from the denied IP |
| 1500 | 5. Verifying that ping should not be successful |
| 1501 | 6. Delete the iptable rule in vcpe |
| 1502 | 7. From cord-tester ping to 8.8.8.8 from the denied IP |
| 1503 | 8. Verifying the ping should success |
| 1504 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1505 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1506 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1507 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1508 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1509 | df = defer.Deferred() |
| 1510 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1511 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1512 | df.callback(0) |
| 1513 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1514 | host = '8.8.8.8' |
| 1515 | source_ip = get_ip(self.vcpe_dhcp) |
| 1516 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1517 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1518 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 1519 | source_ip = get_ip(vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1520 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1521 | assert_equal(st, False) |
| 1522 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1523 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1524 | assert_equal(st, True) |
| 1525 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1526 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1527 | assert_equal(st, False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1528 | except Exception as error: |
| 1529 | log.info('Got Unexpected error %s'%error) |
| 1530 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1531 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1532 | finally: |
| 1533 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip)) |
| 1534 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1535 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1536 | df.callback(0) |
| 1537 | reactor.callLater(0, vcpe_firewall, df) |
| 1538 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1539 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1540 | @deferred(40) |
| 1541 | 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] | 1542 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1543 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1544 | 1. Get vSG corresponding to vcpe |
| 1545 | 2. Login to compute node |
| 1546 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets |
| 1547 | 4. From cord-tester ping to 8.8.8.8 |
| 1548 | 5. Verifying that ping should not be successful |
| 1549 | 6. Delete the iptable rule |
| 1550 | 7. From cord-tester ping to 8.8.8.8 |
| 1551 | 8. Verifying the ping should success |
| 1552 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1553 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1554 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1555 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1556 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1557 | df = defer.Deferred() |
| 1558 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1559 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1560 | df.callback(0) |
| 1561 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1562 | host = '8.8.8.8' |
| 1563 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1564 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1565 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1566 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1567 | assert_equal(st, False) |
| 1568 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1569 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1570 | assert_equal(st, True) |
| 1571 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1572 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1573 | assert_equal(st, False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1574 | except Exception as error: |
| 1575 | log.info('Got Unexpected error %s'%error) |
| 1576 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1577 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1578 | finally: |
| 1579 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1580 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1581 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1582 | df.callback(0) |
| 1583 | reactor.callLater(0, vcpe_firewall, df) |
| 1584 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1585 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1586 | @deferred(40) |
| 1587 | 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] | 1588 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1589 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1590 | 1. Get vSG corresponding to vcpe |
| 1591 | 2. Login to compute node |
| 1592 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets |
| 1593 | 4. From cord-tester ping to 8.8.8.8 |
| 1594 | 5. Verifying that ping should not be successful |
| 1595 | 6. Delete the iptable rule |
| 1596 | 7. From cord-tester ping to 8.8.8.8 |
| 1597 | 8. Verifying the ping should success |
| 1598 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1599 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1600 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1601 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1602 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1603 | df = defer.Deferred() |
| 1604 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1605 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1606 | df.callback(0) |
| 1607 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1608 | host = '8.8.8.8' |
| 1609 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1610 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1611 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1612 | st, _ = getstatusoutput('ping -c 1 {}'.format('8.8.8.8')) |
| 1613 | assert_equal(st, False) |
| 1614 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1615 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1616 | assert_equal(st, True) |
| 1617 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1618 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1619 | assert_equal(st,False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1620 | except Exception as error: |
| 1621 | log.info('Got Unexpected error %s'%error) |
| 1622 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1623 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1624 | finally: |
| 1625 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1626 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1627 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1628 | df.callback(0) |
| 1629 | reactor.callLater(0, vcpe_firewall, df) |
| 1630 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1631 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1632 | @deferred(40) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 1633 | 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] | 1634 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1635 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1636 | 1. Get vSG corresponding to vcpe |
| 1637 | 2. Login to compute node |
| 1638 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets |
| 1639 | 4. From cord-tester ping to 8.8.8.8 |
| 1640 | 5. Verifying that ping should not be successful |
| 1641 | 6. Insert another rule to accept the icmp-echo requests protocol packets |
| 1642 | 7. From cord-tester ping to 8.8.8.8 |
| 1643 | 8. Verifying the ping should success |
| 1644 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1645 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1646 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1647 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1648 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1649 | df = defer.Deferred() |
| 1650 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1651 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1652 | df.callback(0) |
| 1653 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1654 | host = '8.8.8.8' |
| 1655 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1656 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1657 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1658 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1659 | assert_equal(st, False) |
| 1660 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1661 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1662 | assert_equal(st, True) |
| 1663 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name)) |
| 1664 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1665 | assert_equal(st,False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1666 | except Exception as error: |
| 1667 | log.info('Got Unexpected error %s'%error) |
| 1668 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1669 | finally: |
| 1670 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name)) |
| 1671 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name)) |
| 1672 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1673 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1674 | df.callback(0) |
| 1675 | reactor.callLater(0, vcpe_firewall, df) |
| 1676 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1677 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1678 | @deferred(40) |
| 1679 | def test_vsg_firewall_changing_deny_rule_to_accept_rule_with_icmp_protocol_echo_reply_type(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1680 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1681 | Test Method: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1682 | 1. Get vSG corresponding to vcpe |
| 1683 | 2. Login to compute node |
| 1684 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets |
| 1685 | 4. From cord-tester ping to 8.8.8.8 |
| 1686 | 5. Verifying the ping should not success |
| 1687 | 6. Insert another rule to accept the icmp-echo requests protocol packets |
| 1688 | 7. From cord-tester ping to 8.8.8.8 |
| 1689 | 8. Verifying the ping should success |
| 1690 | """ |
| 1691 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1692 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1693 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1694 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1695 | df = defer.Deferred() |
| 1696 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1697 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1698 | df.callback(0) |
| 1699 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1700 | host = '8.8.8.8' |
| 1701 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1702 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1703 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1704 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1705 | assert_equal(st, False) |
| 1706 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1707 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1708 | assert_equal(st, True) |
| 1709 | st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name)) |
| 1710 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1711 | assert_equal(st,False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1712 | except Exception as error: |
| 1713 | log.info('Got Unexpected error %s'%error) |
| 1714 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1715 | finally: |
| 1716 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name)) |
| 1717 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name)) |
| 1718 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1719 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1720 | df.callback(0) |
| 1721 | reactor.callLater(0, vcpe_firewall, df) |
| 1722 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1723 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1724 | @deferred(40) |
| 1725 | 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] | 1726 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1727 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1728 | 1. Get vSG corresponding to vcpe |
| 1729 | 2. Login to compute node |
| 1730 | 3. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 1731 | 4. From cord-tester ping to 8.8.8.8 |
| 1732 | 5. Verifying that ping should not be successful |
| 1733 | 6. Delete the iptable rule |
| 1734 | 7. From cord-tester ping to 8.8.8.8 |
| 1735 | 8. Verifying the ping should success |
| 1736 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1737 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1738 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1739 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1740 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1741 | df = defer.Deferred() |
| 1742 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1743 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1744 | df.callback(0) |
| 1745 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1746 | host = '8.8.8.8' |
| 1747 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1748 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1749 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1750 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1751 | assert_equal(st, False) |
| 1752 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1753 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1754 | assert_equal(st, True) |
| 1755 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1756 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1757 | assert_equal(st,False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1758 | except Exception as error: |
| 1759 | log.info('Got Unexpected error %s'%error) |
| 1760 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1761 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1762 | finally: |
| 1763 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1764 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1765 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1766 | df.callback(0) |
| 1767 | reactor.callLater(0, vcpe_firewall, df) |
| 1768 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1769 | |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1770 | @deferred(60) |
| 1771 | 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] | 1772 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1773 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1774 | 1. Get vSG corresponding to vcpe |
| 1775 | 2. Login to compute node |
| 1776 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 1777 | 4. From cord-tester ping to 8.8.8.8 |
| 1778 | 5. Verifying that ping should not be successful |
| 1779 | 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 1780 | 7. From cord-tester ping to 8.8.8.8 |
| 1781 | 8. Verifying the ping should success |
| 1782 | 9. Delete the rule added in step 3 |
| 1783 | 10. From cord-tester ping to 8.8.8.8 |
| 1784 | 11. Verifying that ping should not be successful |
| 1785 | 12. Delete the rule added in step 6 |
| 1786 | 13. From cord-tester ping to 8.8.8.8 |
| 1787 | 14. Verifying the ping should success |
| 1788 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1789 | if not vcpe_name: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1790 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1791 | if not vcpe_intf: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1792 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1793 | df = defer.Deferred() |
| 1794 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1795 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1796 | df.callback(0) |
| 1797 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1798 | host = '8.8.8.8' |
| 1799 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1800 | try: |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1801 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1802 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1803 | assert_equal(st, False) |
| 1804 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1805 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1806 | assert_equal(st, True) |
| 1807 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1808 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1809 | assert_equal(st, True) |
| 1810 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1811 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1812 | assert_equal(st, True) |
| 1813 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1814 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1815 | assert_equal(st,False) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1816 | except Exception as error: |
| 1817 | log.info('Got Unexpected error %s'%error) |
| 1818 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1819 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1820 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1821 | finally: |
| 1822 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1823 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1824 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1825 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1826 | df.callback(0) |
| 1827 | reactor.callLater(0, vcpe_firewall, df) |
| 1828 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1829 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1830 | @deferred(100) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1831 | 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] | 1832 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1833 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1834 | 1. Get vSG corresponding to vcpe |
| 1835 | 2. Login to compute node |
| 1836 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 1837 | 4. From cord-tester ping to 8.8.8.8 |
| 1838 | 5. Verifying that ping should not be successful |
| 1839 | 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 1840 | 7. From cord-tester ping to 8.8.8.8 |
| 1841 | 8. Verifying the ping should success |
| 1842 | 9. Flush all the iptable rules configuraed in vcpe |
| 1843 | 10. Delete the rule added in step 6 |
| 1844 | 11. From cord-tester ping to 8.8.8.8 |
| 1845 | 12. Verifying the ping should success |
| 1846 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1847 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1848 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1849 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1850 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1851 | df = defer.Deferred() |
| 1852 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1853 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1854 | df.callback(0) |
| 1855 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1856 | host = '8.8.8.8' |
| 1857 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1858 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1859 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1860 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1861 | assert_equal(st, False) |
| 1862 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 1863 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1864 | assert_equal(st, True) |
| 1865 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1866 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1867 | assert_equal(st, True) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1868 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F FORWARD'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1869 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1870 | assert_equal(st, True) |
| 1871 | vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 1872 | status = False |
| 1873 | clock = 0 |
| 1874 | while(clock <= 30): |
| 1875 | time.sleep(5) |
| 1876 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1877 | if st == False: |
| 1878 | status = True |
| 1879 | break |
| 1880 | clock += 5 |
| 1881 | assert_equal(status, True) |
| 1882 | except Exception as error: |
| 1883 | log.info('Got Unexpected error %s'%error) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1884 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1885 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name)) |
| 1886 | raise |
| 1887 | finally: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1888 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1889 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1890 | df.callback(0) |
| 1891 | reactor.callLater(0, vcpe_firewall, df) |
| 1892 | return df |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 1893 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1894 | @deferred(40) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1895 | 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] | 1896 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1897 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1898 | 1. Get vSG corresponding to vcpe |
| 1899 | 2. Login to compute node |
| 1900 | 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic |
| 1901 | 4. From cord-tester ping to 8.8.8.8 |
| 1902 | 5. Verifying that ping should not be successful |
| 1903 | 6. Delete the iptable rule added |
| 1904 | 7. From cord-tester ping to 8.8.8.8 |
| 1905 | 8. Verifying the ping should success |
| 1906 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1907 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1908 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1909 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1910 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1911 | df = defer.Deferred() |
| 1912 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1913 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1914 | df.callback(0) |
| 1915 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1916 | host = '8.8.8.8' |
| 1917 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1918 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1919 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1920 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1921 | assert_equal(st, False) |
| 1922 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1923 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1924 | assert_equal(st, True) |
| 1925 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1926 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1927 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1928 | except Exception as error: |
| 1929 | log.info('Got Unexpected error %s'%error) |
| 1930 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1931 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1932 | finally: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1933 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1934 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1935 | df.callback(0) |
| 1936 | reactor.callLater(0, vcpe_firewall, df) |
| 1937 | return df |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1938 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1939 | @deferred(40) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1940 | 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] | 1941 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1942 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1943 | 1. Get vSG corresponding to vcpe |
| 1944 | 2. Login to compute node |
| 1945 | 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic |
| 1946 | 4. From cord-tester ping to 8.8.8.8 |
| 1947 | 5. Verifying that ping should not be successful |
| 1948 | 6. Replace the deny rule added in step 3 with accept rule |
| 1949 | 7. From cord-tester ping to 8.8.8.8 |
| 1950 | 8. Verifying the ping should success |
| 1951 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1952 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1953 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1954 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1955 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1956 | df = defer.Deferred() |
| 1957 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 1958 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 1959 | df.callback(0) |
| 1960 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1961 | host = '8.8.8.8' |
| 1962 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 1963 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1964 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1965 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1966 | assert_equal(st, False) |
| 1967 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1968 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1969 | assert_equal(st, True) |
| 1970 | st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -4 -j ACCEPT'.format(vcpe_name)) |
| 1971 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1972 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1973 | except Exception as error: |
| 1974 | log.info('Got Unexpected error %s'%error) |
| 1975 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1976 | finally: |
| 1977 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name)) |
| 1978 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1979 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1980 | df.callback(0) |
| 1981 | reactor.callLater(0, vcpe_firewall, df) |
| 1982 | return df |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1983 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1984 | @deferred(40) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 1985 | def test_vsg_firewall_deny_all_traffic_coming_on_lan_interface_in_vcpe(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1986 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 1987 | Test Method: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1988 | 1. Get vSG corresponding to vcpe |
| 1989 | 2. Login to compute node |
| 1990 | 3. Execute iptable command on vcpe from compute node to deny all the traffic coming on lan interface inside vcpe container |
| 1991 | 4. From cord-tester ping to 8.8.8.8 |
| 1992 | 5. Verifying the ping should not success |
| 1993 | 6. Delete the iptable rule added |
| 1994 | 7. From cord-tester ping to 8.8.8.8 |
| 1995 | 8. Verifying the ping should success |
| 1996 | """ |
| 1997 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 1998 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 1999 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2000 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2001 | df = defer.Deferred() |
| 2002 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 2003 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 2004 | df.callback(0) |
| 2005 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2006 | host = '8.8.8.8' |
| 2007 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2008 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2009 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2010 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2011 | assert_equal(st, False) |
| 2012 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -j DROP'.format(vcpe_name)) |
| 2013 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2014 | assert_equal(st, True) |
| 2015 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name)) |
| 2016 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2017 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2018 | except Exception as error: |
| 2019 | log.info('Got Unexpected error %s'%error) |
| 2020 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name)) |
| 2021 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2022 | finally: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2023 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2024 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2025 | df.callback(0) |
| 2026 | reactor.callLater(0, vcpe_firewall, df) |
| 2027 | return df |
| 2028 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2029 | @deferred(40) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2030 | def test_vsg_firewall_deny_all_traffic_going_out_of_wan_interface_in_vcpe(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2031 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 2032 | Test Method: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2033 | 1. Get vSG corresponding to vcpe |
| 2034 | 2. Login to compute node |
| 2035 | 3. Execute iptable command on vcpe from compute node to deny all the traffic going out of wan interface inside vcpe container |
| 2036 | 4. From cord-tester ping to 8.8.8.8 |
| 2037 | 5. Verifying the ping should not success |
| 2038 | 6. Delete the iptable rule added |
| 2039 | 7. From cord-tester ping to 8.8.8.8 |
| 2040 | 8. Verifying the ping should success |
| 2041 | """ |
| 2042 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2043 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2044 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2045 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2046 | df = defer.Deferred() |
| 2047 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 2048 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 2049 | df.callback(0) |
| 2050 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2051 | host = '8.8.8.8' |
| 2052 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2053 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2054 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2055 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2056 | assert_equal(st, False) |
| 2057 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -o eth0 -j DROP'.format(vcpe_name)) |
| 2058 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2059 | assert_equal(st, True) |
| 2060 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name)) |
| 2061 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2062 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2063 | except Exception as error: |
| 2064 | log.info('Got Unexpected error %s'%error) |
| 2065 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name)) |
| 2066 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2067 | finally: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2068 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2069 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2070 | df.callback(0) |
| 2071 | reactor.callLater(0, vcpe_firewall, df) |
| 2072 | return df |
| 2073 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2074 | @deferred(40) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2075 | 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] | 2076 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 2077 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 2078 | 1. Get vSG corresponding to vcpe |
| 2079 | 2. Login to compute node |
| 2080 | 3. Execute iptable command on vcpe from compute node to deny all the traffic from lan to wan interface in vcpe |
| 2081 | 4. From cord-tester ping to 8.8.8.8 |
| 2082 | 5. Verifying that ping should not be successful |
| 2083 | 6. Delete the iptable rule added |
| 2084 | 7. From cord-tester ping to 8.8.8.8 |
| 2085 | 8. Verifying the ping should success |
| 2086 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2087 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2088 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2089 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2090 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2091 | df = defer.Deferred() |
| 2092 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 2093 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 2094 | df.callback(0) |
| 2095 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2096 | host = '8.8.8.8' |
| 2097 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2098 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2099 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2100 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2101 | assert_equal(st, False) |
| 2102 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name)) |
| 2103 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2104 | assert_equal(st, True) |
| 2105 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name)) |
| 2106 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2107 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2108 | except Exception as error: |
| 2109 | log.info('Got Unexpected error %s'%error) |
| 2110 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name)) |
| 2111 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2112 | finally: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2113 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2114 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2115 | df.callback(0) |
| 2116 | reactor.callLater(0, vcpe_firewall, df) |
| 2117 | return df |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 2118 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2119 | @deferred(60) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2120 | def test_vsg_firewall_deny_all_dns_traffic(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2121 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 2122 | Test Method: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2123 | 1. Get vSG corresponding to vcpe |
| 2124 | 2. Login to compute node |
| 2125 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 2126 | 4. From cord-tester ping to www.google.com |
| 2127 | 5. Verifying the ping should not success |
| 2128 | 6. Delete the iptable rule added |
| 2129 | 7. From cord-tester ping to www.google.com |
| 2130 | 8. Verifying the ping should success |
| 2131 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2132 | mgmt = 'eth0' |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2133 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2134 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2135 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2136 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2137 | df = defer.Deferred() |
| 2138 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 2139 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 2140 | df.callback(0) |
| 2141 | return |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2142 | host = 'google-public-dns-a.google.com' |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2143 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2144 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2145 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name)) |
| 2146 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe_intf, mgmt = mgmt) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2147 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2148 | assert_not_equal(st, False) |
| 2149 | VSGAccess.restore_interface_config(mgmt, vcpe=vcpe_intf) |
| 2150 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name)) |
| 2151 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe_intf, mgmt = mgmt) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2152 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2153 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2154 | VSGAccess.restore_interface_config(mgmt, vcpe=vcpe_intf) |
| 2155 | except Exception as error: |
| 2156 | log.info('Got Unexpected error %s'%error) |
| 2157 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name)) |
| 2158 | VSGAccess.restore_interface_config(mgmt,vcpe=vcpe_intf) |
| 2159 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2160 | df.callback(0) |
| 2161 | reactor.callLater(0, vcpe_firewall, df) |
| 2162 | return df |
| 2163 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2164 | @deferred(60) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2165 | 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] | 2166 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 2167 | Test Method: |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 2168 | 1. Get vSG corresponding to vcpe |
| 2169 | 2. Login to compute node |
| 2170 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 2171 | 4. From cord-tester ping to www.google.com |
| 2172 | 5. Verifying that ping should not be successful |
| 2173 | 6. Delete the iptable rule added |
| 2174 | 7. From cord-tester ping to www.google.com |
| 2175 | 8. Verifying the ping should success |
| 2176 | """ |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2177 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2178 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2179 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2180 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2181 | df = defer.Deferred() |
| 2182 | def vcpe_firewall(df): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 2183 | if self.on_pod is False: |
A R Karthick | 93ba8d0 | 2017-04-13 11:59:58 -0700 | [diff] [blame] | 2184 | df.callback(0) |
| 2185 | return |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2186 | host = '8.8.8.8' |
| 2187 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2188 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2189 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2190 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2191 | assert_equal(st, False) |
| 2192 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name)) |
| 2193 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2194 | assert_equal(st, True) |
| 2195 | st,output = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2196 | clock = 0 |
| 2197 | status = False |
| 2198 | while(clock <= 20 ): |
| 2199 | time.sleep(5) |
| 2200 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2201 | if st == False: |
| 2202 | status = True |
| 2203 | break |
| 2204 | clock += 5 |
| 2205 | assert_equal(status, True) |
| 2206 | except Exception as error: |
| 2207 | log.info('Got Unexpected error %s'%error) |
| 2208 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name)) |
| 2209 | raise |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2210 | finally: |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2211 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2212 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | a357c6a | 2017-04-12 17:52:24 +0000 | [diff] [blame] | 2213 | df.callback(0) |
| 2214 | reactor.callLater(0, vcpe_firewall, df) |
| 2215 | return df |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 2216 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2217 | @deferred(40) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2218 | def test_vsg_nat_dnat_modifying_destination_ip(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2219 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 2220 | Test Method: |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2221 | 1. Get vSG corresponding to vcpe |
| 2222 | 2. Login to compute node |
| 2223 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 2224 | 4. From cord-tester ping to www.google.com |
| 2225 | 5. Verifying the ping should not success |
| 2226 | 6. Delete the iptable rule added |
| 2227 | 7. From cord-tester ping to www.google.com |
| 2228 | 8. Verifying the ping should success |
| 2229 | """ |
| 2230 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2231 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2232 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2233 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2234 | df = defer.Deferred() |
| 2235 | def vcpe_firewall(df): |
| 2236 | host = '8.8.8.8' |
| 2237 | dst_ip = '123.123.123.123' |
| 2238 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2239 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2240 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2241 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2242 | assert_equal(st, False) |
| 2243 | 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)) |
| 2244 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2245 | assert_equal(st, True) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2246 | except Exception as error: |
| 2247 | log.info('Got Unexpected error %s'%error) |
| 2248 | raise |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2249 | finally: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2250 | |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2251 | 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)) |
| 2252 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2253 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2254 | df.callback(0) |
| 2255 | reactor.callLater(0,vcpe_firewall,df) |
| 2256 | return df |
| 2257 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2258 | @deferred(40) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2259 | def test_vsg_nat_dnat_modifying_destination_ip_and_delete(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2260 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 2261 | Test Method: |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2262 | 1. Get vSG corresponding to vcpe |
| 2263 | 2. Login to compute node |
| 2264 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 2265 | 4. From cord-tester ping to www.google.com |
| 2266 | 5. Verifying the ping should not success |
| 2267 | 6. Delete the iptable rule added |
| 2268 | 7. From cord-tester ping to www.google.com |
| 2269 | 8. Verifying the ping should success |
| 2270 | """ |
| 2271 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2272 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2273 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2274 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2275 | df = defer.Deferred() |
| 2276 | def vcpe_firewall(df): |
| 2277 | host = '8.8.8.8' |
| 2278 | dst_ip = '123.123.123.123' |
| 2279 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2280 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2281 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2282 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2283 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2284 | st, _ = 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)) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2285 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2286 | assert_equal(st, True) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2287 | st, _ = 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)) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2288 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2289 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2290 | except Exception as error: |
| 2291 | log.info('Got Unexpected error %s'%error) |
| 2292 | 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)) |
| 2293 | raise |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2294 | finally: |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2295 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2296 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2297 | df.callback(0) |
| 2298 | reactor.callLater(0,vcpe_firewall,df) |
| 2299 | return df |
| 2300 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2301 | @deferred(50) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2302 | def test_vsg_dnat_change_modifying_destination_ip_address(self, vcpe_name=None, vcpe_intf=None): |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2303 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 2304 | Test Method: |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2305 | 1. Get vSG corresponding to vcpe |
| 2306 | 2. Login to compute node |
| 2307 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 2308 | 4. From cord-tester ping to www.google.com |
| 2309 | 5. Verifying the ping should not success |
| 2310 | 6. Delete the iptable rule added |
| 2311 | 7. From cord-tester ping to www.google.com |
| 2312 | 8. Verifying the ping should success |
| 2313 | """ |
| 2314 | if not vcpe_name: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2315 | vcpe_name = self.container_vcpes_reserved[0] |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2316 | if not vcpe_intf: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2317 | vcpe_intf = self.dhcp_vcpes_reserved[0] |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2318 | df = defer.Deferred() |
| 2319 | def vcpe_firewall(df): |
| 2320 | host = '8.8.8.8' |
| 2321 | dst_ip = '123.123.123.123' |
| 2322 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2323 | try: |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2324 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2325 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2326 | assert_equal(st, False) |
| 2327 | 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)) |
| 2328 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2329 | assert_equal(st, True) |
| 2330 | 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)) |
| 2331 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2332 | assert_equal(st, False) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2333 | except Exception as error: |
| 2334 | log.info('Got Unexpected error %s'%error) |
| 2335 | raise |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2336 | finally: |
| 2337 | 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)) |
| 2338 | 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)) |
| 2339 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2340 | #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
Anil Kumar Sanka | 5fa8d8b | 2017-04-18 22:01:48 +0000 | [diff] [blame] | 2341 | df.callback(0) |
| 2342 | reactor.callLater(0,vcpe_firewall,df) |
| 2343 | return df |
| 2344 | |
A.R Karthick | a3fa2f9 | 2017-05-18 18:51:36 -0700 | [diff] [blame] | 2345 | def vsg_xos_subscriber_create(self, index, subscriber_info = None, volt_subscriber_info = None): |
A R Karthick | 1977119 | 2017-04-25 14:57:05 -0700 | [diff] [blame] | 2346 | if self.on_pod is False: |
A.R Karthick | a3fa2f9 | 2017-05-18 18:51:36 -0700 | [diff] [blame] | 2347 | return '' |
| 2348 | if subscriber_info is None: |
| 2349 | subscriber_info = self.subscriber_info[index] |
| 2350 | if volt_subscriber_info is None: |
| 2351 | volt_subscriber_info = self.volt_subscriber_info[index] |
A R Karthick | d0b0679 | 2017-04-25 15:11:23 -0700 | [diff] [blame] | 2352 | s_tag = int(volt_subscriber_info['voltTenant']['s_tag']) |
| 2353 | c_tag = int(volt_subscriber_info['voltTenant']['c_tag']) |
| 2354 | vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag) |
| 2355 | 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] | 2356 | subId = '' |
| 2357 | try: |
| 2358 | result = self.restApiXos.ApiPost('TENANT_SUBSCRIBER', subscriber_info) |
| 2359 | assert_equal(result, True) |
| 2360 | result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 2361 | assert_not_equal(result, None) |
| 2362 | subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num']) |
| 2363 | assert_not_equal(subId, '0') |
A.R Karthick | a3fa2f9 | 2017-05-18 18:51:36 -0700 | [diff] [blame] | 2364 | log.info('Subscriber ID for account num %s = %s' %(str(volt_subscriber_info['account_num']), subId)) |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 2365 | volt_tenant = volt_subscriber_info['voltTenant'] |
| 2366 | #update the subscriber id in the tenant info before making the rest |
| 2367 | volt_tenant['subscriber'] = subId |
| 2368 | result = self.restApiXos.ApiPost('TENANT_VOLT', volt_tenant) |
| 2369 | assert_equal(result, True) |
| 2370 | #if the vsg instance was already instantiated, then reduce delay |
| 2371 | if c_tag % self.subscribers_per_s_tag == 0: |
| 2372 | delay = 350 |
| 2373 | else: |
| 2374 | delay = 90 |
| 2375 | log.info('Delaying %d seconds for the VCPE to be provisioned' %(delay)) |
| 2376 | time.sleep(delay) |
| 2377 | log.info('Testing for external connectivity to VCPE %s' %(vcpe)) |
| 2378 | self.vsg_for_external_connectivity(index) |
| 2379 | finally: |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 2380 | return subId |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 2381 | |
A.R Karthick | a3fa2f9 | 2017-05-18 18:51:36 -0700 | [diff] [blame] | 2382 | def vsg_xos_subscriber_delete(self, index, subId = '', voltId = '', subscriber_info = None, volt_subscriber_info = None): |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 2383 | if self.on_pod is False: |
| 2384 | return |
A.R Karthick | a3fa2f9 | 2017-05-18 18:51:36 -0700 | [diff] [blame] | 2385 | if subscriber_info is None: |
| 2386 | subscriber_info = self.subscriber_info[index] |
| 2387 | if volt_subscriber_info is None: |
| 2388 | volt_subscriber_info = self.volt_subscriber_info[index] |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 2389 | s_tag = int(volt_subscriber_info['voltTenant']['s_tag']) |
| 2390 | c_tag = int(volt_subscriber_info['voltTenant']['c_tag']) |
| 2391 | vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag) |
| 2392 | log.info('Deleting tenant with s_tag: %d, c_tag: %d' %(s_tag, c_tag)) |
| 2393 | if not subId: |
| 2394 | #get the subscriber id first |
| 2395 | result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 2396 | assert_not_equal(result, None) |
| 2397 | subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num']) |
| 2398 | assert_not_equal(subId, '0') |
A.R Karthick | a3fa2f9 | 2017-05-18 18:51:36 -0700 | [diff] [blame] | 2399 | if not voltId: |
| 2400 | #get the volt id for the subscriber |
| 2401 | result = self.restApiXos.ApiGet('TENANT_VOLT') |
| 2402 | assert_not_equal(result, None) |
| 2403 | voltId = self.getVoltId(result, subId) |
| 2404 | assert_not_equal(voltId, None) |
| 2405 | log.info('Deleting subscriber ID %s for account num %s' %(subId, str(volt_subscriber_info['account_num']))) |
A R Karthick | a385cea | 2017-04-26 10:12:43 -0700 | [diff] [blame] | 2406 | status = self.restApiXos.ApiDelete('TENANT_SUBSCRIBER', subId) |
| 2407 | assert_equal(status, True) |
A R Karthick | 97e0885 | 2017-04-26 10:06:38 -0700 | [diff] [blame] | 2408 | #Delete the tenant |
| 2409 | 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] | 2410 | self.restApiXos.ApiDelete('TENANT_VOLT', voltId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 2411 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 2412 | def vsg_xos_subscriber_id(self, index): |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2413 | log.info('index and its type are %s, %s'%(index, type(index))) |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 2414 | volt_subscriber_info = self.volt_subscriber_info[index] |
| 2415 | result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 2416 | assert_not_equal(result, None) |
| 2417 | subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num']) |
| 2418 | return subId |
| 2419 | |
A.R Karthick | a3fa2f9 | 2017-05-18 18:51:36 -0700 | [diff] [blame] | 2420 | def test_vsg_xos_subscriber_create_reserved(self): |
A.R Karthick | a296091 | 2017-05-18 18:52:55 -0700 | [diff] [blame] | 2421 | if self.on_pod is False: |
| 2422 | return |
A.R Karthick | a3fa2f9 | 2017-05-18 18:51:36 -0700 | [diff] [blame] | 2423 | tags_reserved = [ (int(vcpe['s_tag']), int(vcpe['c_tag'])) for vcpe in self.vcpes_reserved ] |
| 2424 | volt_tenants = self.restApiXos.ApiGet('TENANT_VOLT') |
| 2425 | subscribers = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 2426 | reserved_tenants = filter(lambda tenant: (int(tenant['s_tag']), int(tenant['c_tag'])) in tags_reserved, volt_tenants) |
| 2427 | reserved_config = [] |
| 2428 | for tenant in reserved_tenants: |
| 2429 | for subscriber in subscribers: |
| 2430 | if int(subscriber['id']) == int(tenant['subscriber']): |
| 2431 | volt_subscriber_info = {} |
| 2432 | volt_subscriber_info['voltTenant'] = dict(s_tag = tenant['s_tag'], |
| 2433 | c_tag = tenant['c_tag'], |
| 2434 | subscriber = tenant['subscriber']) |
| 2435 | volt_subscriber_info['volt_id'] = tenant['id'] |
| 2436 | volt_subscriber_info['account_num'] = subscriber['identity']['account_num'] |
| 2437 | reserved_config.append( (subscriber, volt_subscriber_info) ) |
| 2438 | break |
| 2439 | else: |
| 2440 | log.info('Subscriber not found for tenant %s, s_tag: %s, c_tag: %s' %(str(tenant['subscriber']), |
| 2441 | str(tenant['s_tag']), |
| 2442 | str(tenant['c_tag']))) |
| 2443 | |
| 2444 | for subscriber_info, volt_subscriber_info in reserved_config: |
| 2445 | self.vsg_xos_subscriber_delete(0, |
| 2446 | subId = str(subscriber_info['id']), |
| 2447 | voltId = str(volt_subscriber_info['volt_id']), |
| 2448 | subscriber_info = subscriber_info, |
| 2449 | volt_subscriber_info = volt_subscriber_info) |
| 2450 | subId = self.vsg_xos_subscriber_create(0, |
| 2451 | subscriber_info = subscriber_info, |
| 2452 | volt_subscriber_info = volt_subscriber_info) |
| 2453 | log.info('Created reserved subscriber %s' %(subId)) |
| 2454 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 2455 | def test_vsg_xos_subscriber_create_all(self): |
| 2456 | for index in xrange(len(self.subscriber_info)): |
| 2457 | #check if the index exists |
| 2458 | subId = self.vsg_xos_subscriber_id(index) |
| 2459 | if subId and subId != '0': |
| 2460 | self.vsg_xos_subscriber_delete(index, subId = subId) |
| 2461 | subId = self.vsg_xos_subscriber_create(index) |
| 2462 | log.info('Created Subscriber %s' %(subId)) |
| 2463 | |
| 2464 | def test_vsg_xos_subscriber_delete_all(self): |
| 2465 | for index in xrange(len(self.subscriber_info)): |
| 2466 | subId = self.vsg_xos_subscriber_id(index) |
| 2467 | if subId and subId != '0': |
| 2468 | self.vsg_xos_subscriber_delete(index, subId = subId) |
| 2469 | |
| 2470 | def test_vsg_xos_subscriber_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 2471 | subId = self.vsg_xos_subscriber_create(0) |
| 2472 | if subId and subId != '0': |
| 2473 | self.vsg_xos_subscriber_delete(0, subId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 2474 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2475 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 2476 | def test_vsg_xos_subscriber_2_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 2477 | subId = self.vsg_xos_subscriber_create(1) |
| 2478 | if subId and subId != '0': |
| 2479 | self.vsg_xos_subscriber_delete(1, subId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 2480 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 2481 | def test_vsg_xos_subscriber_3_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 2482 | subId = self.vsg_xos_subscriber_create(2) |
| 2483 | if subId and subId != '0': |
| 2484 | self.vsg_xos_subscriber_delete(2, subId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 2485 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 2486 | def test_vsg_xos_subscriber_4_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 2487 | subId = self.vsg_xos_subscriber_create(3) |
| 2488 | if subId and subId != '0': |
| 2489 | self.vsg_xos_subscriber_delete(3, subId) |
A R Karthick | 035d2e2 | 2017-04-25 13:53:00 -0700 | [diff] [blame] | 2490 | |
A R Karthick | e29c8d4 | 2017-04-27 11:38:52 -0700 | [diff] [blame] | 2491 | def test_vsg_xos_subscriber_5_create_and_delete(self): |
A R Karthick | 5d30b3c | 2017-04-27 10:25:40 -0700 | [diff] [blame] | 2492 | subId = self.vsg_xos_subscriber_create(4) |
| 2493 | if subId and subId != '0': |
| 2494 | self.vsg_xos_subscriber_delete(4, subId) |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 2495 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2496 | @deferred(400) |
| 2497 | def test_vsg_xos_subscriber_external_connectivity_through_vcpe_instance(self, index=0): |
| 2498 | df = defer.Deferred() |
| 2499 | status = False |
| 2500 | def test_xos_subscriber(df): |
| 2501 | subId = self.vsg_xos_subscriber_id(index) |
| 2502 | if subId == '0': |
| 2503 | log.info('Creating vcpe instance ') |
| 2504 | subId = self.vsg_xos_subscriber_create(index) |
| 2505 | assert_not_equal(subId,'0') |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 2506 | vcpe = self.dhcp_vcpes[index] |
| 2507 | host = '8.8.8.8' |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2508 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe) |
| 2509 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2510 | assert_equal(st, False) |
| 2511 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe) |
| 2512 | df.callback(0) |
| 2513 | reactor.callLater(0,test_xos_subscriber,df) |
| 2514 | return df |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 2515 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2516 | #pass |
| 2517 | @deferred(50) |
| 2518 | def test_vsg_xos_subscriber_external_connectivity_without_creating_vcpe_instance(self, index=0): |
| 2519 | df = defer.Deferred() |
| 2520 | def test_xos_subscriber(df): |
| 2521 | subId = self.vsg_xos_subscriber_id(index) |
| 2522 | if subId != '0': |
| 2523 | log.info('deleting already existing vcpe instance ') |
| 2524 | self.vsg_xos_subscriber_delete(index, subId) |
| 2525 | vcpe = self.dhcp_vcpes[index] |
| 2526 | host = '8.8.8.8' |
| 2527 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe) |
| 2528 | st, out = getstatusoutput('route -n') |
| 2529 | log.info('route -n outpu-1-1-1--1-1-1-1-1-1-1 is %s'%out) |
| 2530 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2531 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe) |
| 2532 | assert_equal(st, True) |
| 2533 | df.callback(0) |
| 2534 | reactor.callLater(0,test_xos_subscriber,df) |
| 2535 | return df |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 2536 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2537 | @deferred(400) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2538 | def test_vsg_xos_subscriber_external_connectivity_after_removing_vcpe_instance_from_xos(self,index=0,host = '8.8.8.8'): |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2539 | df = defer.Deferred() |
| 2540 | def test_xos_subscriber(df): |
| 2541 | subId = self.vsg_xos_subscriber_id(index) |
| 2542 | if subId == '0': |
| 2543 | subId = self.vsg_xos_subscriber_create(index) |
| 2544 | assert_not_equal(subId,'0') |
| 2545 | vcpe = self.dhcp_vcpes[index] |
| 2546 | if subId and subId != '0': |
| 2547 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe) |
| 2548 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2549 | assert_equal(st, False) |
| 2550 | self.vsg_xos_subscriber_delete(index, subId) |
| 2551 | time.sleep(2) |
| 2552 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2553 | assert_equal(st, True) |
| 2554 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe) |
| 2555 | df.callback(0) |
| 2556 | reactor.callLater(0,test_xos_subscriber,df) |
| 2557 | return df |
| 2558 | |
| 2559 | @deferred(400) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2560 | def test_vsg_xos_subscriber_external_connectivity_after_restarting_vcpe_instance(self, index=0, host = '8.8.8.8'): |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2561 | df = defer.Deferred() |
| 2562 | def test_xos_subscriber(df): |
| 2563 | subId = self.vsg_xos_subscriber_id(index) |
| 2564 | if subId == '0': |
| 2565 | subId = self.vsg_xos_subscriber_create(index) |
| 2566 | assert_not_equal(subId,'0') |
| 2567 | vcpe_intf = self.dhcp_vcpes[index] |
| 2568 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2569 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2570 | assert_equal(st, False) |
| 2571 | vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2]) |
| 2572 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2573 | st, _ = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name)) |
| 2574 | assert_equal(st, True) |
| 2575 | time.sleep(5) |
| 2576 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2577 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2578 | assert_equal(st, False) |
| 2579 | df.callback(0) |
| 2580 | reactor.callLater(0,test_xos_subscriber,df) |
| 2581 | return df |
| 2582 | |
| 2583 | @deferred(400) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2584 | def test_vsg_xos_subscriber_external_connectivity_toggling_vcpe_instance(self, index=0, host = '8.8.8.8'): |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2585 | df = defer.Deferred() |
| 2586 | def test_xos_subscriber(df): |
| 2587 | subId = self.vsg_xos_subscriber_id(index) |
| 2588 | if subId == '0': |
| 2589 | subId = self.vsg_xos_subscriber_create(index) |
| 2590 | assert_not_equal(subId,'0') |
| 2591 | vcpe_intf = self.dhcp_vcpes[index] |
| 2592 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2593 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2594 | assert_equal(st, False) |
| 2595 | vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2]) |
| 2596 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2597 | st, _ = vsg.run_cmd('sudo docker stop {}'.format(vcpe_name)) |
| 2598 | assert_equal(st, True) |
| 2599 | time.sleep(3) |
| 2600 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2601 | assert_equal(st, True) |
| 2602 | st, _ = vsg.run_cmd('sudo docker start {}'.format(vcpe_name)) |
| 2603 | assert_equal(st, True) |
| 2604 | time.sleep(5) |
| 2605 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2606 | assert_equal(st, False) |
| 2607 | df.callback(0) |
| 2608 | reactor.callLater(0,test_xos_subscriber,df) |
| 2609 | return df |
| 2610 | |
| 2611 | #getting list out of range error while creating vcpe of index 6 |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2612 | def test_vsg_create_xos_subscribers_in_different_vsg_vm(self, index1=4, index2=6): |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2613 | indexes = list(index1,index2) |
| 2614 | subids = [] |
| 2615 | for index in indexes: |
| 2616 | subId = self.vsg_xos_subscriber_id(index) |
| 2617 | if not subId: |
| 2618 | subId = self.vsg_xos_subscriber_create(index) |
| 2619 | assert_not_equal(subId,'0') |
| 2620 | subids.append(subId) |
| 2621 | log.info('succesfully created two vcpe instances in two different vSG VMs') |
| 2622 | self.vsg_xos_subscriber_delete(index1, subid[0]) |
| 2623 | self.vsg_xos_subscriber_delete(index2, subid[1]) |
| 2624 | |
| 2625 | #Unable to reach external network via vcpes created by XOS |
| 2626 | @deferred(TIMEOUT+400) |
| 2627 | def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_goes_down(self): |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2628 | """ |
| 2629 | Test Method: |
| 2630 | 1.Create two vcpe instances in two different vsg vms using XOS |
| 2631 | 2.Verify external connectivity through vcpe instances from cord-tester |
| 2632 | 3.Kill first vcpe instance |
| 2633 | 4.Verify external network cant be reachable form first vcpe interface |
| 2634 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2635 | df = defer.Deferred() |
| 2636 | def test_xos_subscriber(df): |
| 2637 | host1 = '8.8.8.8' |
| 2638 | host2 = '4.2.2.2' |
| 2639 | vcpe_intf1 = self.dhcp_vcpes[0] |
| 2640 | vcpe_intf2 = self.dhcp_vcpes[1] |
| 2641 | vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2]) |
| 2642 | vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2]) |
| 2643 | subId1 = self.vsg_xos_subscriber_id(0) |
| 2644 | log.info('already existing subid of index 0 is %s'%subId1) |
| 2645 | if subId1 == '0': |
| 2646 | log.info('creating vcpe instance of index 0') |
| 2647 | subId1 = self.vsg_xos_subscriber_create(0) |
| 2648 | assert_not_equal(subId1,'0') |
| 2649 | subId2 = self.vsg_xos_subscriber_id(1) |
| 2650 | log.info('already existing subid of index 1 is %s'%subId2) |
| 2651 | if subId2 == '0': |
| 2652 | log.info('creating vcpe instance of index 1') |
| 2653 | subId2 = self.vsg_xos_subscriber_create(1) |
| 2654 | assert_not_equal(subId2,'0') |
| 2655 | vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1) |
| 2656 | vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2) |
| 2657 | try: |
| 2658 | for intf in [vcpe_intf1,vcpe_intf2]: |
| 2659 | host = host1 if intf is vcpe_intf1 else host2 |
| 2660 | self.add_static_route_via_vcpe_interface([host],vcpe=intf) |
| 2661 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2662 | assert_equal(st, False) |
| 2663 | if intf is vcpe_intf2: |
| 2664 | self.vsg_xos_subscriber_delete(1, subId2) |
| 2665 | st, _ = vsg2.run_cmd('sudo docker kill {}'.format(vcpe_name2)) |
| 2666 | time.sleep(2) |
| 2667 | self.add_static_route_via_vcpe_interface([host],vcpe=intf) |
| 2668 | st,_ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 2669 | assert_equal(st, False) |
| 2670 | st,_ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 2671 | assert_equal(st, True) |
| 2672 | except Exception as error: |
| 2673 | log.info('Got Unexpected error %s'%error) |
| 2674 | raise |
| 2675 | finally: |
| 2676 | self.vsg_xos_subscriber_delete(0, subId1) |
| 2677 | self.vsg_xos_subscriber_delete(1, subId2) |
| 2678 | self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1) |
| 2679 | self.del_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2) |
| 2680 | df.callback(0) |
| 2681 | reactor.callLater(0,test_xos_subscriber,df) |
| 2682 | return df |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2683 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2684 | @deferred(TIMEOUT+400) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2685 | def test_vsg_xos_subscriber_external_connectivity_after_vcpe_is_removed_and_added_again(self,index=0): |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2686 | """ |
| 2687 | Test Method: |
| 2688 | 1.Create two vcpe instances in two different vsg vms using XOS |
| 2689 | 2.Verify external connectivity through vcpe instances from cord-tester |
| 2690 | 3.Remove first vcpe instance |
| 2691 | 4.Verify external network cant be reachable form first vcpe interface |
| 2692 | 5.Add back the removed vcpe instance |
| 2693 | 6.Verify external connectivity through vcpe instances from cord-tester |
| 2694 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2695 | df = defer.Deferred() |
| 2696 | def test_xos_subscriber(df,index=index): |
| 2697 | host = '8.8.8.8' |
| 2698 | subId = self.vsg_xos_subscriber_id(index) |
| 2699 | log.info('already existing subid of index 0 is %s'%subId) |
| 2700 | if subId == '0': |
| 2701 | log.info('creating vcpe instance of index %s'%index) |
| 2702 | subId = self.vsg_xos_subscriber_create(index) |
| 2703 | assert_not_equal(subId,'0') |
| 2704 | vcpe_intf = self.dhcp_vcpes[0] |
| 2705 | vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2]) |
| 2706 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2707 | try: |
| 2708 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2709 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2710 | assert_equal(st, False) |
| 2711 | log.info('Deleting vcpe Instance of index %s'%index) |
| 2712 | self.vsg_xos_subscriber_delete(0, subId) |
| 2713 | st, _ = vsg.run_cmd('sudo docker kill {}'.format(vcpe_name)) |
| 2714 | time.sleep(1) |
| 2715 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2716 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2717 | assert_equal(st, True) |
| 2718 | subId = self.vsg_xos_subscriber_create(index) |
| 2719 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2720 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2721 | assert_equal(st, False) |
| 2722 | except Exception as error: |
| 2723 | log.info('Got Unexpected error %s'%error) |
| 2724 | raise |
| 2725 | finally: |
| 2726 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2727 | self.vsg_xos_subscriber_delete(0, subId) |
| 2728 | df.callback(0) |
| 2729 | reactor.callLater(0,test_xos_subscriber,df) |
| 2730 | return df |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2731 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2732 | @deferred(TIMEOUT+400) |
| 2733 | def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_restarts(self): |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2734 | """ |
| 2735 | Test Method: |
| 2736 | 1.Create two vcpe instances in two different vsg vms using XOS |
| 2737 | 2.Verify external connectivity through vcpe instances from cord-tester |
| 2738 | 3.Restart first vcpe instance |
| 2739 | 4.Verify external network cant be reachable form first vcpe interface |
| 2740 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2741 | df = defer.Deferred() |
| 2742 | def test_xos_subscriber(df): |
| 2743 | host1 = '8.8.8.8' |
| 2744 | host2 = '4.2.2.2' |
| 2745 | subId1 = self.vsg_xos_subscriber_id(0) |
| 2746 | log.info('already existing subid of index 0 is %s'%subId1) |
| 2747 | if subId1 == '0': |
| 2748 | log.info('creating vcpe instance of index 0') |
| 2749 | subId1 = self.vsg_xos_subscriber_create(0) |
| 2750 | assert_not_equal(subId1,'0') |
| 2751 | subId2 = self.vsg_xos_subscriber_id(1) |
| 2752 | log.info('already existing subid of index 1 is %s'%subId2) |
| 2753 | if subId2 == '0': |
| 2754 | log.info('creating vcpe instance of index 1') |
| 2755 | subId2 = self.vsg_xos_subscriber_create(1) |
| 2756 | vcpe_intf1 = self.dhcp_vcpes[0] |
| 2757 | vcpe_intf2 = self.dhcp_vcpes[1] |
| 2758 | vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2]) |
| 2759 | vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2]) |
| 2760 | vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1) |
| 2761 | vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2) |
| 2762 | try: |
| 2763 | #checking external connectivity from vcpe interface 1 before vcpe 2 restart |
| 2764 | self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1) |
| 2765 | st,_ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 2766 | assert_equal(st, False) |
| 2767 | #checking external connectivity from vcpe interface 2 before vcpe 2 restart |
| 2768 | self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2) |
| 2769 | st,_ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 2770 | assert_equal(st, False) |
| 2771 | st, _ = vsg2.run_cmd('sudo docker restart {}'.format(vcpe_name2)) |
| 2772 | time.sleep(10) |
| 2773 | #checking external connectivity from vcpe interface 1 after vcpe 2 restart |
| 2774 | st,_ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 2775 | assert_equal(st, False) |
| 2776 | self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2) |
| 2777 | time = 0 |
| 2778 | status = False |
| 2779 | while(time <= 100): |
| 2780 | time.sleep(10) |
| 2781 | st,_ = getstatusoutput('ping -c 1 {}'.format(hos2)) |
| 2782 | if st is False: |
| 2783 | status = True |
| 2784 | break |
| 2785 | time += 10 |
| 2786 | assert_equal(status, True) |
| 2787 | except Exception as error: |
| 2788 | log.info('Got Unexpected error %s'%error) |
| 2789 | raise |
| 2790 | finally: |
| 2791 | self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1) |
| 2792 | self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2) |
| 2793 | self.vsg_xos_subscriber_delete(0, subId1) |
| 2794 | self.vsg_xos_subscriber_delete(1, subId2) |
| 2795 | df.callback(0) |
| 2796 | reactor.callLater(0,test_xos_subscriber,df) |
| 2797 | return df |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2798 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2799 | @deferred(500) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2800 | def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_is_paused(self): |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2801 | """ |
| 2802 | Test Method: |
| 2803 | 1.Create two vcpe instances in two different vsg vms using XOS |
| 2804 | 2.Verify external connectivity through vcpe instances from cord-tester |
| 2805 | 3.Pause running first vcpe instance |
| 2806 | 4.Verify external network cant be reachable form first vcpe interface |
| 2807 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2808 | df = defer.Deferred() |
| 2809 | def test_xos_subscriber(df): |
| 2810 | host1 = '8.8.8.8' |
| 2811 | host2 = '4.2.2.2' |
| 2812 | subId1 = self.vsg_xos_subscriber_id(0) |
| 2813 | log.info('already existing subid of index 0 is %s'%subId1) |
| 2814 | if subId1 == '0': |
| 2815 | log.info('creating vcpe instance of index 0') |
| 2816 | subId1 = self.vsg_xos_subscriber_create(0) |
| 2817 | assert_not_equal(subId1,'0') |
| 2818 | subId2 = self.vsg_xos_subscriber_id(1) |
| 2819 | log.info('already existing subid of index 1 is %s'%subId2) |
| 2820 | if subId2 == '0': |
| 2821 | log.info('creating vcpe instance of index 1') |
| 2822 | subId2 = self.vsg_xos_subscriber_create(1) |
| 2823 | vcpe_intf1 = self.dhcp_vcpes[0] |
| 2824 | vcpe_intf2 = self.dhcp_vcpes[1] |
| 2825 | vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2]) |
| 2826 | vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2]) |
| 2827 | vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1) |
| 2828 | vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2) |
| 2829 | try: |
| 2830 | #checking external connectivity from vcpe interface 1 before vcpe 2 pause |
| 2831 | self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1) |
| 2832 | st,_ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 2833 | assert_equal(st, False) |
| 2834 | #checking external connectivity from vcpe interface 2 before vcpe 2 pause |
| 2835 | self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2) |
| 2836 | st,_ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 2837 | assert_equal(st, False) |
| 2838 | st, _ = vsg2.run_cmd('sudo docker pause {}'.format(vcpe_name2)) |
| 2839 | time.sleep(1) |
| 2840 | #checking external connectivity from vcpe interface 1 after vcpe 2 pause |
| 2841 | st,_ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 2842 | assert_equal(st, False) |
| 2843 | #checking external connectivity from vcpe interface 2 after vcpe 2 pause |
| 2844 | st,_ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 2845 | assert_equal(st, True) |
| 2846 | except Exception as error: |
| 2847 | log.info('Got Unexpected error %s'%error) |
| 2848 | raise |
| 2849 | finally: |
| 2850 | log.info('In Finally block 3333333333333333') |
| 2851 | st, _ = vsg2.run_cmd('sudo docker unpause {}'.format(vcpe_name2)) |
| 2852 | self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1) |
| 2853 | self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2) |
| 2854 | self.vsg_xos_subscriber_delete(0, subId1) |
| 2855 | self.vsg_xos_subscriber_delete(1, subId2) |
| 2856 | df.callback(0) |
| 2857 | reactor.callLater(0,test_xos_subscriber,df) |
| 2858 | return df |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2859 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2860 | @deferred(500) |
| 2861 | def test_vsg_xos_subscriber_external_connectivity_if_one_vcpe_stops(self): |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2862 | """ |
| 2863 | Test Method: |
| 2864 | 1.Create two vcpe instances in two different vsg vms using XOS |
| 2865 | 2.Verify external connectivity through vcpe instances from cord-tester |
| 2866 | 3.Stop running first vcpe instance |
| 2867 | 4.Verify external network cant be reachable form first vcpe interface |
| 2868 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2869 | df = defer.Deferred() |
| 2870 | def test_xos_subscriber(df): |
| 2871 | host1 = '8.8.8.8' |
| 2872 | host2 = '4.2.2.2' |
| 2873 | subId1 = self.vsg_xos_subscriber_id(0) |
| 2874 | log.info('already existing subid of index 0 is %s'%subId1) |
| 2875 | if subId1 == '0': |
| 2876 | log.info('creating vcpe instance of index 0') |
| 2877 | subId1 = self.vsg_xos_subscriber_create(0) |
| 2878 | assert_not_equal(subId1,'0') |
| 2879 | subId2 = self.vsg_xos_subscriber_id(1) |
| 2880 | log.info('already existing subid of index 1 is %s'%subId2) |
| 2881 | if subId2 == '0': |
| 2882 | log.info('creating vcpe instance of index 1') |
| 2883 | subId2 = self.vsg_xos_subscriber_create(1) |
| 2884 | vcpe_intf1 = self.dhcp_vcpes[0] |
| 2885 | vcpe_intf2 = self.dhcp_vcpes[1] |
| 2886 | vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2]) |
| 2887 | vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2]) |
| 2888 | vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1) |
| 2889 | vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2) |
| 2890 | try: |
| 2891 | #checking external connectivity from vcpe interface 1 before vcpe 2 stop |
| 2892 | self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1) |
| 2893 | st,_ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 2894 | assert_equal(st, False) |
| 2895 | #checking external connectivity from vcpe interface 2 before vcpe 2 stop |
| 2896 | self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2) |
| 2897 | st,_ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 2898 | assert_equal(st, False) |
| 2899 | st, _ = vsg2.run_cmd('sudo docker stop {}'.format(vcpe_name2)) |
| 2900 | time.sleep(5) |
| 2901 | #checking external connectivity from vcpe interface 1 after vcpe 2 stop |
| 2902 | st,_ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 2903 | assert_equal(st, False) |
| 2904 | #checking external connectivity from vcpe interface 1 after vcpe 2 stop |
| 2905 | self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2) |
| 2906 | st,_ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 2907 | assert_equal(st, True) |
| 2908 | except Exception as error: |
| 2909 | log.info('Got Unexpected error %s'%error) |
| 2910 | raise |
| 2911 | finally: |
| 2912 | st, _ = vsg2.run_cmd('sudo docker start {}'.format(vcpe_name2)) |
| 2913 | time.sleep(10) |
| 2914 | self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1) |
| 2915 | self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2) |
| 2916 | self.vsg_xos_subscriber_delete(0, subId1) |
| 2917 | self.vsg_xos_subscriber_delete(1, subId2) |
| 2918 | df.callback(0) |
| 2919 | reactor.callLater(0,test_xos_subscriber,df) |
| 2920 | return df |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2921 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2922 | @deferred(420) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2923 | def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_stopped(self, index=0): |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2924 | """ |
| 2925 | Test Method: |
| 2926 | 1.Create two vcpe instances in two different vsg vms using XOS |
| 2927 | 2.Verify external connectivity through vcpe instances from cord-tester |
| 2928 | 3.Bring down first vSG vm |
| 2929 | 4.Verify external network cant be reachable form first vcpe interface |
| 2930 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2931 | df = defer.Deferred() |
| 2932 | def test_xos_subscriber(df,index=index): |
| 2933 | host = '8.8.8.8' |
| 2934 | subId = self.vsg_xos_subscriber_id(index) |
| 2935 | if subId == '0': |
| 2936 | log.info('creating vcpe instance of index 0') |
| 2937 | subId = self.vsg_xos_subscriber_create(index) |
| 2938 | assert_not_equal(subId,'0') |
| 2939 | vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag) |
| 2940 | vcpe_name = self.container_vcpes[index] |
| 2941 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2942 | try: |
| 2943 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2944 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2945 | assert_equal(st, False) |
| 2946 | log.info('Stopping vsg instance') |
| 2947 | vsg.stop() |
| 2948 | time.sleep(5) |
| 2949 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2950 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2951 | assert_equal(st, True) |
| 2952 | except Exception as error: |
| 2953 | log.info('Got Unexpected error %s'%error) |
| 2954 | raise |
| 2955 | finally: |
| 2956 | vsg.start() |
| 2957 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2958 | self.vsg_xos_subscriber_delete(index, subId) |
| 2959 | df.callback(0) |
| 2960 | reactor.callLater(0,test_xos_subscriber,df) |
| 2961 | return df |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 2962 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2963 | @deferred(420) |
Chetan Gaonker | e1f6638 | 2017-06-02 21:34:07 +0000 | [diff] [blame] | 2964 | def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_restarted(self, index=0): |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2965 | """ |
| 2966 | Test Method: |
Chetan Gaonker | fe1048f | 2017-06-13 20:16:25 +0000 | [diff] [blame] | 2967 | 1.Create subscriber |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 2968 | 2.Verify external connectivity through vcpe instances from cord-tester |
| 2969 | 3.Bring down first vSG vm |
| 2970 | 4.Verify external network cant be reachable form first vcpe interface |
| 2971 | """ |
| 2972 | df = defer.Deferred() |
| 2973 | def test_xos_subscriber(df,index=index): |
| 2974 | host = '8.8.8.8' |
| 2975 | subId = self.vsg_xos_subscriber_id(index) |
| 2976 | if subId == '0': |
| 2977 | log.info('creating vcpe instance of index 0') |
| 2978 | subId = self.vsg_xos_subscriber_create(index) |
| 2979 | assert_not_equal(subId,'0') |
| 2980 | vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag) |
| 2981 | vcpe_name = self.container_vcpes[index] |
| 2982 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 2983 | try: |
| 2984 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2985 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2986 | assert_equal(st, False) |
| 2987 | log.info('Restarting vsg instance') |
| 2988 | vsg.reboot() |
| 2989 | time.sleep(10) |
| 2990 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 2991 | time = 0 |
| 2992 | status = False |
| 2993 | while(time <= 100): |
| 2994 | time.sleep(10) |
| 2995 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 2996 | if st is False: |
| 2997 | status = True |
| 2998 | break |
| 2999 | time += 10 |
| 3000 | assert_equal(status, True) |
| 3001 | except Exception as error: |
| 3002 | log.info('Got Unexpected error %s'%error) |
| 3003 | raise |
| 3004 | finally: |
| 3005 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 3006 | self.vsg_xos_subscriber_delete(index, subId) |
| 3007 | df.callback(0) |
| 3008 | reactor.callLater(0,test_xos_subscriber,df) |
| 3009 | return df |
| 3010 | |
| 3011 | @deferred(780) |
Chetan Gaonker | fe1048f | 2017-06-13 20:16:25 +0000 | [diff] [blame] | 3012 | def test_vsg_xos_multiple_subscribers_external_connectivity_if_two_vsgs_stop_and_start(self, index1=4, index2=6): |
Anil Kumar Sanka | 5bb352a | 2017-05-16 22:24:01 +0000 | [diff] [blame] | 3013 | """ |
| 3014 | Test Method: |
| 3015 | 1.Create two vcpe instances in two different vsg vms using XOS |
| 3016 | 2.Verify external connectivity through vcpe instances from cord-tester |
| 3017 | 3.Bring down first vSG vm |
| 3018 | 4.Verify external network cant be reachable form first vcpe interface |
| 3019 | 5.Bring down second vSG vm also |
| 3020 | 6.Verify external network cant be reachable form first vcpe interface also |
| 3021 | """ |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 3022 | df = defer.Deferred(df,index1=index1,index2=index2) |
| 3023 | def test_xos_subscriber(df,index=index): |
| 3024 | subId1 = self.vsg_xos_subscriber_create(index1) |
| 3025 | subId2 = self.vsg_xos_subscriber_create(index2) |
| 3026 | if subId1 == '0': |
| 3027 | self.vsg_xos_subscriber_delete(index1, subId1) |
| 3028 | assert_not_equal(subId1, '0') |
| 3029 | if subId2 == '0': |
| 3030 | self.vsg_xos_subscriber_delete(index2, subId2) |
| 3031 | assert_not_equal(subId2, '0') |
| 3032 | for index in [index1,index2]: |
| 3033 | vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag) |
| 3034 | vcpe_name = self.container_vcpes[index] |
| 3035 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
| 3036 | try: |
| 3037 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 3038 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 3039 | assert_equal(st, False) |
| 3040 | log.info('Stopping vsg instance of index %s'%index) |
| 3041 | vsg.stop() |
| 3042 | time.sleep(5) |
| 3043 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 3044 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 3045 | assert_equal(st, True) |
| 3046 | except Exception as error: |
| 3047 | log.info('Got Unexpected error %s'%error) |
| 3048 | raise |
| 3049 | finally: |
| 3050 | vsg.start() |
| 3051 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 3052 | df.callback(0) |
| 3053 | reactor.callLater(0,test_xos_subscriber,df) |
| 3054 | return df |
Anil Kumar Sanka | 52a39f8 | 2017-05-10 17:39:31 +0000 | [diff] [blame] | 3055 | |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 3056 | @deferred(420) |
| 3057 | def test_vsg_xos_subscriber_external_connectivity_with_creating_firewall_rule(self,index=0): |
| 3058 | """ |
| 3059 | Alog: |
| 3060 | 1.Cretae a vcpe instance using XOS |
| 3061 | 2.Get dhcp IP to vcpe interface in cord-tester |
| 3062 | 3.Verify external network can be reachable from cord-tester |
| 3063 | 4.Add an iptable rule to drop packets destined to external network in vcpe |
| 3064 | 5.Verify now external network cant be reachable |
Chetan Gaonker | fe1048f | 2017-06-13 20:16:25 +0000 | [diff] [blame] | 3065 | 6.Delele the iptable in vcpe instance |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 3066 | 7.Verify external network can be reachable from cord-tester |
| 3067 | """ |
| 3068 | df = defer.Deferred() |
| 3069 | def test_xos_subscriber(df,index=index): |
| 3070 | log.info('cls.dhcp_vcpes is %s'%self.dhcp_vcpes) |
| 3071 | host = '8.8.8.8' |
| 3072 | subId = self.vsg_xos_subscriber_create(index) |
| 3073 | if subId == '0': |
| 3074 | subId = self.vsg_xos_subscriber_create(index) |
| 3075 | assert_not_equal(subId, '0') |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 3076 | vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 3077 | vcpe_name = self.container_vcpes[index] |
| 3078 | vsg = VSGAccess.get_vcpe_vsg(vcpe_name) |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 3079 | try: |
| 3080 | self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
| 3081 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 3082 | #ssert_equal(st, False) |
| 3083 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 3084 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 3085 | assert_equal(st, True) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 3086 | st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
| 3087 | self.vsg_xos_subscriber_delete(index, subId) |
| 3088 | except Exception as error: |
| 3089 | log.info('Got Unexpected error %s'%error) |
| 3090 | raise |
| 3091 | finally: |
| 3092 | vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host)) |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 3093 | self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf) |
Anil Kumar Sanka | 5db80d0 | 2017-06-02 21:10:19 +0000 | [diff] [blame] | 3094 | self.vsg_xos_subscriber_delete(index, subId) |
| 3095 | df.callback(0) |
| 3096 | reactor.callLater(0,test_xos_subscriber,df) |
| 3097 | return df |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3098 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3099 | def test_vsg_for_packet_received_with_invalid_ip_fields(self): |
| 3100 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3101 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3102 | 1.Create a vSG VM in compute node |
| 3103 | 2.Create a vCPE container in vSG VM |
| 3104 | 3.Ensure vSG VM and vCPE container created properly |
| 3105 | 4.From subscriber, send a ping packet with invalid ip fields |
| 3106 | 5.Verify that vSG drops the packet |
| 3107 | 6.Verify ping fails |
| 3108 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3109 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3110 | def test_vsg_for_packet_received_with_invalid_mac_fields(self): |
| 3111 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3112 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3113 | 1.Create a vSG VM in compute node |
| 3114 | 2.Create a vCPE container in vSG VM |
| 3115 | 3.Ensure vSG VM and vCPE container created properly |
| 3116 | 4.From subscriber, send a ping packet with invalid mac fields |
| 3117 | 5.Verify that vSG drops the packet |
| 3118 | 6.Verify ping fails |
| 3119 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3120 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3121 | def test_vsg_for_vlan_id_mismatch_in_stag(self): |
| 3122 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3123 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3124 | 1.Create a vSG VM in compute Node |
| 3125 | 2.Create a vCPE container in vSG VM |
| 3126 | 3.Ensure vSG VM and vCPE container created properly |
| 3127 | 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag |
| 3128 | 5.Verify that ping fails as the packet drops at VM entry |
| 3129 | 6.Repeat step 4 with correct s-tag |
| 3130 | 7.Verify that ping success |
| 3131 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3132 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3133 | def test_vsg_for_vlan_id_mismatch_in_ctag(self): |
| 3134 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3135 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3136 | 1.Create a vSG VM in compute node |
| 3137 | 2.Create a vCPE container in vSG VM |
| 3138 | 3.Ensure vSG VM and vCPE container created properly |
| 3139 | 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag |
| 3140 | 5.Verify that ping fails as the packet drops at vCPE container entry |
| 3141 | 6.Repeat step 4 with valid s-tag and c-tag |
| 3142 | 7.Verify that ping success |
| 3143 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3144 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3145 | def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self): |
| 3146 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3147 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3148 | 1.Create two vSG VMs in compute node |
| 3149 | 2.Create a vCPE container in each vSG VM |
| 3150 | 3.Ensure vSG VM and vCPE container created properly |
| 3151 | 4.From subscriber one, send ping request with valid s and c tags |
| 3152 | 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags |
| 3153 | 6.Verify that ping success for only subscriber one and fails for two. |
| 3154 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3155 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3156 | def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self): |
| 3157 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3158 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3159 | 1.Create a vSG VM in compute node |
| 3160 | 2.Create two vCPE containers in vSG VM |
| 3161 | 3.Ensure vSG VM and vCPE container created properly |
| 3162 | 4.From subscriber one, send ping request with valid s and c tags |
| 3163 | 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag |
| 3164 | 6.Verify that ping success for only subscriber one and fails for two |
| 3165 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3166 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3167 | def test_vsg_for_out_of_range_vlanid_in_ctag(self): |
| 3168 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3169 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3170 | 1.Create a vSG VM in compute node |
| 3171 | 2.Create a vCPE container in vSG VM |
| 3172 | 3.Ensure vSG VM and vCPE container created properly |
| 3173 | 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 ) |
| 3174 | 4.Verify that ping fails as the ping packets drops at vCPE container entry |
| 3175 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3176 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3177 | def test_vsg_for_out_of_range_vlanid_in_stag(self): |
| 3178 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3179 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3180 | 1.Create a vSG VM in compute node |
| 3181 | 2.Create a vCPE container in vSG VM |
| 3182 | 3.Ensure vSG VM and vCPE container created properly |
| 3183 | 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 |
| 3184 | 4.Verify that ping fails as the ping packets drops at vSG VM entry |
| 3185 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3186 | |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 3187 | def test_vsg_for_extracting_all_compute_stats_from_all_vcpe_containers(self): |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3188 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3189 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3190 | 1.Create a vSG VM in compute node |
| 3191 | 2.Create 10 vCPE containers in VM |
| 3192 | 3.Ensure vSG VM and vCPE containers created properly |
| 3193 | 4.Login to all vCPE containers |
| 3194 | 4.Get all compute stats from all vCPE containers |
| 3195 | 5.Verify the stats # verification method need to add |
| 3196 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3197 | |
Anil Kumar Sanka | f6a9f39 | 2017-05-06 00:18:31 +0000 | [diff] [blame] | 3198 | def test_vsg_for_extracting_dns_stats_from_all_vcpe_containers(self): |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3199 | """ |
Chetan Gaonker | 72f3c4e | 2017-05-10 18:16:49 +0000 | [diff] [blame] | 3200 | Test Method: |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 3201 | 1.Create a vSG VM in compute node |
| 3202 | 2.Create 10 vCPE containers in VM |
| 3203 | 3.Ensure vSG VM and vCPE containers created properly |
| 3204 | 4.From 10 subscribers, send ping to valid and invalid dns hosts |
| 3205 | 5.Verify dns resolves and ping success for valid dns hosts |
| 3206 | 6.Verify ping fails for invalid dns hosts |
| 3207 | 7.Verify dns host name resolve flows in OvS |
| 3208 | 8.Login to all 10 vCPE containers |
| 3209 | 9.Extract all dns stats |
| 3210 | 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios |
| 3211 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3212 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 3213 | |