blob: 38f5c2e6dfc6889b1d29038afa763e54a64e0559 [file] [log] [blame]
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Chetan Gaonker52418832017-01-26 23:03:13 +000017#copyright 2016-present Ciena Corporation
18#
19# Licensed under the Apache License, Version 2.0 (the "License");
20# you may not use this file except in compliance with the License.
21# You may obtain a copy of the License at
22#
23# http://www.apache.org/licenses/LICENSE-2.0
24#
25# Unless required by applicable law or agreed to in writing, software
26# distributed under the License is distributed on an "AS IS" BASIS,
27# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28# See the License for the specific language governing permissions and
29# limitations under the License.
30#
A R Karthickd0fdf3b2017-03-21 16:54:22 -070031import time
32import os
A.R Karthick282f0d32017-03-28 16:43:59 -070033import sys
34import json
Chetan Gaonker0bf76312017-05-09 16:48:10 +000035import requests
Chetan Gaonker52418832017-01-26 23:03:13 +000036from nose.tools import *
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +000037from twisted.internet import defer
38from nose.twistedtools import reactor, deferred
A.R Karthick33cfdbe2017-03-17 18:03:48 -070039from CordTestUtils import *
Chetan Gaonker52418832017-01-26 23:03:13 +000040from OltConfig import OltConfig
Chetan Gaonker52418832017-01-26 23:03:13 +000041from onosclidriver import OnosCliDriver
A.R Karthick9ccd0d02017-03-16 17:11:08 -070042from SSHTestAgent import SSHTestAgent
Chetan Gaonker52418832017-01-26 23:03:13 +000043from CordLogger import CordLogger
A R Karthickd0fdf3b2017-03-21 16:54:22 -070044from VSGAccess import VSGAccess
A R Karthick933f5b52017-03-27 15:27:16 -070045from CordTestUtils import log_test as log
A R Karthick9dc6e922017-07-12 14:40:16 -070046from CordTestConfig import setup_module, running_on_ciab, teardown_module
A.R Karthicka9b594d2017-03-29 16:25:22 -070047from OnosCtrl import OnosCtrl
A R Karthickb608d402017-06-02 11:48:41 -070048from CordContainer import Onos
A R Karthicked3a2ca2017-07-06 15:50:03 -070049from CordSubscriberUtils import CordSubscriberUtils, XosUtils
Chetan Gaonker52418832017-01-26 23:03:13 +000050log.setLevel('INFO')
51
52class vsg_exchange(CordLogger):
53 ONOS_INSTANCES = 3
54 V_INF1 = 'veth0'
55 device_id = 'of:' + get_mac()
Chetan Gaonker52418832017-01-26 23:03:13 +000056 TEST_IP = '8.8.8.8'
57 HOST = "10.1.0.1"
58 USER = "vagrant"
59 PASS = "vagrant"
A R Karthick63751492017-03-22 09:28:01 -070060 head_node = os.getenv('HEAD_NODE', 'prod')
A.R Karthick9ccd0d02017-03-16 17:11:08 -070061 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
A R Karthick03f40aa2017-03-20 19:33:55 -070062 test_path = os.path.dirname(os.path.realpath(__file__))
A.R Karthick5968e0d2017-05-16 14:50:46 -070063 olt_conf_file = os.getenv('OLT_CONFIG_FILE', os.path.join(test_path, '..', 'setup/olt_config.json'))
A.R Karthick282f0d32017-03-28 16:43:59 -070064 restApiXos = None
A R Karthicked3a2ca2017-07-06 15:50:03 -070065 cord_subscriber = None
66 SUBSCRIBER_ACCOUNT_NUM = 200
67 SUBSCRIBER_S_TAG = 304
68 SUBSCRIBER_C_TAG = 304
69 SUBSCRIBERS_PER_S_TAG = 8
A R Karthickb0cec7c2017-04-21 10:42:54 -070070 subscriber_info = []
71 volt_subscriber_info = []
A R Karthick9a16a112017-04-07 15:40:05 -070072 restore_methods = []
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +000073 TIMEOUT=120
A.R Karthickb145da82017-04-20 14:45:43 -070074 FABRIC_PORT_HEAD_NODE = 1
75 FABRIC_PORT_COMPUTE_NODE = 2
76 APP_NAME = 'org.ciena.xconnect'
77 APP_FILE = os.path.join(test_path, '..', 'apps/xconnect-1.0-SNAPSHOT.oar')
A.R Karthick50f4d9a2017-04-20 16:44:19 -070078 NUM_SUBSCRIBERS = 5
A R Karthick0a4ca3a2017-03-30 09:36:53 -070079
80 @classmethod
A R Karthick037cb982017-07-07 17:35:30 -070081 def setUpCordApi(cls, **subscriber_config):
82 num_subscribers = subscriber_config.get('num_subscribers', cls.NUM_SUBSCRIBERS)
83 account_num = subscriber_config.get('account_num', cls.SUBSCRIBER_ACCOUNT_NUM)
84 s_tag = subscriber_config.get('s_tag', cls.SUBSCRIBER_S_TAG)
85 c_tag = subscriber_config.get('c_tag', cls.SUBSCRIBER_C_TAG)
86 subscribers_per_s_tag = subscriber_config.get('subscribers_per_s_tag', cls.SUBSCRIBERS_PER_S_TAG)
A R Karthicked3a2ca2017-07-06 15:50:03 -070087 cls.cord_subscriber = CordSubscriberUtils(num_subscribers,
A R Karthick037cb982017-07-07 17:35:30 -070088 account_num = account_num,
89 s_tag = s_tag,
90 c_tag = c_tag,
91 subscribers_per_s_tag = subscribers_per_s_tag)
A R Karthicked3a2ca2017-07-06 15:50:03 -070092 cls.restApiXos = XosUtils.getRestApi()
A R Karthick97e08852017-04-26 10:06:38 -070093
94 @classmethod
A R Karthickb0cec7c2017-04-21 10:42:54 -070095 def closeVCPEAccess(cls, volt_subscriber_info):
A R Karthick5d30b3c2017-04-27 10:25:40 -070096 OnosCtrl.uninstall_app(cls.APP_NAME, onos_ip = cls.HEAD_NODE)
A.R Karthickb145da82017-04-20 14:45:43 -070097
98 @classmethod
A R Karthickb0cec7c2017-04-21 10:42:54 -070099 def openVCPEAccess(cls, volt_subscriber_info):
A.R Karthickb145da82017-04-20 14:45:43 -0700100 """
A R Karthickb0cec7c2017-04-21 10:42:54 -0700101 This code is used to configure leaf switch for head node access to compute node over fabric.
102 Care is to be taken to avoid overwriting existing/default vcpe flows.
103 The access is opened for generated subscriber info which should not overlap.
104 We target the fabric onos instance on head node.
A.R Karthickb145da82017-04-20 14:45:43 -0700105 """
A R Karthickb608d402017-06-02 11:48:41 -0700106 version = Onos.getVersion(onos_ip = cls.HEAD_NODE)
107 app_version = '1.0-SNAPSHOT'
108 major = int(version.split('.')[0])
109 minor = int(version.split('.')[1])
110 if major > 1:
111 app_version = '2.0-SNAPSHOT'
112 elif major == 1 and minor > 10:
113 app_version = '2.0-SNAPSHOT'
114 cls.APP_FILE = os.path.join(cls.test_path, '..', 'apps/xconnect-{}.oar'.format(app_version))
A.R Karthickb145da82017-04-20 14:45:43 -0700115 OnosCtrl.install_app(cls.APP_FILE, onos_ip = cls.HEAD_NODE)
116 time.sleep(2)
A R Karthickb0cec7c2017-04-21 10:42:54 -0700117 s_tags = map(lambda tenant: int(tenant['voltTenant']['s_tag']), volt_subscriber_info)
118 #only get unique vlan tags
119 s_tags = list(set(s_tags))
A.R Karthickb145da82017-04-20 14:45:43 -0700120 devices = OnosCtrl.get_device_ids(controller = cls.HEAD_NODE)
A R Karthickb0cec7c2017-04-21 10:42:54 -0700121 if devices:
122 device_config = {}
123 for device in devices:
124 device_config[device] = []
125 for s_tag in s_tags:
126 xconnect_config = {'vlan': s_tag, 'ports' : [ cls.FABRIC_PORT_HEAD_NODE, cls.FABRIC_PORT_COMPUTE_NODE ] }
127 device_config[device].append(xconnect_config)
A.R Karthickb145da82017-04-20 14:45:43 -0700128
A R Karthickb0cec7c2017-04-21 10:42:54 -0700129 cfg = { 'apps' : { 'org.ciena.xconnect' : { 'xconnectTestConfig' : device_config } } }
130 OnosCtrl.config(cfg, controller = cls.HEAD_NODE)
A.R Karthickb145da82017-04-20 14:45:43 -0700131
132 @classmethod
A R Karthick037cb982017-07-07 17:35:30 -0700133 def vsgSetup(cls, **subscriber_config):
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700134 cls.controllers = get_controllers()
135 cls.controller = cls.controllers[0]
136 cls.cli = None
A R Karthick19771192017-04-25 14:57:05 -0700137 cls.on_pod = running_on_pod()
138 cls.on_ciab = running_on_ciab()
A R Karthick03f40aa2017-03-20 19:33:55 -0700139 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
140 cls.vcpes = cls.olt.get_vcpes()
141 cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp')
A R Karthick035d2e22017-04-25 13:53:00 -0700142 cls.vcpes_reserved = cls.olt.get_vcpes_by_type('reserved')
143 cls.dhcp_vcpes_reserved = [ 'vcpe{}.{}.{}'.format(i, cls.vcpes_reserved[i]['s_tag'], cls.vcpes_reserved[i]['c_tag'])
144 for i in xrange(len(cls.vcpes_reserved)) ]
145 cls.untagged_dhcp_vcpes_reserved = [ 'vcpe{}'.format(i) for i in xrange(len(cls.vcpes_reserved)) ]
146 cls.container_vcpes_reserved = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ]
147 vcpe_dhcp_reserved = None
148 vcpe_container_reserved = None
149 if cls.vcpes_reserved:
150 vcpe_dhcp_reserved = cls.dhcp_vcpes_reserved[0]
A R Karthick19771192017-04-25 14:57:05 -0700151 if cls.on_pod is False:
A R Karthick035d2e22017-04-25 13:53:00 -0700152 vcpe_dhcp_reserved = cls.untagged_dhcp_vcpes_reserved[0]
153 vcpe_container_reserved = cls.container_vcpes_reserved[0]
154
155 cls.vcpe_dhcp_reserved = vcpe_dhcp_reserved
156 cls.vcpe_container_reserved = vcpe_container_reserved
157 dhcp_vcpe_offset = len(cls.vcpes_reserved)
A R Karthick927129c2017-04-25 14:08:02 -0700158 cls.dhcp_vcpes = [ 'vcpe{}.{}.{}'.format(i+dhcp_vcpe_offset, cls.vcpes_dhcp[i]['s_tag'], cls.vcpes_dhcp[i]['c_tag'])
159 for i in xrange(len(cls.vcpes_dhcp)) ]
160 cls.untagged_dhcp_vcpes = [ 'vcpe{}'.format(i+dhcp_vcpe_offset) for i in xrange(len(cls.vcpes_dhcp)) ]
161 cls.container_vcpes = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_dhcp ]
A R Karthick03f40aa2017-03-20 19:33:55 -0700162 vcpe_dhcp = None
A R Karthick03f40aa2017-03-20 19:33:55 -0700163 vcpe_container = None
164 #cache the first dhcp vcpe in the class for quick testing
165 if cls.vcpes_dhcp:
A R Karthick035d2e22017-04-25 13:53:00 -0700166 vcpe_container = cls.container_vcpes[0]
167 vcpe_dhcp = cls.dhcp_vcpes[0]
A R Karthick19771192017-04-25 14:57:05 -0700168 if cls.on_pod is False:
A R Karthick035d2e22017-04-25 13:53:00 -0700169 vcpe_dhcp = cls.untagged_dhcp_vcpes[0]
170 cls.vcpe_container = vcpe_container_reserved or vcpe_container
171 cls.vcpe_dhcp = vcpe_dhcp_reserved or vcpe_dhcp
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700172 VSGAccess.setUp()
A R Karthick037cb982017-07-07 17:35:30 -0700173 cls.setUpCordApi(**subscriber_config)
A R Karthick19771192017-04-25 14:57:05 -0700174 if cls.on_pod is True:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700175 cls.openVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Chetan Gaonker52418832017-01-26 23:03:13 +0000176
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700177 @classmethod
A R Karthick037cb982017-07-07 17:35:30 -0700178 def setUpClass(cls):
179 num_subscribers = max(cls.NUM_SUBSCRIBERS, 5)
180 cls.vsgSetup(num_subscribers = num_subscribers)
181
182 @classmethod
183 def vsgTeardown(cls):
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700184 VSGAccess.tearDown()
A R Karthick19771192017-04-25 14:57:05 -0700185 if cls.on_pod is True:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700186 cls.closeVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Chetan Gaonker52418832017-01-26 23:03:13 +0000187
A R Karthick037cb982017-07-07 17:35:30 -0700188 @classmethod
189 def tearDownClass(cls):
190 cls.vsgTeardown()
191
Chetan Gaonker52418832017-01-26 23:03:13 +0000192 def onos_shutdown(self, controller = None):
193 status = True
A R Karthickb608d402017-06-02 11:48:41 -0700194 cli = Onos.cliEnter(onos_ip = controller)
Chetan Gaonker52418832017-01-26 23:03:13 +0000195 try:
A R Karthickb608d402017-06-02 11:48:41 -0700196 cli.shutdown(timeout = 10)
Chetan Gaonker52418832017-01-26 23:03:13 +0000197 except:
198 log.info('Graceful shutdown of ONOS failed for controller: %s' %controller)
199 status = False
200
A R Karthickb608d402017-06-02 11:48:41 -0700201 Onos.cliExit(cli)
Chetan Gaonker52418832017-01-26 23:03:13 +0000202 return status
203
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700204 def log_set(self, level = None, app = 'org.onosproject'):
205 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000206
A R Karthick9a16a112017-04-07 15:40:05 -0700207 @classmethod
208 def get_dhcp(cls, vcpe, mgmt = 'eth0'):
209 """Get DHCP for vcpe interface saving management settings"""
210
211 def put_dhcp():
212 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
213
214 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
215 if vcpe_ip is not None:
216 cls.restore_methods.append(put_dhcp)
217 return vcpe_ip
218
219 @classmethod
220 def config_restore(cls):
221 """Restore the vsg test configuration on test case failures"""
222 for restore_method in cls.restore_methods:
223 restore_method()
224
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000225 def get_vsg_vcpe_pair(self):
226 vcpes = self.vcpes_dhcp
227 vcpe_containers = []
228 vsg_vcpe = {}
229 for vcp in vcpes:
230 vcpe_container = 'vcpe-{}-{}'.format(vcp['s_tag'], vcp['c_tag'])
231 vcpe_containers.append(vcpe_container)
232 vsg = VSGAccess.get_vcpe_vsg(vcpe_container)
233 vsg_vcpe[vcpe_container]=str(vsg.get_ip())
234 return vsg_vcpe
235
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000236 def get_vcpe_containers_and_interfaces(self):
237 vcpe_containers = {}
238 vcpe_interfaces = []
239 vcpes = self.vcpes_dhcp
240 count = 0
241 for vcpe in vcpes:
242 vcpe_intf = 'vcpe{}.{}.{}'.format(count,vcpe['s_tag'],vcpe['c_tag'])
243 vcpe_interfaces.append(vcpe_intf)
244 vcpe_container = 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag'])
245 vcpe_containers[vcpe_intf] = vcpe_container
246 count += 1
247 log.info('vcpe interfaces are %s'%vcpe_interfaces)
248 log.info('vcpe containers are %s'%vcpe_containers)
249 return vcpe_interfaces,vcpe_containers
250
251 def get_vcpe_interface_dhcp_ip(self,vcpe=None):
252 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000253 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000254 st, _ = getstatusoutput('dhclient {}'.format(vcpe))
255 vcpe_ip = get_ip(vcpe)
256 return vcpe_ip
257
258 def release_vcpe_interface_dhcp_ip(self,vcpe=None):
259 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000260 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000261 st, _ = getstatusoutput('dhclient {} -r'.format(vcpe))
262 vcpe_ip = get_ip(vcpe)
263 assert_equal(vcpe_ip, None)
264
265 def add_static_route_via_vcpe_interface(self, routes, vcpe=None,dhcp_ip=True):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000266 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000267 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000268 if dhcp_ip:
A R Karthick035d2e22017-04-25 13:53:00 -0700269 os.system('dhclient '+vcpe)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000270 time.sleep(1)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000271 for route in routes:
A R Karthick035d2e22017-04-25 13:53:00 -0700272 log.info('route is %s'%route)
273 cmd = 'ip route add ' + route + ' via 192.168.0.1 '+ 'dev ' + vcpe
A R Karthick035d2e22017-04-25 13:53:00 -0700274 os.system(cmd)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000275 return True
276
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000277 def del_static_route_via_vcpe_interface(self,routes,vcpe=None,dhcp_release=True):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000278 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000279 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000280 cmds = []
281 for route in routes:
A R Karthick035d2e22017-04-25 13:53:00 -0700282 cmd = 'ip route del ' + route + ' via 192.168.0.1 ' + 'dev ' + vcpe
283 os.system(cmd)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000284 if dhcp_release:
A R Karthick035d2e22017-04-25 13:53:00 -0700285 os.system('dhclient '+vcpe+' -r')
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000286 return True
287
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000288 def vsg_for_external_connectivity(self, subscriber_index, reserved = False):
289 if reserved is True:
290 if self.on_pod is True:
291 vcpe = self.dhcp_vcpes_reserved[subscriber_index]
292 else:
293 vcpe = self.untagged_dhcp_vcpes_reserved[subscriber_index]
294 else:
295 if self.on_pod is True:
296 vcpe = self.dhcp_vcpes[subscriber_index]
297 else:
298 vcpe = self.untagged_dhcp_vcpes[subscriber_index]
299 mgmt = 'eth0'
300 host = '8.8.8.8'
301 self.success = False
302 assert_not_equal(vcpe, None)
303 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
304 assert_not_equal(vcpe_ip, None)
305 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
306 log.info('Sending icmp echo requests to external network 8.8.8.8')
307 st, _ = getstatusoutput('ping -c 3 8.8.8.8')
308 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
309 assert_equal(st, 0)
310
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000311 def get_vsg_health_check(self, vsg_name=None):
312 if self.on_pod is False:
313 return
314 if vsg_name is None:
315 vcpe = self.container_vcpes_reserved[0]
316 vsg = VSGAccess.get_vcpe_vsg(vcpe)
317 status = vsg.get_health()
318 return status
319 else:
320 vsgs = VSGAccess.get_vsgs()
321 for vsg in vsgs:
322 if vsg.name == vsg_name:
323 status = vsg.get_health()
324 return status
325 return None
326
A R Karthick63751492017-03-22 09:28:01 -0700327 def test_vsg_health(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000328 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000329 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000330 1. Login to compute node VM
331 2. Get all vSGs
332 3. Ping to all vSGs
333 4. Verifying Ping success
334 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700335 status = True
A R Karthick19771192017-04-25 14:57:05 -0700336 if self.on_pod is True:
A R Karthick93ba8d02017-04-13 11:59:58 -0700337 status = VSGAccess.health_check()
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700338 assert_equal(status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000339
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000340 def test_vsg_health_check(self, vsg_name=None, verify_status=True):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000341 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000342 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000343 1. If vsg name not specified, Get vsg corresponding to vcpe
344 1. Login to compute mode VM
345 3. Ping to the vSG
346 4. Verifying Ping success
347 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000348 st = self.get_vsg_health_check(vsg_name=vsg_name)
349 assert_equal(st,verify_status)
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000350
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000351 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700352 def test_vsg_for_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000353 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000354 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000355 1. Get list of all compute nodes created using Openstack
356 2. Login to compute mode VM
357 3. Get all vSGs
358 4. Verifying atleast one compute node and one vSG created
359 """
A R Karthick035d2e22017-04-25 13:53:00 -0700360 df = defer.Deferred()
361 def vsg_for_vcpe_df(df):
A R Karthick19771192017-04-25 14:57:05 -0700362 if self.on_pod is True:
A R Karthick93ba8d02017-04-13 11:59:58 -0700363 vsgs = VSGAccess.get_vsgs()
364 compute_nodes = VSGAccess.get_compute_nodes()
365 time.sleep(14)
366 assert_not_equal(len(vsgs), 0)
367 assert_not_equal(len(compute_nodes), 0)
A R Karthick035d2e22017-04-25 13:53:00 -0700368 df.callback(0)
369 reactor.callLater(0,vsg_for_vcpe_df,df)
370 return df
Chetan Gaonker52418832017-01-26 23:03:13 +0000371
A R Karthick63751492017-03-22 09:28:01 -0700372 def test_vsg_for_login(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000373 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000374 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000375 1. Login to compute node VM
376 2. Get all vSGs
377 3. Verifying login to vSG is success
378 """
A R Karthick19771192017-04-25 14:57:05 -0700379 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700380 return
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700381 vsgs = VSGAccess.get_vsgs()
382 vsg_access_status = map(lambda vsg: vsg.check_access(), vsgs)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700383 status = filter(lambda st: st == False, vsg_access_status)
384 assert_equal(len(status), 0)
385
A R Karthick63751492017-03-22 09:28:01 -0700386 def test_vsg_for_default_route_through_testclient(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000387 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000388 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000389 1. Login to head node
390 2. Verifying for default route in lxc test client
391 """
A R Karthick19771192017-04-25 14:57:05 -0700392 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700393 return
A R Karthick63751492017-03-22 09:28:01 -0700394 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
395 cmd = "sudo lxc exec testclient -- route | grep default"
396 status, output = ssh_agent.run_cmd(cmd)
397 assert_equal(status, True)
398
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000399 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700400 def test_vsg_for_external_connectivity_through_testclient(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000401 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000402 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000403 1. Login to head node
404 2. On head node, executing ping to 8.8.8.8 from lxc test client
405 3. Verifying for the ping success
406 """
A R Karthick19771192017-04-25 14:57:05 -0700407 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700408 return
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000409 df = defer.Deferred()
410 def test_external_connectivity(df):
411 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
412 cmd = "sudo lxc exec testclient -- ping -c 3 8.8.8.8"
413 status, output = ssh_agent.run_cmd(cmd)
414 assert_equal( status, True)
415 df.callback(0)
416 reactor.callLater(0,test_external_connectivity,df)
417 return df
A R Karthick63751492017-03-22 09:28:01 -0700418
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000419 @deferred(30)
A R Karthick035d2e22017-04-25 13:53:00 -0700420 def test_vsg_for_external_connectivity(self):
421 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000422 Test Method:
A R Karthick035d2e22017-04-25 13:53:00 -0700423 1. Get dhcp IP to vcpe interface in cord-tester
424 2. Verifying vcpe interface gets dhcp IP
425 3. Ping to 8.8.8.8 and Verifying ping should success
426 4. Restoring management interface configuration in cord-tester
427 """
A R Karthick19771192017-04-25 14:57:05 -0700428 reserved = True
429 if self.on_pod:
430 reserved = self.on_ciab
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000431 df = defer.Deferred()
432 def test_external_connectivity(df):
433 self.vsg_for_external_connectivity(0, reserved = reserved)
434 df.callback(0)
435 reactor.callLater(0,test_external_connectivity,df)
436 return df
A R Karthick035d2e22017-04-25 13:53:00 -0700437
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000438 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700439 def test_vsg_for_external_connectivity_to_google(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000440 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000441 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000442 1. Get dhcp IP to vcpe interface in cord-tester
443 2. Verifying vcpe interface gets dhcp IP
444 3. Ping to www.google.com and Verifying ping should success
445 4. Restoring management interface configuration in cord-tester
446 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000447 df = defer.Deferred()
448 def test_external_connectivity(df):
449 host = 'www.google.com'
450 vcpe = self.dhcp_vcpes_reserved[0]
451 mgmt = 'eth0'
452 assert_not_equal(vcpe, None)
453 try:
454 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
455 assert_not_equal(vcpe_ip, None)
456 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
457 log.info('Sending icmp ping requests to %s' %host)
458 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
459 assert_equal(st, 0)
460 except Exception as error:
461 log.info('Got Unexpected error %s'%error)
462 raise
463 finally:
464 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
465 df.callback(0)
466 reactor.callLater(0,test_external_connectivity,df)
467 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000468
A R Karthickb2618052017-05-10 09:23:22 -0700469 def retrieve_content_from_host_to_validate_path_mtu(self, host):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000470 vcpe = self.dhcp_vcpes_reserved[0]
A R Karthickb2618052017-05-10 09:23:22 -0700471 mgmt = 'eth0'
472 assert_not_equal(vcpe, None)
473 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
474 assert_not_equal(vcpe_ip, None)
475 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
476 log.info('Initiating get requests to %s' %host)
477 r = requests.get('http://{}'.format(host))
478 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
479 return r.status_code
480
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000481 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000482 def test_vsg_to_retrieve_content_from_google_to_validate_path_mtu(self):
483 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000484 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000485 1. Get dhcp IP to vcpe interface in cord-tester
486 2. Verifying vcpe interface gets dhcp IP
487 3. Retrieve contents from www.google.com and Verify response status is 200 ok.
488 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
489 (Based on website response, size differs, needs check on MTU)
490 4. Restoring management interface configuration in cord-tester
491 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000492 df = defer.Deferred()
493 def test_external_connectivity(df):
494 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.google.com')
495 assert_equal(status_code, 200)
496 df.callback(0)
497 reactor.callLater(0,test_external_connectivity,df)
498 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000499
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000500 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000501 def test_vsg_to_retrieve_content_from_rediff_to_validate_path_mtu(self):
502 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000503 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000504 1. Get dhcp IP to vcpe interface in cord-tester
505 2. Verifying vcpe interface gets dhcp IP
506 3. Retrieve contents from www.rediff.com and Verify response status is 200 ok.
507 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
508 (Based on website response, size differs, needs check on MTU)
509 4. Restoring management interface configuration in cord-tester
510 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000511 df = defer.Deferred()
512 def test_external_connectivity(df):
513 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.rediff.com')
514 assert_equal(status_code, 200)
515 df.callback(0)
516 reactor.callLater(0,test_external_connectivity,df)
517 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000518
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000519 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000520 def test_vsg_to_retrieve_content_from_yahoo_to_validate_path_mtu(self):
521 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000522 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000523 1. Get dhcp IP to vcpe interface in cord-tester
524 2. Verifying vcpe interface gets dhcp IP
525 3. Retrieve contents from www.yahoo.com and Verify response status is 200 ok.
526 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
527 (Based on website response, size differs, needs check on MTU)
528 4. Restoring management interface configuration in cord-tester
529 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000530 df = defer.Deferred()
531 def test_external_connectivity(df):
532 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.yahoo.com')
533 assert_equal(status_code, 200)
534 df.callback(0)
535 reactor.callLater(0,test_external_connectivity,df)
536 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000537
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000538 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000539 def test_vsg_to_retrieve_content_from_facebook_to_validate_path_mtu(self):
540 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000541 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000542 1. Get dhcp IP to vcpe interface in cord-tester
543 2. Verifying vcpe interface gets dhcp IP
544 3. Retrieve contents from www.facebook.com and Verify response status is 200 ok.
545 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
546 (Based on website response, size differs, needs check on MTU)
547 4. Restoring management interface configuration in cord-tester
548 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000549 df = defer.Deferred()
550 def test_external_connectivity(df):
551 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.facebook.com')
552 assert_equal(status_code, 200)
553 df.callback(0)
554 reactor.callLater(0,test_external_connectivity,df)
555 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000556
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000557
558 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700559 def test_vsg_for_external_connectivity_to_invalid_host(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000560 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000561 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000562 1. Get dhcp IP to vcpe interface in cord-tester
563 2. Verifying vcpe interface gets dhcp IP
564 3. Ping to www.goglee.com and Verifying ping should not success
565 4. Restoring management interface configuration in cord-tester
566 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000567 df = defer.Deferred()
568 def test_external_connectivity(df):
569 host = 'www.goglee.com'
570 vcpe = self.dhcp_vcpes_reserved[0]
571 mgmt = 'eth0'
572 assert_not_equal(vcpe, None)
573 try:
574 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
575 assert_not_equal(vcpe_ip, None)
576 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
577 log.info('Sending icmp ping requests to non existent host %s' %host)
578 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
579 assert_not_equal(st, 0)
580 except Exception as error:
581 log.info('Got Unexpected error %s'%error)
582 raise
583 finally:
584 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
585 df.callback(0)
586 reactor.callLater(0,test_external_connectivity,df)
587 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000588
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000589 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700590 def test_vsg_for_external_connectivity_with_ttl_1(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000591 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000592 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000593 1. Get dhcp IP to vcpe interface in cord-tester
594 2. Verifying vcpe interface gets dhcp IP
595 3. Ping to 8.8.8.8 with ttl set to 1
596 4. Verifying ping should not success
597 5. Restoring management interface configuration in cord-tester
598 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000599 df = defer.Deferred()
600 def test_external_connectivity(df):
601 host = '8.8.8.8'
602 vcpe = self.dhcp_vcpes_reserved[0]
603 mgmt = 'eth0'
604 assert_not_equal(vcpe, None)
605 try:
606 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
607 assert_not_equal(vcpe_ip, None)
608 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
609 log.info('Sending icmp ping requests to host %s with ttl 1' %host)
610 st, _ = getstatusoutput('ping -c 1 -t 1 {}'.format(host))
611 assert_not_equal(st, 0)
612 except Exception as error:
613 log.info('Got Unexpected error %s'%error)
614 raise
615 finally:
616 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
617 df.callback(0)
618 reactor.callLater(0,test_external_connectivity,df)
619 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000620
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000621 @deferred(60)
A R Karthick63751492017-03-22 09:28:01 -0700622 def test_vsg_for_external_connectivity_with_wan_interface_toggle_in_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000623 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000624 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000625 1. Get dhcp IP to vcpe interface in cord-tester
626 2. Verifying vcpe interface gets dhcp IP
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700627 3. Ping to 8.8.8.8 and Verifying ping succeeds
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000628 4. Now down the WAN interface of vcpe
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700629 5. Ping to 8.8.8.8 and Verifying ping fails
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000630 6. Now Up the WAN interface of vcpe
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700631 7. Ping to 8.8.8.8 and Verifying ping succeeds
632 8. Restoring management interface configuration in cord-tester
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000633 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000634 df = defer.Deferred()
635 def test_external_connectivity(df):
636 if self.on_pod is False:
637 return
638 host = '8.8.8.8'
639 mgmt = 'eth0'
640 vcpe = self.dhcp_vcpes_reserved[0]
641 vcpe_name = self.container_vcpes_reserved[0]
642 assert_not_equal(vcpe_name, None)
643 assert_not_equal(vcpe, None)
644 #first get dhcp on the vcpe interface
645 try:
646 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
647 assert_not_equal(vcpe_ip, None)
648 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
649 log.info('Sending ICMP pings to host %s' %(host))
650 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
651 if st != 0:
652 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
653 assert_equal(st, 0)
654 #bring down the wan interface and check again
655 st = VSGAccess.vcpe_wan_down(vcpe_name)
656 if st is False:
657 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
658 assert_equal(st, True)
659 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
660 if st == 0:
661 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
662 assert_not_equal(st, 0)
663 st = VSGAccess.vcpe_wan_up(vcpe_name)
664 if st is False:
665 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
666 assert_equal(st, True)
667 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
668 assert_equal(st, 0)
669 except Exception as error:
670 log.info('Got Unexpected error %s'%error)
671 raise
672 finally:
673 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
674 df.callback(0)
675 reactor.callLater(0,test_external_connectivity,df)
676 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000677
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000678 @deferred(60)
A R Karthick63751492017-03-22 09:28:01 -0700679 def test_vsg_for_external_connectivity_with_lan_interface_toggle_in_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000680 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000681 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000682 1. Get dhcp IP to vcpe interface in cord-tester
683 2. Verifying vcpe interface gets dhcp IP
684 3. Ping to 8.8.8.8 and Verifying ping should success
685 4. Now down the LAN interface of vcpe
686 5. Ping to 8.8.8.8 and Verifying ping should not success
687 6. Now Up the LAN interface of vcpe
688 7. Ping to 8.8.8.8 and Verifying ping should success
689 8. Restoring management interface configuration in cord-tester
690 """
A R Karthick19771192017-04-25 14:57:05 -0700691 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700692 return
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000693 df = defer.Deferred()
694 def test_external_connectivity(df):
695 host = '8.8.8.8'
696 mgmt = 'eth0'
697 vcpe = self.dhcp_vcpes_reserved[0]
698 vcpe_name = self.container_vcpes_reserved[0]
699 assert_not_equal(vcpe, None)
700 assert_not_equal(vcpe_name, None)
701 #first get dhcp on the vcpe interface
702 try:
703 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
704 assert_not_equal(vcpe_ip, None)
705 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
706 log.info('Sending ICMP pings to host %s' %(host))
707 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
708 if st != 0:
709 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
710 assert_equal(st, 0)
711 #bring down the lan interface and check again
712 st = VSGAccess.vcpe_lan_down(vcpe_name)
713 if st is False:
714 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
715 assert_equal(st, True)
716 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
717 if st == 0:
718 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
719 assert_not_equal(st, 0)
720 st = VSGAccess.vcpe_lan_up(vcpe_name)
721 if st is False:
722 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
723 assert_equal(st, True)
724 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
725 assert_equal(st, 0)
726 except Exception as error:
727 log.info('Got Unexpected error %s'%error)
728 raise
729 finally:
730 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
731 df.callback(0)
732 reactor.callLater(0,test_external_connectivity,df)
733 return df
Chetan Gaonker52418832017-01-26 23:03:13 +0000734
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000735 @deferred(120)
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +0000736 def test_vsg_multiple_subscribers_for_same_vcpe_instance(self):
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000737 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000738 Test Method:
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000739 1. Create a vcpe instance
740 2. Create multiple vcpe interfaces in cord-tester with same s-tag and c-tag to access vcpe instance
741 3. Verify all the interfaces gets dhcp IP in same subnet
742 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000743 df = defer.Deferred()
744 def test_external_connectivity(df):
745 vcpe_intfs,containers = self.get_vcpe_containers_and_interfaces()
746 for vcpe in vcpe_intfs:
747 vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe)
748 assert_not_equal(vcpe_ip,None)
749 for vcpe in vcpe_intfs:
750 self.release_vcpe_interface_dhcp_ip(vcpe=vcpe)
751 df.callback(0)
752 reactor.callLater(0,test_external_connectivity,df)
753 return df
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000754
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000755 @deferred(120)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000756 def test_vsg_for_multiple_subscribers_with_same_vcpe_instance_and_validate_external_connectivity(self):
757 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000758 Test Method:
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000759 1. Create a vcpe instance
760 2. Create multiple vcpe interfaces in cord-tester with same s-tag and c-tag to access vcpe instance
761 3. Verify all the interfaces gets dhcp IP in same subnet
762 4. From cord-tester ping to external with vcpe interface option
763 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000764 df = defer.Deferred()
765 def test_external_connectivity(df):
766 host = '8.8.8.8'
767 vcpe_intfs, containers = self.get_vcpe_containers_and_interfaces()
768 try:
769 for vcpe in vcpe_intfs:
770 vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe)
771 assert_not_equal(vcpe_ip,None)
772 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_ip=False)
773 st, _ = getstatusoutput('ping -I {} -c 3 {}'.format(vcpe,host))
774 assert_equal(st, 0)
775 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_release=False)
776 except Exception as error:
777 log.info('Got Unexpected error %s'%error)
778 raise
779 finally:
780 for vcpe in vcpe_intfs:
781 self.release_vcpe_interface_dhcp_ip(vcpe=vcpe)
782 df.callback(0)
783 reactor.callLater(0,test_external_connectivity,df)
784 return df
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000785
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000786 @deferred(30)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000787 def test_vsg_vcpe_interface_and_validate_dhcp_ip_after_interface_toggle(self):
788 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000789 Test Method:
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000790 1. Create a vcpe instance
791 2. Create a vcpe interface in cord-tester
792 3. Verify the interface gets dhcp IP
793 4. Toggle the interface
794 5. Verify the interface gets dhcp IP
795 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000796 df = defer.Deferred()
797 def test_external_connectivity(df):
798 vcpe_intf = self.dhcp_vcpes_reserved[0]
799 host = '8.8.8.8'
800 try:
801 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
802 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
803 assert_equal(st, 0)
804 os.system('ifconfig {} down'.format(vcpe_intf))
805 time.sleep(1)
806 os.system('ifconfig {} up'.format(vcpe_intf))
807 time.sleep(1)
808 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
809 assert_equal(st, 0)
810 except Exception as error:
811 log.info('Got Unexpected error %s'%error)
812 raise
813 finally:
814 self.del_static_route_via_vcpe_interface([host], vcpe=vcpe_intf)
815 df.callback(0)
816 reactor.callLater(0,test_external_connectivity,df)
817 return df
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000818
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000819 @deferred(TIMEOUT)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000820 def test_vsg_for_external_connectivity_after_restarting_vcpe_instance(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000821 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000822 Test Method:
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000823 1. Get vSG corresponding to vcpe
824 2. Get dhcp ip to vcpe interface
825 3. Add static route to destination route in test container
826 4. From test container ping to destination route and verify ping success
827 5. Login to compute node and execute command to pause vcpe container
828 6. From test container ping to destination route and verify ping success
829 """
830 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000831 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000832 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000833 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000834 df = defer.Deferred()
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000835 def test_external_connectivity(df):
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000836 if self.on_pod is False:
837 df.callback(0)
838 return
839 host = '8.8.8.8'
840 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
841 try:
842 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
843 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
844 assert_equal(st, False)
845 st, _ = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000846 clock = 0
847 status = False
848 while(clock <= 20):
849 time.sleep(5)
850 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
851 if st == False:
852 status = True
853 break
854 clock += 5
855 assert_equal(status, True)
856 except Exception as error:
857 log.info('Got Unexpected error %s'%error)
858 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
859 raise
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000860 finally:
861 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
862 df.callback(0)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000863 reactor.callLater(0, test_external_connectivity, df)
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000864 return df
865
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000866 @nottest #Setup getting distrubed if vSG VM restart
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000867 @deferred(TIMEOUT)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000868 def test_vsg_for_external_connectivity_after_restarting_vsg_vm(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000869 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000870 Test Method:
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000871 1. Get vSG corresponding to vcpe
872 2. Get dhcp ip to vcpe interface
873 3. Add static route to destination route in test container
874 4. From test container ping to destination route and verify ping success
875 5. Login to compute node and execute command to pause vcpe container
876 6. From test container ping to destination route and verify ping success
877 """
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000878 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000879 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000880 df = defer.Deferred()
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000881 def test_external_connectivity(df):
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000882 if self.on_pod is False:
883 df.callback(0)
884 return
885 host = '8.8.8.8'
886 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
887 try:
888 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
889 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
890 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000891 vsg.reboot()
892 clock = 0
893 status = False
894 while(clock <= 30):
895 time.sleep(5)
896 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
897 if st == False:
898 status = True
899 break
900 clock += 5
901 assert_equal(status, True)
902 except Exception as error:
903 log.info('Got Unexpected error %s'%error)
904 vsg.reboot()
905 raise
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000906 finally:
907 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
908 df.callback(0)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000909 reactor.callLater(0, test_external_connectivity, df)
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000910 return df
911
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000912 @deferred(60)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000913 def test_vsg_for_external_connectivity_with_vcpe_container_paused(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000914 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000915 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000916 1. Get vSG corresponding to vcpe
917 2. Get dhcp ip to vcpe interface
918 3. Add static route to destination route in test container
919 4. From test container ping to destination route and verify ping success
920 5. Login to compute node and execute command to pause vcpe container
921 6. From test container ping to destination route and verify ping success
922 """
923 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000924 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000925 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000926 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000927 df = defer.Deferred()
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000928 def test_external_connectivity(df):
A R Karthick19771192017-04-25 14:57:05 -0700929 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700930 df.callback(0)
931 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000932 host = '8.8.8.8'
933 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
934 try:
935 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
936 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
937 assert_equal(st, False)
938 st, _ = vsg.run_cmd('sudo docker pause {}'.format(vcpe_name))
939 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
940 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000941 vsg.run_cmd('sudo docker unpause {}'.format(vcpe_name))
942 except Exception as error:
943 log.info('Got Unexpected error %s'%error)
944 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
945 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000946 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000947 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
948 df.callback(0)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000949 reactor.callLater(0, test_external_connectivity, df)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000950 return df
951
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000952 @deferred(30)
953 def test_vsg_firewall_with_deny_destination_ip_set(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000954 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000955 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000956 1. Get vSG corresponding to vcpe
957 2. Login to compute node
958 3. Execute iptable command on vcpe from compute node to deny a destination IP
959 4. From cord-tester ping to the denied IP address
960 5. Verifying that ping should not be successful
961 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000962 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000963 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000964 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000965 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000966 df = defer.Deferred()
967 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -0700968 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700969 df.callback(0)
970 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000971 host = '8.8.8.8'
972 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
973 try:
974 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
975 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
976 assert_equal(st, False)
977 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
978 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
979 assert_equal(st, True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000980 except Exception as error:
981 log.info('Got Unexpected error %s'%error)
982 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000983 finally:
984 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
985 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000986 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000987 df.callback(0)
988 reactor.callLater(0, vcpe_firewall, df)
989 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000990
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000991 @deferred(60)
992 def test_vsg_firewall_with_rule_to_add_and_delete_dest_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000993 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000994 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000995 1. Get vSG corresponding to vcpe
996 2. Login to compute node
997 3. Execute iptable command on vcpe from compute node to deny a destination IP
998 4. From cord-tester ping to the denied IP address
999 5. Verifying that ping should not be successful
1000 6. Delete the iptable rule in vcpe
1001 7. From cord-tester ping to the denied IP address
1002 8. Verifying the ping should success
1003 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001004 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001005 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001006 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001007 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001008 df = defer.Deferred()
1009 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001010 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001011 df.callback(0)
1012 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001013 host = '8.8.8.8'
1014 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1015 try:
1016 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1017 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1018 assert_equal(st, False)
1019 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1020 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1021 assert_equal(st, True)
1022 st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1023 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1024 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001025 except Exception as error:
1026 log.info('Got Unexpected error %s'%error)
1027 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1028 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001029 finally:
1030 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1031 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001032 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001033 df.callback(0)
1034 reactor.callLater(0, vcpe_firewall, df)
1035 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001036
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001037 @deferred(40)
1038 def test_vsg_firewall_verifying_reachability_for_non_blocked_dest_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001039 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001040 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001041 1. Get vSG corresponding to vcpe
1042 2. Login to compute node
1043 3. Execute iptable command on vcpe from compute node to deny a destination IP
1044 4. From cord-tester ping to the denied IP address
1045 5. Verifying that ping should not be successful
1046 6. From cord-tester ping to the denied IP address other than the denied one
1047 7. Verifying the ping should success
1048 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001049 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001050 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001051 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001052 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001053 df = defer.Deferred()
1054 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001055 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001056 df.callback(0)
1057 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001058 host1 = '8.8.8.8'
1059 host2 = '204.79.197.203'
1060 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1061 try:
1062 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
1063 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1064 assert_equal(st, False)
1065 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1066 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1067 assert_equal(st, True)
1068 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1069 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001070 except Exception as error:
1071 log.info('Got Unexpected error %s'%error)
1072 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001073 finally:
1074 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1075 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001076 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001077 df.callback(0)
1078 reactor.callLater(0, vcpe_firewall, df)
1079 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001080
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001081 @deferred(60)
1082 def test_vsg_firewall_appending_rules_with_deny_dest_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001083 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001084 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001085 1. Get vSG corresponding to vcpe
1086 2. Login to compute node
1087 3. Execute iptable command on vcpe from compute node to deny a destination IP1
1088 4. From cord-tester ping to the denied IP address IP1
1089 5. Verifying that ping should not be successful
1090 6. Execute iptable command on vcpe from compute node to deny a destination IP2
1091 6. From cord-tester ping to the denied IP address IP2
1092 7. Verifying that ping should not be successful
1093 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001094 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001095 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001096 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001097 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001098 df = defer.Deferred()
1099 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001100 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001101 df.callback(0)
1102 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001103 host1 = '8.8.8.8'
1104 host2 = '204.79.197.203'
1105 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1106 try:
1107 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
1108 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1109 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001110 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1111 assert_equal(st, False)
1112 st,_ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1113 time.sleep(1)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001114 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1115 assert_equal(st, True)
1116 st, out = getstatusoutput('ping -c 1 {}'.format(host2))
1117 log.info('host2 ping output is %s'%out)
1118 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001119 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,host2))
1120 time.sleep(1)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001121 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1122 assert_equal(st,True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001123 except Exception as error:
1124 log.info('Got Unexpected error %s'%error)
1125 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001126 finally:
1127 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1128 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1129 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001130 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001131 df.callback(0)
1132 reactor.callLater(0, vcpe_firewall, df)
1133 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001134
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001135 @deferred(TIMEOUT)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001136 def test_vsg_firewall_removing_one_rule_denying_dest_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001137 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001138 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001139 1. Get vSG corresponding to vcpe
1140 2. Login to compute node
1141 3. Execute iptable command on vcpe from compute node to deny a destination IP1
1142 4. Execute iptable command on vcpe from compute node to deny a destination IP2
1143 5. From cord-tester ping to the denied IP address IP1
1144 6. Verifying that ping should not be successful
1145 7. From cord-tester ping to the denied IP address IP2
1146 8. Verifying that ping should not be successful
1147 9. Execute iptable command on vcpe from compute node to remove deny a destination IP2 rule
1148 10. From cord-tester ping to the denied IP address IP2
1149 11. Verifying the ping should success
1150 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001151 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001152 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001153 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001154 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001155 df = defer.Deferred()
1156 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001157 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001158 df.callback(0)
1159 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001160 host1 = '8.8.8.8'
1161 host2 = '204.79.197.203'
1162 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1163 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001164 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001165 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1166 assert_equal(st, False)
1167 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1168 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1169 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1170 assert_equal(st, True)
1171 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1172 assert_equal(st,True)
1173 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1174 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1175 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001176 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1177 assert_equal(st, True)
1178 except Exception as error:
1179 log.info('Got Unexpected error %s'%error)
1180 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001181 finally:
1182 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1183 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1184 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001185 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001186 df.callback(0)
1187 reactor.callLater(0, vcpe_firewall, df)
1188 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001189
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001190 @deferred(60)
1191 def test_vsg_firewall_changing_rule_id_deny_dest_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001192 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001193 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001194 1. Get vSG corresponding to vcpe
1195 2. Login to compute node
1196 3. Execute iptable command on vcpe from compute node to deny a destination IP
1197 5. From cord-tester ping to the denied IP address IP1
1198 6. Verifying that ping should not be successful
1199 9. Execute iptable command on vcpe from compute node to change the rule ID to 2 to deny the same destination IP
1200 10. From cord-tester ping to the denied IP address IP
1201 11. Verifying that ping should not be successful
1202 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001203 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001204 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001205 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001206 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001207 df = defer.Deferred()
1208 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001209 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001210 df.callback(0)
1211 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001212 host = '8.8.8.8'
1213 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1214 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001215 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001216 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1217 assert_equal(st, False)
1218 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1219 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1220 assert_equal(st, True)
1221 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP '.format(vcpe_name,host))
1222 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1223 assert_equal(st,True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001224 except Exception as error:
1225 log.info('Got Unexpected error %s'%error)
1226 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001227 finally:
1228 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1229 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001230 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001231 df.callback(0)
1232 reactor.callLater(0, vcpe_firewall, df)
1233 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001234
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001235 @deferred(50)
1236 def test_vsg_firewall_changing_deny_rule_to_accept_dest_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001237 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001238 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001239 1. Get vSG corresponding to vcpe
1240 2. Login to compute node
1241 3. Execute iptable command on vcpe from compute node to deny a destination IP
1242 5. From cord-tester ping to the denied IP address IP1
1243 6. Verifying that ping should not be successful
1244 9. Execute iptable command on vcpe from compute node to accept the same destination IP
1245 10. From cord-tester ping to the accepted IP
1246 11. Verifying the ping should success
1247 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001248 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001249 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001250 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001251 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001252 df = defer.Deferred()
1253 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001254 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001255 df.callback(0)
1256 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001257 host = '8.8.8.8'
1258 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1259 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001260 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001261 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1262 assert_equal(st, False)
1263 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1264 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1265 assert_equal(st, True)
1266 st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -d {} -j ACCEPT'.format(vcpe_name,host))
1267 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1268 assert_equal(st,False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001269 except Exception as error:
1270 log.info('Got Unexpected error %s'%error)
1271 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001272 finally:
1273 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1274 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j ACCEPT'.format(vcpe_name,host))
1275 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001276 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001277 df.callback(0)
1278 reactor.callLater(0, vcpe_firewall, df)
1279 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001280
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001281 @deferred(60)
1282 def test_vsg_firewall_denying_destination_network(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001283 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001284 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001285 1. Get vSG corresponding to vcpe
1286 2. Login to compute node
1287 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet
1288 4. From cord-tester ping to the denied IP address IP1 in the denied subnet
1289 5. Verifying that ping should not be successful
1290 6. From cord-tester ping to the denied IP address IP2 in the denied subnet
1291 7. Verifying that ping should not be successful
1292 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001293 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001294 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001295 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001296 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001297 df = defer.Deferred()
1298 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001299 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001300 df.callback(0)
1301 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001302 network = '204.79.197.192/28'
1303 host1 = '204.79.197.203'
1304 host2 = '204.79.197.210'
1305 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1306 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001307 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001308 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1309 assert_equal(st, False)
1310 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network))
1311 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1312 assert_equal(st, True)
1313 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1314 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001315 except Exception as error:
1316 log.info('Got Unexpected error %s'%error)
1317 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001318 finally:
1319 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network))
1320 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001321 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001322 df.callback(0)
1323 reactor.callLater(0, vcpe_firewall, df)
1324 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001325
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001326 @deferred(60)
1327 def test_vsg_firewall_denying_destination_network_subnet_modification(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001328 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001329 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001330 1. Get vSG corresponding to vcpe
1331 2. Login to compute node
1332 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet
1333 4. From cord-tester ping to the denied IP address IP1 in the denied subnet
1334 5. Verifying that ping should not be successful
1335 6. From cord-tester ping to the denied IP address IP2 in the denied subnet
1336 7. Verifying that ping should not be successful
1337 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001338 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001339 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001340 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001341 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001342 df = defer.Deferred()
1343 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001344 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001345 df.callback(0)
1346 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001347 network1 = '204.79.197.192/28'
1348 network2 = '204.79.197.192/27'
1349 host1 = '204.79.197.203'
1350 host2 = '204.79.197.210'
1351 host3 = '204.79.197.224'
1352 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1353 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001354 self.add_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001355 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1356 assert_equal(st, False)
1357 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network1))
1358 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1359 assert_equal(st, True)
1360 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1361 assert_equal(st,False)
1362 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,network2))
1363 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1364 assert_equal(st, True)
1365 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1366 assert_equal(st, True)
1367 st, _ = getstatusoutput('ping -c 1 {}'.format(host3))
1368 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001369 except Exception as error:
1370 log.info('Got Unexpected error %s'%error)
1371 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001372 finally:
1373 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network1))
1374 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network2))
1375 self.del_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001376 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001377 df.callback(0)
1378 reactor.callLater(0, vcpe_firewall, df)
1379 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001380
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001381 @deferred(40)
1382 def test_vsg_firewall_with_deny_source_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001383 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001384 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001385 1. Get vSG corresponding to vcpe
1386 2. Login to compute node
1387 3. Execute iptable command on vcpe from compute node to deny a source IP
1388 4. From cord-tester ping to 8.8.8.8 from the denied IP
1389 5. Verifying that ping should not be successful
1390 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001391 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001392 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001393 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001394 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001395 df = defer.Deferred()
1396 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001397 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001398 df.callback(0)
1399 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001400 host = '8.8.8.8'
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001401 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1402 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001403 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1404 source_ip = get_ip(vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001405 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1406 assert_equal(st, False)
1407 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1408 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1409 assert_equal(st, True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001410 except Exception as error:
1411 log.info('Got Unexpected error %s'%error)
1412 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1413 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001414 finally:
1415 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1416 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001417 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001418 df.callback(0)
1419 reactor.callLater(0, vcpe_firewall, df)
1420 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001421
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001422 @deferred(40)
1423 def test_vsg_firewall_rule_with_add_and_delete_deny_source_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001424 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001425 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001426 1. Get vSG corresponding to vcpe
1427 2. Login to compute node
1428 3. Execute iptable command on vcpe from compute node to deny a source IP
1429 4. From cord-tester ping to 8.8.8.8 from the denied IP
1430 5. Verifying that ping should not be successful
1431 6. Delete the iptable rule in vcpe
1432 7. From cord-tester ping to 8.8.8.8 from the denied IP
1433 8. Verifying the ping should success
1434 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001435 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001436 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001437 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001438 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001439 df = defer.Deferred()
1440 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001441 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001442 df.callback(0)
1443 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001444 host = '8.8.8.8'
1445 source_ip = get_ip(self.vcpe_dhcp)
1446 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1447 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001448 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1449 source_ip = get_ip(vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001450 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1451 assert_equal(st, False)
1452 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1453 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1454 assert_equal(st, True)
1455 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1456 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1457 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001458 except Exception as error:
1459 log.info('Got Unexpected error %s'%error)
1460 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1461 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001462 finally:
1463 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1464 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001465 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001466 df.callback(0)
1467 reactor.callLater(0, vcpe_firewall, df)
1468 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001469
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001470 @deferred(40)
1471 def test_vsg_firewall_rule_with_deny_icmp_protocol_echo_requests_type(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001472 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001473 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001474 1. Get vSG corresponding to vcpe
1475 2. Login to compute node
1476 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets
1477 4. From cord-tester ping to 8.8.8.8
1478 5. Verifying that ping should not be successful
1479 6. Delete the iptable rule
1480 7. From cord-tester ping to 8.8.8.8
1481 8. Verifying the ping should success
1482 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001483 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001484 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001485 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001486 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001487 df = defer.Deferred()
1488 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001489 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001490 df.callback(0)
1491 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001492 host = '8.8.8.8'
1493 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1494 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001495 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001496 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1497 assert_equal(st, False)
1498 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1499 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1500 assert_equal(st, True)
1501 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1502 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1503 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001504 except Exception as error:
1505 log.info('Got Unexpected error %s'%error)
1506 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1507 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001508 finally:
1509 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1510 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001511 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001512 df.callback(0)
1513 reactor.callLater(0, vcpe_firewall, df)
1514 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001515
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001516 @deferred(40)
1517 def test_vsg_firewall_rule_with_deny_icmp_protocol_echo_reply_type(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001518 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001519 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001520 1. Get vSG corresponding to vcpe
1521 2. Login to compute node
1522 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets
1523 4. From cord-tester ping to 8.8.8.8
1524 5. Verifying that ping should not be successful
1525 6. Delete the iptable rule
1526 7. From cord-tester ping to 8.8.8.8
1527 8. Verifying the ping should success
1528 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001529 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001530 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001531 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001532 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001533 df = defer.Deferred()
1534 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001535 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001536 df.callback(0)
1537 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001538 host = '8.8.8.8'
1539 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1540 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001541 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001542 st, _ = getstatusoutput('ping -c 1 {}'.format('8.8.8.8'))
1543 assert_equal(st, False)
1544 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1545 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1546 assert_equal(st, True)
1547 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1548 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1549 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001550 except Exception as error:
1551 log.info('Got Unexpected error %s'%error)
1552 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1553 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001554 finally:
1555 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1556 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001557 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001558 df.callback(0)
1559 reactor.callLater(0, vcpe_firewall, df)
1560 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001561
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001562 @deferred(40)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00001563 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 Sanka72755c92017-04-06 17:19:02 +00001564 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001565 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001566 1. Get vSG corresponding to vcpe
1567 2. Login to compute node
1568 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets
1569 4. From cord-tester ping to 8.8.8.8
1570 5. Verifying that ping should not be successful
1571 6. Insert another rule to accept the icmp-echo requests protocol packets
1572 7. From cord-tester ping to 8.8.8.8
1573 8. Verifying the ping should success
1574 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001575 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001576 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001577 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001578 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001579 df = defer.Deferred()
1580 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001581 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001582 df.callback(0)
1583 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001584 host = '8.8.8.8'
1585 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1586 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001587 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001588 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1589 assert_equal(st, False)
1590 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1591 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1592 assert_equal(st, True)
1593 st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name))
1594 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1595 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001596 except Exception as error:
1597 log.info('Got Unexpected error %s'%error)
1598 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001599 finally:
1600 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1601 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name))
1602 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001603 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001604 df.callback(0)
1605 reactor.callLater(0, vcpe_firewall, df)
1606 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001607
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001608 @deferred(40)
1609 def test_vsg_firewall_changing_deny_rule_to_accept_rule_with_icmp_protocol_echo_reply_type(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001610 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001611 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001612 1. Get vSG corresponding to vcpe
1613 2. Login to compute node
1614 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets
1615 4. From cord-tester ping to 8.8.8.8
1616 5. Verifying the ping should not success
1617 6. Insert another rule to accept the icmp-echo requests protocol packets
1618 7. From cord-tester ping to 8.8.8.8
1619 8. Verifying the ping should success
1620 """
1621 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001622 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001623 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001624 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001625 df = defer.Deferred()
1626 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001627 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001628 df.callback(0)
1629 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001630 host = '8.8.8.8'
1631 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1632 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001633 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001634 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1635 assert_equal(st, False)
1636 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1637 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1638 assert_equal(st, True)
1639 st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name))
1640 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1641 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001642 except Exception as error:
1643 log.info('Got Unexpected error %s'%error)
1644 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001645 finally:
1646 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1647 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name))
1648 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001649 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001650 df.callback(0)
1651 reactor.callLater(0, vcpe_firewall, df)
1652 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001653
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001654 @deferred(40)
1655 def test_vsg_firewall_for_deny_icmp_protocol(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001656 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001657 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001658 1. Get vSG corresponding to vcpe
1659 2. Login to compute node
1660 3. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1661 4. From cord-tester ping to 8.8.8.8
1662 5. Verifying that ping should not be successful
1663 6. Delete the iptable rule
1664 7. From cord-tester ping to 8.8.8.8
1665 8. Verifying the ping should success
1666 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001667 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001668 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001669 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001670 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001671 df = defer.Deferred()
1672 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001673 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001674 df.callback(0)
1675 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001676 host = '8.8.8.8'
1677 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1678 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001679 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001680 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1681 assert_equal(st, False)
1682 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1683 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1684 assert_equal(st, True)
1685 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1686 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1687 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001688 except Exception as error:
1689 log.info('Got Unexpected error %s'%error)
1690 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1691 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001692 finally:
1693 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1694 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001695 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001696 df.callback(0)
1697 reactor.callLater(0, vcpe_firewall, df)
1698 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001699
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001700 @deferred(60)
1701 def test_vsg_firewall_rule_deny_icmp_protocol_and_destination_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001702 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001703 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001704 1. Get vSG corresponding to vcpe
1705 2. Login to compute node
1706 3. Execute iptable command on vcpe from compute node to deny a destination IP
1707 4. From cord-tester ping to 8.8.8.8
1708 5. Verifying that ping should not be successful
1709 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1710 7. From cord-tester ping to 8.8.8.8
1711 8. Verifying the ping should success
1712 9. Delete the rule added in step 3
1713 10. From cord-tester ping to 8.8.8.8
1714 11. Verifying that ping should not be successful
1715 12. Delete the rule added in step 6
1716 13. From cord-tester ping to 8.8.8.8
1717 14. Verifying the ping should success
1718 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001719 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001720 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001721 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001722 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001723 df = defer.Deferred()
1724 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001725 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001726 df.callback(0)
1727 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001728 host = '8.8.8.8'
1729 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1730 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001731 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001732 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1733 assert_equal(st, False)
1734 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1735 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1736 assert_equal(st, True)
1737 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1738 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1739 assert_equal(st, True)
1740 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1741 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1742 assert_equal(st, True)
1743 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1744 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1745 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001746 except Exception as error:
1747 log.info('Got Unexpected error %s'%error)
1748 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1749 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1750 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001751 finally:
1752 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1753 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1754 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001755 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001756 df.callback(0)
1757 reactor.callLater(0, vcpe_firewall, df)
1758 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001759
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001760 @deferred(100)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001761 def test_vsg_firewall_flushing_all_configured_rules(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001762 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001763 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001764 1. Get vSG corresponding to vcpe
1765 2. Login to compute node
1766 3. Execute iptable command on vcpe from compute node to deny a destination IP
1767 4. From cord-tester ping to 8.8.8.8
1768 5. Verifying that ping should not be successful
1769 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1770 7. From cord-tester ping to 8.8.8.8
1771 8. Verifying the ping should success
1772 9. Flush all the iptable rules configuraed in vcpe
1773 10. Delete the rule added in step 6
1774 11. From cord-tester ping to 8.8.8.8
1775 12. Verifying the ping should success
1776 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001777 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001778 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001779 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001780 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001781 df = defer.Deferred()
1782 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001783 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001784 df.callback(0)
1785 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001786 host = '8.8.8.8'
1787 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1788 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001789 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001790 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1791 assert_equal(st, False)
1792 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1793 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1794 assert_equal(st, True)
1795 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1796 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1797 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001798 st, _ = vsg.run_cmd('sudo docker exec {} iptables -F FORWARD'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001799 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001800 assert_equal(st, True)
1801 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1802 status = False
1803 clock = 0
1804 while(clock <= 30):
1805 time.sleep(5)
1806 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1807 if st == False:
1808 status = True
1809 break
1810 clock += 5
1811 assert_equal(status, True)
1812 except Exception as error:
1813 log.info('Got Unexpected error %s'%error)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001814 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001815 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1816 raise
1817 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001818 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001819 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001820 df.callback(0)
1821 reactor.callLater(0, vcpe_firewall, df)
1822 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001823
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001824 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001825 def test_vsg_firewall_deny_all_ipv4_traffic(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001826 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001827 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001828 1. Get vSG corresponding to vcpe
1829 2. Login to compute node
1830 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic
1831 4. From cord-tester ping to 8.8.8.8
1832 5. Verifying that ping should not be successful
1833 6. Delete the iptable rule added
1834 7. From cord-tester ping to 8.8.8.8
1835 8. Verifying the ping should success
1836 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001837 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001838 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001839 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001840 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001841 df = defer.Deferred()
1842 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001843 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001844 df.callback(0)
1845 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001846 host = '8.8.8.8'
1847 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1848 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001849 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001850 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1851 assert_equal(st, False)
1852 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
1853 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1854 assert_equal(st, True)
1855 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1856 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1857 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001858 except Exception as error:
1859 log.info('Got Unexpected error %s'%error)
1860 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1861 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001862 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001863 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001864 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001865 df.callback(0)
1866 reactor.callLater(0, vcpe_firewall, df)
1867 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001868
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001869 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001870 def test_vsg_firewall_replacing_deny_rule_to_accept_rule_ipv4_traffic(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001871 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001872 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001873 1. Get vSG corresponding to vcpe
1874 2. Login to compute node
1875 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic
1876 4. From cord-tester ping to 8.8.8.8
1877 5. Verifying that ping should not be successful
1878 6. Replace the deny rule added in step 3 with accept rule
1879 7. From cord-tester ping to 8.8.8.8
1880 8. Verifying the ping should success
1881 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001882 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001883 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001884 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001885 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001886 df = defer.Deferred()
1887 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001888 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001889 df.callback(0)
1890 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001891 host = '8.8.8.8'
1892 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1893 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001894 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001895 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1896 assert_equal(st, False)
1897 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
1898 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1899 assert_equal(st, True)
1900 st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -4 -j ACCEPT'.format(vcpe_name))
1901 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1902 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001903 except Exception as error:
1904 log.info('Got Unexpected error %s'%error)
1905 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001906 finally:
1907 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1908 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001909 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001910 df.callback(0)
1911 reactor.callLater(0, vcpe_firewall, df)
1912 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001913
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001914 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001915 def test_vsg_firewall_deny_all_traffic_coming_on_lan_interface_in_vcpe(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001916 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001917 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001918 1. Get vSG corresponding to vcpe
1919 2. Login to compute node
1920 3. Execute iptable command on vcpe from compute node to deny all the traffic coming on lan interface inside vcpe container
1921 4. From cord-tester ping to 8.8.8.8
1922 5. Verifying the ping should not success
1923 6. Delete the iptable rule added
1924 7. From cord-tester ping to 8.8.8.8
1925 8. Verifying the ping should success
1926 """
1927 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001928 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001929 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001930 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001931 df = defer.Deferred()
1932 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001933 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001934 df.callback(0)
1935 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001936 host = '8.8.8.8'
1937 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1938 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001939 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001940 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1941 assert_equal(st, False)
1942 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -j DROP'.format(vcpe_name))
1943 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1944 assert_equal(st, True)
1945 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name))
1946 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1947 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001948 except Exception as error:
1949 log.info('Got Unexpected error %s'%error)
1950 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name))
1951 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001952 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001953 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001954 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001955 df.callback(0)
1956 reactor.callLater(0, vcpe_firewall, df)
1957 return df
1958
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001959 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001960 def test_vsg_firewall_deny_all_traffic_going_out_of_wan_interface_in_vcpe(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001961 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001962 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001963 1. Get vSG corresponding to vcpe
1964 2. Login to compute node
1965 3. Execute iptable command on vcpe from compute node to deny all the traffic going out of wan interface inside vcpe container
1966 4. From cord-tester ping to 8.8.8.8
1967 5. Verifying the ping should not success
1968 6. Delete the iptable rule added
1969 7. From cord-tester ping to 8.8.8.8
1970 8. Verifying the ping should success
1971 """
1972 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001973 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001974 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001975 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001976 df = defer.Deferred()
1977 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001978 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001979 df.callback(0)
1980 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001981 host = '8.8.8.8'
1982 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1983 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001984 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001985 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1986 assert_equal(st, False)
1987 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -o eth0 -j DROP'.format(vcpe_name))
1988 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1989 assert_equal(st, True)
1990 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name))
1991 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1992 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001993 except Exception as error:
1994 log.info('Got Unexpected error %s'%error)
1995 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name))
1996 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001997 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001998 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001999 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002000 df.callback(0)
2001 reactor.callLater(0, vcpe_firewall, df)
2002 return df
2003
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002004 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002005 def test_vsg_firewall_deny_all_traffic_from_lan_to_wan_in_vcpe(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00002006 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002007 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00002008 1. Get vSG corresponding to vcpe
2009 2. Login to compute node
2010 3. Execute iptable command on vcpe from compute node to deny all the traffic from lan to wan interface in vcpe
2011 4. From cord-tester ping to 8.8.8.8
2012 5. Verifying that ping should not be successful
2013 6. Delete the iptable rule added
2014 7. From cord-tester ping to 8.8.8.8
2015 8. Verifying the ping should success
2016 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002017 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002018 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002019 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002020 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002021 df = defer.Deferred()
2022 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07002023 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07002024 df.callback(0)
2025 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002026 host = '8.8.8.8'
2027 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2028 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002029 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002030 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2031 assert_equal(st, False)
2032 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
2033 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2034 assert_equal(st, True)
2035 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
2036 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2037 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002038 except Exception as error:
2039 log.info('Got Unexpected error %s'%error)
2040 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
2041 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002042 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002043 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002044 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002045 df.callback(0)
2046 reactor.callLater(0, vcpe_firewall, df)
2047 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00002048
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002049 @deferred(60)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002050 def test_vsg_firewall_deny_all_dns_traffic(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002051 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002052 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002053 1. Get vSG corresponding to vcpe
2054 2. Login to compute node
2055 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2056 4. From cord-tester ping to www.google.com
2057 5. Verifying the ping should not success
2058 6. Delete the iptable rule added
2059 7. From cord-tester ping to www.google.com
2060 8. Verifying the ping should success
2061 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002062 mgmt = 'eth0'
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002063 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002064 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002065 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002066 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002067 df = defer.Deferred()
2068 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07002069 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07002070 df.callback(0)
2071 return
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002072 host = 'google-public-dns-a.google.com'
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002073 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2074 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002075 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
2076 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe_intf, mgmt = mgmt)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002077 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002078 assert_not_equal(st, False)
2079 VSGAccess.restore_interface_config(mgmt, vcpe=vcpe_intf)
2080 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
2081 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe_intf, mgmt = mgmt)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002082 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2083 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002084 VSGAccess.restore_interface_config(mgmt, vcpe=vcpe_intf)
2085 except Exception as error:
2086 log.info('Got Unexpected error %s'%error)
2087 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
2088 VSGAccess.restore_interface_config(mgmt,vcpe=vcpe_intf)
2089 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002090 df.callback(0)
2091 reactor.callLater(0, vcpe_firewall, df)
2092 return df
2093
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002094 @deferred(60)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002095 def test_vsg_firewall_deny_all_ipv4_traffic_vcpe_container_restart(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00002096 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002097 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00002098 1. Get vSG corresponding to vcpe
2099 2. Login to compute node
2100 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2101 4. From cord-tester ping to www.google.com
2102 5. Verifying that ping should not be successful
2103 6. Delete the iptable rule added
2104 7. From cord-tester ping to www.google.com
2105 8. Verifying the ping should success
2106 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002107 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002108 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002109 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002110 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002111 df = defer.Deferred()
2112 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07002113 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07002114 df.callback(0)
2115 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002116 host = '8.8.8.8'
2117 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2118 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002119 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002120 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2121 assert_equal(st, False)
2122 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
2123 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2124 assert_equal(st, True)
2125 st,output = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002126 clock = 0
2127 status = False
2128 while(clock <= 20 ):
2129 time.sleep(5)
2130 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2131 if st == False:
2132 status = True
2133 break
2134 clock += 5
2135 assert_equal(status, True)
2136 except Exception as error:
2137 log.info('Got Unexpected error %s'%error)
2138 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
2139 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002140 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002141 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002142 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002143 df.callback(0)
2144 reactor.callLater(0, vcpe_firewall, df)
2145 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00002146
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002147 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002148 def test_vsg_nat_dnat_modifying_destination_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002149 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002150 Test Method:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002151 1. Get vSG corresponding to vcpe
2152 2. Login to compute node
2153 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2154 4. From cord-tester ping to www.google.com
2155 5. Verifying the ping should not success
2156 6. Delete the iptable rule added
2157 7. From cord-tester ping to www.google.com
2158 8. Verifying the ping should success
2159 """
2160 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002161 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002162 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002163 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002164 df = defer.Deferred()
2165 def vcpe_firewall(df):
2166 host = '8.8.8.8'
2167 dst_ip = '123.123.123.123'
2168 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2169 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002170 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002171 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2172 assert_equal(st, False)
2173 st,output = vsg.run_cmd('sudo docker exec {} iptables -t nat -A PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip))
2174 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2175 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002176 except Exception as error:
2177 log.info('Got Unexpected error %s'%error)
2178 raise
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002179 finally:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002180
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002181 vsg.run_cmd('sudo docker exec {} iptables -t nat -D PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip))
2182 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002183 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002184 df.callback(0)
2185 reactor.callLater(0,vcpe_firewall,df)
2186 return df
2187
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002188 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002189 def test_vsg_nat_dnat_modifying_destination_ip_and_delete(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002190 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002191 Test Method:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002192 1. Get vSG corresponding to vcpe
2193 2. Login to compute node
2194 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2195 4. From cord-tester ping to www.google.com
2196 5. Verifying the ping should not success
2197 6. Delete the iptable rule added
2198 7. From cord-tester ping to www.google.com
2199 8. Verifying the ping should success
2200 """
2201 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002202 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002203 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002204 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002205 df = defer.Deferred()
2206 def vcpe_firewall(df):
2207 host = '8.8.8.8'
2208 dst_ip = '123.123.123.123'
2209 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2210 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002211 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002212 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2213 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002214 st, _ = vsg.run_cmd('sudo docker exec {} iptables -t nat -A PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002215 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2216 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002217 st, _ = vsg.run_cmd('sudo docker exec {} iptables -t nat -D PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002218 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2219 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002220 except Exception as error:
2221 log.info('Got Unexpected error %s'%error)
2222 vsg.run_cmd('sudo docker exec {} iptables -t nat -D PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip))
2223 raise
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002224 finally:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002225 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002226 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002227 df.callback(0)
2228 reactor.callLater(0,vcpe_firewall,df)
2229 return df
2230
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002231 @deferred(50)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002232 def test_vsg_dnat_change_modifying_destination_ip_address(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002233 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002234 Test Method:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002235 1. Get vSG corresponding to vcpe
2236 2. Login to compute node
2237 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2238 4. From cord-tester ping to www.google.com
2239 5. Verifying the ping should not success
2240 6. Delete the iptable rule added
2241 7. From cord-tester ping to www.google.com
2242 8. Verifying the ping should success
2243 """
2244 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002245 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002246 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002247 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002248 df = defer.Deferred()
2249 def vcpe_firewall(df):
2250 host = '8.8.8.8'
2251 dst_ip = '123.123.123.123'
2252 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2253 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002254 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002255 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2256 assert_equal(st, False)
2257 st,output = vsg.run_cmd('sudo docker exec {} iptables -t nat -A PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip))
2258 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2259 assert_equal(st, True)
2260 st,output = vsg.run_cmd('sudo docker exec {} iptables -t nat -R PREROUTING 1 -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,host))
2261 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2262 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002263 except Exception as error:
2264 log.info('Got Unexpected error %s'%error)
2265 raise
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002266 finally:
2267 vsg.run_cmd('sudo docker exec {} iptables -t nat -D PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,dst_ip))
2268 vsg.run_cmd('sudo docker exec {} iptables -t nat -D PREROUTING -s 192.168.0.0/16 -i eth1 -j DNAT --to-destination {}'.format(vcpe_name,host))
2269 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002270 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002271 df.callback(0)
2272 reactor.callLater(0,vcpe_firewall,df)
2273 return df
2274
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002275 def vsg_xos_subscriber_create(self, index, subscriber_info = None, volt_subscriber_info = None):
A R Karthick19771192017-04-25 14:57:05 -07002276 if self.on_pod is False:
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002277 return ''
2278 if subscriber_info is None:
A R Karthicked3a2ca2017-07-06 15:50:03 -07002279 subscriber_info = self.cord_subscriber.subscriber_info[index]
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002280 if volt_subscriber_info is None:
A R Karthicked3a2ca2017-07-06 15:50:03 -07002281 volt_subscriber_info = self.cord_subscriber.volt_subscriber_info[index]
A R Karthickd0b06792017-04-25 15:11:23 -07002282 s_tag = int(volt_subscriber_info['voltTenant']['s_tag'])
2283 c_tag = int(volt_subscriber_info['voltTenant']['c_tag'])
2284 vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag)
A R Karthicked3a2ca2017-07-06 15:50:03 -07002285 subId = self.cord_subscriber.subscriberCreate(index, subscriber_info, volt_subscriber_info)
2286 if subId:
A R Karthick97e08852017-04-26 10:06:38 -07002287 #if the vsg instance was already instantiated, then reduce delay
A R Karthicked3a2ca2017-07-06 15:50:03 -07002288 if c_tag % self.SUBSCRIBERS_PER_S_TAG == 0:
A R Karthick97e08852017-04-26 10:06:38 -07002289 delay = 350
2290 else:
2291 delay = 90
2292 log.info('Delaying %d seconds for the VCPE to be provisioned' %(delay))
2293 time.sleep(delay)
2294 log.info('Testing for external connectivity to VCPE %s' %(vcpe))
2295 self.vsg_for_external_connectivity(index)
A R Karthicked3a2ca2017-07-06 15:50:03 -07002296
2297 return subId
A R Karthick97e08852017-04-26 10:06:38 -07002298
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002299 def vsg_xos_subscriber_delete(self, index, subId = '', voltId = '', subscriber_info = None, volt_subscriber_info = None):
A R Karthick97e08852017-04-26 10:06:38 -07002300 if self.on_pod is False:
2301 return
A R Karthicked3a2ca2017-07-06 15:50:03 -07002302 self.cord_subscriber.subscriberDelete(index, subId = subId, voltId = voltId,
2303 subscriber_info = subscriber_info,
2304 volt_subscriber_info = volt_subscriber_info)
A R Karthick035d2e22017-04-25 13:53:00 -07002305
A R Karthicke29c8d42017-04-27 11:38:52 -07002306 def vsg_xos_subscriber_id(self, index):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002307 if self.on_pod is False:
2308 return ''
2309 return self.cord_subscriber.subscriberId(index)
A R Karthicke29c8d42017-04-27 11:38:52 -07002310
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002311 def test_vsg_xos_subscriber_create_reserved(self):
A.R Karthicka2960912017-05-18 18:52:55 -07002312 if self.on_pod is False:
2313 return
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002314 tags_reserved = [ (int(vcpe['s_tag']), int(vcpe['c_tag'])) for vcpe in self.vcpes_reserved ]
2315 volt_tenants = self.restApiXos.ApiGet('TENANT_VOLT')
2316 subscribers = self.restApiXos.ApiGet('TENANT_SUBSCRIBER')
2317 reserved_tenants = filter(lambda tenant: (int(tenant['s_tag']), int(tenant['c_tag'])) in tags_reserved, volt_tenants)
2318 reserved_config = []
2319 for tenant in reserved_tenants:
2320 for subscriber in subscribers:
2321 if int(subscriber['id']) == int(tenant['subscriber']):
2322 volt_subscriber_info = {}
2323 volt_subscriber_info['voltTenant'] = dict(s_tag = tenant['s_tag'],
2324 c_tag = tenant['c_tag'],
2325 subscriber = tenant['subscriber'])
2326 volt_subscriber_info['volt_id'] = tenant['id']
2327 volt_subscriber_info['account_num'] = subscriber['identity']['account_num']
2328 reserved_config.append( (subscriber, volt_subscriber_info) )
2329 break
2330 else:
2331 log.info('Subscriber not found for tenant %s, s_tag: %s, c_tag: %s' %(str(tenant['subscriber']),
2332 str(tenant['s_tag']),
2333 str(tenant['c_tag'])))
2334
2335 for subscriber_info, volt_subscriber_info in reserved_config:
2336 self.vsg_xos_subscriber_delete(0,
2337 subId = str(subscriber_info['id']),
2338 voltId = str(volt_subscriber_info['volt_id']),
2339 subscriber_info = subscriber_info,
2340 volt_subscriber_info = volt_subscriber_info)
2341 subId = self.vsg_xos_subscriber_create(0,
2342 subscriber_info = subscriber_info,
2343 volt_subscriber_info = volt_subscriber_info)
2344 log.info('Created reserved subscriber %s' %(subId))
2345
A R Karthick037cb982017-07-07 17:35:30 -07002346 def vsg_create(self, num_subscribers):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002347 if self.on_pod is False:
2348 return
A R Karthick037cb982017-07-07 17:35:30 -07002349 num_subscribers = min(num_subscribers, len(self.cord_subscriber.subscriber_info))
2350 for index in xrange(num_subscribers):
A R Karthicke29c8d42017-04-27 11:38:52 -07002351 #check if the index exists
2352 subId = self.vsg_xos_subscriber_id(index)
2353 if subId and subId != '0':
2354 self.vsg_xos_subscriber_delete(index, subId = subId)
2355 subId = self.vsg_xos_subscriber_create(index)
2356 log.info('Created Subscriber %s' %(subId))
2357
A R Karthick037cb982017-07-07 17:35:30 -07002358 def test_vsg_xos_subscriber_create_all(self):
2359 self.vsg_create(len(self.cord_subscriber.subscriber_info))
2360
2361 def vsg_delete(self, num_subscribers):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002362 if self.on_pod is False:
2363 return
A R Karthick037cb982017-07-07 17:35:30 -07002364 num_subscribers = min(num_subscribers, len(self.cord_subscriber.subscriber_info))
2365 for index in xrange(num_subscribers):
A R Karthicke29c8d42017-04-27 11:38:52 -07002366 subId = self.vsg_xos_subscriber_id(index)
2367 if subId and subId != '0':
2368 self.vsg_xos_subscriber_delete(index, subId = subId)
2369
A R Karthick037cb982017-07-07 17:35:30 -07002370 def test_vsg_xos_subscriber_delete_all(self):
2371 self.vsg_delete(len(self.cord_subscriber.subscriber_info))
2372
A R Karthicke29c8d42017-04-27 11:38:52 -07002373 def test_vsg_xos_subscriber_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002374 subId = self.vsg_xos_subscriber_create(0)
2375 if subId and subId != '0':
2376 self.vsg_xos_subscriber_delete(0, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002377
A R Karthicke29c8d42017-04-27 11:38:52 -07002378 def test_vsg_xos_subscriber_2_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002379 subId = self.vsg_xos_subscriber_create(1)
2380 if subId and subId != '0':
2381 self.vsg_xos_subscriber_delete(1, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002382
A R Karthicke29c8d42017-04-27 11:38:52 -07002383 def test_vsg_xos_subscriber_3_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002384 subId = self.vsg_xos_subscriber_create(2)
2385 if subId and subId != '0':
2386 self.vsg_xos_subscriber_delete(2, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002387
A R Karthicke29c8d42017-04-27 11:38:52 -07002388 def test_vsg_xos_subscriber_4_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002389 subId = self.vsg_xos_subscriber_create(3)
2390 if subId and subId != '0':
2391 self.vsg_xos_subscriber_delete(3, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002392
A R Karthicke29c8d42017-04-27 11:38:52 -07002393 def test_vsg_xos_subscriber_5_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002394 subId = self.vsg_xos_subscriber_create(4)
2395 if subId and subId != '0':
2396 self.vsg_xos_subscriber_delete(4, subId)
A.R Karthick282f0d32017-03-28 16:43:59 -07002397
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002398 @deferred(400)
2399 def test_vsg_xos_subscriber_external_connectivity_through_vcpe_instance(self, index=0):
2400 df = defer.Deferred()
2401 status = False
2402 def test_xos_subscriber(df):
2403 subId = self.vsg_xos_subscriber_id(index)
2404 if subId == '0':
2405 log.info('Creating vcpe instance ')
2406 subId = self.vsg_xos_subscriber_create(index)
2407 assert_not_equal(subId,'0')
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002408 vcpe = self.dhcp_vcpes[index]
2409 host = '8.8.8.8'
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002410 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2411 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2412 assert_equal(st, False)
2413 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2414 df.callback(0)
2415 reactor.callLater(0,test_xos_subscriber,df)
2416 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002417
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002418 #pass
2419 @deferred(50)
2420 def test_vsg_xos_subscriber_external_connectivity_without_creating_vcpe_instance(self, index=0):
2421 df = defer.Deferred()
2422 def test_xos_subscriber(df):
2423 subId = self.vsg_xos_subscriber_id(index)
2424 if subId != '0':
2425 log.info('deleting already existing vcpe instance ')
2426 self.vsg_xos_subscriber_delete(index, subId)
2427 vcpe = self.dhcp_vcpes[index]
2428 host = '8.8.8.8'
2429 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2430 st, out = getstatusoutput('route -n')
2431 log.info('route -n outpu-1-1-1--1-1-1-1-1-1-1 is %s'%out)
2432 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2433 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2434 assert_equal(st, True)
2435 df.callback(0)
2436 reactor.callLater(0,test_xos_subscriber,df)
2437 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002438
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002439 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002440 def test_vsg_xos_subscriber_external_connectivity_after_removing_vcpe_instance_from_xos(self,index=0,host = '8.8.8.8'):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002441 df = defer.Deferred()
2442 def test_xos_subscriber(df):
2443 subId = self.vsg_xos_subscriber_id(index)
2444 if subId == '0':
2445 subId = self.vsg_xos_subscriber_create(index)
2446 assert_not_equal(subId,'0')
2447 vcpe = self.dhcp_vcpes[index]
2448 if subId and subId != '0':
2449 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2450 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2451 assert_equal(st, False)
2452 self.vsg_xos_subscriber_delete(index, subId)
2453 time.sleep(2)
2454 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2455 assert_equal(st, True)
2456 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2457 df.callback(0)
2458 reactor.callLater(0,test_xos_subscriber,df)
2459 return df
2460
2461 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002462 def test_vsg_xos_subscriber_external_connectivity_after_restarting_vcpe_instance(self, index=0, host = '8.8.8.8'):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002463 df = defer.Deferred()
2464 def test_xos_subscriber(df):
2465 subId = self.vsg_xos_subscriber_id(index)
2466 if subId == '0':
2467 subId = self.vsg_xos_subscriber_create(index)
2468 assert_not_equal(subId,'0')
2469 vcpe_intf = self.dhcp_vcpes[index]
2470 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2471 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2472 assert_equal(st, False)
2473 vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
2474 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2475 st, _ = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
2476 assert_equal(st, True)
2477 time.sleep(5)
2478 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2479 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2480 assert_equal(st, False)
2481 df.callback(0)
2482 reactor.callLater(0,test_xos_subscriber,df)
2483 return df
2484
2485 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002486 def test_vsg_xos_subscriber_external_connectivity_toggling_vcpe_instance(self, index=0, host = '8.8.8.8'):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002487 df = defer.Deferred()
2488 def test_xos_subscriber(df):
2489 subId = self.vsg_xos_subscriber_id(index)
2490 if subId == '0':
2491 subId = self.vsg_xos_subscriber_create(index)
2492 assert_not_equal(subId,'0')
2493 vcpe_intf = self.dhcp_vcpes[index]
2494 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2495 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2496 assert_equal(st, False)
2497 vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
2498 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2499 st, _ = vsg.run_cmd('sudo docker stop {}'.format(vcpe_name))
2500 assert_equal(st, True)
2501 time.sleep(3)
2502 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2503 assert_equal(st, True)
2504 st, _ = vsg.run_cmd('sudo docker start {}'.format(vcpe_name))
2505 assert_equal(st, True)
2506 time.sleep(5)
2507 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2508 assert_equal(st, False)
2509 df.callback(0)
2510 reactor.callLater(0,test_xos_subscriber,df)
2511 return df
2512
2513 #getting list out of range error while creating vcpe of index 6
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002514 def test_vsg_create_xos_subscribers_in_different_vsg_vm(self, index1=4, index2=6):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002515 indexes = list(index1,index2)
2516 subids = []
2517 for index in indexes:
2518 subId = self.vsg_xos_subscriber_id(index)
2519 if not subId:
2520 subId = self.vsg_xos_subscriber_create(index)
2521 assert_not_equal(subId,'0')
2522 subids.append(subId)
2523 log.info('succesfully created two vcpe instances in two different vSG VMs')
2524 self.vsg_xos_subscriber_delete(index1, subid[0])
2525 self.vsg_xos_subscriber_delete(index2, subid[1])
2526
2527 #Unable to reach external network via vcpes created by XOS
2528 @deferred(TIMEOUT+400)
2529 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_goes_down(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002530 """
2531 Test Method:
2532 1.Create two vcpe instances in two different vsg vms using XOS
2533 2.Verify external connectivity through vcpe instances from cord-tester
2534 3.Kill first vcpe instance
2535 4.Verify external network cant be reachable form first vcpe interface
2536 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002537 df = defer.Deferred()
2538 def test_xos_subscriber(df):
2539 host1 = '8.8.8.8'
2540 host2 = '4.2.2.2'
2541 vcpe_intf1 = self.dhcp_vcpes[0]
2542 vcpe_intf2 = self.dhcp_vcpes[1]
2543 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2544 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2545 subId1 = self.vsg_xos_subscriber_id(0)
2546 log.info('already existing subid of index 0 is %s'%subId1)
2547 if subId1 == '0':
2548 log.info('creating vcpe instance of index 0')
2549 subId1 = self.vsg_xos_subscriber_create(0)
2550 assert_not_equal(subId1,'0')
2551 subId2 = self.vsg_xos_subscriber_id(1)
2552 log.info('already existing subid of index 1 is %s'%subId2)
2553 if subId2 == '0':
2554 log.info('creating vcpe instance of index 1')
2555 subId2 = self.vsg_xos_subscriber_create(1)
2556 assert_not_equal(subId2,'0')
2557 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2558 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2559 try:
2560 for intf in [vcpe_intf1,vcpe_intf2]:
2561 host = host1 if intf is vcpe_intf1 else host2
2562 self.add_static_route_via_vcpe_interface([host],vcpe=intf)
2563 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2564 assert_equal(st, False)
2565 if intf is vcpe_intf2:
2566 self.vsg_xos_subscriber_delete(1, subId2)
2567 st, _ = vsg2.run_cmd('sudo docker kill {}'.format(vcpe_name2))
2568 time.sleep(2)
2569 self.add_static_route_via_vcpe_interface([host],vcpe=intf)
2570 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2571 assert_equal(st, False)
2572 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2573 assert_equal(st, True)
2574 except Exception as error:
2575 log.info('Got Unexpected error %s'%error)
2576 raise
2577 finally:
2578 self.vsg_xos_subscriber_delete(0, subId1)
2579 self.vsg_xos_subscriber_delete(1, subId2)
2580 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2581 self.del_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2582 df.callback(0)
2583 reactor.callLater(0,test_xos_subscriber,df)
2584 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002585
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002586 @deferred(TIMEOUT+400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002587 def test_vsg_xos_subscriber_external_connectivity_after_vcpe_is_removed_and_added_again(self,index=0):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002588 """
2589 Test Method:
2590 1.Create two vcpe instances in two different vsg vms using XOS
2591 2.Verify external connectivity through vcpe instances from cord-tester
2592 3.Remove first vcpe instance
2593 4.Verify external network cant be reachable form first vcpe interface
2594 5.Add back the removed vcpe instance
2595 6.Verify external connectivity through vcpe instances from cord-tester
2596 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002597 df = defer.Deferred()
2598 def test_xos_subscriber(df,index=index):
2599 host = '8.8.8.8'
2600 subId = self.vsg_xos_subscriber_id(index)
2601 log.info('already existing subid of index 0 is %s'%subId)
2602 if subId == '0':
2603 log.info('creating vcpe instance of index %s'%index)
2604 subId = self.vsg_xos_subscriber_create(index)
2605 assert_not_equal(subId,'0')
2606 vcpe_intf = self.dhcp_vcpes[0]
2607 vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
2608 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2609 try:
2610 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2611 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2612 assert_equal(st, False)
2613 log.info('Deleting vcpe Instance of index %s'%index)
2614 self.vsg_xos_subscriber_delete(0, subId)
2615 st, _ = vsg.run_cmd('sudo docker kill {}'.format(vcpe_name))
2616 time.sleep(1)
2617 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2618 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2619 assert_equal(st, True)
2620 subId = self.vsg_xos_subscriber_create(index)
2621 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2622 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2623 assert_equal(st, False)
2624 except Exception as error:
2625 log.info('Got Unexpected error %s'%error)
2626 raise
2627 finally:
2628 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2629 self.vsg_xos_subscriber_delete(0, subId)
2630 df.callback(0)
2631 reactor.callLater(0,test_xos_subscriber,df)
2632 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002633
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002634 @deferred(TIMEOUT+400)
2635 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_restarts(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002636 """
2637 Test Method:
2638 1.Create two vcpe instances in two different vsg vms using XOS
2639 2.Verify external connectivity through vcpe instances from cord-tester
2640 3.Restart first vcpe instance
2641 4.Verify external network cant be reachable form first vcpe interface
2642 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002643 df = defer.Deferred()
2644 def test_xos_subscriber(df):
2645 host1 = '8.8.8.8'
2646 host2 = '4.2.2.2'
2647 subId1 = self.vsg_xos_subscriber_id(0)
2648 log.info('already existing subid of index 0 is %s'%subId1)
2649 if subId1 == '0':
2650 log.info('creating vcpe instance of index 0')
2651 subId1 = self.vsg_xos_subscriber_create(0)
2652 assert_not_equal(subId1,'0')
2653 subId2 = self.vsg_xos_subscriber_id(1)
2654 log.info('already existing subid of index 1 is %s'%subId2)
2655 if subId2 == '0':
2656 log.info('creating vcpe instance of index 1')
2657 subId2 = self.vsg_xos_subscriber_create(1)
2658 vcpe_intf1 = self.dhcp_vcpes[0]
2659 vcpe_intf2 = self.dhcp_vcpes[1]
2660 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2661 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2662 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2663 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2664 try:
2665 #checking external connectivity from vcpe interface 1 before vcpe 2 restart
2666 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2667 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2668 assert_equal(st, False)
2669 #checking external connectivity from vcpe interface 2 before vcpe 2 restart
2670 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2671 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2672 assert_equal(st, False)
2673 st, _ = vsg2.run_cmd('sudo docker restart {}'.format(vcpe_name2))
2674 time.sleep(10)
2675 #checking external connectivity from vcpe interface 1 after vcpe 2 restart
2676 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2677 assert_equal(st, False)
2678 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2679 time = 0
2680 status = False
2681 while(time <= 100):
2682 time.sleep(10)
2683 st,_ = getstatusoutput('ping -c 1 {}'.format(hos2))
2684 if st is False:
2685 status = True
2686 break
2687 time += 10
2688 assert_equal(status, True)
2689 except Exception as error:
2690 log.info('Got Unexpected error %s'%error)
2691 raise
2692 finally:
2693 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2694 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2695 self.vsg_xos_subscriber_delete(0, subId1)
2696 self.vsg_xos_subscriber_delete(1, subId2)
2697 df.callback(0)
2698 reactor.callLater(0,test_xos_subscriber,df)
2699 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002700
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002701 @deferred(500)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002702 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_is_paused(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002703 """
2704 Test Method:
2705 1.Create two vcpe instances in two different vsg vms using XOS
2706 2.Verify external connectivity through vcpe instances from cord-tester
2707 3.Pause running first vcpe instance
2708 4.Verify external network cant be reachable form first vcpe interface
2709 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002710 df = defer.Deferred()
2711 def test_xos_subscriber(df):
2712 host1 = '8.8.8.8'
2713 host2 = '4.2.2.2'
2714 subId1 = self.vsg_xos_subscriber_id(0)
2715 log.info('already existing subid of index 0 is %s'%subId1)
2716 if subId1 == '0':
2717 log.info('creating vcpe instance of index 0')
2718 subId1 = self.vsg_xos_subscriber_create(0)
2719 assert_not_equal(subId1,'0')
2720 subId2 = self.vsg_xos_subscriber_id(1)
2721 log.info('already existing subid of index 1 is %s'%subId2)
2722 if subId2 == '0':
2723 log.info('creating vcpe instance of index 1')
2724 subId2 = self.vsg_xos_subscriber_create(1)
2725 vcpe_intf1 = self.dhcp_vcpes[0]
2726 vcpe_intf2 = self.dhcp_vcpes[1]
2727 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2728 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2729 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2730 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2731 try:
2732 #checking external connectivity from vcpe interface 1 before vcpe 2 pause
2733 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2734 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2735 assert_equal(st, False)
2736 #checking external connectivity from vcpe interface 2 before vcpe 2 pause
2737 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2738 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2739 assert_equal(st, False)
2740 st, _ = vsg2.run_cmd('sudo docker pause {}'.format(vcpe_name2))
2741 time.sleep(1)
2742 #checking external connectivity from vcpe interface 1 after vcpe 2 pause
2743 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2744 assert_equal(st, False)
2745 #checking external connectivity from vcpe interface 2 after vcpe 2 pause
2746 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2747 assert_equal(st, True)
2748 except Exception as error:
2749 log.info('Got Unexpected error %s'%error)
2750 raise
2751 finally:
2752 log.info('In Finally block 3333333333333333')
2753 st, _ = vsg2.run_cmd('sudo docker unpause {}'.format(vcpe_name2))
2754 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2755 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2756 self.vsg_xos_subscriber_delete(0, subId1)
2757 self.vsg_xos_subscriber_delete(1, subId2)
2758 df.callback(0)
2759 reactor.callLater(0,test_xos_subscriber,df)
2760 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002761
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002762 @deferred(500)
2763 def test_vsg_xos_subscriber_external_connectivity_if_one_vcpe_stops(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002764 """
2765 Test Method:
2766 1.Create two vcpe instances in two different vsg vms using XOS
2767 2.Verify external connectivity through vcpe instances from cord-tester
2768 3.Stop running first vcpe instance
2769 4.Verify external network cant be reachable form first vcpe interface
2770 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002771 df = defer.Deferred()
2772 def test_xos_subscriber(df):
2773 host1 = '8.8.8.8'
2774 host2 = '4.2.2.2'
2775 subId1 = self.vsg_xos_subscriber_id(0)
2776 log.info('already existing subid of index 0 is %s'%subId1)
2777 if subId1 == '0':
2778 log.info('creating vcpe instance of index 0')
2779 subId1 = self.vsg_xos_subscriber_create(0)
2780 assert_not_equal(subId1,'0')
2781 subId2 = self.vsg_xos_subscriber_id(1)
2782 log.info('already existing subid of index 1 is %s'%subId2)
2783 if subId2 == '0':
2784 log.info('creating vcpe instance of index 1')
2785 subId2 = self.vsg_xos_subscriber_create(1)
2786 vcpe_intf1 = self.dhcp_vcpes[0]
2787 vcpe_intf2 = self.dhcp_vcpes[1]
2788 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2789 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2790 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2791 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2792 try:
2793 #checking external connectivity from vcpe interface 1 before vcpe 2 stop
2794 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2795 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2796 assert_equal(st, False)
2797 #checking external connectivity from vcpe interface 2 before vcpe 2 stop
2798 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2799 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2800 assert_equal(st, False)
2801 st, _ = vsg2.run_cmd('sudo docker stop {}'.format(vcpe_name2))
2802 time.sleep(5)
2803 #checking external connectivity from vcpe interface 1 after vcpe 2 stop
2804 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2805 assert_equal(st, False)
2806 #checking external connectivity from vcpe interface 1 after vcpe 2 stop
2807 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2808 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2809 assert_equal(st, True)
2810 except Exception as error:
2811 log.info('Got Unexpected error %s'%error)
2812 raise
2813 finally:
2814 st, _ = vsg2.run_cmd('sudo docker start {}'.format(vcpe_name2))
2815 time.sleep(10)
2816 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2817 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2818 self.vsg_xos_subscriber_delete(0, subId1)
2819 self.vsg_xos_subscriber_delete(1, subId2)
2820 df.callback(0)
2821 reactor.callLater(0,test_xos_subscriber,df)
2822 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002823
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002824 @deferred(420)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002825 def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_stopped(self, index=0):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002826 """
2827 Test Method:
2828 1.Create two vcpe instances in two different vsg vms using XOS
2829 2.Verify external connectivity through vcpe instances from cord-tester
2830 3.Bring down first vSG vm
2831 4.Verify external network cant be reachable form first vcpe interface
2832 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002833 df = defer.Deferred()
2834 def test_xos_subscriber(df,index=index):
2835 host = '8.8.8.8'
2836 subId = self.vsg_xos_subscriber_id(index)
2837 if subId == '0':
2838 log.info('creating vcpe instance of index 0')
2839 subId = self.vsg_xos_subscriber_create(index)
2840 assert_not_equal(subId,'0')
2841 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2842 vcpe_name = self.container_vcpes[index]
2843 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2844 try:
2845 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2846 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2847 assert_equal(st, False)
2848 log.info('Stopping vsg instance')
2849 vsg.stop()
2850 time.sleep(5)
2851 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2852 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2853 assert_equal(st, True)
2854 except Exception as error:
2855 log.info('Got Unexpected error %s'%error)
2856 raise
2857 finally:
2858 vsg.start()
2859 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2860 self.vsg_xos_subscriber_delete(index, subId)
2861 df.callback(0)
2862 reactor.callLater(0,test_xos_subscriber,df)
2863 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002864
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002865 @deferred(420)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002866 def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_restarted(self, index=0):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002867 """
2868 Test Method:
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002869 1.Create subscriber
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002870 2.Verify external connectivity through vcpe instances from cord-tester
2871 3.Bring down first vSG vm
2872 4.Verify external network cant be reachable form first vcpe interface
2873 """
2874 df = defer.Deferred()
2875 def test_xos_subscriber(df,index=index):
2876 host = '8.8.8.8'
2877 subId = self.vsg_xos_subscriber_id(index)
2878 if subId == '0':
2879 log.info('creating vcpe instance of index 0')
2880 subId = self.vsg_xos_subscriber_create(index)
2881 assert_not_equal(subId,'0')
2882 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2883 vcpe_name = self.container_vcpes[index]
2884 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2885 try:
2886 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2887 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2888 assert_equal(st, False)
2889 log.info('Restarting vsg instance')
2890 vsg.reboot()
2891 time.sleep(10)
2892 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2893 time = 0
2894 status = False
2895 while(time <= 100):
2896 time.sleep(10)
2897 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2898 if st is False:
2899 status = True
2900 break
2901 time += 10
2902 assert_equal(status, True)
2903 except Exception as error:
2904 log.info('Got Unexpected error %s'%error)
2905 raise
2906 finally:
2907 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2908 self.vsg_xos_subscriber_delete(index, subId)
2909 df.callback(0)
2910 reactor.callLater(0,test_xos_subscriber,df)
2911 return df
2912
2913 @deferred(780)
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002914 def test_vsg_xos_multiple_subscribers_external_connectivity_if_two_vsgs_stop_and_start(self, index1=4, index2=6):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002915 """
2916 Test Method:
2917 1.Create two vcpe instances in two different vsg vms using XOS
2918 2.Verify external connectivity through vcpe instances from cord-tester
2919 3.Bring down first vSG vm
2920 4.Verify external network cant be reachable form first vcpe interface
2921 5.Bring down second vSG vm also
2922 6.Verify external network cant be reachable form first vcpe interface also
2923 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002924 df = defer.Deferred(df,index1=index1,index2=index2)
2925 def test_xos_subscriber(df,index=index):
2926 subId1 = self.vsg_xos_subscriber_create(index1)
2927 subId2 = self.vsg_xos_subscriber_create(index2)
2928 if subId1 == '0':
2929 self.vsg_xos_subscriber_delete(index1, subId1)
2930 assert_not_equal(subId1, '0')
2931 if subId2 == '0':
2932 self.vsg_xos_subscriber_delete(index2, subId2)
2933 assert_not_equal(subId2, '0')
2934 for index in [index1,index2]:
2935 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2936 vcpe_name = self.container_vcpes[index]
2937 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2938 try:
2939 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2940 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2941 assert_equal(st, False)
2942 log.info('Stopping vsg instance of index %s'%index)
2943 vsg.stop()
2944 time.sleep(5)
2945 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2946 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2947 assert_equal(st, True)
2948 except Exception as error:
2949 log.info('Got Unexpected error %s'%error)
2950 raise
2951 finally:
2952 vsg.start()
2953 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2954 df.callback(0)
2955 reactor.callLater(0,test_xos_subscriber,df)
2956 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002957
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002958 @deferred(420)
2959 def test_vsg_xos_subscriber_external_connectivity_with_creating_firewall_rule(self,index=0):
2960 """
2961 Alog:
2962 1.Cretae a vcpe instance using XOS
2963 2.Get dhcp IP to vcpe interface in cord-tester
2964 3.Verify external network can be reachable from cord-tester
2965 4.Add an iptable rule to drop packets destined to external network in vcpe
2966 5.Verify now external network cant be reachable
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002967 6.Delele the iptable in vcpe instance
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002968 7.Verify external network can be reachable from cord-tester
2969 """
2970 df = defer.Deferred()
2971 def test_xos_subscriber(df,index=index):
2972 log.info('cls.dhcp_vcpes is %s'%self.dhcp_vcpes)
2973 host = '8.8.8.8'
2974 subId = self.vsg_xos_subscriber_create(index)
2975 if subId == '0':
2976 subId = self.vsg_xos_subscriber_create(index)
2977 assert_not_equal(subId, '0')
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002978 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002979 vcpe_name = self.container_vcpes[index]
2980 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002981 try:
2982 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2983 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002984 #ssert_equal(st, False)
2985 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002986 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2987 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002988 st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
2989 self.vsg_xos_subscriber_delete(index, subId)
2990 except Exception as error:
2991 log.info('Got Unexpected error %s'%error)
2992 raise
2993 finally:
2994 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002995 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002996 self.vsg_xos_subscriber_delete(index, subId)
2997 df.callback(0)
2998 reactor.callLater(0,test_xos_subscriber,df)
2999 return df
A R Karthick63751492017-03-22 09:28:01 -07003000
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003001 def test_vsg_for_packet_received_with_invalid_ip_fields(self):
3002 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003003 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003004 1.Create a vSG VM in compute node
3005 2.Create a vCPE container in vSG VM
3006 3.Ensure vSG VM and vCPE container created properly
3007 4.From subscriber, send a ping packet with invalid ip fields
3008 5.Verify that vSG drops the packet
3009 6.Verify ping fails
3010 """
A R Karthick63751492017-03-22 09:28:01 -07003011
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003012 def test_vsg_for_packet_received_with_invalid_mac_fields(self):
3013 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003014 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003015 1.Create a vSG VM in compute node
3016 2.Create a vCPE container in vSG VM
3017 3.Ensure vSG VM and vCPE container created properly
3018 4.From subscriber, send a ping packet with invalid mac fields
3019 5.Verify that vSG drops the packet
3020 6.Verify ping fails
3021 """
A R Karthick63751492017-03-22 09:28:01 -07003022
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003023 def test_vsg_for_vlan_id_mismatch_in_stag(self):
3024 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003025 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003026 1.Create a vSG VM in compute Node
3027 2.Create a vCPE container in vSG VM
3028 3.Ensure vSG VM and vCPE container created properly
3029 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag
3030 5.Verify that ping fails as the packet drops at VM entry
3031 6.Repeat step 4 with correct s-tag
3032 7.Verify that ping success
3033 """
A R Karthick63751492017-03-22 09:28:01 -07003034
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003035 def test_vsg_for_vlan_id_mismatch_in_ctag(self):
3036 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003037 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003038 1.Create a vSG VM in compute node
3039 2.Create a vCPE container in vSG VM
3040 3.Ensure vSG VM and vCPE container created properly
3041 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag
3042 5.Verify that ping fails as the packet drops at vCPE container entry
3043 6.Repeat step 4 with valid s-tag and c-tag
3044 7.Verify that ping success
3045 """
A R Karthick63751492017-03-22 09:28:01 -07003046
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003047 def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self):
3048 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003049 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003050 1.Create two vSG VMs in compute node
3051 2.Create a vCPE container in each vSG VM
3052 3.Ensure vSG VM and vCPE container created properly
3053 4.From subscriber one, send ping request with valid s and c tags
3054 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags
3055 6.Verify that ping success for only subscriber one and fails for two.
3056 """
A R Karthick63751492017-03-22 09:28:01 -07003057
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003058 def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self):
3059 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003060 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003061 1.Create a vSG VM in compute node
3062 2.Create two vCPE containers in vSG VM
3063 3.Ensure vSG VM and vCPE container created properly
3064 4.From subscriber one, send ping request with valid s and c tags
3065 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag
3066 6.Verify that ping success for only subscriber one and fails for two
3067 """
A R Karthick63751492017-03-22 09:28:01 -07003068
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003069 def test_vsg_for_out_of_range_vlanid_in_ctag(self):
3070 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003071 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003072 1.Create a vSG VM in compute node
3073 2.Create a vCPE container in vSG VM
3074 3.Ensure vSG VM and vCPE container created properly
3075 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 )
3076 4.Verify that ping fails as the ping packets drops at vCPE container entry
3077 """
A R Karthick63751492017-03-22 09:28:01 -07003078
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003079 def test_vsg_for_out_of_range_vlanid_in_stag(self):
3080 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003081 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003082 1.Create a vSG VM in compute node
3083 2.Create a vCPE container in vSG VM
3084 3.Ensure vSG VM and vCPE container created properly
3085 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
3086 4.Verify that ping fails as the ping packets drops at vSG VM entry
3087 """
A R Karthick63751492017-03-22 09:28:01 -07003088
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00003089 def test_vsg_for_extracting_all_compute_stats_from_all_vcpe_containers(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003090 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003091 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003092 1.Create a vSG VM in compute node
3093 2.Create 10 vCPE containers in VM
3094 3.Ensure vSG VM and vCPE containers created properly
3095 4.Login to all vCPE containers
3096 4.Get all compute stats from all vCPE containers
3097 5.Verify the stats # verification method need to add
3098 """
A R Karthick63751492017-03-22 09:28:01 -07003099
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00003100 def test_vsg_for_extracting_dns_stats_from_all_vcpe_containers(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003101 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003102 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003103 1.Create a vSG VM in compute node
3104 2.Create 10 vCPE containers in VM
3105 3.Ensure vSG VM and vCPE containers created properly
3106 4.From 10 subscribers, send ping to valid and invalid dns hosts
3107 5.Verify dns resolves and ping success for valid dns hosts
3108 6.Verify ping fails for invalid dns hosts
3109 7.Verify dns host name resolve flows in OvS
3110 8.Login to all 10 vCPE containers
3111 9.Extract all dns stats
3112 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios
3113 """
A R Karthick037cb982017-07-07 17:35:30 -07003114 pass