blob: 41ebeabe74ab31f6a67645d3a3e9d7396806610a [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 Karthick705a5bf2017-10-27 11:17:04 -070060 head_node = os.getenv('HEAD_NODE', 'head1')
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)) ]
A R Karthickb2638632017-10-25 16:01:16 -0700146 cls.container_vcpes_reserved = [ 'vsg-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ]
A R Karthick035d2e22017-04-25 13:53:00 -0700147 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)) ]
A R Karthickb2638632017-10-25 16:01:16 -0700161 cls.container_vcpes = [ 'vsg-{}-{}'.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:
A R Karthickb2638632017-10-25 16:01:16 -0700230 vcpe_container = 'vsg-{}-{}'.format(vcp['s_tag'], vcp['c_tag'])
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000231 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)
A R Karthickb2638632017-10-25 16:01:16 -0700244 vcpe_container = 'vsg-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag'])
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000245 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'])
A R Karthickb2638632017-10-25 16:01:16 -07002284 vcpe = 'vsg-{}-{}'.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 ]
A R Karthick028edaf2017-11-06 16:34:57 -08002315 volt_tenants = self.restApiXos.ApiGet('VOLT_TENANT')
2316 subscribers = self.restApiXos.ApiGet('VOLT_SUBSCRIBER')
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002317 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:
A R Karthick028edaf2017-11-06 16:34:57 -08002321 volt_id = self.cord_subscriber.getVoltId(subscriber)
2322 provider_id = self.cord_subscriber.getProviderInstance(tenant)
2323 if int(volt_id) == int(provider_id):
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002324 volt_subscriber_info = {}
2325 volt_subscriber_info['voltTenant'] = dict(s_tag = tenant['s_tag'],
A R Karthick028edaf2017-11-06 16:34:57 -08002326 c_tag = tenant['c_tag'])
2327 volt_subscriber_info['volt_id'] = volt_id
2328 volt_subscriber_info['service_specific_id'] = subscriber['service_specific_id']
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002329 reserved_config.append( (subscriber, volt_subscriber_info) )
2330 break
2331 else:
A R Karthick028edaf2017-11-06 16:34:57 -08002332 log.info('Subscriber not found for tenant. s_tag: %s, c_tag: %s' %(\
2333 str(tenant['s_tag']),\
2334 str(tenant['c_tag'])))
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002335
2336 for subscriber_info, volt_subscriber_info in reserved_config:
2337 self.vsg_xos_subscriber_delete(0,
2338 subId = str(subscriber_info['id']),
2339 voltId = str(volt_subscriber_info['volt_id']),
2340 subscriber_info = subscriber_info,
2341 volt_subscriber_info = volt_subscriber_info)
2342 subId = self.vsg_xos_subscriber_create(0,
2343 subscriber_info = subscriber_info,
2344 volt_subscriber_info = volt_subscriber_info)
2345 log.info('Created reserved subscriber %s' %(subId))
2346
A R Karthick037cb982017-07-07 17:35:30 -07002347 def vsg_create(self, num_subscribers):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002348 if self.on_pod is False:
2349 return
A R Karthick037cb982017-07-07 17:35:30 -07002350 num_subscribers = min(num_subscribers, len(self.cord_subscriber.subscriber_info))
2351 for index in xrange(num_subscribers):
A R Karthicke29c8d42017-04-27 11:38:52 -07002352 #check if the index exists
2353 subId = self.vsg_xos_subscriber_id(index)
2354 if subId and subId != '0':
2355 self.vsg_xos_subscriber_delete(index, subId = subId)
2356 subId = self.vsg_xos_subscriber_create(index)
2357 log.info('Created Subscriber %s' %(subId))
2358
A R Karthick037cb982017-07-07 17:35:30 -07002359 def test_vsg_xos_subscriber_create_all(self):
2360 self.vsg_create(len(self.cord_subscriber.subscriber_info))
2361
2362 def vsg_delete(self, num_subscribers):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002363 if self.on_pod is False:
2364 return
A R Karthick037cb982017-07-07 17:35:30 -07002365 num_subscribers = min(num_subscribers, len(self.cord_subscriber.subscriber_info))
2366 for index in xrange(num_subscribers):
A R Karthicke29c8d42017-04-27 11:38:52 -07002367 subId = self.vsg_xos_subscriber_id(index)
2368 if subId and subId != '0':
2369 self.vsg_xos_subscriber_delete(index, subId = subId)
2370
A R Karthick037cb982017-07-07 17:35:30 -07002371 def test_vsg_xos_subscriber_delete_all(self):
2372 self.vsg_delete(len(self.cord_subscriber.subscriber_info))
2373
A R Karthicke29c8d42017-04-27 11:38:52 -07002374 def test_vsg_xos_subscriber_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002375 subId = self.vsg_xos_subscriber_create(0)
2376 if subId and subId != '0':
2377 self.vsg_xos_subscriber_delete(0, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002378
A R Karthicke29c8d42017-04-27 11:38:52 -07002379 def test_vsg_xos_subscriber_2_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002380 subId = self.vsg_xos_subscriber_create(1)
2381 if subId and subId != '0':
2382 self.vsg_xos_subscriber_delete(1, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002383
A R Karthicke29c8d42017-04-27 11:38:52 -07002384 def test_vsg_xos_subscriber_3_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002385 subId = self.vsg_xos_subscriber_create(2)
2386 if subId and subId != '0':
2387 self.vsg_xos_subscriber_delete(2, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002388
A R Karthicke29c8d42017-04-27 11:38:52 -07002389 def test_vsg_xos_subscriber_4_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002390 subId = self.vsg_xos_subscriber_create(3)
2391 if subId and subId != '0':
2392 self.vsg_xos_subscriber_delete(3, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002393
A R Karthicke29c8d42017-04-27 11:38:52 -07002394 def test_vsg_xos_subscriber_5_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002395 subId = self.vsg_xos_subscriber_create(4)
2396 if subId and subId != '0':
2397 self.vsg_xos_subscriber_delete(4, subId)
A.R Karthick282f0d32017-03-28 16:43:59 -07002398
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002399 @deferred(400)
2400 def test_vsg_xos_subscriber_external_connectivity_through_vcpe_instance(self, index=0):
2401 df = defer.Deferred()
2402 status = False
2403 def test_xos_subscriber(df):
2404 subId = self.vsg_xos_subscriber_id(index)
2405 if subId == '0':
2406 log.info('Creating vcpe instance ')
2407 subId = self.vsg_xos_subscriber_create(index)
2408 assert_not_equal(subId,'0')
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002409 vcpe = self.dhcp_vcpes[index]
2410 host = '8.8.8.8'
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002411 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2412 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2413 assert_equal(st, False)
2414 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2415 df.callback(0)
2416 reactor.callLater(0,test_xos_subscriber,df)
2417 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002418
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002419 #pass
2420 @deferred(50)
2421 def test_vsg_xos_subscriber_external_connectivity_without_creating_vcpe_instance(self, index=0):
2422 df = defer.Deferred()
2423 def test_xos_subscriber(df):
2424 subId = self.vsg_xos_subscriber_id(index)
2425 if subId != '0':
2426 log.info('deleting already existing vcpe instance ')
2427 self.vsg_xos_subscriber_delete(index, subId)
2428 vcpe = self.dhcp_vcpes[index]
2429 host = '8.8.8.8'
2430 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2431 st, out = getstatusoutput('route -n')
2432 log.info('route -n outpu-1-1-1--1-1-1-1-1-1-1 is %s'%out)
2433 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2434 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2435 assert_equal(st, True)
2436 df.callback(0)
2437 reactor.callLater(0,test_xos_subscriber,df)
2438 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002439
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002440 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002441 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 +00002442 df = defer.Deferred()
2443 def test_xos_subscriber(df):
2444 subId = self.vsg_xos_subscriber_id(index)
2445 if subId == '0':
2446 subId = self.vsg_xos_subscriber_create(index)
2447 assert_not_equal(subId,'0')
2448 vcpe = self.dhcp_vcpes[index]
2449 if subId and subId != '0':
2450 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2451 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2452 assert_equal(st, False)
2453 self.vsg_xos_subscriber_delete(index, subId)
2454 time.sleep(2)
2455 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2456 assert_equal(st, True)
2457 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2458 df.callback(0)
2459 reactor.callLater(0,test_xos_subscriber,df)
2460 return df
2461
2462 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002463 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 +00002464 df = defer.Deferred()
2465 def test_xos_subscriber(df):
2466 subId = self.vsg_xos_subscriber_id(index)
2467 if subId == '0':
2468 subId = self.vsg_xos_subscriber_create(index)
2469 assert_not_equal(subId,'0')
2470 vcpe_intf = self.dhcp_vcpes[index]
2471 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2472 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2473 assert_equal(st, False)
A R Karthickb2638632017-10-25 16:01:16 -07002474 vcpe_name = 'vsg-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002475 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2476 st, _ = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
2477 assert_equal(st, True)
2478 time.sleep(5)
2479 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2480 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2481 assert_equal(st, False)
2482 df.callback(0)
2483 reactor.callLater(0,test_xos_subscriber,df)
2484 return df
2485
2486 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002487 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 +00002488 df = defer.Deferred()
2489 def test_xos_subscriber(df):
2490 subId = self.vsg_xos_subscriber_id(index)
2491 if subId == '0':
2492 subId = self.vsg_xos_subscriber_create(index)
2493 assert_not_equal(subId,'0')
2494 vcpe_intf = self.dhcp_vcpes[index]
2495 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2496 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2497 assert_equal(st, False)
A R Karthickb2638632017-10-25 16:01:16 -07002498 vcpe_name = 'vsg-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002499 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2500 st, _ = vsg.run_cmd('sudo docker stop {}'.format(vcpe_name))
2501 assert_equal(st, True)
2502 time.sleep(3)
2503 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2504 assert_equal(st, True)
2505 st, _ = vsg.run_cmd('sudo docker start {}'.format(vcpe_name))
2506 assert_equal(st, True)
2507 time.sleep(5)
2508 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2509 assert_equal(st, False)
2510 df.callback(0)
2511 reactor.callLater(0,test_xos_subscriber,df)
2512 return df
2513
2514 #getting list out of range error while creating vcpe of index 6
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002515 def test_vsg_create_xos_subscribers_in_different_vsg_vm(self, index1=4, index2=6):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002516 indexes = list(index1,index2)
2517 subids = []
2518 for index in indexes:
2519 subId = self.vsg_xos_subscriber_id(index)
2520 if not subId:
2521 subId = self.vsg_xos_subscriber_create(index)
2522 assert_not_equal(subId,'0')
2523 subids.append(subId)
2524 log.info('succesfully created two vcpe instances in two different vSG VMs')
2525 self.vsg_xos_subscriber_delete(index1, subid[0])
2526 self.vsg_xos_subscriber_delete(index2, subid[1])
2527
2528 #Unable to reach external network via vcpes created by XOS
2529 @deferred(TIMEOUT+400)
2530 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_goes_down(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002531 """
2532 Test Method:
2533 1.Create two vcpe instances in two different vsg vms using XOS
2534 2.Verify external connectivity through vcpe instances from cord-tester
2535 3.Kill first vcpe instance
2536 4.Verify external network cant be reachable form first vcpe interface
2537 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002538 df = defer.Deferred()
2539 def test_xos_subscriber(df):
2540 host1 = '8.8.8.8'
2541 host2 = '4.2.2.2'
2542 vcpe_intf1 = self.dhcp_vcpes[0]
2543 vcpe_intf2 = self.dhcp_vcpes[1]
A R Karthickb2638632017-10-25 16:01:16 -07002544 vcpe_name1 = 'vsg-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2545 vcpe_name2 = 'vsg-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002546 subId1 = self.vsg_xos_subscriber_id(0)
2547 log.info('already existing subid of index 0 is %s'%subId1)
2548 if subId1 == '0':
2549 log.info('creating vcpe instance of index 0')
2550 subId1 = self.vsg_xos_subscriber_create(0)
2551 assert_not_equal(subId1,'0')
2552 subId2 = self.vsg_xos_subscriber_id(1)
2553 log.info('already existing subid of index 1 is %s'%subId2)
2554 if subId2 == '0':
2555 log.info('creating vcpe instance of index 1')
2556 subId2 = self.vsg_xos_subscriber_create(1)
2557 assert_not_equal(subId2,'0')
2558 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2559 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2560 try:
2561 for intf in [vcpe_intf1,vcpe_intf2]:
2562 host = host1 if intf is vcpe_intf1 else host2
2563 self.add_static_route_via_vcpe_interface([host],vcpe=intf)
2564 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2565 assert_equal(st, False)
2566 if intf is vcpe_intf2:
2567 self.vsg_xos_subscriber_delete(1, subId2)
2568 st, _ = vsg2.run_cmd('sudo docker kill {}'.format(vcpe_name2))
2569 time.sleep(2)
2570 self.add_static_route_via_vcpe_interface([host],vcpe=intf)
2571 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2572 assert_equal(st, False)
2573 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2574 assert_equal(st, True)
2575 except Exception as error:
2576 log.info('Got Unexpected error %s'%error)
2577 raise
2578 finally:
2579 self.vsg_xos_subscriber_delete(0, subId1)
2580 self.vsg_xos_subscriber_delete(1, subId2)
2581 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2582 self.del_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2583 df.callback(0)
2584 reactor.callLater(0,test_xos_subscriber,df)
2585 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002586
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002587 @deferred(TIMEOUT+400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002588 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 +00002589 """
2590 Test Method:
2591 1.Create two vcpe instances in two different vsg vms using XOS
2592 2.Verify external connectivity through vcpe instances from cord-tester
2593 3.Remove first vcpe instance
2594 4.Verify external network cant be reachable form first vcpe interface
2595 5.Add back the removed vcpe instance
2596 6.Verify external connectivity through vcpe instances from cord-tester
2597 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002598 df = defer.Deferred()
2599 def test_xos_subscriber(df,index=index):
2600 host = '8.8.8.8'
2601 subId = self.vsg_xos_subscriber_id(index)
2602 log.info('already existing subid of index 0 is %s'%subId)
2603 if subId == '0':
2604 log.info('creating vcpe instance of index %s'%index)
2605 subId = self.vsg_xos_subscriber_create(index)
2606 assert_not_equal(subId,'0')
2607 vcpe_intf = self.dhcp_vcpes[0]
A R Karthickb2638632017-10-25 16:01:16 -07002608 vcpe_name = 'vsg-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002609 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2610 try:
2611 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2612 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2613 assert_equal(st, False)
2614 log.info('Deleting vcpe Instance of index %s'%index)
2615 self.vsg_xos_subscriber_delete(0, subId)
2616 st, _ = vsg.run_cmd('sudo docker kill {}'.format(vcpe_name))
2617 time.sleep(1)
2618 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2619 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2620 assert_equal(st, True)
2621 subId = self.vsg_xos_subscriber_create(index)
2622 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2623 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2624 assert_equal(st, False)
2625 except Exception as error:
2626 log.info('Got Unexpected error %s'%error)
2627 raise
2628 finally:
2629 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2630 self.vsg_xos_subscriber_delete(0, subId)
2631 df.callback(0)
2632 reactor.callLater(0,test_xos_subscriber,df)
2633 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002634
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002635 @deferred(TIMEOUT+400)
2636 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_restarts(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002637 """
2638 Test Method:
2639 1.Create two vcpe instances in two different vsg vms using XOS
2640 2.Verify external connectivity through vcpe instances from cord-tester
2641 3.Restart first vcpe instance
2642 4.Verify external network cant be reachable form first vcpe interface
2643 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002644 df = defer.Deferred()
2645 def test_xos_subscriber(df):
2646 host1 = '8.8.8.8'
2647 host2 = '4.2.2.2'
2648 subId1 = self.vsg_xos_subscriber_id(0)
2649 log.info('already existing subid of index 0 is %s'%subId1)
2650 if subId1 == '0':
2651 log.info('creating vcpe instance of index 0')
2652 subId1 = self.vsg_xos_subscriber_create(0)
2653 assert_not_equal(subId1,'0')
2654 subId2 = self.vsg_xos_subscriber_id(1)
2655 log.info('already existing subid of index 1 is %s'%subId2)
2656 if subId2 == '0':
2657 log.info('creating vcpe instance of index 1')
2658 subId2 = self.vsg_xos_subscriber_create(1)
2659 vcpe_intf1 = self.dhcp_vcpes[0]
2660 vcpe_intf2 = self.dhcp_vcpes[1]
A R Karthickb2638632017-10-25 16:01:16 -07002661 vcpe_name1 = 'vsg-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2662 vcpe_name2 = 'vsg-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002663 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2664 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2665 try:
2666 #checking external connectivity from vcpe interface 1 before vcpe 2 restart
2667 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2668 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2669 assert_equal(st, False)
2670 #checking external connectivity from vcpe interface 2 before vcpe 2 restart
2671 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2672 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2673 assert_equal(st, False)
2674 st, _ = vsg2.run_cmd('sudo docker restart {}'.format(vcpe_name2))
2675 time.sleep(10)
2676 #checking external connectivity from vcpe interface 1 after vcpe 2 restart
2677 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2678 assert_equal(st, False)
2679 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2680 time = 0
2681 status = False
2682 while(time <= 100):
2683 time.sleep(10)
2684 st,_ = getstatusoutput('ping -c 1 {}'.format(hos2))
2685 if st is False:
2686 status = True
2687 break
2688 time += 10
2689 assert_equal(status, True)
2690 except Exception as error:
2691 log.info('Got Unexpected error %s'%error)
2692 raise
2693 finally:
2694 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2695 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2696 self.vsg_xos_subscriber_delete(0, subId1)
2697 self.vsg_xos_subscriber_delete(1, subId2)
2698 df.callback(0)
2699 reactor.callLater(0,test_xos_subscriber,df)
2700 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002701
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002702 @deferred(500)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002703 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_is_paused(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002704 """
2705 Test Method:
2706 1.Create two vcpe instances in two different vsg vms using XOS
2707 2.Verify external connectivity through vcpe instances from cord-tester
2708 3.Pause running first vcpe instance
2709 4.Verify external network cant be reachable form first vcpe interface
2710 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002711 df = defer.Deferred()
2712 def test_xos_subscriber(df):
2713 host1 = '8.8.8.8'
2714 host2 = '4.2.2.2'
2715 subId1 = self.vsg_xos_subscriber_id(0)
2716 log.info('already existing subid of index 0 is %s'%subId1)
2717 if subId1 == '0':
2718 log.info('creating vcpe instance of index 0')
2719 subId1 = self.vsg_xos_subscriber_create(0)
2720 assert_not_equal(subId1,'0')
2721 subId2 = self.vsg_xos_subscriber_id(1)
2722 log.info('already existing subid of index 1 is %s'%subId2)
2723 if subId2 == '0':
2724 log.info('creating vcpe instance of index 1')
2725 subId2 = self.vsg_xos_subscriber_create(1)
2726 vcpe_intf1 = self.dhcp_vcpes[0]
2727 vcpe_intf2 = self.dhcp_vcpes[1]
A R Karthickb2638632017-10-25 16:01:16 -07002728 vcpe_name1 = 'vsg-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2729 vcpe_name2 = 'vsg-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002730 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2731 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2732 try:
2733 #checking external connectivity from vcpe interface 1 before vcpe 2 pause
2734 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2735 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2736 assert_equal(st, False)
2737 #checking external connectivity from vcpe interface 2 before vcpe 2 pause
2738 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2739 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2740 assert_equal(st, False)
2741 st, _ = vsg2.run_cmd('sudo docker pause {}'.format(vcpe_name2))
2742 time.sleep(1)
2743 #checking external connectivity from vcpe interface 1 after vcpe 2 pause
2744 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2745 assert_equal(st, False)
2746 #checking external connectivity from vcpe interface 2 after vcpe 2 pause
2747 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2748 assert_equal(st, True)
2749 except Exception as error:
2750 log.info('Got Unexpected error %s'%error)
2751 raise
2752 finally:
2753 log.info('In Finally block 3333333333333333')
2754 st, _ = vsg2.run_cmd('sudo docker unpause {}'.format(vcpe_name2))
2755 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2756 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2757 self.vsg_xos_subscriber_delete(0, subId1)
2758 self.vsg_xos_subscriber_delete(1, subId2)
2759 df.callback(0)
2760 reactor.callLater(0,test_xos_subscriber,df)
2761 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002762
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002763 @deferred(500)
2764 def test_vsg_xos_subscriber_external_connectivity_if_one_vcpe_stops(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002765 """
2766 Test Method:
2767 1.Create two vcpe instances in two different vsg vms using XOS
2768 2.Verify external connectivity through vcpe instances from cord-tester
2769 3.Stop running first vcpe instance
2770 4.Verify external network cant be reachable form first vcpe interface
2771 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002772 df = defer.Deferred()
2773 def test_xos_subscriber(df):
2774 host1 = '8.8.8.8'
2775 host2 = '4.2.2.2'
2776 subId1 = self.vsg_xos_subscriber_id(0)
2777 log.info('already existing subid of index 0 is %s'%subId1)
2778 if subId1 == '0':
2779 log.info('creating vcpe instance of index 0')
2780 subId1 = self.vsg_xos_subscriber_create(0)
2781 assert_not_equal(subId1,'0')
2782 subId2 = self.vsg_xos_subscriber_id(1)
2783 log.info('already existing subid of index 1 is %s'%subId2)
2784 if subId2 == '0':
2785 log.info('creating vcpe instance of index 1')
2786 subId2 = self.vsg_xos_subscriber_create(1)
2787 vcpe_intf1 = self.dhcp_vcpes[0]
2788 vcpe_intf2 = self.dhcp_vcpes[1]
A R Karthickb2638632017-10-25 16:01:16 -07002789 vcpe_name1 = 'vsg-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2790 vcpe_name2 = 'vsg-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002791 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2792 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2793 try:
2794 #checking external connectivity from vcpe interface 1 before vcpe 2 stop
2795 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2796 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2797 assert_equal(st, False)
2798 #checking external connectivity from vcpe interface 2 before vcpe 2 stop
2799 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2800 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2801 assert_equal(st, False)
2802 st, _ = vsg2.run_cmd('sudo docker stop {}'.format(vcpe_name2))
2803 time.sleep(5)
2804 #checking external connectivity from vcpe interface 1 after vcpe 2 stop
2805 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2806 assert_equal(st, False)
2807 #checking external connectivity from vcpe interface 1 after vcpe 2 stop
2808 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2809 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2810 assert_equal(st, True)
2811 except Exception as error:
2812 log.info('Got Unexpected error %s'%error)
2813 raise
2814 finally:
2815 st, _ = vsg2.run_cmd('sudo docker start {}'.format(vcpe_name2))
2816 time.sleep(10)
2817 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2818 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2819 self.vsg_xos_subscriber_delete(0, subId1)
2820 self.vsg_xos_subscriber_delete(1, subId2)
2821 df.callback(0)
2822 reactor.callLater(0,test_xos_subscriber,df)
2823 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002824
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002825 @deferred(420)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002826 def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_stopped(self, index=0):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002827 """
2828 Test Method:
2829 1.Create two vcpe instances in two different vsg vms using XOS
2830 2.Verify external connectivity through vcpe instances from cord-tester
2831 3.Bring down first vSG vm
2832 4.Verify external network cant be reachable form first vcpe interface
2833 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002834 df = defer.Deferred()
2835 def test_xos_subscriber(df,index=index):
2836 host = '8.8.8.8'
2837 subId = self.vsg_xos_subscriber_id(index)
2838 if subId == '0':
2839 log.info('creating vcpe instance of index 0')
2840 subId = self.vsg_xos_subscriber_create(index)
2841 assert_not_equal(subId,'0')
2842 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2843 vcpe_name = self.container_vcpes[index]
2844 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2845 try:
2846 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2847 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2848 assert_equal(st, False)
2849 log.info('Stopping vsg instance')
2850 vsg.stop()
2851 time.sleep(5)
2852 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2853 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2854 assert_equal(st, True)
2855 except Exception as error:
2856 log.info('Got Unexpected error %s'%error)
2857 raise
2858 finally:
2859 vsg.start()
2860 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2861 self.vsg_xos_subscriber_delete(index, subId)
2862 df.callback(0)
2863 reactor.callLater(0,test_xos_subscriber,df)
2864 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002865
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002866 @deferred(420)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002867 def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_restarted(self, index=0):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002868 """
2869 Test Method:
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002870 1.Create subscriber
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002871 2.Verify external connectivity through vcpe instances from cord-tester
2872 3.Bring down first vSG vm
2873 4.Verify external network cant be reachable form first vcpe interface
2874 """
2875 df = defer.Deferred()
2876 def test_xos_subscriber(df,index=index):
2877 host = '8.8.8.8'
2878 subId = self.vsg_xos_subscriber_id(index)
2879 if subId == '0':
2880 log.info('creating vcpe instance of index 0')
2881 subId = self.vsg_xos_subscriber_create(index)
2882 assert_not_equal(subId,'0')
2883 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2884 vcpe_name = self.container_vcpes[index]
2885 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2886 try:
2887 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2888 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2889 assert_equal(st, False)
2890 log.info('Restarting vsg instance')
2891 vsg.reboot()
2892 time.sleep(10)
2893 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2894 time = 0
2895 status = False
2896 while(time <= 100):
2897 time.sleep(10)
2898 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2899 if st is False:
2900 status = True
2901 break
2902 time += 10
2903 assert_equal(status, True)
2904 except Exception as error:
2905 log.info('Got Unexpected error %s'%error)
2906 raise
2907 finally:
2908 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2909 self.vsg_xos_subscriber_delete(index, subId)
2910 df.callback(0)
2911 reactor.callLater(0,test_xos_subscriber,df)
2912 return df
2913
2914 @deferred(780)
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002915 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 +00002916 """
2917 Test Method:
2918 1.Create two vcpe instances in two different vsg vms using XOS
2919 2.Verify external connectivity through vcpe instances from cord-tester
2920 3.Bring down first vSG vm
2921 4.Verify external network cant be reachable form first vcpe interface
2922 5.Bring down second vSG vm also
2923 6.Verify external network cant be reachable form first vcpe interface also
2924 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002925 df = defer.Deferred(df,index1=index1,index2=index2)
2926 def test_xos_subscriber(df,index=index):
2927 subId1 = self.vsg_xos_subscriber_create(index1)
2928 subId2 = self.vsg_xos_subscriber_create(index2)
2929 if subId1 == '0':
2930 self.vsg_xos_subscriber_delete(index1, subId1)
2931 assert_not_equal(subId1, '0')
2932 if subId2 == '0':
2933 self.vsg_xos_subscriber_delete(index2, subId2)
2934 assert_not_equal(subId2, '0')
2935 for index in [index1,index2]:
2936 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2937 vcpe_name = self.container_vcpes[index]
2938 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2939 try:
2940 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2941 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2942 assert_equal(st, False)
2943 log.info('Stopping vsg instance of index %s'%index)
2944 vsg.stop()
2945 time.sleep(5)
2946 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2947 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2948 assert_equal(st, True)
2949 except Exception as error:
2950 log.info('Got Unexpected error %s'%error)
2951 raise
2952 finally:
2953 vsg.start()
2954 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2955 df.callback(0)
2956 reactor.callLater(0,test_xos_subscriber,df)
2957 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002958
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002959 @deferred(420)
2960 def test_vsg_xos_subscriber_external_connectivity_with_creating_firewall_rule(self,index=0):
2961 """
2962 Alog:
2963 1.Cretae a vcpe instance using XOS
2964 2.Get dhcp IP to vcpe interface in cord-tester
2965 3.Verify external network can be reachable from cord-tester
2966 4.Add an iptable rule to drop packets destined to external network in vcpe
2967 5.Verify now external network cant be reachable
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002968 6.Delele the iptable in vcpe instance
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002969 7.Verify external network can be reachable from cord-tester
2970 """
2971 df = defer.Deferred()
2972 def test_xos_subscriber(df,index=index):
2973 log.info('cls.dhcp_vcpes is %s'%self.dhcp_vcpes)
2974 host = '8.8.8.8'
2975 subId = self.vsg_xos_subscriber_create(index)
2976 if subId == '0':
2977 subId = self.vsg_xos_subscriber_create(index)
2978 assert_not_equal(subId, '0')
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002979 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002980 vcpe_name = self.container_vcpes[index]
2981 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002982 try:
2983 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2984 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002985 #ssert_equal(st, False)
2986 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 +00002987 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2988 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002989 st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
2990 self.vsg_xos_subscriber_delete(index, subId)
2991 except Exception as error:
2992 log.info('Got Unexpected error %s'%error)
2993 raise
2994 finally:
2995 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002996 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002997 self.vsg_xos_subscriber_delete(index, subId)
2998 df.callback(0)
2999 reactor.callLater(0,test_xos_subscriber,df)
3000 return df
A R Karthick63751492017-03-22 09:28:01 -07003001
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003002 def test_vsg_for_packet_received_with_invalid_ip_fields(self):
3003 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003004 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003005 1.Create a vSG VM in compute node
3006 2.Create a vCPE container in vSG VM
3007 3.Ensure vSG VM and vCPE container created properly
3008 4.From subscriber, send a ping packet with invalid ip fields
3009 5.Verify that vSG drops the packet
3010 6.Verify ping fails
3011 """
A R Karthick63751492017-03-22 09:28:01 -07003012
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003013 def test_vsg_for_packet_received_with_invalid_mac_fields(self):
3014 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003015 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003016 1.Create a vSG VM in compute node
3017 2.Create a vCPE container in vSG VM
3018 3.Ensure vSG VM and vCPE container created properly
3019 4.From subscriber, send a ping packet with invalid mac fields
3020 5.Verify that vSG drops the packet
3021 6.Verify ping fails
3022 """
A R Karthick63751492017-03-22 09:28:01 -07003023
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003024 def test_vsg_for_vlan_id_mismatch_in_stag(self):
3025 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003026 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003027 1.Create a vSG VM in compute Node
3028 2.Create a vCPE container in vSG VM
3029 3.Ensure vSG VM and vCPE container created properly
3030 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag
3031 5.Verify that ping fails as the packet drops at VM entry
3032 6.Repeat step 4 with correct s-tag
3033 7.Verify that ping success
3034 """
A R Karthick63751492017-03-22 09:28:01 -07003035
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003036 def test_vsg_for_vlan_id_mismatch_in_ctag(self):
3037 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003038 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003039 1.Create a vSG VM in compute node
3040 2.Create a vCPE container in vSG VM
3041 3.Ensure vSG VM and vCPE container created properly
3042 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag
3043 5.Verify that ping fails as the packet drops at vCPE container entry
3044 6.Repeat step 4 with valid s-tag and c-tag
3045 7.Verify that ping success
3046 """
A R Karthick63751492017-03-22 09:28:01 -07003047
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003048 def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self):
3049 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003050 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003051 1.Create two vSG VMs in compute node
3052 2.Create a vCPE container in each vSG VM
3053 3.Ensure vSG VM and vCPE container created properly
3054 4.From subscriber one, send ping request with valid s and c tags
3055 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags
3056 6.Verify that ping success for only subscriber one and fails for two.
3057 """
A R Karthick63751492017-03-22 09:28:01 -07003058
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003059 def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self):
3060 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003061 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003062 1.Create a vSG VM in compute node
3063 2.Create two vCPE containers in vSG VM
3064 3.Ensure vSG VM and vCPE container created properly
3065 4.From subscriber one, send ping request with valid s and c tags
3066 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag
3067 6.Verify that ping success for only subscriber one and fails for two
3068 """
A R Karthick63751492017-03-22 09:28:01 -07003069
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003070 def test_vsg_for_out_of_range_vlanid_in_ctag(self):
3071 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003072 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003073 1.Create a vSG VM in compute node
3074 2.Create a vCPE container in vSG VM
3075 3.Ensure vSG VM and vCPE container created properly
3076 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 )
3077 4.Verify that ping fails as the ping packets drops at vCPE container entry
3078 """
A R Karthick63751492017-03-22 09:28:01 -07003079
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003080 def test_vsg_for_out_of_range_vlanid_in_stag(self):
3081 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003082 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003083 1.Create a vSG VM in compute node
3084 2.Create a vCPE container in vSG VM
3085 3.Ensure vSG VM and vCPE container created properly
3086 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
3087 4.Verify that ping fails as the ping packets drops at vSG VM entry
3088 """
A R Karthick63751492017-03-22 09:28:01 -07003089
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00003090 def test_vsg_for_extracting_all_compute_stats_from_all_vcpe_containers(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003091 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003092 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003093 1.Create a vSG VM in compute node
3094 2.Create 10 vCPE containers in VM
3095 3.Ensure vSG VM and vCPE containers created properly
3096 4.Login to all vCPE containers
3097 4.Get all compute stats from all vCPE containers
3098 5.Verify the stats # verification method need to add
3099 """
A R Karthick63751492017-03-22 09:28:01 -07003100
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00003101 def test_vsg_for_extracting_dns_stats_from_all_vcpe_containers(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003102 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003103 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003104 1.Create a vSG VM in compute node
3105 2.Create 10 vCPE containers in VM
3106 3.Ensure vSG VM and vCPE containers created properly
3107 4.From 10 subscribers, send ping to valid and invalid dns hosts
3108 5.Verify dns resolves and ping success for valid dns hosts
3109 6.Verify ping fails for invalid dns hosts
3110 7.Verify dns host name resolve flows in OvS
3111 8.Login to all 10 vCPE containers
3112 9.Extract all dns stats
3113 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios
3114 """
A R Karthick037cb982017-07-07 17:35:30 -07003115 pass