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