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 | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 396 | vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 397 | assert_not_equal(vcpe_ip, None) |
| 398 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp)) |
| 399 | log.info('Sending ICMP pings to host %s' %(host)) |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 400 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 401 | assert_equal(st, 0) |
| 402 | #bring down the wan interface and check again |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 403 | st = VSGAccess.vcpe_wan_down(vcpe) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 404 | assert_equal(st, True) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 405 | st_ping, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 406 | st = VSGAccess.vcpe_wan_up(vcpe) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 407 | assert_not_equal(st_ping, 0) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 408 | assert_equal(st, True) |
| 409 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 410 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 411 | assert_equal(st, 0) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 412 | |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 413 | 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] | 414 | """ |
| 415 | Algo: |
| 416 | 1. Get dhcp IP to vcpe interface in cord-tester |
| 417 | 2. Verifying vcpe interface gets dhcp IP |
| 418 | 3. Ping to 8.8.8.8 and Verifying ping should success |
| 419 | 4. Now down the LAN interface of vcpe |
| 420 | 5. Ping to 8.8.8.8 and Verifying ping should not success |
| 421 | 6. Now Up the LAN interface of vcpe |
| 422 | 7. Ping to 8.8.8.8 and Verifying ping should success |
| 423 | 8. Restoring management interface configuration in cord-tester |
| 424 | """ |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 425 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 426 | mgmt = 'eth0' |
| 427 | vcpe = self.vcpe_container |
| 428 | assert_not_equal(vcpe, None) |
| 429 | assert_not_equal(self.vcpe_dhcp, None) |
| 430 | #first get dhcp on the vcpe interface |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 431 | vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 432 | assert_not_equal(vcpe_ip, None) |
| 433 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp)) |
| 434 | log.info('Sending ICMP pings to host %s' %(host)) |
| 435 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 436 | assert_equal(st, 0) |
| 437 | #bring down the lan interface and check again |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 438 | st = VSGAccess.vcpe_lan_down(vcpe) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 439 | assert_equal(st, True) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 440 | st_ping, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 441 | st = VSGAccess.vcpe_lan_up(vcpe) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 442 | assert_not_equal(st_ping, 0) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 443 | assert_equal(st, True) |
| 444 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | d0fdf3b | 2017-03-21 16:54:22 -0700 | [diff] [blame] | 445 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame] | 446 | assert_equal(st, 0) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 447 | |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 448 | def test_vsg_firewall_with_deny_destination_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 449 | """ |
| 450 | Algo: |
| 451 | 1. Get vSG corresponding to vcpe |
| 452 | 2. Login to compute node |
| 453 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 454 | 4. From cord-tester ping to the denied IP address |
| 455 | 5. Verifying that ping should not be successful |
| 456 | """ |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 457 | mgmt = 'eth0' |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 458 | host = '8.8.8.8' |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 459 | assert_not_equal(self.vcpe_dhcp, None) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 460 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 461 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 462 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 463 | assert_not_equal(vsg, None) |
| 464 | vcpe_ip = self.get_dhcp(self.vcpe_dhcp, mgmt = mgmt) |
| 465 | assert_not_equal(vcpe_ip, None) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 466 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 467 | assert_equal(st, 0) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 468 | try: |
| 469 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 470 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 471 | assert_not_equal(st, 0) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 472 | finally: |
| 473 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 474 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
A R Karthick | 9a16a11 | 2017-04-07 15:40:05 -0700 | [diff] [blame^] | 475 | VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 476 | |
| 477 | 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] | 478 | """ |
| 479 | Algo: |
| 480 | 1. Get vSG corresponding to vcpe |
| 481 | 2. Login to compute node |
| 482 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 483 | 4. From cord-tester ping to the denied IP address |
| 484 | 5. Verifying that ping should not be successful |
| 485 | 6. Delete the iptable rule in vcpe |
| 486 | 7. From cord-tester ping to the denied IP address |
| 487 | 8. Verifying the ping should success |
| 488 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 489 | host = '8.8.8.8' |
| 490 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 491 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 492 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 493 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 494 | assert_equal(st, False) |
| 495 | try: |
| 496 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 497 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 498 | assert_equal(st, True) |
| 499 | st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 500 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 501 | assert_equal(st,False) |
| 502 | finally: |
| 503 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 504 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 505 | |
| 506 | 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] | 507 | """ |
| 508 | Algo: |
| 509 | 1. Get vSG corresponding to vcpe |
| 510 | 2. Login to compute node |
| 511 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 512 | 4. From cord-tester ping to the denied IP address |
| 513 | 5. Verifying that ping should not be successful |
| 514 | 6. From cord-tester ping to the denied IP address other than the denied one |
| 515 | 7. Verifying the ping should success |
| 516 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 517 | host1 = '8.8.8.8' |
| 518 | host2 = '204.79.197.203' |
| 519 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 520 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 521 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 522 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 523 | assert_equal(st, False) |
| 524 | try: |
| 525 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host1)) |
| 526 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 527 | assert_equal(st, True) |
| 528 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 529 | assert_equal(st,False) |
| 530 | finally: |
| 531 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 532 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 533 | |
| 534 | 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] | 535 | """ |
| 536 | Algo: |
| 537 | 1. Get vSG corresponding to vcpe |
| 538 | 2. Login to compute node |
| 539 | 3. Execute iptable command on vcpe from compute node to deny a destination IP1 |
| 540 | 4. From cord-tester ping to the denied IP address IP1 |
| 541 | 5. Verifying that ping should not be successful |
| 542 | 6. Execute iptable command on vcpe from compute node to deny a destination IP2 |
| 543 | 6. From cord-tester ping to the denied IP address IP2 |
| 544 | 7. Verifying that ping should not be successful |
| 545 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 546 | host1 = '8.8.8.8' |
| 547 | host2 = '204.79.197.203' |
| 548 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 549 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 550 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 551 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 552 | assert_equal(st, False) |
| 553 | try: |
| 554 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host1)) |
| 555 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 556 | assert_equal(st, True) |
| 557 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 558 | assert_equal(st, False) |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 559 | 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] | 560 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 561 | assert_equal(st,True) |
| 562 | finally: |
| 563 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 564 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 565 | |
| 566 | 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] | 567 | """ |
| 568 | Algo: |
| 569 | 1. Get vSG corresponding to vcpe |
| 570 | 2. Login to compute node |
| 571 | 3. Execute iptable command on vcpe from compute node to deny a destination IP1 |
| 572 | 4. Execute iptable command on vcpe from compute node to deny a destination IP2 |
| 573 | 5. From cord-tester ping to the denied IP address IP1 |
| 574 | 6. Verifying that ping should not be successful |
| 575 | 7. From cord-tester ping to the denied IP address IP2 |
| 576 | 8. Verifying that ping should not be successful |
| 577 | 9. Execute iptable command on vcpe from compute node to remove deny a destination IP2 rule |
| 578 | 10. From cord-tester ping to the denied IP address IP2 |
| 579 | 11. Verifying the ping should success |
| 580 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 581 | host1 = '8.8.8.8' |
| 582 | host2 = '204.79.197.203' |
| 583 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 584 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 585 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 586 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 587 | assert_equal(st, False) |
| 588 | try: |
| 589 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host1)) |
| 590 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host2)) |
| 591 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 592 | assert_equal(st, True) |
| 593 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 594 | assert_equal(st,True) |
| 595 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe,host2)) |
| 596 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 597 | assert_equal(st,False) |
| 598 | finally: |
| 599 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 600 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 601 | |
| 602 | 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] | 603 | """ |
| 604 | Algo: |
| 605 | 1. Get vSG corresponding to vcpe |
| 606 | 2. Login to compute node |
| 607 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 608 | 5. From cord-tester ping to the denied IP address IP1 |
| 609 | 6. Verifying that ping should not be successful |
| 610 | 9. Execute iptable command on vcpe from compute node to change the rule ID to 2 to deny the same destination IP |
| 611 | 10. From cord-tester ping to the denied IP address IP |
| 612 | 11. Verifying that ping should not be successful |
| 613 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 614 | host = '8.8.8.8' |
| 615 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 616 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 617 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 618 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 619 | assert_equal(st, False) |
| 620 | try: |
| 621 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 622 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 623 | assert_equal(st, True) |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 624 | 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] | 625 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 626 | assert_equal(st,False) |
| 627 | finally: |
| 628 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 629 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 630 | |
| 631 | 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] | 632 | """ |
| 633 | Algo: |
| 634 | 1. Get vSG corresponding to vcpe |
| 635 | 2. Login to compute node |
| 636 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 637 | 5. From cord-tester ping to the denied IP address IP1 |
| 638 | 6. Verifying that ping should not be successful |
| 639 | 9. Execute iptable command on vcpe from compute node to accept the same destination IP |
| 640 | 10. From cord-tester ping to the accepted IP |
| 641 | 11. Verifying the ping should success |
| 642 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 643 | host1 = '8.8.8.8' |
| 644 | host2 = '204.79.197.203' |
| 645 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 646 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 647 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 648 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 649 | assert_equal(st, False) |
| 650 | try: |
| 651 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 652 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 653 | assert_equal(st, True) |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 654 | 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] | 655 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 656 | assert_equal(st,False) |
| 657 | finally: |
| 658 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 659 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 660 | |
| 661 | def test_vsg_firewall_denying_destination_network(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 662 | """ |
| 663 | Algo: |
| 664 | 1. Get vSG corresponding to vcpe |
| 665 | 2. Login to compute node |
| 666 | 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet |
| 667 | 4. From cord-tester ping to the denied IP address IP1 in the denied subnet |
| 668 | 5. Verifying that ping should not be successful |
| 669 | 6. From cord-tester ping to the denied IP address IP2 in the denied subnet |
| 670 | 7. Verifying that ping should not be successful |
| 671 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 672 | network = '206.190.36.44/28' |
| 673 | host1 = '204.79.197.46' |
| 674 | host2 = '204.79.197.51' |
| 675 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 676 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 677 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 678 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 679 | assert_equal(st, False) |
| 680 | try: |
| 681 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,network)) |
| 682 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 683 | assert_equal(st, True) |
| 684 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 685 | assert_equal(st,False) |
| 686 | finally: |
| 687 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 688 | |
| 689 | 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] | 690 | """ |
| 691 | Algo: |
| 692 | 1. Get vSG corresponding to vcpe |
| 693 | 2. Login to compute node |
| 694 | 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet |
| 695 | 4. From cord-tester ping to the denied IP address IP1 in the denied subnet |
| 696 | 5. Verifying that ping should not be successful |
| 697 | 6. From cord-tester ping to the denied IP address IP2 in the denied subnet |
| 698 | 7. Verifying that ping should not be successful |
| 699 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 700 | network1 = '206.190.36.44/28' |
| 701 | network2 = '206.190.36.44/26' |
| 702 | host1 = '204.79.197.46' |
| 703 | host2 = '204.79.197.51' |
| 704 | host2 = '204.79.197.63' |
| 705 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 706 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 707 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 708 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 709 | assert_equal(st, False) |
| 710 | try: |
| 711 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,network1)) |
| 712 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 713 | assert_equal(st, True) |
| 714 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 715 | assert_equal(st,False) |
| 716 | st,output = vsg.run_cmd('sudo docker exec {} iptables -A FORWARD -d {} -j DROP'.format(vcpe,network2)) |
| 717 | st, _ = getstatusoutput('ping -c 1 {}'.format(host1)) |
| 718 | assert_equal(st, True) |
| 719 | st, _ = getstatusoutput('ping -c 1 {}'.format(host2)) |
| 720 | assert_equal(st, True) |
| 721 | st, _ = getstatusoutput('ping -c 1 {}'.format(host3)) |
| 722 | assert_equal(st, False) |
| 723 | finally: |
| 724 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 725 | |
| 726 | def test_vsg_firewall_with_deny_source_ip(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 727 | """ |
| 728 | Algo: |
| 729 | 1. Get vSG corresponding to vcpe |
| 730 | 2. Login to compute node |
| 731 | 3. Execute iptable command on vcpe from compute node to deny a source IP |
| 732 | 4. From cord-tester ping to 8.8.8.8 from the denied IP |
| 733 | 5. Verifying that ping should not be successful |
| 734 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 735 | host = '8.8.8.8' |
| 736 | source_ip = self.vcpe_dhcp |
| 737 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 738 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 739 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 740 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 741 | assert_equal(st, False) |
| 742 | try: |
| 743 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe,source_ip)) |
| 744 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 745 | assert_equal(st, True) |
| 746 | finally: |
| 747 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 748 | |
| 749 | 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] | 750 | """ |
| 751 | Algo: |
| 752 | 1. Get vSG corresponding to vcpe |
| 753 | 2. Login to compute node |
| 754 | 3. Execute iptable command on vcpe from compute node to deny a source IP |
| 755 | 4. From cord-tester ping to 8.8.8.8 from the denied IP |
| 756 | 5. Verifying that ping should not be successful |
| 757 | 6. Delete the iptable rule in vcpe |
| 758 | 7. From cord-tester ping to 8.8.8.8 from the denied IP |
| 759 | 8. Verifying the ping should success |
| 760 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 761 | host = '8.8.8.8' |
| 762 | source_ip = self.vcpe_dhcp |
| 763 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 764 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 765 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 766 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 767 | assert_equal(st, False) |
| 768 | try: |
| 769 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe,source_ip)) |
| 770 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 771 | assert_equal(st, True) |
| 772 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe,source_ip)) |
| 773 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 774 | assert_equal(st, False) |
| 775 | finally: |
| 776 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 777 | |
| 778 | 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] | 779 | """ |
| 780 | Algo: |
| 781 | 1. Get vSG corresponding to vcpe |
| 782 | 2. Login to compute node |
| 783 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets |
| 784 | 4. From cord-tester ping to 8.8.8.8 |
| 785 | 5. Verifying that ping should not be successful |
| 786 | 6. Delete the iptable rule |
| 787 | 7. From cord-tester ping to 8.8.8.8 |
| 788 | 8. Verifying the ping should success |
| 789 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 790 | host = '8.8.8.8' |
| 791 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 792 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 793 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 794 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 795 | assert_equal(st, False) |
| 796 | try: |
| 797 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe)) |
| 798 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 799 | assert_equal(st, True) |
| 800 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe)) |
| 801 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 802 | assert_equal(st, False) |
| 803 | finally: |
| 804 | vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 805 | vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 806 | |
| 807 | 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] | 808 | """ |
| 809 | Algo: |
| 810 | 1. Get vSG corresponding to vcpe |
| 811 | 2. Login to compute node |
| 812 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets |
| 813 | 4. From cord-tester ping to 8.8.8.8 |
| 814 | 5. Verifying that ping should not be successful |
| 815 | 6. Delete the iptable rule |
| 816 | 7. From cord-tester ping to 8.8.8.8 |
| 817 | 8. Verifying the ping should success |
| 818 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 819 | host = '8.8.8.8' |
| 820 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 821 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 822 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 823 | st, _ = getstatusoutput('ping -c 1 {}'.format('8.8.8.8')) |
| 824 | assert_equal(st, False) |
| 825 | try: |
| 826 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe)) |
| 827 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 828 | assert_equal(st, True) |
| 829 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe)) |
| 830 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 831 | assert_equal(st,False) |
| 832 | finally: |
| 833 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 834 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 835 | |
| 836 | 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] | 837 | """ |
| 838 | Algo: |
| 839 | 1. Get vSG corresponding to vcpe |
| 840 | 2. Login to compute node |
| 841 | 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets |
| 842 | 4. From cord-tester ping to 8.8.8.8 |
| 843 | 5. Verifying that ping should not be successful |
| 844 | 6. Insert another rule to accept the icmp-echo requests protocol packets |
| 845 | 7. From cord-tester ping to 8.8.8.8 |
| 846 | 8. Verifying the ping should success |
| 847 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 848 | host = '8.8.8.8' |
| 849 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 850 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 851 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 852 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 853 | assert_equal(st, False) |
| 854 | try: |
| 855 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p icmp --icmp-type echo-request -j DROP'.format(vcpe)) |
| 856 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 857 | assert_equal(st, True) |
| 858 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe)) |
| 859 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 860 | assert_equal(st,False) |
| 861 | finally: |
| 862 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 863 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 864 | |
| 865 | def test_vsg_firewall_changing_deny_rule_to_accept_rule_with_icmp_protocol_echo_reply_type(self, vcpe=None): |
| 866 | host = '8.8.8.8' |
| 867 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 868 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 869 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 870 | st, out1 = getstatusoutput('ping -c 1 {}'.format(host)) |
| 871 | assert_equal(st, False) |
| 872 | try: |
| 873 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p icmp --icmp-type echo-reply -j DROP'.format(vcpe)) |
| 874 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 875 | assert_equal(st, True) |
| 876 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe)) |
| 877 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 878 | assert_equal(st,False) |
| 879 | finally: |
| 880 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 881 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 882 | |
| 883 | def test_vsg_firewall_for_deny_icmp_protocol(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 884 | """ |
| 885 | Algo: |
| 886 | 1. Get vSG corresponding to vcpe |
| 887 | 2. Login to compute node |
| 888 | 3. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 889 | 4. From cord-tester ping to 8.8.8.8 |
| 890 | 5. Verifying that ping should not be successful |
| 891 | 6. Delete the iptable rule |
| 892 | 7. From cord-tester ping to 8.8.8.8 |
| 893 | 8. Verifying the ping should success |
| 894 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 895 | host = '8.8.8.8' |
| 896 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 897 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 898 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 899 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 900 | assert_equal(st, False) |
| 901 | try: |
| 902 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe)) |
| 903 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 904 | assert_equal(st, True) |
| 905 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe)) |
| 906 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 907 | assert_equal(st,False) |
| 908 | finally: |
| 909 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 910 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 911 | |
| 912 | 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] | 913 | """ |
| 914 | Algo: |
| 915 | 1. Get vSG corresponding to vcpe |
| 916 | 2. Login to compute node |
| 917 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 918 | 4. From cord-tester ping to 8.8.8.8 |
| 919 | 5. Verifying that ping should not be successful |
| 920 | 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 921 | 7. From cord-tester ping to 8.8.8.8 |
| 922 | 8. Verifying the ping should success |
| 923 | 9. Delete the rule added in step 3 |
| 924 | 10. From cord-tester ping to 8.8.8.8 |
| 925 | 11. Verifying that ping should not be successful |
| 926 | 12. Delete the rule added in step 6 |
| 927 | 13. From cord-tester ping to 8.8.8.8 |
| 928 | 14. Verifying the ping should success |
| 929 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 930 | host = '8.8.8.8' |
| 931 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 932 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 933 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 934 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 935 | assert_equal(st, False) |
| 936 | try: |
| 937 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 938 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 939 | assert_equal(st, True) |
| 940 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe)) |
| 941 | assert_equal(st, True) |
| 942 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 943 | assert_equal(st, True) |
| 944 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe)) |
| 945 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 946 | assert_equal(st,False) |
| 947 | finally: |
| 948 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 949 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 950 | |
| 951 | def test_vsg_firewall_flushing_all_configured_rules(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 952 | """ |
| 953 | Algo: |
| 954 | 1. Get vSG corresponding to vcpe |
| 955 | 2. Login to compute node |
| 956 | 3. Execute iptable command on vcpe from compute node to deny a destination IP |
| 957 | 4. From cord-tester ping to 8.8.8.8 |
| 958 | 5. Verifying that ping should not be successful |
| 959 | 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets |
| 960 | 7. From cord-tester ping to 8.8.8.8 |
| 961 | 8. Verifying the ping should success |
| 962 | 9. Flush all the iptable rules configuraed in vcpe |
| 963 | 10. Delete the rule added in step 6 |
| 964 | 11. From cord-tester ping to 8.8.8.8 |
| 965 | 12. Verifying the ping should success |
| 966 | """ |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 967 | host = '8.8.8.8' |
| 968 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 969 | vcpe = self.vcpe_container |
Anil Kumar Sanka | d47023a | 2017-03-29 21:11:09 +0000 | [diff] [blame] | 970 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 971 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 972 | assert_equal(st, False) |
| 973 | try: |
| 974 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe,host)) |
| 975 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 976 | assert_equal(st, True) |
| 977 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe)) |
| 978 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 979 | assert_equal(st, True) |
| 980 | st,output = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 981 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 982 | assert_equal(st, False) |
| 983 | finally: |
| 984 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 985 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -F'.format(vcpe)) |
| 986 | |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 987 | def test_vsg_firewall_deny_all_ipv4_traffic(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 988 | """ |
| 989 | Algo: |
| 990 | 1. Get vSG corresponding to vcpe |
| 991 | 2. Login to compute node |
| 992 | 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic |
| 993 | 4. From cord-tester ping to 8.8.8.8 |
| 994 | 5. Verifying that ping should not be successful |
| 995 | 6. Delete the iptable rule added |
| 996 | 7. From cord-tester ping to 8.8.8.8 |
| 997 | 8. Verifying the ping should success |
| 998 | """ |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 999 | host = '8.8.8.8' |
| 1000 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 1001 | vcpe = self.vcpe_container |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1002 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 1003 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1004 | assert_equal(st, False) |
| 1005 | try: |
| 1006 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe)) |
| 1007 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1008 | assert_equal(st, True) |
| 1009 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe)) |
| 1010 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1011 | assert_equal(st, False) |
| 1012 | finally: |
| 1013 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 1014 | |
| 1015 | 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] | 1016 | """ |
| 1017 | Algo: |
| 1018 | 1. Get vSG corresponding to vcpe |
| 1019 | 2. Login to compute node |
| 1020 | 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic |
| 1021 | 4. From cord-tester ping to 8.8.8.8 |
| 1022 | 5. Verifying that ping should not be successful |
| 1023 | 6. Replace the deny rule added in step 3 with accept rule |
| 1024 | 7. From cord-tester ping to 8.8.8.8 |
| 1025 | 8. Verifying the ping should success |
| 1026 | """ |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1027 | host = '8.8.8.8' |
| 1028 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 1029 | vcpe = self.vcpe_container |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1030 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 1031 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1032 | assert_equal(st, False) |
| 1033 | try: |
| 1034 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -4 -j DROP'.format(vcpe)) |
| 1035 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1036 | assert_equal(st, True) |
| 1037 | st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -4 -j ACCEPT'.format(vcpe)) |
| 1038 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1039 | assert_equal(st, False) |
| 1040 | finally: |
| 1041 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 1042 | |
| 1043 | 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] | 1044 | """ |
| 1045 | Algo: |
| 1046 | 1. Get vSG corresponding to vcpe |
| 1047 | 2. Login to compute node |
| 1048 | 3. Execute iptable command on vcpe from compute node to deny all the traffic from lan to wan interface in vcpe |
| 1049 | 4. From cord-tester ping to 8.8.8.8 |
| 1050 | 5. Verifying that ping should not be successful |
| 1051 | 6. Delete the iptable rule added |
| 1052 | 7. From cord-tester ping to 8.8.8.8 |
| 1053 | 8. Verifying the ping should success |
| 1054 | """ |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1055 | host = '8.8.8.8' |
| 1056 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 1057 | vcpe = self.vcpe_container |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1058 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 1059 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1060 | assert_equal(st, False) |
| 1061 | try: |
| 1062 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe)) |
| 1063 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1064 | assert_equal(st, True) |
| 1065 | st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j ACCEPT'.format(vcpe)) |
| 1066 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1067 | assert_equal(st, False) |
| 1068 | finally: |
| 1069 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 1070 | |
| 1071 | def test_vsg_firewall_deny_all_dns_traffic(self, vcpe=None): |
Anil Kumar Sanka | 72755c9 | 2017-04-06 17:19:02 +0000 | [diff] [blame] | 1072 | """ |
| 1073 | Algo: |
| 1074 | 1. Get vSG corresponding to vcpe |
| 1075 | 2. Login to compute node |
| 1076 | 3. Execute iptable command on vcpe from compute node to deny all dns Traffic |
| 1077 | 4. From cord-tester ping to www.google.com |
| 1078 | 5. Verifying that ping should not be successful |
| 1079 | 6. Delete the iptable rule added |
| 1080 | 7. From cord-tester ping to www.google.com |
| 1081 | 8. Verifying the ping should success |
| 1082 | """ |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1083 | host = 'www.google.com' |
| 1084 | if not vcpe: |
A.R Karthick | 8f7f1b6 | 2017-04-06 18:25:07 -0700 | [diff] [blame] | 1085 | vcpe = self.vcpe_container |
Anil Kumar Sanka | 966c193 | 2017-03-31 00:48:31 +0000 | [diff] [blame] | 1086 | vsg = VSGAccess.get_vcpe_vsg(vcpe) |
| 1087 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1088 | assert_equal(st, False) |
| 1089 | try: |
| 1090 | st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 1 -p udp --dport 53 -j DROP'.format(vcpe)) |
| 1091 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1092 | assert_equal(st, True) |
| 1093 | st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p udp --dport 53 -j ACCEPT'.format(vcpe)) |
| 1094 | st,_ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 1095 | assert_equal(st, False) |
| 1096 | finally: |
| 1097 | st, _ = vsg.run_cmd('sudo docker exec {} iptables -X'.format(vcpe)) |
| 1098 | |
A.R Karthick | 282f0d3 | 2017-03-28 16:43:59 -0700 | [diff] [blame] | 1099 | def test_vsg_xos_subscriber(self): |
| 1100 | subscriber_info = self.subscriber_info[0] |
| 1101 | volt_subscriber_info = self.volt_subscriber_info[0] |
| 1102 | result = self.restApiXos.ApiPost('TENANT_SUBSCRIBER', subscriber_info) |
| 1103 | assert_equal(result, True) |
| 1104 | result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER') |
| 1105 | assert_not_equal(result, None) |
| 1106 | subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num']) |
| 1107 | assert_not_equal(subId, '0') |
| 1108 | log.info('Subscriber ID for account num %d = %s' %(volt_subscriber_info['account_num'], subId)) |
| 1109 | volt_tenant = volt_subscriber_info['voltTenant'] |
| 1110 | #update the subscriber id in the tenant info before making the rest |
| 1111 | volt_tenant['subscriber'] = subId |
| 1112 | result = self.restApiXos.ApiPost('TENANT_VOLT', volt_tenant) |
| 1113 | assert_equal(result, True) |
| 1114 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1115 | def test_vsg_for_ping_from_vsg_to_external_network(self): |
| 1116 | """ |
| 1117 | Algo: |
| 1118 | 1.Create a vSG VM in compute node |
| 1119 | 2.Ensure VM created properly |
| 1120 | 3.Verify login to VM success |
| 1121 | 4.Do ping to external network from vSG VM |
| 1122 | 5.Verify that ping gets success |
| 1123 | 6.Verify ping success flows added in OvS |
| 1124 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1125 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1126 | def test_vsg_for_ping_from_vcpe_to_external_network(self): |
| 1127 | """ |
| 1128 | Algo: |
| 1129 | 1.Create a vSG VM in compute node |
| 1130 | 2.Create a vCPE container inside VM |
| 1131 | 3.Verify both VM and Container created properly |
| 1132 | 4.Verify login to vCPE container success |
| 1133 | 5.Do ping to external network from vCPE container |
| 1134 | 6.Verify that ping gets success |
| 1135 | 7.Verify ping success flows added in OvS |
| 1136 | """ |
| 1137 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 1138 | def test_vsg_for_dns_service(self): |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1139 | """ |
| 1140 | Algo: |
| 1141 | 1. Create a test client in Prod VM |
| 1142 | 2. Create a vCPE container in vSG VM inside compute Node |
| 1143 | 3. Ensure vSG VM and vCPE container created properly |
| 1144 | 4. Enable dns service in vCPE ( if not by default ) |
| 1145 | 5. Send ping request from test client to valid domain address say, 'www.google'com |
| 1146 | 6. Verify that dns should resolve ping should success |
| 1147 | 7. Now send ping request to invalid domain address say 'www.invalidaddress'.com' |
| 1148 | 8. Verify that dns resolve should fail and hence ping |
| 1149 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1150 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1151 | def test_vsg_for_10_subscribers_for_same_service(self): |
| 1152 | """ |
| 1153 | Algo: |
| 1154 | 1.Create a vSG VM in compute node |
| 1155 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 1156 | 3.Ensure vSG VM and vCPE container created properly |
| 1157 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP |
| 1158 | 5.Verify that ping success for all 10 subscribers |
| 1159 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1160 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1161 | def test_vsg_for_10_subscribers_for_same_service_ping_invalid_ip(self): |
| 1162 | """ |
| 1163 | Algo: |
| 1164 | 1.Create a vSG VM in compute Node |
| 1165 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 1166 | 3.Ensure vSG VM and vCPE container created properly |
| 1167 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP |
| 1168 | 5.Verify that ping fails for all 10 subscribers |
| 1169 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1170 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1171 | def test_vsg_for_10_subscribers_for_same_service_ping_valid_and_invalid_ip(self): |
| 1172 | """ |
| 1173 | Algo: |
| 1174 | 1.Create a vSG VM in VM |
| 1175 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 1176 | 3.Ensure vSG VM and vCPE container created properly |
| 1177 | 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP |
| 1178 | 5.Verify that ping success for all 5 subscribers |
| 1179 | 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP |
| 1180 | 7.Verify that ping fails for all 5 subscribers |
| 1181 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1182 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1183 | def test_vsg_for_100_subscribers_for_same_service(self): |
| 1184 | """ |
| 1185 | Algo: |
| 1186 | 1.Create a vSG VM in compute node |
| 1187 | 2.Create 100 vCPE containers for 100 subscribers, in vSG VM |
| 1188 | 3.Ensure vSG VM and vCPE container created properly |
| 1189 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP |
| 1190 | 5.Verify that ping success for all 100 subscribers |
| 1191 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1192 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1193 | def test_vsg_for_100_subscribers_for_same_service_ping_invalid_ip(self): |
| 1194 | """ |
| 1195 | Algo: |
| 1196 | 1.Create a vSG VM in compute Node |
| 1197 | 2.Create 10 vCPE containers for 100 subscribers, in vSG VM |
| 1198 | 3.Ensure vSG VM and vCPE container created properly |
| 1199 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP |
| 1200 | 5.Verify that ping fails for all 100 subscribers |
| 1201 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1202 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1203 | def test_vsg_for_100_subscribers_for_same_service_ping_valid_and_invalid_ip(self): |
| 1204 | """ |
| 1205 | Algo: |
| 1206 | 1.Create a vSG VM in VM |
| 1207 | 2.Create 10 vCPE containers for 100 subscribers, in vSG VM |
| 1208 | 3.Ensure vSG VM and vCPE container created properly |
| 1209 | 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP |
| 1210 | 5.Verify that ping success for all 5 subscribers |
| 1211 | 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP |
| 1212 | 7.Verify that ping fails for all 5 subscribers |
| 1213 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1214 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1215 | def test_vsg_for_packet_received_with_invalid_ip_fields(self): |
| 1216 | """ |
| 1217 | Algo: |
| 1218 | 1.Create a vSG VM in compute node |
| 1219 | 2.Create a vCPE container in vSG VM |
| 1220 | 3.Ensure vSG VM and vCPE container created properly |
| 1221 | 4.From subscriber, send a ping packet with invalid ip fields |
| 1222 | 5.Verify that vSG drops the packet |
| 1223 | 6.Verify ping fails |
| 1224 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1225 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1226 | def test_vsg_for_packet_received_with_invalid_mac_fields(self): |
| 1227 | """ |
| 1228 | Algo: |
| 1229 | 1.Create a vSG VM in compute node |
| 1230 | 2.Create a vCPE container in vSG VM |
| 1231 | 3.Ensure vSG VM and vCPE container created properly |
| 1232 | 4.From subscriber, send a ping packet with invalid mac fields |
| 1233 | 5.Verify that vSG drops the packet |
| 1234 | 6.Verify ping fails |
| 1235 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1236 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1237 | def test_vsg_for_vlan_id_mismatch_in_stag(self): |
| 1238 | """ |
| 1239 | Algo: |
| 1240 | 1.Create a vSG VM in compute Node |
| 1241 | 2.Create a vCPE container in vSG VM |
| 1242 | 3.Ensure vSG VM and vCPE container created properly |
| 1243 | 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag |
| 1244 | 5.Verify that ping fails as the packet drops at VM entry |
| 1245 | 6.Repeat step 4 with correct s-tag |
| 1246 | 7.Verify that ping success |
| 1247 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1248 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1249 | def test_vsg_for_vlan_id_mismatch_in_ctag(self): |
| 1250 | """ |
| 1251 | Algo: |
| 1252 | 1.Create a vSG VM in compute node |
| 1253 | 2.Create a vCPE container in vSG VM |
| 1254 | 3.Ensure vSG VM and vCPE container created properly |
| 1255 | 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag |
| 1256 | 5.Verify that ping fails as the packet drops at vCPE container entry |
| 1257 | 6.Repeat step 4 with valid s-tag and c-tag |
| 1258 | 7.Verify that ping success |
| 1259 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1260 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1261 | def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self): |
| 1262 | """ |
| 1263 | Algo: |
| 1264 | 1.Create two vSG VMs in compute node |
| 1265 | 2.Create a vCPE container in each vSG VM |
| 1266 | 3.Ensure vSG VM and vCPE container created properly |
| 1267 | 4.From subscriber one, send ping request with valid s and c tags |
| 1268 | 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags |
| 1269 | 6.Verify that ping success for only subscriber one and fails for two. |
| 1270 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1271 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1272 | def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self): |
| 1273 | """ |
| 1274 | Algo: |
| 1275 | 1.Create a vSG VM in compute node |
| 1276 | 2.Create two vCPE containers in vSG VM |
| 1277 | 3.Ensure vSG VM and vCPE container created properly |
| 1278 | 4.From subscriber one, send ping request with valid s and c tags |
| 1279 | 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag |
| 1280 | 6.Verify that ping success for only subscriber one and fails for two |
| 1281 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1282 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1283 | def test_vsg_for_out_of_range_vlanid_in_ctag(self): |
| 1284 | """ |
| 1285 | Algo: |
| 1286 | 1.Create a vSG VM in compute node |
| 1287 | 2.Create a vCPE container in vSG VM |
| 1288 | 3.Ensure vSG VM and vCPE container created properly |
| 1289 | 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 ) |
| 1290 | 4.Verify that ping fails as the ping packets drops at vCPE container entry |
| 1291 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1292 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1293 | def test_vsg_for_out_of_range_vlanid_in_stag(self): |
| 1294 | """ |
| 1295 | Algo: |
| 1296 | 1.Create a vSG VM in compute node |
| 1297 | 2.Create a vCPE container in vSG VM |
| 1298 | 3.Ensure vSG VM and vCPE container created properly |
| 1299 | 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 |
| 1300 | 4.Verify that ping fails as the ping packets drops at vSG VM entry |
| 1301 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1302 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1303 | def test_vsg_without_creating_vcpe_instance(self): |
| 1304 | """ |
| 1305 | Algo: |
| 1306 | 1.Create a vSG VM in compute Node |
| 1307 | 2.Ensure vSG VM created properly |
| 1308 | 3.Do not create vCPE container inside vSG VM |
| 1309 | 4.From a subscriber, send ping to external valid IP |
| 1310 | 5.Verify that ping fails as the ping packet drops at vSG VM entry itself. |
| 1311 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1312 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1313 | def test_vsg_for_remove_vcpe_instance(self): |
| 1314 | """ |
| 1315 | Algo: |
| 1316 | 1.Create a vSG VM in compute node |
| 1317 | 2.Create a vCPE container in vSG VM |
| 1318 | 3.Ensure vSG VM and vCPE container created properly |
| 1319 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 1320 | 5.Verify that ping success |
| 1321 | 6.Verify ping success flows in OvS switch in compute node |
| 1322 | 7.Now remove the vCPE container in vSG VM |
| 1323 | 8.Ensure that the container removed properly |
| 1324 | 9.Repeat step 4 |
| 1325 | 10.Verify that now, ping fails |
| 1326 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1327 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1328 | def test_vsg_for_restart_vcpe_instance(self): |
| 1329 | """ |
| 1330 | Algo: |
| 1331 | 1.Create a vSG VM in compute node |
| 1332 | 2.Create a vCPE container in vSG VM |
| 1333 | 3.Ensure vSG VM and vCPE container created properly |
| 1334 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 1335 | 5.Verify that ping success |
| 1336 | 6.Verify ping success flows in OvS switch in compute node |
| 1337 | 7.Now restart the vCPE container in vSG VM |
| 1338 | 8.Ensure that the container came up after restart |
| 1339 | 9.Repeat step 4 |
| 1340 | 10.Verify that now,ping gets success and flows added in OvS |
| 1341 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1342 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1343 | def test_vsg_for_restart_vsg_vm(self): |
| 1344 | """ |
| 1345 | Algo: |
| 1346 | 1.Create a vSG VM in compute node |
| 1347 | 2.Create a vCPE container in vSG VM |
| 1348 | 3.Ensure vSG VM and vCPE container created properly |
| 1349 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 1350 | 5.Verify that ping success |
| 1351 | 6.Verify ping success flows in OvS switch in compute node |
| 1352 | 7.Now restart the vSG VM |
| 1353 | 8.Ensure that the vSG comes up properly after restart |
| 1354 | 9.Verify that vCPE container comes up after vSG restart |
| 1355 | 10.Repeat step 4 |
| 1356 | 11.Verify that now,ping gets success and flows added in OvS |
| 1357 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1358 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1359 | def test_vsg_for_pause_vcpe_instance(self): |
| 1360 | """ |
| 1361 | Algo: |
| 1362 | 1.Create a vSG VM in compute node |
| 1363 | 2.Create a vCPE container in vSG VM |
| 1364 | 3.Ensure vSG VM and vCPE container created properly |
| 1365 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 1366 | 5.Verify that ping success |
| 1367 | 6.Verify ping success flows in OvS switch in compute node |
| 1368 | 7.Now pause vCPE container in vSG VM for a while |
| 1369 | 8.Ensure that the container state is pause |
| 1370 | 9.Repeat step 4 |
| 1371 | 10.Verify that now,ping fails now and verify flows in OvS |
| 1372 | 11.Now resume the container |
| 1373 | 12.Now repeat step 4 again |
| 1374 | 13.Verify that now, ping gets success |
| 1375 | 14.Verify ping success flows in OvS |
| 1376 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1377 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1378 | def test_vsg_for_extract_all_compute_stats_from_all_vcpe_containers(self): |
| 1379 | """ |
| 1380 | Algo: |
| 1381 | 1.Create a vSG VM in compute node |
| 1382 | 2.Create 10 vCPE containers in VM |
| 1383 | 3.Ensure vSG VM and vCPE containers created properly |
| 1384 | 4.Login to all vCPE containers |
| 1385 | 4.Get all compute stats from all vCPE containers |
| 1386 | 5.Verify the stats # verification method need to add |
| 1387 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1388 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1389 | def test_vsg_for_extract_dns_stats_from_all_vcpe_containers(self): |
| 1390 | """ |
| 1391 | Algo: |
| 1392 | 1.Create a vSG VM in compute node |
| 1393 | 2.Create 10 vCPE containers in VM |
| 1394 | 3.Ensure vSG VM and vCPE containers created properly |
| 1395 | 4.From 10 subscribers, send ping to valid and invalid dns hosts |
| 1396 | 5.Verify dns resolves and ping success for valid dns hosts |
| 1397 | 6.Verify ping fails for invalid dns hosts |
| 1398 | 7.Verify dns host name resolve flows in OvS |
| 1399 | 8.Login to all 10 vCPE containers |
| 1400 | 9.Extract all dns stats |
| 1401 | 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios |
| 1402 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1403 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1404 | def test_vsg_for_subscriber_access_two_vsg_services(self): |
| 1405 | """ |
| 1406 | # Intention is to verify if subscriber can reach internet via two vSG VMs |
| 1407 | Algo: |
| 1408 | 1.Create two vSG VMs for two services in compute node |
| 1409 | 2.Create one vCPE container in each VM for one subscriber |
| 1410 | 3.Ensure VMs and containers created properly |
| 1411 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 1412 | 5.Verify ping gets success |
| 1413 | 6.Verify ping success flows in OvS |
| 1414 | 7.Now repeat step 4 with stag corresponds to vSG-2 VM |
| 1415 | 8.Verify that ping again success |
| 1416 | 9.Verify ping success flows in OvS |
| 1417 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1418 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1419 | def test_vsg_for_subscriber_access_service2_if_service1_goes_down(self): |
| 1420 | """ |
| 1421 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down |
| 1422 | Algo: |
| 1423 | 1.Create two vSG VMs for two services in compute node |
| 1424 | 2.Create one vCPE container in each VM for one subscriber |
| 1425 | 3.Ensure VMs and containers created properly |
| 1426 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 1427 | 5.Verify ping gets success |
| 1428 | 6.Verify ping success flows in OvS |
| 1429 | 7.Down the vSG-1 VM |
| 1430 | 8.Now repeat step 4 |
| 1431 | 9.Verify that ping fails as vSG-1 is down |
| 1432 | 10.Repeat step 4 with stag corresponding to vSG-2 |
| 1433 | 9.Verify ping success and flows added in OvS |
| 1434 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1435 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1436 | def test_vsg_for_subscriber_access_service2_if_service1_goes_restart(self): |
| 1437 | """ |
| 1438 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts |
| 1439 | Algo: |
| 1440 | 1.Create two vSG VMs for two services in compute node |
| 1441 | 2.Create one vCPE container in each VM for one subscriber |
| 1442 | 3.Ensure VMs and containers created properly |
| 1443 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 1444 | 5.Verify ping gets success |
| 1445 | 6.Verify ping success flows added in OvS |
| 1446 | 7.Now restart vSG-1 VM |
| 1447 | 8.Now repeat step 4 while vSG-1 VM restarts |
| 1448 | 9.Verify that ping fails as vSG-1 is restarting |
| 1449 | 10.Repeat step 4 with stag corresponding to vSG-2 while vSG-1 VM restarts |
| 1450 | 11.Verify ping success and flows added in OvS |
| 1451 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1452 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1453 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_goes_down(self): |
| 1454 | """ |
| 1455 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down |
| 1456 | Algo: |
| 1457 | 1.Create a vSG VM in compute node |
| 1458 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 1459 | 3.Ensure VM and containers created properly |
| 1460 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 1461 | 5.Verify ping gets success |
| 1462 | 6.Verify ping success flows added in OvS |
| 1463 | 7.Now stop vCPE-1 container |
| 1464 | 8.Now repeat step 4 |
| 1465 | 9.Verify that ping fails as vCPE-1 container is down |
| 1466 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container |
| 1467 | 11.Verify ping success and flows added in OvS |
| 1468 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1469 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1470 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_restart(self): |
| 1471 | """ |
| 1472 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts |
| 1473 | Algo: |
| 1474 | 1.Create a vSG VM in compute node |
| 1475 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 1476 | 3.Ensure VM and containers created properly |
| 1477 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 1478 | 5.Verify ping gets success |
| 1479 | 6.Verify ping success flows added in OvS |
| 1480 | 7.Now restart vCPE-1 container |
| 1481 | 8.Now repeat step 4 while vCPE-1 restarts |
| 1482 | 9.Verify that ping fails as vCPE-1 container is restarts |
| 1483 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 restarts |
| 1484 | 11..Verify ping success and flows added in OvS |
| 1485 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1486 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1487 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_pause(self): |
| 1488 | """ |
| 1489 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 paused |
| 1490 | Algo: |
| 1491 | 1.Create a vSG VM in compute node |
| 1492 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 1493 | 3.Ensure VM and containers created properly |
| 1494 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 1495 | 5.Verify ping gets success |
| 1496 | 6.Verify ping success flows added in OvS |
| 1497 | 7.Now pause vCPE-1 container |
| 1498 | 8.Now repeat step 4 while vCPE-1 in pause state |
| 1499 | 9.Verify that ping fails as vCPE-1 container in pause state |
| 1500 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 in pause state |
| 1501 | 11.Verify ping success and flows added in OvS |
| 1502 | """ |
| 1503 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_removed(self): |
| 1504 | """ |
| 1505 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 removed |
| 1506 | Algo: |
| 1507 | 1.Create a vSG VM in compute node |
| 1508 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 1509 | 3.Ensure VM and containers created properly |
| 1510 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 1511 | 5.Verify ping gets success |
| 1512 | 6.Verify ping success flows added in OvS |
| 1513 | 7.Now remove vCPE-1 container |
| 1514 | 8.Now repeat step 4 |
| 1515 | 9.Verify that ping fails as vCPE-1 container removed |
| 1516 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container |
| 1517 | 11.Verify ping success and flows added in OvS |
| 1518 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1519 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1520 | def test_vsg_for_vcpe_instance_removed_and_added_again(self): |
| 1521 | """ |
| 1522 | Algo: |
| 1523 | 1.Create a vSG VM in compute node |
| 1524 | 2.Create a vCPE container in vSG VM |
| 1525 | 3.Ensure VM and containers created properly |
| 1526 | 4.From subscriber end, send ping to public IP |
| 1527 | 5.Verify ping gets success |
| 1528 | 6.Verify ping success flows added in OvS |
| 1529 | 7.Now remove vCPE container in vSG VM |
| 1530 | 8.Now repeat step 4 |
| 1531 | 9.Verify that ping fails as vCPE container removed |
| 1532 | 10.Create the vCPE container again for the same subscriber |
| 1533 | 11.Ensure that vCPE created now |
| 1534 | 12.Now repeat step 4 |
| 1535 | 13.Verify ping success and flows added in OvS |
| 1536 | """ |
A R Karthick | 6375149 | 2017-03-22 09:28:01 -0700 | [diff] [blame] | 1537 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 1538 | def test_vsg_for_vsg_vm_removed_and_added_again(self): |
| 1539 | """ |
| 1540 | Algo: |
| 1541 | 1.Create a vSG VM in compute node |
| 1542 | 2.Create a vCPE container in vSG VM |
| 1543 | 3.Ensure VM and containers created properly |
| 1544 | 4.From subscriber end, send ping to public IP |
| 1545 | 5.Verify ping gets success |
| 1546 | 6.Verify ping success flows added in OvS |
| 1547 | 7.Now remove vSG VM |
| 1548 | 8.Now repeat step 4 |
| 1549 | 9.Verify that ping fails as vSG VM not exists |
| 1550 | 10.Create the vSG VM and vCPE container in VM again |
| 1551 | 11.Ensure that vSG and vCPE created |
| 1552 | 12.Now repeat step 4 |
| 1553 | 13.Verify ping success and flows added in OvS |
| 1554 | """ |
| 1555 | |
| 1556 | #Test vSG - Subscriber Configuration |
| 1557 | def test_vsg_for_configuring_new_subscriber_in_vcpe(self): |
| 1558 | """ |
| 1559 | Algo: |
| 1560 | 1.Create a vSG VM in compute node |
| 1561 | 2.Create a vCPE container in vSG VM |
| 1562 | 3.Ensure VM and containers created properly |
| 1563 | 4.Configure a subscriber in XOS and assign a service id |
| 1564 | 5.Set the admin privileges to the subscriber |
| 1565 | 6.Verify subscriber configuration is success |
| 1566 | """ |
| 1567 | def test_vsg_for_adding_subscriber_devices_in_vcpe(self): |
| 1568 | """ |
| 1569 | Algo: |
| 1570 | 1.Create a vSG VM in compute node |
| 1571 | 2.Create a vCPE container in vSG VM |
| 1572 | 3.Ensure VM and containers created properly |
| 1573 | 4.Configure a subscriber in XOS and assign a service id |
| 1574 | 5.Verify subscriber successfully configured in vCPE |
| 1575 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1576 | 7.Verify all devices ( Macs ) added successfully |
| 1577 | """ |
| 1578 | def test_vsg_for_removing_subscriber_devices_in_vcpe(self): |
| 1579 | """ |
| 1580 | Algo: |
| 1581 | 1.Create a vSG VM in compute node |
| 1582 | 2.Create a vCPE container in vSG VM |
| 1583 | 3.Ensure VM and containers created properly |
| 1584 | 4.Configure a subscriber in XOS and assign a service id |
| 1585 | 5.Verify subscriber successfully configured |
| 1586 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1587 | 7.Verify all devices ( Macs ) added successfully |
| 1588 | 8.Now remove All the added devices in XOS |
| 1589 | 9.Verify all the devices removed |
| 1590 | """ |
| 1591 | def test_vsg_for_modify_subscriber_devices_in_vcpe(self): |
| 1592 | """ |
| 1593 | Algo: |
| 1594 | 1.Create a vSG VM in compute node |
| 1595 | 2.Create a vCPE container in vSG VM |
| 1596 | 3.Ensure VM and containers created properly |
| 1597 | 4.Configure a user in XOS and assign a service id |
| 1598 | 5.Verify subscriber successfully configured in vCPE. |
| 1599 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1600 | 7.Verify all devices ( Macs ) added successfully |
| 1601 | 8.Now remove few devices in XOS |
| 1602 | 9.Verify devices removed successfully |
| 1603 | 10.Now add few additional devices in XOS under the same subscriber admin group |
| 1604 | 11.Verify newly added devices successfully added |
| 1605 | """ |
| 1606 | def test_vsg_for_vcpe_login_fails_with_incorrect_subscriber_credentials(self): |
| 1607 | """ |
| 1608 | Algo: |
| 1609 | 1.Create a vSG VM in compute node |
| 1610 | 2.Create a vCPE container in vSG VM |
| 1611 | 3.Ensure VM and containers created properly |
| 1612 | 4.Configure a subscriber in XOS and assign a service id |
| 1613 | 5.Verify subscriber successfully configured |
| 1614 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1615 | 7.Verify all devices ( Macs ) added successfully |
| 1616 | 8.Login vCPE with credentials with which subscriber configured |
| 1617 | 9.Verify subscriber successfully logged in |
| 1618 | 10.Logout and login again with incorrect credentials ( either user name or password ) |
| 1619 | 11.Verify login attempt to vCPE fails wtih incorrect credentials |
| 1620 | """ |
| 1621 | def test_vsg_for_subscriber_configuration_in_vcpe_retain_after_vcpe_restart(self): |
| 1622 | """ |
| 1623 | Algo: |
| 1624 | 1.Create a vSG VM in compute node |
| 1625 | 2.Create a vCPE container in vSG VM |
| 1626 | 3.Ensure VM and containers created properly |
| 1627 | 4.Configure a subscriber in XOS and assign a service id |
| 1628 | 5.Verify subscriber successfully configured |
| 1629 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1630 | 7.Verify all devices ( Macs ) added successfully |
| 1631 | 8.Restart vCPE ( locate backup config path while restart ) |
| 1632 | 9.Verify subscriber details in vCPE after restart should be same as before the restart |
| 1633 | """ |
| 1634 | def test_vsg_for_create_multiple_vcpe_instances_and_configure_subscriber_in_each_instance(self): |
| 1635 | """ |
| 1636 | Algo: |
| 1637 | 1.Create a vSG VM in compute node |
| 1638 | 2.Create 2 vCPE containers in vSG VM |
| 1639 | 3.Ensure VM and containers created properly |
| 1640 | 4.Configure a subscriber in XOS for each vCPE instance and assign a service id |
| 1641 | 5.Verify subscribers successfully configured |
| 1642 | 6.Now login vCPE-2 with subscriber-1 credentials |
| 1643 | 7.Verify login fails |
| 1644 | 8.Now login vCPE-1 with subscriber-2 credentials |
| 1645 | 9.Verify login fails |
| 1646 | 10.Now login vCPE-1 with subscriber-1 and vCPE-2 with subscriber-2 credentials |
| 1647 | 11.Verify that both the subscribers able to login to their respective vCPE containers |
| 1648 | """ |
| 1649 | def test_vsg_for_same_subscriber_can_be_configured_for_multiple_services(self): |
| 1650 | """ |
| 1651 | Algo: |
| 1652 | 1.Create 2 vSG VMs in compute node |
| 1653 | 2.Create a vCPE container in each vSG VM |
| 1654 | 3.Ensure VMs and containers created properly |
| 1655 | 4.Configure same subscriber in XOS for each vCPE instance and assign a service id |
| 1656 | 5.Verify subscriber successfully configured |
| 1657 | 6.Now login vCPE-1 with subscriber credentials |
| 1658 | 7.Verify login success |
| 1659 | 8.Now login vCPE-2 with the same subscriber credentials |
| 1660 | 9.Verify login success |
| 1661 | """ |
| 1662 | |
| 1663 | #Test Example Service |
| 1664 | def test_vsg_for_subcriber_avail_example_service_running_in_apache_server(self): |
| 1665 | """ |
| 1666 | Algo: |
| 1667 | 1.Create a vSG VM in compute node |
| 1668 | 2.Create a vCPE container in each vSG VM |
| 1669 | 3.Ensure VM and container created properly |
| 1670 | 4.Configure a subscriber in XOS for the vCPE instance and assign a service id |
| 1671 | 5.On-board an example service into cord pod |
| 1672 | 6.Create a VM in compute node and run the example service ( Apache server ) |
| 1673 | 7.Configure the example service with service specific and subscriber specific messages |
| 1674 | 8.Verify example service on-boarded successfully |
| 1675 | 9.Verify example service running in VM |
| 1676 | 10.Run a curl command from subscriber to reach example service |
| 1677 | 11.Verify subscriber can successfully reach example service via vSG |
| 1678 | 12.Verify that service specific and subscriber specific messages |
| 1679 | """ |
| 1680 | def test_vsg_for_subcriber_avail_example_service_running_in_apache_server_after_service_restart(self): |
| 1681 | """ |
| 1682 | Algo: |
| 1683 | 1.Create a vSG VM in compute node |
| 1684 | 2.Create a vCPE container in each vSG VM |
| 1685 | 3.Ensure VM and container created properly |
| 1686 | 4.Configure a subscriber in XOS for the vCPE instance and assign a service id |
| 1687 | 5.On-board an example service into cord pod |
| 1688 | 6.Create a VM in compute node and run the example service ( Apache server ) |
| 1689 | 7.Configure the example service with service specific and subscriber specific messages |
| 1690 | 8.Verify example service on-boarded successfully |
| 1691 | 9.Verify example service running in VM |
| 1692 | 10.Run a curl command from subscriber to reach example service |
| 1693 | 11.Verify subscriber can successfully reach example service via vSG |
| 1694 | 12.Verify that service specific and subscriber specific messages |
| 1695 | 13.Restart example service running in VM |
| 1696 | 14.Repeat step 10 |
| 1697 | 15.Verify the same results as mentioned in steps 11, 12 |
| 1698 | """ |
| 1699 | |
| 1700 | #vCPE Firewall Functionality |
| 1701 | def test_vsg_firewall_for_creating_acl_rule_based_on_source_ip(self): |
| 1702 | """ |
| 1703 | Algo: |
| 1704 | 1.Create a vSG VM in compute node |
| 1705 | 2.Create vCPE container in the VM |
| 1706 | 3.Ensure vSG VM and vCPE container created properly |
| 1707 | 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP |
| 1708 | 5.Bound the acl rule to WAN interface of vCPE |
| 1709 | 6.Verify configuration in vCPE is success |
| 1710 | 8.Verify flows added in OvS |
| 1711 | """ |
| 1712 | def test_vsg_firewall_for_creating_acl_rule_based_on_destination_ip(self): |
| 1713 | """ |
| 1714 | Algo: |
| 1715 | 1.Create a vSG VM in compute node |
| 1716 | 2.Create vCPE container in the VM |
| 1717 | 3.Ensure vSG VM and vCPE container created properly |
| 1718 | 4.Configure ac acl rule in vCPE to deny IP traffic to a destination ip |
| 1719 | 5.Bound the acl rule to WAN interface of vCPE |
| 1720 | 6.Verify configuration in vCPE is success |
| 1721 | 8.Verify flows added in OvS |
| 1722 | """ |
| 1723 | def test_vsg_firewall_for_acl_deny_rule_based_on_source_ip_traffic(self): |
| 1724 | """ |
| 1725 | Algo: |
| 1726 | 1.Create a vSG VM in compute node |
| 1727 | 2.Create vCPE container in the VM |
| 1728 | 3.Ensure vSG VM and vCPE container created properly |
| 1729 | 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP |
| 1730 | 5.Bound the acl rule to WAN interface of vCPE |
| 1731 | 6.From subscriber, send ping to the denied IP address |
| 1732 | 7.Verify that ping fails as vCPE denies ping response |
| 1733 | 8.Verify flows added in OvS |
| 1734 | """ |
| 1735 | def test_vsg_firewall_for_acl_deny_rule_based_on_destination_ip_traffic(self): |
| 1736 | """ |
| 1737 | Algo: |
| 1738 | 1.Create a vSG VM in compute node |
| 1739 | 2.Create vCPE container in the VM |
| 1740 | 3.Ensure vSG VM and vCPE container created properly |
| 1741 | 4.Configure ac acl rule in vCPE to deny IP traffic to a destination IP |
| 1742 | 5.Bound the acl rule to WAN interface of vCPE |
| 1743 | 6.From subscriber, send ping to the denied IP address |
| 1744 | 7.Verify that ping fails as vCPE drops the ping request at WAN interface |
| 1745 | 8.Verify flows added in OvS |
| 1746 | """ |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 1747 | |
| 1748 | def test_vsg_dnsmasq(self): |
| 1749 | pass |
| 1750 | |
| 1751 | def test_vsg_with_external_parental_control_family_shield_for_filter(self): |
| 1752 | pass |
| 1753 | |
| 1754 | def test_vsg_with_external_parental_control_with_answerx(self): |
| 1755 | pass |
| 1756 | |
| 1757 | def test_vsg_for_subscriber_upstream_bandwidth(self): |
| 1758 | pass |
| 1759 | |
| 1760 | def test_vsg_for_subscriber_downstream_bandwidth(self): |
| 1761 | pass |
| 1762 | |
| 1763 | def test_vsg_for_diagnostic_run_of_traceroute(self): |
| 1764 | pass |
| 1765 | |
| 1766 | def test_vsg_for_diagnostic_run_of_tcpdump(self): |
| 1767 | pass |
| 1768 | |
| 1769 | def test_vsg_for_iptable_rules(self): |
| 1770 | pass |
| 1771 | |
| 1772 | def test_vsg_for_iptables_with_neutron(self): |
| 1773 | pass |