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