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