Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 1 | #copyright 2016-present Ciena Corporation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 15 | import time |
| 16 | import os |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 17 | import sys |
| 18 | import json |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 19 | from nose.tools import * |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 20 | from CordTestUtils import * |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 21 | from OltConfig import OltConfig |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 22 | from onosclidriver import OnosCliDriver |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 23 | from SSHTestAgent import SSHTestAgent |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 24 | from CordLogger import CordLogger |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 25 | from VSGAccess import VSGAccess |
A R Karthick | 933f5b5 | 2017-03-27 15:27:16 -0700 | [diff] [blame] | 26 | from CordTestUtils import log_test as log |
A.R Karthick | a9b594d | 2017-03-29 16:25:22 -0700 | [diff] [blame] | 27 | from OnosCtrl import OnosCtrl |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 28 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 29 | log.setLevel('INFO') |
| 30 | |
| 31 | class vsg_exchange(CordLogger): |
| 32 | ONOS_INSTANCES = 3 |
| 33 | V_INF1 = 'veth0' |
| 34 | device_id = 'of:' + get_mac() |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 35 | TEST_IP = '8.8.8.8' |
| 36 | HOST = "10.1.0.1" |
| 37 | USER = "vagrant" |
| 38 | PASS = "vagrant" |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 39 | head_node = os.getenv('HEAD_NODE', 'prod') |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 40 | 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] | 41 | test_path = os.path.dirname(os.path.realpath(__file__)) |
| 42 | olt_conf_file = os.path.join(test_path, '..', 'setup/olt_config.json') |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 43 | restApiXos = None |
A R Karthick | 0a4ca3a | 2017-03-30 09:36:53 -0700 | [diff] [blame] | 44 | subscriber_account_num = 200 |
| 45 | subscriber_s_tag = 304 |
| 46 | subscriber_c_tag = 304 |
| 47 | subscribers_per_s_tag = 8 |
| 48 | subscriber_map = {} |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 49 | restore_methods = [] |
A R Karthick | 0a4ca3a | 2017-03-30 09:36:53 -0700 | [diff] [blame] | 50 | |
| 51 | @classmethod |
| 52 | def getSubscriberCredentials(cls, subId): |
| 53 | """Generate our own account num, s_tag and c_tags""" |
| 54 | if subId in cls.subscriber_map: |
| 55 | return cls.subscriber_map[subId] |
| 56 | account_num = cls.subscriber_account_num |
| 57 | cls.subscriber_account_num += 1 |
| 58 | s_tag, c_tag = cls.subscriber_s_tag, cls.subscriber_c_tag |
| 59 | cls.subscriber_c_tag += 1 |
| 60 | if cls.subscriber_c_tag % cls.subscribers_per_s_tag == 0: |
| 61 | cls.subscriber_s_tag += 1 |
| 62 | cls.subscriber_map[subId] = account_num, s_tag, c_tag |
| 63 | return cls.subscriber_map[subId] |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 64 | |
| 65 | @classmethod |
A.R Karthick | a9b594d | 2017-03-29 16:25:22 -0700 | [diff] [blame] | 66 | def getXosCredentials(cls): |
| 67 | onos_cfg = OnosCtrl.get_config() |
| 68 | if onos_cfg is None: |
| 69 | return None |
| 70 | if 'apps' in onos_cfg and \ |
| 71 | 'org.opencord.vtn' in onos_cfg['apps'] and \ |
| 72 | 'cordvtn' in onos_cfg['apps']['org.opencord.vtn'] and \ |
| 73 | 'xos' in onos_cfg['apps']['org.opencord.vtn']['cordvtn']: |
| 74 | xos_cfg = onos_cfg['apps']['org.opencord.vtn']['cordvtn']['xos'] |
| 75 | endpoint = xos_cfg['endpoint'] |
| 76 | user = xos_cfg['user'] |
| 77 | password = xos_cfg['password'] |
| 78 | xos_endpoints = endpoint.split(':') |
| 79 | xos_host = xos_endpoints[1][len('//'):] |
| 80 | xos_port = xos_endpoints[2][:-1] |
| 81 | #log.info('xos_host: %s, port: %s, user: %s, password: %s' %(xos_host, xos_port, user, password)) |
| 82 | return dict(host = xos_host, port = xos_port, user = user, password = password) |
| 83 | |
| 84 | return None |
| 85 | |
| 86 | @classmethod |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 87 | def setUpCordApi(cls): |
| 88 | our_path = os.path.dirname(os.path.realpath(__file__)) |
| 89 | cord_api_path = os.path.join(our_path, '..', 'cord-api') |
| 90 | framework_path = os.path.join(cord_api_path, 'Framework') |
| 91 | utils_path = os.path.join(framework_path, 'utils') |
| 92 | data_path = os.path.join(cord_api_path, 'Tests', 'data') |
| 93 | subscriber_cfg = os.path.join(data_path, 'Subscriber.json') |
| 94 | volt_tenant_cfg = os.path.join(data_path, 'VoltTenant.json') |
| 95 | |
| 96 | with open(subscriber_cfg) as f: |
| 97 | subscriber_data = json.load(f) |
| 98 | subscriber_info = subscriber_data['SubscriberInfo'] |
A R Karthick | 0a4ca3a | 2017-03-30 09:36:53 -0700 | [diff] [blame] | 99 | for i in xrange(len(subscriber_info)): |
| 100 | subscriber = subscriber_info[i] |
| 101 | account_num, _, _ = cls.getSubscriberCredentials('sub{}'.format(i)) |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 102 | subscriber['identity']['account_num'] = str(account_num) |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 103 | cls.subscriber_info = subscriber_info |
| 104 | |
| 105 | with open(volt_tenant_cfg) as f: |
| 106 | volt_tenant_data = json.load(f) |
| 107 | volt_subscriber_info = volt_tenant_data['voltSubscriberInfo'] |
| 108 | assert_equal(len(volt_subscriber_info), len(cls.subscriber_info)) |
A R Karthick | 0a4ca3a | 2017-03-30 09:36:53 -0700 | [diff] [blame] | 109 | for i in xrange(len(volt_subscriber_info)): |
| 110 | volt_subscriber = volt_subscriber_info[i] |
| 111 | account_num, s_tag, c_tag = cls.getSubscriberCredentials('sub{}'.format(i)) |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 112 | volt_subscriber['account_num'] = account_num |
A R Karthick | 0a4ca3a | 2017-03-30 09:36:53 -0700 | [diff] [blame] | 113 | volt_subscriber['voltTenant']['s_tag'] = str(s_tag) |
| 114 | volt_subscriber['voltTenant']['c_tag'] = str(c_tag) |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 115 | cls.volt_subscriber_info = volt_subscriber_info |
| 116 | |
| 117 | sys.path.append(utils_path) |
| 118 | sys.path.append(framework_path) |
| 119 | from restApi import restApi |
| 120 | restApiXos = restApi() |
A.R Karthick | a9b594d | 2017-03-29 16:25:22 -0700 | [diff] [blame] | 121 | xos_credentials = cls.getXosCredentials() |
| 122 | if xos_credentials is None: |
| 123 | restApiXos.controllerIP = cls.HEAD_NODE |
| 124 | restApiXos.controllerPort = '9000' |
| 125 | else: |
| 126 | restApiXos.controllerIP = xos_credentials['host'] |
| 127 | restApiXos.controllerPort = xos_credentials['port'] |
| 128 | restApiXos.user = xos_credentials['user'] |
| 129 | restApiXos.password = xos_credentials['password'] |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 130 | cls.restApiXos = restApiXos |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 131 | |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 132 | @classmethod |
| 133 | def setUpClass(cls): |
| 134 | cls.controllers = get_controllers() |
| 135 | cls.controller = cls.controllers[0] |
| 136 | cls.cli = None |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 137 | cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file) |
| 138 | cls.vcpes = cls.olt.get_vcpes() |
| 139 | cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp') |
| 140 | vcpe_dhcp = None |
| 141 | vcpe_dhcp_stag = None |
| 142 | vcpe_container = None |
| 143 | #cache the first dhcp vcpe in the class for quick testing |
| 144 | if cls.vcpes_dhcp: |
| 145 | vcpe_container = 'vcpe-{}-{}'.format(cls.vcpes_dhcp[0]['s_tag'], cls.vcpes_dhcp[0]['c_tag']) |
| 146 | vcpe_dhcp = 'vcpe0.{}.{}'.format(cls.vcpes_dhcp[0]['s_tag'], cls.vcpes_dhcp[0]['c_tag']) |
| 147 | vcpe_dhcp_stag = 'vcpe0.{}'.format(cls.vcpes_dhcp[0]['s_tag']) |
| 148 | cls.vcpe_container = vcpe_container |
| 149 | cls.vcpe_dhcp = vcpe_dhcp |
| 150 | cls.vcpe_dhcp_stag = vcpe_dhcp_stag |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 151 | VSGAccess.setUp() |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 152 | cls.setUpCordApi() |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 153 | |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 154 | @classmethod |
| 155 | def tearDownClass(cls): |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 156 | VSGAccess.tearDown() |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 157 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 158 | def cliEnter(self, controller = None): |
| 159 | retries = 0 |
| 160 | while retries < 30: |
| 161 | self.cli = OnosCliDriver(controller = controller, connect = True) |
| 162 | if self.cli.handle: |
| 163 | break |
| 164 | else: |
| 165 | retries += 1 |
| 166 | time.sleep(2) |
| 167 | |
| 168 | def cliExit(self): |
| 169 | self.cli.disconnect() |
| 170 | |
| 171 | def onos_shutdown(self, controller = None): |
| 172 | status = True |
| 173 | self.cliEnter(controller = controller) |
| 174 | try: |
| 175 | self.cli.shutdown(timeout = 10) |
| 176 | except: |
| 177 | log.info('Graceful shutdown of ONOS failed for controller: %s' %controller) |
| 178 | status = False |
| 179 | |
| 180 | self.cliExit() |
| 181 | return status |
| 182 | |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 183 | def log_set(self, level = None, app = 'org.onosproject'): |
| 184 | CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 185 | |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 186 | @classmethod |
| 187 | def get_dhcp(cls, vcpe, mgmt = 'eth0'): |
| 188 | """Get DHCP for vcpe interface saving management settings""" |
| 189 | |
| 190 | def put_dhcp(): |
| 191 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
| 192 | |
| 193 | vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt) |
| 194 | if vcpe_ip is not None: |
| 195 | cls.restore_methods.append(put_dhcp) |
| 196 | return vcpe_ip |
| 197 | |
| 198 | @classmethod |
| 199 | def config_restore(cls): |
| 200 | """Restore the vsg test configuration on test case failures""" |
| 201 | for restore_method in cls.restore_methods: |
| 202 | restore_method() |
| 203 | |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 204 | def get_vsg_vcpe_pair(self): |
| 205 | vcpes = self.vcpes_dhcp |
| 206 | vcpe_containers = [] |
| 207 | vsg_vcpe = {} |
| 208 | for vcp in vcpes: |
| 209 | vcpe_container = 'vcpe-{}-{}'.format(vcp['s_tag'], vcp['c_tag']) |
| 210 | vcpe_containers.append(vcpe_container) |
| 211 | vsg = VSGAccess.get_vcpe_vsg(vcpe_container) |
| 212 | vsg_vcpe[vcpe_container]=str(vsg.get_ip()) |
| 213 | return vsg_vcpe |
| 214 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 215 | def test_vsg_health(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 216 | """ |
| 217 | Algo: |
| 218 | 1. Login to compute node VM |
| 219 | 2. Get all vSGs |
| 220 | 3. Ping to all vSGs |
| 221 | 4. Verifying Ping success |
| 222 | """ |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 223 | status = VSGAccess.health_check() |
| 224 | assert_equal(status, True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 225 | |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 226 | def test_vsg_health_check(self,vsg_name='mysite_vsg-1',verify_status=True): |
| 227 | """ |
| 228 | Algo: |
| 229 | 1. If vsg name not specified, Get vsg corresponding to vcpe |
| 230 | 1. Login to compute mode VM |
| 231 | 3. Ping to the vSG |
| 232 | 4. Verifying Ping success |
| 233 | """ |
| 234 | if not vsg_name: |
| 235 | vcpe = self.vcpe_container |
| 236 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 237 | status = vsg.get_health() |
| 238 | assert_equal(status, verify_status) |
| 239 | else: |
| 240 | vsgs = VSGAccess.get_vsgs() |
| 241 | status = None |
| 242 | for vsg in vsgs: |
| 243 | if vsg.name == vsg_name: |
| 244 | status = vsg.get_health() |
| 245 | log.info('vsg health check status is %s'%status) |
| 246 | assert_equal(status,verify_status) |
| 247 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 248 | def test_vsg_for_vcpe(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 249 | """ |
| 250 | Algo: |
| 251 | 1. Get list of all compute nodes created using Openstack |
| 252 | 2. Login to compute mode VM |
| 253 | 3. Get all vSGs |
| 254 | 4. Verifying atleast one compute node and one vSG created |
| 255 | """ |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 256 | vsgs = VSGAccess.get_vsgs() |
| 257 | compute_nodes = VSGAccess.get_compute_nodes() |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 258 | assert_not_equal(len(vsgs), 0) |
| 259 | assert_not_equal(len(compute_nodes), 0) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 260 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 261 | def test_vsg_for_login(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 262 | """ |
| 263 | Algo: |
| 264 | 1. Login to compute node VM |
| 265 | 2. Get all vSGs |
| 266 | 3. Verifying login to vSG is success |
| 267 | """ |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 268 | vsgs = VSGAccess.get_vsgs() |
| 269 | vsg_access_status = map(lambda vsg: vsg.check_access(), vsgs) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 270 | status = filter(lambda st: st == False, vsg_access_status) |
| 271 | assert_equal(len(status), 0) |
| 272 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 273 | def test_vsg_for_default_route_through_testclient(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 274 | """ |
| 275 | Algo: |
| 276 | 1. Login to head node |
| 277 | 2. Verifying for default route in lxc test client |
| 278 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 279 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 280 | cmd = "sudo lxc exec testclient -- route | grep default" |
| 281 | status, output = ssh_agent.run_cmd(cmd) |
| 282 | assert_equal(status, True) |
| 283 | |
| 284 | def test_vsg_for_external_connectivity_through_testclient(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 285 | """ |
| 286 | Algo: |
| 287 | 1. Login to head node |
| 288 | 2. On head node, executing ping to 8.8.8.8 from lxc test client |
| 289 | 3. Verifying for the ping success |
| 290 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 291 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
| 292 | cmd = "lxc exec testclient -- ping -c 3 8.8.8.8" |
| 293 | status, output = ssh_agent.run_cmd(cmd) |
| 294 | assert_equal( status, True) |
| 295 | |
| 296 | def test_vsg_for_external_connectivity(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 297 | """ |
| 298 | Algo: |
| 299 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 300 | 2. Verifying vcpe interface gets dhcp IP |
| 301 | 3. Ping to 8.8.8.8 and Verifying ping should success |
| 302 | 4. Restoring management interface configuration in cord-tester |
| 303 | """ |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 304 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 305 | mgmt = 'eth0' |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 306 | host = '8.8.8.8' |
| 307 | self.success = False |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 308 | assert_not_equal(vcpe, None) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 309 | vcpe_ip = self.get_dhcp(vcpe, mgmt = mgmt) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [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') |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 314 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 315 | assert_equal(st, 0) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 316 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 317 | def test_vsg_for_external_connectivity_to_google(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 318 | """ |
| 319 | Algo: |
| 320 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 321 | 2. Verifying vcpe interface gets dhcp IP |
| 322 | 3. Ping to www.google.com and Verifying ping should success |
| 323 | 4. Restoring management interface configuration in cord-tester |
| 324 | """ |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 325 | host = 'www.google.com' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 326 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 327 | mgmt = 'eth0' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 328 | assert_not_equal(vcpe, None) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 329 | vcpe_ip = self.get_dhcp(vcpe, mgmt = mgmt) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 330 | assert_not_equal(vcpe_ip, None) |
| 331 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 332 | log.info('Sending icmp ping requests to %s' %host) |
| 333 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 334 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 335 | assert_equal(st, 0) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 336 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 337 | def test_vsg_for_external_connectivity_to_invalid_host(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 338 | """ |
| 339 | Algo: |
| 340 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 341 | 2. Verifying vcpe interface gets dhcp IP |
| 342 | 3. Ping to www.goglee.com and Verifying ping should not success |
| 343 | 4. Restoring management interface configuration in cord-tester |
| 344 | """ |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 345 | host = 'www.goglee.com' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 346 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 347 | mgmt = 'eth0' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 348 | assert_not_equal(vcpe, None) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 349 | vcpe_ip = self.get_dhcp(vcpe, mgmt = mgmt) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 350 | assert_not_equal(vcpe_ip, None) |
| 351 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 352 | log.info('Sending icmp ping requests to non existent host %s' %host) |
| 353 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 354 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 355 | assert_not_equal(st, 0) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 356 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 357 | def test_vsg_for_external_connectivity_with_ttl_1(self): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 358 | """ |
| 359 | Algo: |
| 360 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 361 | 2. Verifying vcpe interface gets dhcp IP |
| 362 | 3. Ping to 8.8.8.8 with ttl set to 1 |
| 363 | 4. Verifying ping should not success |
| 364 | 5. Restoring management interface configuration in cord-tester |
| 365 | """ |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 366 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 367 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 368 | mgmt = 'eth0' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 369 | assert_not_equal(vcpe, None) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 370 | vcpe_ip = self.get_dhcp(vcpe, mgmt = mgmt) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 371 | assert_not_equal(vcpe_ip, None) |
| 372 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe)) |
| 373 | log.info('Sending icmp ping requests to host %s with ttl 1' %host) |
| 374 | st, _ = getstatusoutput('ping -c 1 -t 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 375 | VSGAccess.restore_interface_config(mgmt, vcpe = vcpe) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 376 | assert_not_equal(st, 0) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 377 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 378 | 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] | 379 | """ |
| 380 | Algo: |
| 381 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 382 | 2. Verifying vcpe interface gets dhcp IP |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 383 | 3. Ping to 8.8.8.8 and Verifying ping succeeds |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 384 | 4. Now down the WAN interface of vcpe |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 385 | 5. Ping to 8.8.8.8 and Verifying ping fails |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 386 | 6. Now Up the WAN interface of vcpe |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 387 | 7. Ping to 8.8.8.8 and Verifying ping succeeds |
| 388 | 8. Restoring management interface configuration in cord-tester |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 389 | """ |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 390 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 391 | mgmt = 'eth0' |
| 392 | vcpe = self.vcpe_container |
| 393 | assert_not_equal(vcpe, None) |
| 394 | assert_not_equal(self.vcpe_dhcp, None) |
| 395 | #first get dhcp on the vcpe interface |
A R Karthick | 2daa1af | 2017-04-11 09:32:31 -0700 | [diff] [blame] | 396 | try: |
| 397 | vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt) |
| 398 | assert_not_equal(vcpe_ip, None) |
| 399 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp)) |
| 400 | log.info('Sending ICMP pings to host %s' %(host)) |
| 401 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 402 | assert_equal(st, 0) |
| 403 | #bring down the wan interface and check again |
| 404 | st = VSGAccess.vcpe_wan_down(vcpe) |
| 405 | assert_equal(st, True) |
| 406 | st_ping, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 407 | st = VSGAccess.vcpe_wan_up(vcpe) |
| 408 | assert_not_equal(st_ping, 0) |
| 409 | assert_equal(st, True) |
| 410 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 411 | assert_equal(st, 0) |
| 412 | finally: |
| 413 | self.config_restore() |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 414 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 415 | 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] | 416 | """ |
| 417 | Algo: |
| 418 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 419 | 2. Verifying vcpe interface gets dhcp IP |
| 420 | 3. Ping to 8.8.8.8 and Verifying ping should success |
| 421 | 4. Now down the LAN interface of vcpe |
| 422 | 5. Ping to 8.8.8.8 and Verifying ping should not success |
| 423 | 6. Now Up the LAN interface of vcpe |
| 424 | 7. Ping to 8.8.8.8 and Verifying ping should success |
| 425 | 8. Restoring management interface configuration in cord-tester |
| 426 | """ |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 427 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 428 | mgmt = 'eth0' |
| 429 | vcpe = self.vcpe_container |
| 430 | assert_not_equal(vcpe, None) |
| 431 | assert_not_equal(self.vcpe_dhcp, None) |
| 432 | #first get dhcp on the vcpe interface |
A R Karthick | 2daa1af | 2017-04-11 09:32:31 -0700 | [diff] [blame] | 433 | try: |
| 434 | vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt) |
| 435 | assert_not_equal(vcpe_ip, None) |
| 436 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp)) |
| 437 | log.info('Sending ICMP pings to host %s' %(host)) |
| 438 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 439 | assert_equal(st, 0) |
| 440 | #bring down the lan interface and check again |
| 441 | st = VSGAccess.vcpe_lan_down(vcpe) |
| 442 | assert_equal(st, True) |
| 443 | st_ping, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 444 | st = VSGAccess.vcpe_lan_up(vcpe) |
| 445 | assert_not_equal(st_ping, 0) |
| 446 | assert_equal(st, True) |
| 447 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 448 | assert_equal(st, 0) |
| 449 | finally: |
| 450 | self.config_restore() |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 451 | |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 452 | def test_vsg_firewall_with_deny_destination_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 453 | """ |
| 454 | Algo: |
| 455 | 1. Get vSG corresponding to vcpe |
| 456 | 2. Login to compute node |
| 457 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 458 | 4. From cord-tester ping to the denied IP address |
| 459 | 5. Verifying that ping should not be successful |
| 460 | """ |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 461 | mgmt = 'eth0' |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 462 | host = '8.8.8.8' |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 463 | assert_not_equal(self.vcpe_dhcp, None) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 464 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 465 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 466 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 467 | assert_not_equal(vsg, None) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 468 | try: |
A R Karthick | 2daa1af | 2017-04-11 09:32:31 -0700 | [diff] [blame] | 469 | vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt) |
| 470 | assert_not_equal(vcpe_ip, None) |
| 471 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 472 | assert_equal(st, 0) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 473 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 474 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame] | 475 | assert_not_equal(st, 0) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 476 | finally: |
| 477 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 478 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
A R Karthick | 2daa1af | 2017-04-11 09:32:31 -0700 | [diff] [blame] | 479 | self.config_restore() |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 480 | |
| 481 | def test_vsg_firewall_with_rule_add_and_delete_dest_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 482 | """ |
| 483 | Algo: |
| 484 | 1. Get vSG corresponding to vcpe |
| 485 | 2. Login to compute node |
| 486 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 487 | 4. From cord-tester ping to the denied IP address |
| 488 | 5. Verifying that ping should not be successful |
| 489 | 6. Delete the iptable rule in vcpe |
| 490 | 7. From cord-tester ping to the denied IP address |
| 491 | 8. Verifying the ping should success |
| 492 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 493 | host = '8.8.8.8' |
| 494 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 495 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 496 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 497 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 498 | assert_equal(st, False) |
| 499 | try: |
| 500 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 501 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 502 | assert_equal(st, True) |
| 503 | st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 504 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 505 | assert_equal(st,False) |
| 506 | finally: |
| 507 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 508 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 509 | |
| 510 | def test_vsg_firewall_verifying_reachability_for_non_blocked_dest_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 511 | """ |
| 512 | Algo: |
| 513 | 1. Get vSG corresponding to vcpe |
| 514 | 2. Login to compute node |
| 515 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 516 | 4. From cord-tester ping to the denied IP address |
| 517 | 5. Verifying that ping should not be successful |
| 518 | 6. From cord-tester ping to the denied IP address other than the denied one |
| 519 | 7. Verifying the ping should success |
| 520 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 521 | host1 = '8.8.8.8' |
| 522 | host2 = '204.79.197.203' |
| 523 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 524 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 525 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 526 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 527 | assert_equal(st, False) |
| 528 | try: |
| 529 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host1)) |
| 530 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 531 | assert_equal(st, True) |
| 532 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 533 | assert_equal(st,False) |
| 534 | finally: |
| 535 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 536 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 537 | |
| 538 | def test_vsg_firewall_appending_rules_with_deny_dest_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 539 | """ |
| 540 | Algo: |
| 541 | 1. Get vSG corresponding to vcpe |
| 542 | 2. Login to compute node |
| 543 | 3. Execute iptable command on vcpe from compute node to deny a destination IP1 |
| 544 | 4. From cord-tester ping to the denied IP address IP1 |
| 545 | 5. Verifying that ping should not be successful |
| 546 | 6. Execute iptable command on vcpe from compute node to deny a destination IP2 |
| 547 | 6. From cord-tester ping to the denied IP address IP2 |
| 548 | 7. Verifying that ping should not be successful |
| 549 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 550 | host1 = '8.8.8.8' |
| 551 | host2 = '204.79.197.203' |
| 552 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 553 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 554 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 555 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 556 | assert_equal(st, False) |
| 557 | try: |
| 558 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host1)) |
| 559 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 560 | assert_equal(st, True) |
| 561 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 562 | assert_equal(st, False) |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 563 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -A FORWARD -d {} -j DROP'.format(vcpe,host2)) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 564 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 565 | assert_equal(st,True) |
| 566 | finally: |
| 567 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 568 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 569 | |
| 570 | def test_vsg_firewall_removing_one_rule_denying_dest_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 571 | """ |
| 572 | Algo: |
| 573 | 1. Get vSG corresponding to vcpe |
| 574 | 2. Login to compute node |
| 575 | 3. Execute iptable command on vcpe from compute node to deny a destination IP1 |
| 576 | 4. Execute iptable command on vcpe from compute node to deny a destination IP2 |
| 577 | 5. From cord-tester ping to the denied IP address IP1 |
| 578 | 6. Verifying that ping should not be successful |
| 579 | 7. From cord-tester ping to the denied IP address IP2 |
| 580 | 8. Verifying that ping should not be successful |
| 581 | 9. Execute iptable command on vcpe from compute node to remove deny a destination IP2 rule |
| 582 | 10. From cord-tester ping to the denied IP address IP2 |
| 583 | 11. Verifying the ping should success |
| 584 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 585 | host1 = '8.8.8.8' |
| 586 | host2 = '204.79.197.203' |
| 587 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 588 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 589 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 590 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 591 | assert_equal(st, False) |
| 592 | try: |
| 593 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host1)) |
| 594 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host2)) |
| 595 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 596 | assert_equal(st, True) |
| 597 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 598 | assert_equal(st,True) |
| 599 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe,host2)) |
| 600 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 601 | assert_equal(st,False) |
| 602 | finally: |
| 603 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 604 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 605 | |
| 606 | def test_vsg_firewall_changing_rule_id_deny_dest_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 607 | """ |
| 608 | Algo: |
| 609 | 1. Get vSG corresponding to vcpe |
| 610 | 2. Login to compute node |
| 611 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 612 | 5. From cord-tester ping to the denied IP address IP1 |
| 613 | 6. Verifying that ping should not be successful |
| 614 | 9. Execute iptable command on vcpe from compute node to change the rule ID to 2 to deny the same destination IP |
| 615 | 10. From cord-tester ping to the denied IP address IP |
| 616 | 11. Verifying that ping should not be successful |
| 617 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 618 | host = '8.8.8.8' |
| 619 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 620 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 621 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 622 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 623 | assert_equal(st, False) |
| 624 | try: |
| 625 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 626 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 627 | assert_equal(st, True) |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 628 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP '.format(vcpe,host)) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 629 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 630 | assert_equal(st,False) |
| 631 | finally: |
| 632 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 633 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 634 | |
| 635 | def test_vsg_firewall_changing_deny_rule_to_accept_dest_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 636 | """ |
| 637 | Algo: |
| 638 | 1. Get vSG corresponding to vcpe |
| 639 | 2. Login to compute node |
| 640 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 641 | 5. From cord-tester ping to the denied IP address IP1 |
| 642 | 6. Verifying that ping should not be successful |
| 643 | 9. Execute iptable command on vcpe from compute node to accept the same destination IP |
| 644 | 10. From cord-tester ping to the accepted IP |
| 645 | 11. Verifying the ping should success |
| 646 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 647 | host1 = '8.8.8.8' |
| 648 | host2 = '204.79.197.203' |
| 649 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 650 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 651 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 652 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 653 | assert_equal(st, False) |
| 654 | try: |
| 655 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 656 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 657 | assert_equal(st, True) |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 658 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -d {} -j ACCEPT'.format(vcpe,host)) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 659 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 660 | assert_equal(st,False) |
| 661 | finally: |
| 662 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 663 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 664 | |
| 665 | def test_vsg_firewall_denying_destination_network(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 666 | """ |
| 667 | Algo: |
| 668 | 1. Get vSG corresponding to vcpe |
| 669 | 2. Login to compute node |
| 670 | 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet |
| 671 | 4. From cord-tester ping to the denied IP address IP1 in the denied subnet |
| 672 | 5. Verifying that ping should not be successful |
| 673 | 6. From cord-tester ping to the denied IP address IP2 in the denied subnet |
| 674 | 7. Verifying that ping should not be successful |
| 675 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 676 | network = '206.190.36.44/28' |
| 677 | host1 = '204.79.197.46' |
| 678 | host2 = '204.79.197.51' |
| 679 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 680 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 681 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 682 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 683 | assert_equal(st, False) |
| 684 | try: |
| 685 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,network)) |
| 686 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 687 | assert_equal(st, True) |
| 688 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 689 | assert_equal(st,False) |
| 690 | finally: |
| 691 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 692 | |
| 693 | def test_vsg_firewall_denying_destination_network_subnet_modification(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 694 | """ |
| 695 | Algo: |
| 696 | 1. Get vSG corresponding to vcpe |
| 697 | 2. Login to compute node |
| 698 | 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet |
| 699 | 4. From cord-tester ping to the denied IP address IP1 in the denied subnet |
| 700 | 5. Verifying that ping should not be successful |
| 701 | 6. From cord-tester ping to the denied IP address IP2 in the denied subnet |
| 702 | 7. Verifying that ping should not be successful |
| 703 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 704 | network1 = '206.190.36.44/28' |
| 705 | network2 = '206.190.36.44/26' |
| 706 | host1 = '204.79.197.46' |
| 707 | host2 = '204.79.197.51' |
| 708 | host2 = '204.79.197.63' |
| 709 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 710 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 711 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 712 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 713 | assert_equal(st, False) |
| 714 | try: |
| 715 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,network1)) |
| 716 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 717 | assert_equal(st, True) |
| 718 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 719 | assert_equal(st,False) |
| 720 | st,output = vsg.run_cmd('sudo docker exec {} iptables -A FORWARD -d {} -j DROP'.format(vcpe,network2)) |
| 721 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 722 | assert_equal(st, True) |
| 723 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 724 | assert_equal(st, True) |
| 725 | st, _ = getstatusoutput('ping -c 1 {}'.format(host3)) |
| 726 | assert_equal(st, False) |
| 727 | finally: |
| 728 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 729 | |
| 730 | def test_vsg_firewall_with_deny_source_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 731 | """ |
| 732 | Algo: |
| 733 | 1. Get vSG corresponding to vcpe |
| 734 | 2. Login to compute node |
| 735 | 3. Execute iptable command on vcpe from compute node to deny a source IP |
| 736 | 4. From cord-tester ping to 8.8.8.8 from the denied IP |
| 737 | 5. Verifying that ping should not be successful |
| 738 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 739 | host = '8.8.8.8' |
| 740 | source_ip = self.vcpe_dhcp |
| 741 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 742 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 743 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 744 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 745 | assert_equal(st, False) |
| 746 | try: |
| 747 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe,source_ip)) |
| 748 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 749 | assert_equal(st, True) |
| 750 | finally: |
| 751 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 752 | |
| 753 | def test_vsg_firewall_rule_with_add_and_delete_deny_source_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 754 | """ |
| 755 | Algo: |
| 756 | 1. Get vSG corresponding to vcpe |
| 757 | 2. Login to compute node |
| 758 | 3. Execute iptable command on vcpe from compute node to deny a source IP |
| 759 | 4. From cord-tester ping to 8.8.8.8 from the denied IP |
| 760 | 5. Verifying that ping should not be successful |
| 761 | 6. Delete the iptable rule in vcpe |
| 762 | 7. From cord-tester ping to 8.8.8.8 from the denied IP |
| 763 | 8. Verifying the ping should success |
| 764 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 765 | host = '8.8.8.8' |
| 766 | source_ip = self.vcpe_dhcp |
| 767 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 768 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 769 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 770 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 771 | assert_equal(st, False) |
| 772 | try: |
| 773 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe,source_ip)) |
| 774 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 775 | assert_equal(st, True) |
| 776 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe,source_ip)) |
| 777 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 778 | assert_equal(st, False) |
| 779 | finally: |
| 780 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 781 | |
| 782 | def test_vsg_firewall_rule_with_deny_icmp_protocol_echo_requests_type(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 783 | """ |
| 784 | Algo: |
| 785 | 1. Get vSG corresponding to vcpe |
| 786 | 2. Login to compute node |
| 787 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets |
| 788 | 4. From cord-tester ping to 8.8.8.8 |
| 789 | 5. Verifying that ping should not be successful |
| 790 | 6. Delete the iptable rule |
| 791 | 7. From cord-tester ping to 8.8.8.8 |
| 792 | 8. Verifying the ping should success |
| 793 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 794 | host = '8.8.8.8' |
| 795 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 796 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 797 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 798 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 799 | assert_equal(st, False) |
| 800 | try: |
| 801 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe)) |
| 802 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 803 | assert_equal(st, True) |
| 804 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe)) |
| 805 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 806 | assert_equal(st, False) |
| 807 | finally: |
| 808 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 809 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 810 | |
| 811 | def test_vsg_firewall_rule_with_deny_icmp_protocol_echo_reply_type(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 812 | """ |
| 813 | Algo: |
| 814 | 1. Get vSG corresponding to vcpe |
| 815 | 2. Login to compute node |
| 816 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets |
| 817 | 4. From cord-tester ping to 8.8.8.8 |
| 818 | 5. Verifying that ping should not be successful |
| 819 | 6. Delete the iptable rule |
| 820 | 7. From cord-tester ping to 8.8.8.8 |
| 821 | 8. Verifying the ping should success |
| 822 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 823 | host = '8.8.8.8' |
| 824 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 825 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 826 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 827 | st, _ = getstatusoutput('ping -c 1 {}'.format('8.8.8.8')) |
| 828 | assert_equal(st, False) |
| 829 | try: |
| 830 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe)) |
| 831 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 832 | assert_equal(st, True) |
| 833 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe)) |
| 834 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 835 | assert_equal(st,False) |
| 836 | finally: |
| 837 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 838 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 839 | |
| 840 | def test_vsg_firewall_changing_deny_rule_to_accept_rule_with_icmp_protocol_echo_requests_type(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 841 | """ |
| 842 | Algo: |
| 843 | 1. Get vSG corresponding to vcpe |
| 844 | 2. Login to compute node |
| 845 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets |
| 846 | 4. From cord-tester ping to 8.8.8.8 |
| 847 | 5. Verifying that ping should not be successful |
| 848 | 6. Insert another rule to accept the icmp-echo requests protocol packets |
| 849 | 7. From cord-tester ping to 8.8.8.8 |
| 850 | 8. Verifying the ping should success |
| 851 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 852 | host = '8.8.8.8' |
| 853 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 854 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 855 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 856 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 857 | assert_equal(st, False) |
| 858 | try: |
| 859 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p icmp --icmp-type echo-request -j DROP'.format(vcpe)) |
| 860 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 861 | assert_equal(st, True) |
| 862 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe)) |
| 863 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 864 | assert_equal(st,False) |
| 865 | finally: |
| 866 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 867 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 868 | |
| 869 | def test_vsg_firewall_changing_deny_rule_to_accept_rule_with_icmp_protocol_echo_reply_type(self, vcpe=None): |
| 870 | host = '8.8.8.8' |
| 871 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 872 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 873 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 874 | st, out1 = getstatusoutput('ping -c 1 {}'.format(host)) |
| 875 | assert_equal(st, False) |
| 876 | try: |
| 877 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p icmp --icmp-type echo-reply -j DROP'.format(vcpe)) |
| 878 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 879 | assert_equal(st, True) |
| 880 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe)) |
| 881 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 882 | assert_equal(st,False) |
| 883 | finally: |
| 884 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 885 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 886 | |
| 887 | def test_vsg_firewall_for_deny_icmp_protocol(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 888 | """ |
| 889 | Algo: |
| 890 | 1. Get vSG corresponding to vcpe |
| 891 | 2. Login to compute node |
| 892 | 3. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 893 | 4. From cord-tester ping to 8.8.8.8 |
| 894 | 5. Verifying that ping should not be successful |
| 895 | 6. Delete the iptable rule |
| 896 | 7. From cord-tester ping to 8.8.8.8 |
| 897 | 8. Verifying the ping should success |
| 898 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 899 | host = '8.8.8.8' |
| 900 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 901 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 902 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 903 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 904 | assert_equal(st, False) |
| 905 | try: |
| 906 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe)) |
| 907 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 908 | assert_equal(st, True) |
| 909 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe)) |
| 910 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 911 | assert_equal(st,False) |
| 912 | finally: |
| 913 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 914 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 915 | |
| 916 | def test_vsg_firewall_rule_deny_icmp_protocol_and_destination_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 917 | """ |
| 918 | Algo: |
| 919 | 1. Get vSG corresponding to vcpe |
| 920 | 2. Login to compute node |
| 921 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 922 | 4. From cord-tester ping to 8.8.8.8 |
| 923 | 5. Verifying that ping should not be successful |
| 924 | 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 925 | 7. From cord-tester ping to 8.8.8.8 |
| 926 | 8. Verifying the ping should success |
| 927 | 9. Delete the rule added in step 3 |
| 928 | 10. From cord-tester ping to 8.8.8.8 |
| 929 | 11. Verifying that ping should not be successful |
| 930 | 12. Delete the rule added in step 6 |
| 931 | 13. From cord-tester ping to 8.8.8.8 |
| 932 | 14. Verifying the ping should success |
| 933 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 934 | host = '8.8.8.8' |
| 935 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 936 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 937 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 938 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 939 | assert_equal(st, False) |
| 940 | try: |
| 941 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 942 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 943 | assert_equal(st, True) |
| 944 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe)) |
| 945 | assert_equal(st, True) |
| 946 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 947 | assert_equal(st, True) |
| 948 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe)) |
| 949 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 950 | assert_equal(st,False) |
| 951 | finally: |
| 952 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 953 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 954 | |
| 955 | def test_vsg_firewall_flushing_all_configured_rules(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 956 | """ |
| 957 | Algo: |
| 958 | 1. Get vSG corresponding to vcpe |
| 959 | 2. Login to compute node |
| 960 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 961 | 4. From cord-tester ping to 8.8.8.8 |
| 962 | 5. Verifying that ping should not be successful |
| 963 | 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 964 | 7. From cord-tester ping to 8.8.8.8 |
| 965 | 8. Verifying the ping should success |
| 966 | 9. Flush all the iptable rules configuraed in vcpe |
| 967 | 10. Delete the rule added in step 6 |
| 968 | 11. From cord-tester ping to 8.8.8.8 |
| 969 | 12. Verifying the ping should success |
| 970 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 971 | host = '8.8.8.8' |
| 972 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 973 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 974 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 975 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 976 | assert_equal(st, False) |
| 977 | try: |
| 978 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 979 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 980 | assert_equal(st, True) |
| 981 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe)) |
| 982 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 983 | assert_equal(st, True) |
| 984 | st,output = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 985 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 986 | assert_equal(st, False) |
| 987 | finally: |
| 988 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 989 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 990 | |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 991 | def test_vsg_firewall_deny_all_ipv4_traffic(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 992 | """ |
| 993 | Algo: |
| 994 | 1. Get vSG corresponding to vcpe |
| 995 | 2. Login to compute node |
| 996 | 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic |
| 997 | 4. From cord-tester ping to 8.8.8.8 |
| 998 | 5. Verifying that ping should not be successful |
| 999 | 6. Delete the iptable rule added |
| 1000 | 7. From cord-tester ping to 8.8.8.8 |
| 1001 | 8. Verifying the ping should success |
| 1002 | """ |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1003 | host = '8.8.8.8' |
| 1004 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 1005 | vcpe = self.vcpe_container |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1006 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 1007 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1008 | assert_equal(st, False) |
| 1009 | try: |
| 1010 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe)) |
| 1011 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1012 | assert_equal(st, True) |
| 1013 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe)) |
| 1014 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1015 | assert_equal(st, False) |
| 1016 | finally: |
| 1017 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 1018 | |
| 1019 | def test_vsg_firewall_replacing_deny_rule_to_accept_rule(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1020 | """ |
| 1021 | Algo: |
| 1022 | 1. Get vSG corresponding to vcpe |
| 1023 | 2. Login to compute node |
| 1024 | 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic |
| 1025 | 4. From cord-tester ping to 8.8.8.8 |
| 1026 | 5. Verifying that ping should not be successful |
| 1027 | 6. Replace the deny rule added in step 3 with accept rule |
| 1028 | 7. From cord-tester ping to 8.8.8.8 |
| 1029 | 8. Verifying the ping should success |
| 1030 | """ |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1031 | host = '8.8.8.8' |
| 1032 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 1033 | vcpe = self.vcpe_container |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1034 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 1035 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1036 | assert_equal(st, False) |
| 1037 | try: |
| 1038 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -4 -j DROP'.format(vcpe)) |
| 1039 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1040 | assert_equal(st, True) |
| 1041 | st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -4 -j ACCEPT'.format(vcpe)) |
| 1042 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1043 | assert_equal(st, False) |
| 1044 | finally: |
| 1045 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 1046 | |
| 1047 | def test_vsg_firewall_deny_all_traffic_from_lan_to_wan_in_vcpe(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1048 | """ |
| 1049 | Algo: |
| 1050 | 1. Get vSG corresponding to vcpe |
| 1051 | 2. Login to compute node |
| 1052 | 3. Execute iptable command on vcpe from compute node to deny all the traffic from lan to wan interface in vcpe |
| 1053 | 4. From cord-tester ping to 8.8.8.8 |
| 1054 | 5. Verifying that ping should not be successful |
| 1055 | 6. Delete the iptable rule added |
| 1056 | 7. From cord-tester ping to 8.8.8.8 |
| 1057 | 8. Verifying the ping should success |
| 1058 | """ |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1059 | host = '8.8.8.8' |
| 1060 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 1061 | vcpe = self.vcpe_container |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1062 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 1063 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1064 | assert_equal(st, False) |
| 1065 | try: |
| 1066 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe)) |
| 1067 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1068 | assert_equal(st, True) |
| 1069 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j ACCEPT'.format(vcpe)) |
| 1070 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1071 | assert_equal(st, False) |
| 1072 | finally: |
| 1073 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 1074 | |
| 1075 | def test_vsg_firewall_deny_all_dns_traffic(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1076 | """ |
| 1077 | Algo: |
| 1078 | 1. Get vSG corresponding to vcpe |
| 1079 | 2. Login to compute node |
| 1080 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 1081 | 4. From cord-tester ping to www.google.com |
| 1082 | 5. Verifying that ping should not be successful |
| 1083 | 6. Delete the iptable rule added |
| 1084 | 7. From cord-tester ping to www.google.com |
| 1085 | 8. Verifying the ping should success |
| 1086 | """ |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1087 | host = 'www.google.com' |
| 1088 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 1089 | vcpe = self.vcpe_container |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1090 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 1091 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1092 | assert_equal(st, False) |
| 1093 | try: |
| 1094 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p udp --dport 53 -j DROP'.format(vcpe)) |
| 1095 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1096 | assert_equal(st, True) |
| 1097 | st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p udp --dport 53 -j ACCEPT'.format(vcpe)) |
| 1098 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1099 | assert_equal(st, False) |
| 1100 | finally: |
| 1101 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 1102 | |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 1103 | def test_vsg_xos_subscriber(self): |
| 1104 | subscriber_info = self.subscriber_info[0] |
| 1105 | volt_subscriber_info = self.volt_subscriber_info[0] |
| 1106 | result = self.restApiXos.ApiPost('TENANT_SUBSCRIBER', subscriber_info) |
| 1107 | assert_equal(result, True) |
| 1108 | result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 1109 | assert_not_equal(result, None) |
| 1110 | subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num']) |
| 1111 | assert_not_equal(subId, '0') |
| 1112 | log.info('Subscriber ID for account num %d = %s' %(volt_subscriber_info['account_num'], subId)) |
| 1113 | volt_tenant = volt_subscriber_info['voltTenant'] |
| 1114 | #update the subscriber id in the tenant info before making the rest |
| 1115 | volt_tenant['subscriber'] = subId |
| 1116 | result = self.restApiXos.ApiPost('TENANT_VOLT', volt_tenant) |
| 1117 | assert_equal(result, True) |
| 1118 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1119 | def test_vsg_for_ping_from_vsg_to_external_network(self): |
| 1120 | """ |
| 1121 | Algo: |
| 1122 | 1.Create a vSG VM in compute node |
| 1123 | 2.Ensure VM created properly |
| 1124 | 3.Verify login to VM success |
| 1125 | 4.Do ping to external network from vSG VM |
| 1126 | 5.Verify that ping gets success |
| 1127 | 6.Verify ping success flows added in OvS |
| 1128 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1129 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1130 | def test_vsg_for_ping_from_vcpe_to_external_network(self): |
| 1131 | """ |
| 1132 | Algo: |
| 1133 | 1.Create a vSG VM in compute node |
| 1134 | 2.Create a vCPE container inside VM |
| 1135 | 3.Verify both VM and Container created properly |
| 1136 | 4.Verify login to vCPE container success |
| 1137 | 5.Do ping to external network from vCPE container |
| 1138 | 6.Verify that ping gets success |
| 1139 | 7.Verify ping success flows added in OvS |
| 1140 | """ |
| 1141 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 1142 | def test_vsg_for_dns_service(self): |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1143 | """ |
| 1144 | Algo: |
| 1145 | 1. Create a test client in Prod VM |
| 1146 | 2. Create a vCPE container in vSG VM inside compute Node |
| 1147 | 3. Ensure vSG VM and vCPE container created properly |
| 1148 | 4. Enable dns service in vCPE ( if not by default ) |
| 1149 | 5. Send ping request from test client to valid domain address say, 'www.google'com |
| 1150 | 6. Verify that dns should resolve ping should success |
| 1151 | 7. Now send ping request to invalid domain address say 'www.invalidaddress'.com' |
| 1152 | 8. Verify that dns resolve should fail and hence ping |
| 1153 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1154 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1155 | def test_vsg_for_10_subscribers_for_same_service(self): |
| 1156 | """ |
| 1157 | Algo: |
| 1158 | 1.Create a vSG VM in compute node |
| 1159 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 1160 | 3.Ensure vSG VM and vCPE container created properly |
| 1161 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP |
| 1162 | 5.Verify that ping success for all 10 subscribers |
| 1163 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1164 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1165 | def test_vsg_for_10_subscribers_for_same_service_ping_invalid_ip(self): |
| 1166 | """ |
| 1167 | Algo: |
| 1168 | 1.Create a vSG VM in compute Node |
| 1169 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 1170 | 3.Ensure vSG VM and vCPE container created properly |
| 1171 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP |
| 1172 | 5.Verify that ping fails for all 10 subscribers |
| 1173 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1174 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1175 | def test_vsg_for_10_subscribers_for_same_service_ping_valid_and_invalid_ip(self): |
| 1176 | """ |
| 1177 | Algo: |
| 1178 | 1.Create a vSG VM in VM |
| 1179 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 1180 | 3.Ensure vSG VM and vCPE container created properly |
| 1181 | 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP |
| 1182 | 5.Verify that ping success for all 5 subscribers |
| 1183 | 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP |
| 1184 | 7.Verify that ping fails for all 5 subscribers |
| 1185 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1186 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1187 | def test_vsg_for_100_subscribers_for_same_service(self): |
| 1188 | """ |
| 1189 | Algo: |
| 1190 | 1.Create a vSG VM in compute node |
| 1191 | 2.Create 100 vCPE containers for 100 subscribers, in vSG VM |
| 1192 | 3.Ensure vSG VM and vCPE container created properly |
| 1193 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP |
| 1194 | 5.Verify that ping success for all 100 subscribers |
| 1195 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1196 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1197 | def test_vsg_for_100_subscribers_for_same_service_ping_invalid_ip(self): |
| 1198 | """ |
| 1199 | Algo: |
| 1200 | 1.Create a vSG VM in compute Node |
| 1201 | 2.Create 10 vCPE containers for 100 subscribers, in vSG VM |
| 1202 | 3.Ensure vSG VM and vCPE container created properly |
| 1203 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP |
| 1204 | 5.Verify that ping fails for all 100 subscribers |
| 1205 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1206 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1207 | def test_vsg_for_100_subscribers_for_same_service_ping_valid_and_invalid_ip(self): |
| 1208 | """ |
| 1209 | Algo: |
| 1210 | 1.Create a vSG VM in VM |
| 1211 | 2.Create 10 vCPE containers for 100 subscribers, in vSG VM |
| 1212 | 3.Ensure vSG VM and vCPE container created properly |
| 1213 | 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP |
| 1214 | 5.Verify that ping success for all 5 subscribers |
| 1215 | 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP |
| 1216 | 7.Verify that ping fails for all 5 subscribers |
| 1217 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1218 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1219 | def test_vsg_for_packet_received_with_invalid_ip_fields(self): |
| 1220 | """ |
| 1221 | Algo: |
| 1222 | 1.Create a vSG VM in compute node |
| 1223 | 2.Create a vCPE container in vSG VM |
| 1224 | 3.Ensure vSG VM and vCPE container created properly |
| 1225 | 4.From subscriber, send a ping packet with invalid ip fields |
| 1226 | 5.Verify that vSG drops the packet |
| 1227 | 6.Verify ping fails |
| 1228 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1229 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1230 | def test_vsg_for_packet_received_with_invalid_mac_fields(self): |
| 1231 | """ |
| 1232 | Algo: |
| 1233 | 1.Create a vSG VM in compute node |
| 1234 | 2.Create a vCPE container in vSG VM |
| 1235 | 3.Ensure vSG VM and vCPE container created properly |
| 1236 | 4.From subscriber, send a ping packet with invalid mac fields |
| 1237 | 5.Verify that vSG drops the packet |
| 1238 | 6.Verify ping fails |
| 1239 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1240 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1241 | def test_vsg_for_vlan_id_mismatch_in_stag(self): |
| 1242 | """ |
| 1243 | Algo: |
| 1244 | 1.Create a vSG VM in compute Node |
| 1245 | 2.Create a vCPE container in vSG VM |
| 1246 | 3.Ensure vSG VM and vCPE container created properly |
| 1247 | 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag |
| 1248 | 5.Verify that ping fails as the packet drops at VM entry |
| 1249 | 6.Repeat step 4 with correct s-tag |
| 1250 | 7.Verify that ping success |
| 1251 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1252 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1253 | def test_vsg_for_vlan_id_mismatch_in_ctag(self): |
| 1254 | """ |
| 1255 | Algo: |
| 1256 | 1.Create a vSG VM in compute node |
| 1257 | 2.Create a vCPE container in vSG VM |
| 1258 | 3.Ensure vSG VM and vCPE container created properly |
| 1259 | 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag |
| 1260 | 5.Verify that ping fails as the packet drops at vCPE container entry |
| 1261 | 6.Repeat step 4 with valid s-tag and c-tag |
| 1262 | 7.Verify that ping success |
| 1263 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1264 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1265 | def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self): |
| 1266 | """ |
| 1267 | Algo: |
| 1268 | 1.Create two vSG VMs in compute node |
| 1269 | 2.Create a vCPE container in each vSG VM |
| 1270 | 3.Ensure vSG VM and vCPE container created properly |
| 1271 | 4.From subscriber one, send ping request with valid s and c tags |
| 1272 | 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags |
| 1273 | 6.Verify that ping success for only subscriber one and fails for two. |
| 1274 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1275 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1276 | def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self): |
| 1277 | """ |
| 1278 | Algo: |
| 1279 | 1.Create a vSG VM in compute node |
| 1280 | 2.Create two vCPE containers in vSG VM |
| 1281 | 3.Ensure vSG VM and vCPE container created properly |
| 1282 | 4.From subscriber one, send ping request with valid s and c tags |
| 1283 | 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag |
| 1284 | 6.Verify that ping success for only subscriber one and fails for two |
| 1285 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1286 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1287 | def test_vsg_for_out_of_range_vlanid_in_ctag(self): |
| 1288 | """ |
| 1289 | Algo: |
| 1290 | 1.Create a vSG VM in compute node |
| 1291 | 2.Create a vCPE container in vSG VM |
| 1292 | 3.Ensure vSG VM and vCPE container created properly |
| 1293 | 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 ) |
| 1294 | 4.Verify that ping fails as the ping packets drops at vCPE container entry |
| 1295 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1296 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1297 | def test_vsg_for_out_of_range_vlanid_in_stag(self): |
| 1298 | """ |
| 1299 | Algo: |
| 1300 | 1.Create a vSG VM in compute node |
| 1301 | 2.Create a vCPE container in vSG VM |
| 1302 | 3.Ensure vSG VM and vCPE container created properly |
| 1303 | 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 |
| 1304 | 4.Verify that ping fails as the ping packets drops at vSG VM entry |
| 1305 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1306 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1307 | def test_vsg_without_creating_vcpe_instance(self): |
| 1308 | """ |
| 1309 | Algo: |
| 1310 | 1.Create a vSG VM in compute Node |
| 1311 | 2.Ensure vSG VM created properly |
| 1312 | 3.Do not create vCPE container inside vSG VM |
| 1313 | 4.From a subscriber, send ping to external valid IP |
| 1314 | 5.Verify that ping fails as the ping packet drops at vSG VM entry itself. |
| 1315 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1316 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1317 | def test_vsg_for_remove_vcpe_instance(self): |
| 1318 | """ |
| 1319 | Algo: |
| 1320 | 1.Create a vSG VM in compute node |
| 1321 | 2.Create a vCPE container in vSG VM |
| 1322 | 3.Ensure vSG VM and vCPE container created properly |
| 1323 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 1324 | 5.Verify that ping success |
| 1325 | 6.Verify ping success flows in OvS switch in compute node |
| 1326 | 7.Now remove the vCPE container in vSG VM |
| 1327 | 8.Ensure that the container removed properly |
| 1328 | 9.Repeat step 4 |
| 1329 | 10.Verify that now, ping fails |
| 1330 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1331 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1332 | def test_vsg_for_restart_vcpe_instance(self): |
| 1333 | """ |
| 1334 | Algo: |
| 1335 | 1.Create a vSG VM in compute node |
| 1336 | 2.Create a vCPE container in vSG VM |
| 1337 | 3.Ensure vSG VM and vCPE container created properly |
| 1338 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 1339 | 5.Verify that ping success |
| 1340 | 6.Verify ping success flows in OvS switch in compute node |
| 1341 | 7.Now restart the vCPE container in vSG VM |
| 1342 | 8.Ensure that the container came up after restart |
| 1343 | 9.Repeat step 4 |
| 1344 | 10.Verify that now,ping gets success and flows added in OvS |
| 1345 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1346 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1347 | def test_vsg_for_restart_vsg_vm(self): |
| 1348 | """ |
| 1349 | Algo: |
| 1350 | 1.Create a vSG VM in compute node |
| 1351 | 2.Create a vCPE container in vSG VM |
| 1352 | 3.Ensure vSG VM and vCPE container created properly |
| 1353 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 1354 | 5.Verify that ping success |
| 1355 | 6.Verify ping success flows in OvS switch in compute node |
| 1356 | 7.Now restart the vSG VM |
| 1357 | 8.Ensure that the vSG comes up properly after restart |
| 1358 | 9.Verify that vCPE container comes up after vSG restart |
| 1359 | 10.Repeat step 4 |
| 1360 | 11.Verify that now,ping gets success and flows added in OvS |
| 1361 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1362 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1363 | def test_vsg_for_pause_vcpe_instance(self): |
| 1364 | """ |
| 1365 | Algo: |
| 1366 | 1.Create a vSG VM in compute node |
| 1367 | 2.Create a vCPE container in vSG VM |
| 1368 | 3.Ensure vSG VM and vCPE container created properly |
| 1369 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 1370 | 5.Verify that ping success |
| 1371 | 6.Verify ping success flows in OvS switch in compute node |
| 1372 | 7.Now pause vCPE container in vSG VM for a while |
| 1373 | 8.Ensure that the container state is pause |
| 1374 | 9.Repeat step 4 |
| 1375 | 10.Verify that now,ping fails now and verify flows in OvS |
| 1376 | 11.Now resume the container |
| 1377 | 12.Now repeat step 4 again |
| 1378 | 13.Verify that now, ping gets success |
| 1379 | 14.Verify ping success flows in OvS |
| 1380 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1381 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1382 | def test_vsg_for_extract_all_compute_stats_from_all_vcpe_containers(self): |
| 1383 | """ |
| 1384 | Algo: |
| 1385 | 1.Create a vSG VM in compute node |
| 1386 | 2.Create 10 vCPE containers in VM |
| 1387 | 3.Ensure vSG VM and vCPE containers created properly |
| 1388 | 4.Login to all vCPE containers |
| 1389 | 4.Get all compute stats from all vCPE containers |
| 1390 | 5.Verify the stats # verification method need to add |
| 1391 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1392 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1393 | def test_vsg_for_extract_dns_stats_from_all_vcpe_containers(self): |
| 1394 | """ |
| 1395 | Algo: |
| 1396 | 1.Create a vSG VM in compute node |
| 1397 | 2.Create 10 vCPE containers in VM |
| 1398 | 3.Ensure vSG VM and vCPE containers created properly |
| 1399 | 4.From 10 subscribers, send ping to valid and invalid dns hosts |
| 1400 | 5.Verify dns resolves and ping success for valid dns hosts |
| 1401 | 6.Verify ping fails for invalid dns hosts |
| 1402 | 7.Verify dns host name resolve flows in OvS |
| 1403 | 8.Login to all 10 vCPE containers |
| 1404 | 9.Extract all dns stats |
| 1405 | 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios |
| 1406 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1407 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1408 | def test_vsg_for_subscriber_access_two_vsg_services(self): |
| 1409 | """ |
| 1410 | # Intention is to verify if subscriber can reach internet via two vSG VMs |
| 1411 | Algo: |
| 1412 | 1.Create two vSG VMs for two services in compute node |
| 1413 | 2.Create one vCPE container in each VM for one subscriber |
| 1414 | 3.Ensure VMs and containers created properly |
| 1415 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 1416 | 5.Verify ping gets success |
| 1417 | 6.Verify ping success flows in OvS |
| 1418 | 7.Now repeat step 4 with stag corresponds to vSG-2 VM |
| 1419 | 8.Verify that ping again success |
| 1420 | 9.Verify ping success flows in OvS |
| 1421 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1422 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1423 | def test_vsg_for_subscriber_access_service2_if_service1_goes_down(self): |
| 1424 | """ |
| 1425 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down |
| 1426 | Algo: |
| 1427 | 1.Create two vSG VMs for two services in compute node |
| 1428 | 2.Create one vCPE container in each VM for one subscriber |
| 1429 | 3.Ensure VMs and containers created properly |
| 1430 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 1431 | 5.Verify ping gets success |
| 1432 | 6.Verify ping success flows in OvS |
| 1433 | 7.Down the vSG-1 VM |
| 1434 | 8.Now repeat step 4 |
| 1435 | 9.Verify that ping fails as vSG-1 is down |
| 1436 | 10.Repeat step 4 with stag corresponding to vSG-2 |
| 1437 | 9.Verify ping success and flows added in OvS |
| 1438 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1439 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1440 | def test_vsg_for_subscriber_access_service2_if_service1_goes_restart(self): |
| 1441 | """ |
| 1442 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts |
| 1443 | Algo: |
| 1444 | 1.Create two vSG VMs for two services in compute node |
| 1445 | 2.Create one vCPE container in each VM for one subscriber |
| 1446 | 3.Ensure VMs and containers created properly |
| 1447 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 1448 | 5.Verify ping gets success |
| 1449 | 6.Verify ping success flows added in OvS |
| 1450 | 7.Now restart vSG-1 VM |
| 1451 | 8.Now repeat step 4 while vSG-1 VM restarts |
| 1452 | 9.Verify that ping fails as vSG-1 is restarting |
| 1453 | 10.Repeat step 4 with stag corresponding to vSG-2 while vSG-1 VM restarts |
| 1454 | 11.Verify ping success and flows added in OvS |
| 1455 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1456 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1457 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_goes_down(self): |
| 1458 | """ |
| 1459 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down |
| 1460 | Algo: |
| 1461 | 1.Create a vSG VM in compute node |
| 1462 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 1463 | 3.Ensure VM and containers created properly |
| 1464 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 1465 | 5.Verify ping gets success |
| 1466 | 6.Verify ping success flows added in OvS |
| 1467 | 7.Now stop vCPE-1 container |
| 1468 | 8.Now repeat step 4 |
| 1469 | 9.Verify that ping fails as vCPE-1 container is down |
| 1470 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container |
| 1471 | 11.Verify ping success and flows added in OvS |
| 1472 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1473 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1474 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_restart(self): |
| 1475 | """ |
| 1476 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts |
| 1477 | Algo: |
| 1478 | 1.Create a vSG VM in compute node |
| 1479 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 1480 | 3.Ensure VM and containers created properly |
| 1481 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 1482 | 5.Verify ping gets success |
| 1483 | 6.Verify ping success flows added in OvS |
| 1484 | 7.Now restart vCPE-1 container |
| 1485 | 8.Now repeat step 4 while vCPE-1 restarts |
| 1486 | 9.Verify that ping fails as vCPE-1 container is restarts |
| 1487 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 restarts |
| 1488 | 11..Verify ping success and flows added in OvS |
| 1489 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1490 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1491 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_pause(self): |
| 1492 | """ |
| 1493 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 paused |
| 1494 | Algo: |
| 1495 | 1.Create a vSG VM in compute node |
| 1496 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 1497 | 3.Ensure VM and containers created properly |
| 1498 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 1499 | 5.Verify ping gets success |
| 1500 | 6.Verify ping success flows added in OvS |
| 1501 | 7.Now pause vCPE-1 container |
| 1502 | 8.Now repeat step 4 while vCPE-1 in pause state |
| 1503 | 9.Verify that ping fails as vCPE-1 container in pause state |
| 1504 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 in pause state |
| 1505 | 11.Verify ping success and flows added in OvS |
| 1506 | """ |
| 1507 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_removed(self): |
| 1508 | """ |
| 1509 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 removed |
| 1510 | Algo: |
| 1511 | 1.Create a vSG VM in compute node |
| 1512 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 1513 | 3.Ensure VM and containers created properly |
| 1514 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 1515 | 5.Verify ping gets success |
| 1516 | 6.Verify ping success flows added in OvS |
| 1517 | 7.Now remove vCPE-1 container |
| 1518 | 8.Now repeat step 4 |
| 1519 | 9.Verify that ping fails as vCPE-1 container removed |
| 1520 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container |
| 1521 | 11.Verify ping success and flows added in OvS |
| 1522 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1523 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1524 | def test_vsg_for_vcpe_instance_removed_and_added_again(self): |
| 1525 | """ |
| 1526 | Algo: |
| 1527 | 1.Create a vSG VM in compute node |
| 1528 | 2.Create a vCPE container in vSG VM |
| 1529 | 3.Ensure VM and containers created properly |
| 1530 | 4.From subscriber end, send ping to public IP |
| 1531 | 5.Verify ping gets success |
| 1532 | 6.Verify ping success flows added in OvS |
| 1533 | 7.Now remove vCPE container in vSG VM |
| 1534 | 8.Now repeat step 4 |
| 1535 | 9.Verify that ping fails as vCPE container removed |
| 1536 | 10.Create the vCPE container again for the same subscriber |
| 1537 | 11.Ensure that vCPE created now |
| 1538 | 12.Now repeat step 4 |
| 1539 | 13.Verify ping success and flows added in OvS |
| 1540 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1541 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1542 | def test_vsg_for_vsg_vm_removed_and_added_again(self): |
| 1543 | """ |
| 1544 | Algo: |
| 1545 | 1.Create a vSG VM in compute node |
| 1546 | 2.Create a vCPE container in vSG VM |
| 1547 | 3.Ensure VM and containers created properly |
| 1548 | 4.From subscriber end, send ping to public IP |
| 1549 | 5.Verify ping gets success |
| 1550 | 6.Verify ping success flows added in OvS |
| 1551 | 7.Now remove vSG VM |
| 1552 | 8.Now repeat step 4 |
| 1553 | 9.Verify that ping fails as vSG VM not exists |
| 1554 | 10.Create the vSG VM and vCPE container in VM again |
| 1555 | 11.Ensure that vSG and vCPE created |
| 1556 | 12.Now repeat step 4 |
| 1557 | 13.Verify ping success and flows added in OvS |
| 1558 | """ |
| 1559 | |
| 1560 | #Test vSG - Subscriber Configuration |
| 1561 | def test_vsg_for_configuring_new_subscriber_in_vcpe(self): |
| 1562 | """ |
| 1563 | Algo: |
| 1564 | 1.Create a vSG VM in compute node |
| 1565 | 2.Create a vCPE container in vSG VM |
| 1566 | 3.Ensure VM and containers created properly |
| 1567 | 4.Configure a subscriber in XOS and assign a service id |
| 1568 | 5.Set the admin privileges to the subscriber |
| 1569 | 6.Verify subscriber configuration is success |
| 1570 | """ |
| 1571 | def test_vsg_for_adding_subscriber_devices_in_vcpe(self): |
| 1572 | """ |
| 1573 | Algo: |
| 1574 | 1.Create a vSG VM in compute node |
| 1575 | 2.Create a vCPE container in vSG VM |
| 1576 | 3.Ensure VM and containers created properly |
| 1577 | 4.Configure a subscriber in XOS and assign a service id |
| 1578 | 5.Verify subscriber successfully configured in vCPE |
| 1579 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1580 | 7.Verify all devices ( Macs ) added successfully |
| 1581 | """ |
| 1582 | def test_vsg_for_removing_subscriber_devices_in_vcpe(self): |
| 1583 | """ |
| 1584 | Algo: |
| 1585 | 1.Create a vSG VM in compute node |
| 1586 | 2.Create a vCPE container in vSG VM |
| 1587 | 3.Ensure VM and containers created properly |
| 1588 | 4.Configure a subscriber in XOS and assign a service id |
| 1589 | 5.Verify subscriber successfully configured |
| 1590 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1591 | 7.Verify all devices ( Macs ) added successfully |
| 1592 | 8.Now remove All the added devices in XOS |
| 1593 | 9.Verify all the devices removed |
| 1594 | """ |
| 1595 | def test_vsg_for_modify_subscriber_devices_in_vcpe(self): |
| 1596 | """ |
| 1597 | Algo: |
| 1598 | 1.Create a vSG VM in compute node |
| 1599 | 2.Create a vCPE container in vSG VM |
| 1600 | 3.Ensure VM and containers created properly |
| 1601 | 4.Configure a user in XOS and assign a service id |
| 1602 | 5.Verify subscriber successfully configured in vCPE. |
| 1603 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1604 | 7.Verify all devices ( Macs ) added successfully |
| 1605 | 8.Now remove few devices in XOS |
| 1606 | 9.Verify devices removed successfully |
| 1607 | 10.Now add few additional devices in XOS under the same subscriber admin group |
| 1608 | 11.Verify newly added devices successfully added |
| 1609 | """ |
| 1610 | def test_vsg_for_vcpe_login_fails_with_incorrect_subscriber_credentials(self): |
| 1611 | """ |
| 1612 | Algo: |
| 1613 | 1.Create a vSG VM in compute node |
| 1614 | 2.Create a vCPE container in vSG VM |
| 1615 | 3.Ensure VM and containers created properly |
| 1616 | 4.Configure a subscriber in XOS and assign a service id |
| 1617 | 5.Verify subscriber successfully configured |
| 1618 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1619 | 7.Verify all devices ( Macs ) added successfully |
| 1620 | 8.Login vCPE with credentials with which subscriber configured |
| 1621 | 9.Verify subscriber successfully logged in |
| 1622 | 10.Logout and login again with incorrect credentials ( either user name or password ) |
| 1623 | 11.Verify login attempt to vCPE fails wtih incorrect credentials |
| 1624 | """ |
| 1625 | def test_vsg_for_subscriber_configuration_in_vcpe_retain_after_vcpe_restart(self): |
| 1626 | """ |
| 1627 | Algo: |
| 1628 | 1.Create a vSG VM in compute node |
| 1629 | 2.Create a vCPE container in vSG VM |
| 1630 | 3.Ensure VM and containers created properly |
| 1631 | 4.Configure a subscriber in XOS and assign a service id |
| 1632 | 5.Verify subscriber successfully configured |
| 1633 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1634 | 7.Verify all devices ( Macs ) added successfully |
| 1635 | 8.Restart vCPE ( locate backup config path while restart ) |
| 1636 | 9.Verify subscriber details in vCPE after restart should be same as before the restart |
| 1637 | """ |
| 1638 | def test_vsg_for_create_multiple_vcpe_instances_and_configure_subscriber_in_each_instance(self): |
| 1639 | """ |
| 1640 | Algo: |
| 1641 | 1.Create a vSG VM in compute node |
| 1642 | 2.Create 2 vCPE containers in vSG VM |
| 1643 | 3.Ensure VM and containers created properly |
| 1644 | 4.Configure a subscriber in XOS for each vCPE instance and assign a service id |
| 1645 | 5.Verify subscribers successfully configured |
| 1646 | 6.Now login vCPE-2 with subscriber-1 credentials |
| 1647 | 7.Verify login fails |
| 1648 | 8.Now login vCPE-1 with subscriber-2 credentials |
| 1649 | 9.Verify login fails |
| 1650 | 10.Now login vCPE-1 with subscriber-1 and vCPE-2 with subscriber-2 credentials |
| 1651 | 11.Verify that both the subscribers able to login to their respective vCPE containers |
| 1652 | """ |
| 1653 | def test_vsg_for_same_subscriber_can_be_configured_for_multiple_services(self): |
| 1654 | """ |
| 1655 | Algo: |
| 1656 | 1.Create 2 vSG VMs in compute node |
| 1657 | 2.Create a vCPE container in each vSG VM |
| 1658 | 3.Ensure VMs and containers created properly |
| 1659 | 4.Configure same subscriber in XOS for each vCPE instance and assign a service id |
| 1660 | 5.Verify subscriber successfully configured |
| 1661 | 6.Now login vCPE-1 with subscriber credentials |
| 1662 | 7.Verify login success |
| 1663 | 8.Now login vCPE-2 with the same subscriber credentials |
| 1664 | 9.Verify login success |
| 1665 | """ |
| 1666 | |
| 1667 | #Test Example Service |
| 1668 | def test_vsg_for_subcriber_avail_example_service_running_in_apache_server(self): |
| 1669 | """ |
| 1670 | Algo: |
| 1671 | 1.Create a vSG VM in compute node |
| 1672 | 2.Create a vCPE container in each vSG VM |
| 1673 | 3.Ensure VM and container created properly |
| 1674 | 4.Configure a subscriber in XOS for the vCPE instance and assign a service id |
| 1675 | 5.On-board an example service into cord pod |
| 1676 | 6.Create a VM in compute node and run the example service ( Apache server ) |
| 1677 | 7.Configure the example service with service specific and subscriber specific messages |
| 1678 | 8.Verify example service on-boarded successfully |
| 1679 | 9.Verify example service running in VM |
| 1680 | 10.Run a curl command from subscriber to reach example service |
| 1681 | 11.Verify subscriber can successfully reach example service via vSG |
| 1682 | 12.Verify that service specific and subscriber specific messages |
| 1683 | """ |
| 1684 | def test_vsg_for_subcriber_avail_example_service_running_in_apache_server_after_service_restart(self): |
| 1685 | """ |
| 1686 | Algo: |
| 1687 | 1.Create a vSG VM in compute node |
| 1688 | 2.Create a vCPE container in each vSG VM |
| 1689 | 3.Ensure VM and container created properly |
| 1690 | 4.Configure a subscriber in XOS for the vCPE instance and assign a service id |
| 1691 | 5.On-board an example service into cord pod |
| 1692 | 6.Create a VM in compute node and run the example service ( Apache server ) |
| 1693 | 7.Configure the example service with service specific and subscriber specific messages |
| 1694 | 8.Verify example service on-boarded successfully |
| 1695 | 9.Verify example service running in VM |
| 1696 | 10.Run a curl command from subscriber to reach example service |
| 1697 | 11.Verify subscriber can successfully reach example service via vSG |
| 1698 | 12.Verify that service specific and subscriber specific messages |
| 1699 | 13.Restart example service running in VM |
| 1700 | 14.Repeat step 10 |
| 1701 | 15.Verify the same results as mentioned in steps 11, 12 |
| 1702 | """ |
| 1703 | |
| 1704 | #vCPE Firewall Functionality |
| 1705 | def test_vsg_firewall_for_creating_acl_rule_based_on_source_ip(self): |
| 1706 | """ |
| 1707 | Algo: |
| 1708 | 1.Create a vSG VM in compute node |
| 1709 | 2.Create vCPE container in the VM |
| 1710 | 3.Ensure vSG VM and vCPE container created properly |
| 1711 | 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP |
| 1712 | 5.Bound the acl rule to WAN interface of vCPE |
| 1713 | 6.Verify configuration in vCPE is success |
| 1714 | 8.Verify flows added in OvS |
| 1715 | """ |
| 1716 | def test_vsg_firewall_for_creating_acl_rule_based_on_destination_ip(self): |
| 1717 | """ |
| 1718 | Algo: |
| 1719 | 1.Create a vSG VM in compute node |
| 1720 | 2.Create vCPE container in the VM |
| 1721 | 3.Ensure vSG VM and vCPE container created properly |
| 1722 | 4.Configure ac acl rule in vCPE to deny IP traffic to a destination ip |
| 1723 | 5.Bound the acl rule to WAN interface of vCPE |
| 1724 | 6.Verify configuration in vCPE is success |
| 1725 | 8.Verify flows added in OvS |
| 1726 | """ |
| 1727 | def test_vsg_firewall_for_acl_deny_rule_based_on_source_ip_traffic(self): |
| 1728 | """ |
| 1729 | Algo: |
| 1730 | 1.Create a vSG VM in compute node |
| 1731 | 2.Create vCPE container in the VM |
| 1732 | 3.Ensure vSG VM and vCPE container created properly |
| 1733 | 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP |
| 1734 | 5.Bound the acl rule to WAN interface of vCPE |
| 1735 | 6.From subscriber, send ping to the denied IP address |
| 1736 | 7.Verify that ping fails as vCPE denies ping response |
| 1737 | 8.Verify flows added in OvS |
| 1738 | """ |
| 1739 | def test_vsg_firewall_for_acl_deny_rule_based_on_destination_ip_traffic(self): |
| 1740 | """ |
| 1741 | Algo: |
| 1742 | 1.Create a vSG VM in compute node |
| 1743 | 2.Create vCPE container in the VM |
| 1744 | 3.Ensure vSG VM and vCPE container created properly |
| 1745 | 4.Configure ac acl rule in vCPE to deny IP traffic to a destination IP |
| 1746 | 5.Bound the acl rule to WAN interface of vCPE |
| 1747 | 6.From subscriber, send ping to the denied IP address |
| 1748 | 7.Verify that ping fails as vCPE drops the ping request at WAN interface |
| 1749 | 8.Verify flows added in OvS |
| 1750 | """ |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 1751 | |
| 1752 | def test_vsg_dnsmasq(self): |
| 1753 | pass |
| 1754 | |
| 1755 | def test_vsg_with_external_parental_control_family_shield_for_filter(self): |
| 1756 | pass |
| 1757 | |
| 1758 | def test_vsg_with_external_parental_control_with_answerx(self): |
| 1759 | pass |
| 1760 | |
| 1761 | def test_vsg_for_subscriber_upstream_bandwidth(self): |
| 1762 | pass |
| 1763 | |
| 1764 | def test_vsg_for_subscriber_downstream_bandwidth(self): |
| 1765 | pass |
| 1766 | |
| 1767 | def test_vsg_for_diagnostic_run_of_traceroute(self): |
| 1768 | pass |
| 1769 | |
| 1770 | def test_vsg_for_diagnostic_run_of_tcpdump(self): |
| 1771 | pass |
| 1772 | |
| 1773 | def test_vsg_for_iptable_rules(self): |
| 1774 | pass |
| 1775 | |
| 1776 | def test_vsg_for_iptables_with_neutron(self): |
| 1777 | pass |