blob: 8f733ed37be35e55e31d04458ac0b7e227b7c789 [file] [log] [blame]
Chetan Gaonker52418832017-01-26 23:03:13 +00001#copyright 2016-present Ciena Corporation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
A R Karthickd0fdf3b2017-03-21 16:54:22 -070015import time
16import os
A.R Karthick282f0d32017-03-28 16:43:59 -070017import sys
18import json
Chetan Gaonker0bf76312017-05-09 16:48:10 +000019import requests
Chetan Gaonker52418832017-01-26 23:03:13 +000020from nose.tools import *
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +000021from twisted.internet import defer
22from nose.twistedtools import reactor, deferred
A.R Karthick33cfdbe2017-03-17 18:03:48 -070023from CordTestUtils import *
Chetan Gaonker52418832017-01-26 23:03:13 +000024from OltConfig import OltConfig
Chetan Gaonker52418832017-01-26 23:03:13 +000025from onosclidriver import OnosCliDriver
A.R Karthick9ccd0d02017-03-16 17:11:08 -070026from SSHTestAgent import SSHTestAgent
Chetan Gaonker52418832017-01-26 23:03:13 +000027from CordLogger import CordLogger
A R Karthickd0fdf3b2017-03-21 16:54:22 -070028from VSGAccess import VSGAccess
A R Karthick933f5b52017-03-27 15:27:16 -070029from CordTestUtils import log_test as log
A R Karthick9dc6e922017-07-12 14:40:16 -070030from CordTestConfig import setup_module, running_on_ciab, teardown_module
A.R Karthicka9b594d2017-03-29 16:25:22 -070031from OnosCtrl import OnosCtrl
A R Karthickb608d402017-06-02 11:48:41 -070032from CordContainer import Onos
A R Karthicked3a2ca2017-07-06 15:50:03 -070033from CordSubscriberUtils import CordSubscriberUtils, XosUtils
Chetan Gaonker52418832017-01-26 23:03:13 +000034log.setLevel('INFO')
35
36class vsg_exchange(CordLogger):
37 ONOS_INSTANCES = 3
38 V_INF1 = 'veth0'
39 device_id = 'of:' + get_mac()
Chetan Gaonker52418832017-01-26 23:03:13 +000040 TEST_IP = '8.8.8.8'
41 HOST = "10.1.0.1"
42 USER = "vagrant"
43 PASS = "vagrant"
A R Karthick63751492017-03-22 09:28:01 -070044 head_node = os.getenv('HEAD_NODE', 'prod')
A.R Karthick9ccd0d02017-03-16 17:11:08 -070045 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
A R Karthick03f40aa2017-03-20 19:33:55 -070046 test_path = os.path.dirname(os.path.realpath(__file__))
A.R Karthick5968e0d2017-05-16 14:50:46 -070047 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 -070048 restApiXos = None
A R Karthicked3a2ca2017-07-06 15:50:03 -070049 cord_subscriber = None
50 SUBSCRIBER_ACCOUNT_NUM = 200
51 SUBSCRIBER_S_TAG = 304
52 SUBSCRIBER_C_TAG = 304
53 SUBSCRIBERS_PER_S_TAG = 8
A R Karthickb0cec7c2017-04-21 10:42:54 -070054 subscriber_info = []
55 volt_subscriber_info = []
A R Karthick9a16a112017-04-07 15:40:05 -070056 restore_methods = []
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +000057 TIMEOUT=120
A.R Karthickb145da82017-04-20 14:45:43 -070058 FABRIC_PORT_HEAD_NODE = 1
59 FABRIC_PORT_COMPUTE_NODE = 2
60 APP_NAME = 'org.ciena.xconnect'
61 APP_FILE = os.path.join(test_path, '..', 'apps/xconnect-1.0-SNAPSHOT.oar')
A.R Karthick50f4d9a2017-04-20 16:44:19 -070062 NUM_SUBSCRIBERS = 5
A R Karthick0a4ca3a2017-03-30 09:36:53 -070063
64 @classmethod
A R Karthick037cb982017-07-07 17:35:30 -070065 def setUpCordApi(cls, **subscriber_config):
66 num_subscribers = subscriber_config.get('num_subscribers', cls.NUM_SUBSCRIBERS)
67 account_num = subscriber_config.get('account_num', cls.SUBSCRIBER_ACCOUNT_NUM)
68 s_tag = subscriber_config.get('s_tag', cls.SUBSCRIBER_S_TAG)
69 c_tag = subscriber_config.get('c_tag', cls.SUBSCRIBER_C_TAG)
70 subscribers_per_s_tag = subscriber_config.get('subscribers_per_s_tag', cls.SUBSCRIBERS_PER_S_TAG)
A R Karthicked3a2ca2017-07-06 15:50:03 -070071 cls.cord_subscriber = CordSubscriberUtils(num_subscribers,
A R Karthick037cb982017-07-07 17:35:30 -070072 account_num = account_num,
73 s_tag = s_tag,
74 c_tag = c_tag,
75 subscribers_per_s_tag = subscribers_per_s_tag)
A R Karthicked3a2ca2017-07-06 15:50:03 -070076 cls.restApiXos = XosUtils.getRestApi()
A R Karthick97e08852017-04-26 10:06:38 -070077
78 @classmethod
A R Karthickb0cec7c2017-04-21 10:42:54 -070079 def closeVCPEAccess(cls, volt_subscriber_info):
A R Karthick5d30b3c2017-04-27 10:25:40 -070080 OnosCtrl.uninstall_app(cls.APP_NAME, onos_ip = cls.HEAD_NODE)
A.R Karthickb145da82017-04-20 14:45:43 -070081
82 @classmethod
A R Karthickb0cec7c2017-04-21 10:42:54 -070083 def openVCPEAccess(cls, volt_subscriber_info):
A.R Karthickb145da82017-04-20 14:45:43 -070084 """
A R Karthickb0cec7c2017-04-21 10:42:54 -070085 This code is used to configure leaf switch for head node access to compute node over fabric.
86 Care is to be taken to avoid overwriting existing/default vcpe flows.
87 The access is opened for generated subscriber info which should not overlap.
88 We target the fabric onos instance on head node.
A.R Karthickb145da82017-04-20 14:45:43 -070089 """
A R Karthickb608d402017-06-02 11:48:41 -070090 version = Onos.getVersion(onos_ip = cls.HEAD_NODE)
91 app_version = '1.0-SNAPSHOT'
92 major = int(version.split('.')[0])
93 minor = int(version.split('.')[1])
94 if major > 1:
95 app_version = '2.0-SNAPSHOT'
96 elif major == 1 and minor > 10:
97 app_version = '2.0-SNAPSHOT'
98 cls.APP_FILE = os.path.join(cls.test_path, '..', 'apps/xconnect-{}.oar'.format(app_version))
A.R Karthickb145da82017-04-20 14:45:43 -070099 OnosCtrl.install_app(cls.APP_FILE, onos_ip = cls.HEAD_NODE)
100 time.sleep(2)
A R Karthickb0cec7c2017-04-21 10:42:54 -0700101 s_tags = map(lambda tenant: int(tenant['voltTenant']['s_tag']), volt_subscriber_info)
102 #only get unique vlan tags
103 s_tags = list(set(s_tags))
A.R Karthickb145da82017-04-20 14:45:43 -0700104 devices = OnosCtrl.get_device_ids(controller = cls.HEAD_NODE)
A R Karthickb0cec7c2017-04-21 10:42:54 -0700105 if devices:
106 device_config = {}
107 for device in devices:
108 device_config[device] = []
109 for s_tag in s_tags:
110 xconnect_config = {'vlan': s_tag, 'ports' : [ cls.FABRIC_PORT_HEAD_NODE, cls.FABRIC_PORT_COMPUTE_NODE ] }
111 device_config[device].append(xconnect_config)
A.R Karthickb145da82017-04-20 14:45:43 -0700112
A R Karthickb0cec7c2017-04-21 10:42:54 -0700113 cfg = { 'apps' : { 'org.ciena.xconnect' : { 'xconnectTestConfig' : device_config } } }
114 OnosCtrl.config(cfg, controller = cls.HEAD_NODE)
A.R Karthickb145da82017-04-20 14:45:43 -0700115
116 @classmethod
A R Karthick037cb982017-07-07 17:35:30 -0700117 def vsgSetup(cls, **subscriber_config):
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700118 cls.controllers = get_controllers()
119 cls.controller = cls.controllers[0]
120 cls.cli = None
A R Karthick19771192017-04-25 14:57:05 -0700121 cls.on_pod = running_on_pod()
122 cls.on_ciab = running_on_ciab()
A R Karthick03f40aa2017-03-20 19:33:55 -0700123 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
124 cls.vcpes = cls.olt.get_vcpes()
125 cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp')
A R Karthick035d2e22017-04-25 13:53:00 -0700126 cls.vcpes_reserved = cls.olt.get_vcpes_by_type('reserved')
127 cls.dhcp_vcpes_reserved = [ 'vcpe{}.{}.{}'.format(i, cls.vcpes_reserved[i]['s_tag'], cls.vcpes_reserved[i]['c_tag'])
128 for i in xrange(len(cls.vcpes_reserved)) ]
129 cls.untagged_dhcp_vcpes_reserved = [ 'vcpe{}'.format(i) for i in xrange(len(cls.vcpes_reserved)) ]
130 cls.container_vcpes_reserved = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ]
131 vcpe_dhcp_reserved = None
132 vcpe_container_reserved = None
133 if cls.vcpes_reserved:
134 vcpe_dhcp_reserved = cls.dhcp_vcpes_reserved[0]
A R Karthick19771192017-04-25 14:57:05 -0700135 if cls.on_pod is False:
A R Karthick035d2e22017-04-25 13:53:00 -0700136 vcpe_dhcp_reserved = cls.untagged_dhcp_vcpes_reserved[0]
137 vcpe_container_reserved = cls.container_vcpes_reserved[0]
138
139 cls.vcpe_dhcp_reserved = vcpe_dhcp_reserved
140 cls.vcpe_container_reserved = vcpe_container_reserved
141 dhcp_vcpe_offset = len(cls.vcpes_reserved)
A R Karthick927129c2017-04-25 14:08:02 -0700142 cls.dhcp_vcpes = [ 'vcpe{}.{}.{}'.format(i+dhcp_vcpe_offset, cls.vcpes_dhcp[i]['s_tag'], cls.vcpes_dhcp[i]['c_tag'])
143 for i in xrange(len(cls.vcpes_dhcp)) ]
144 cls.untagged_dhcp_vcpes = [ 'vcpe{}'.format(i+dhcp_vcpe_offset) for i in xrange(len(cls.vcpes_dhcp)) ]
145 cls.container_vcpes = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_dhcp ]
A R Karthick03f40aa2017-03-20 19:33:55 -0700146 vcpe_dhcp = None
A R Karthick03f40aa2017-03-20 19:33:55 -0700147 vcpe_container = None
148 #cache the first dhcp vcpe in the class for quick testing
149 if cls.vcpes_dhcp:
A R Karthick035d2e22017-04-25 13:53:00 -0700150 vcpe_container = cls.container_vcpes[0]
151 vcpe_dhcp = cls.dhcp_vcpes[0]
A R Karthick19771192017-04-25 14:57:05 -0700152 if cls.on_pod is False:
A R Karthick035d2e22017-04-25 13:53:00 -0700153 vcpe_dhcp = cls.untagged_dhcp_vcpes[0]
154 cls.vcpe_container = vcpe_container_reserved or vcpe_container
155 cls.vcpe_dhcp = vcpe_dhcp_reserved or vcpe_dhcp
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700156 VSGAccess.setUp()
A R Karthick037cb982017-07-07 17:35:30 -0700157 cls.setUpCordApi(**subscriber_config)
A R Karthick19771192017-04-25 14:57:05 -0700158 if cls.on_pod is True:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700159 cls.openVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Chetan Gaonker52418832017-01-26 23:03:13 +0000160
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700161 @classmethod
A R Karthick037cb982017-07-07 17:35:30 -0700162 def setUpClass(cls):
163 num_subscribers = max(cls.NUM_SUBSCRIBERS, 5)
164 cls.vsgSetup(num_subscribers = num_subscribers)
165
166 @classmethod
167 def vsgTeardown(cls):
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700168 VSGAccess.tearDown()
A R Karthick19771192017-04-25 14:57:05 -0700169 if cls.on_pod is True:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700170 cls.closeVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Chetan Gaonker52418832017-01-26 23:03:13 +0000171
A R Karthick037cb982017-07-07 17:35:30 -0700172 @classmethod
173 def tearDownClass(cls):
174 cls.vsgTeardown()
175
Chetan Gaonker52418832017-01-26 23:03:13 +0000176 def onos_shutdown(self, controller = None):
177 status = True
A R Karthickb608d402017-06-02 11:48:41 -0700178 cli = Onos.cliEnter(onos_ip = controller)
Chetan Gaonker52418832017-01-26 23:03:13 +0000179 try:
A R Karthickb608d402017-06-02 11:48:41 -0700180 cli.shutdown(timeout = 10)
Chetan Gaonker52418832017-01-26 23:03:13 +0000181 except:
182 log.info('Graceful shutdown of ONOS failed for controller: %s' %controller)
183 status = False
184
A R Karthickb608d402017-06-02 11:48:41 -0700185 Onos.cliExit(cli)
Chetan Gaonker52418832017-01-26 23:03:13 +0000186 return status
187
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700188 def log_set(self, level = None, app = 'org.onosproject'):
189 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000190
A R Karthick9a16a112017-04-07 15:40:05 -0700191 @classmethod
192 def get_dhcp(cls, vcpe, mgmt = 'eth0'):
193 """Get DHCP for vcpe interface saving management settings"""
194
195 def put_dhcp():
196 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
197
198 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
199 if vcpe_ip is not None:
200 cls.restore_methods.append(put_dhcp)
201 return vcpe_ip
202
203 @classmethod
204 def config_restore(cls):
205 """Restore the vsg test configuration on test case failures"""
206 for restore_method in cls.restore_methods:
207 restore_method()
208
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000209 def get_vsg_vcpe_pair(self):
210 vcpes = self.vcpes_dhcp
211 vcpe_containers = []
212 vsg_vcpe = {}
213 for vcp in vcpes:
214 vcpe_container = 'vcpe-{}-{}'.format(vcp['s_tag'], vcp['c_tag'])
215 vcpe_containers.append(vcpe_container)
216 vsg = VSGAccess.get_vcpe_vsg(vcpe_container)
217 vsg_vcpe[vcpe_container]=str(vsg.get_ip())
218 return vsg_vcpe
219
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000220 def get_vcpe_containers_and_interfaces(self):
221 vcpe_containers = {}
222 vcpe_interfaces = []
223 vcpes = self.vcpes_dhcp
224 count = 0
225 for vcpe in vcpes:
226 vcpe_intf = 'vcpe{}.{}.{}'.format(count,vcpe['s_tag'],vcpe['c_tag'])
227 vcpe_interfaces.append(vcpe_intf)
228 vcpe_container = 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag'])
229 vcpe_containers[vcpe_intf] = vcpe_container
230 count += 1
231 log.info('vcpe interfaces are %s'%vcpe_interfaces)
232 log.info('vcpe containers are %s'%vcpe_containers)
233 return vcpe_interfaces,vcpe_containers
234
235 def get_vcpe_interface_dhcp_ip(self,vcpe=None):
236 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000237 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000238 st, _ = getstatusoutput('dhclient {}'.format(vcpe))
239 vcpe_ip = get_ip(vcpe)
240 return vcpe_ip
241
242 def release_vcpe_interface_dhcp_ip(self,vcpe=None):
243 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000244 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000245 st, _ = getstatusoutput('dhclient {} -r'.format(vcpe))
246 vcpe_ip = get_ip(vcpe)
247 assert_equal(vcpe_ip, None)
248
249 def add_static_route_via_vcpe_interface(self, routes, vcpe=None,dhcp_ip=True):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000250 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000251 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000252 if dhcp_ip:
A R Karthick035d2e22017-04-25 13:53:00 -0700253 os.system('dhclient '+vcpe)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000254 time.sleep(1)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000255 for route in routes:
A R Karthick035d2e22017-04-25 13:53:00 -0700256 log.info('route is %s'%route)
257 cmd = 'ip route add ' + route + ' via 192.168.0.1 '+ 'dev ' + vcpe
A R Karthick035d2e22017-04-25 13:53:00 -0700258 os.system(cmd)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000259 return True
260
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000261 def del_static_route_via_vcpe_interface(self,routes,vcpe=None,dhcp_release=True):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000262 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000263 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000264 cmds = []
265 for route in routes:
A R Karthick035d2e22017-04-25 13:53:00 -0700266 cmd = 'ip route del ' + route + ' via 192.168.0.1 ' + 'dev ' + vcpe
267 os.system(cmd)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000268 if dhcp_release:
A R Karthick035d2e22017-04-25 13:53:00 -0700269 os.system('dhclient '+vcpe+' -r')
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000270 return True
271
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000272 def vsg_for_external_connectivity(self, subscriber_index, reserved = False):
273 if reserved is True:
274 if self.on_pod is True:
275 vcpe = self.dhcp_vcpes_reserved[subscriber_index]
276 else:
277 vcpe = self.untagged_dhcp_vcpes_reserved[subscriber_index]
278 else:
279 if self.on_pod is True:
280 vcpe = self.dhcp_vcpes[subscriber_index]
281 else:
282 vcpe = self.untagged_dhcp_vcpes[subscriber_index]
283 mgmt = 'eth0'
284 host = '8.8.8.8'
285 self.success = False
286 assert_not_equal(vcpe, None)
287 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
288 assert_not_equal(vcpe_ip, None)
289 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
290 log.info('Sending icmp echo requests to external network 8.8.8.8')
291 st, _ = getstatusoutput('ping -c 3 8.8.8.8')
292 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
293 assert_equal(st, 0)
294
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000295 def get_vsg_health_check(self, vsg_name=None):
296 if self.on_pod is False:
297 return
298 if vsg_name is None:
299 vcpe = self.container_vcpes_reserved[0]
300 vsg = VSGAccess.get_vcpe_vsg(vcpe)
301 status = vsg.get_health()
302 return status
303 else:
304 vsgs = VSGAccess.get_vsgs()
305 for vsg in vsgs:
306 if vsg.name == vsg_name:
307 status = vsg.get_health()
308 return status
309 return None
310
A R Karthick63751492017-03-22 09:28:01 -0700311 def test_vsg_health(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000312 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000313 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000314 1. Login to compute node VM
315 2. Get all vSGs
316 3. Ping to all vSGs
317 4. Verifying Ping success
318 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700319 status = True
A R Karthick19771192017-04-25 14:57:05 -0700320 if self.on_pod is True:
A R Karthick93ba8d02017-04-13 11:59:58 -0700321 status = VSGAccess.health_check()
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700322 assert_equal(status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000323
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000324 def test_vsg_health_check(self, vsg_name=None, verify_status=True):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000325 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000326 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000327 1. If vsg name not specified, Get vsg corresponding to vcpe
328 1. Login to compute mode VM
329 3. Ping to the vSG
330 4. Verifying Ping success
331 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000332 st = self.get_vsg_health_check(vsg_name=vsg_name)
333 assert_equal(st,verify_status)
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000334
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000335 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700336 def test_vsg_for_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000337 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000338 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000339 1. Get list of all compute nodes created using Openstack
340 2. Login to compute mode VM
341 3. Get all vSGs
342 4. Verifying atleast one compute node and one vSG created
343 """
A R Karthick035d2e22017-04-25 13:53:00 -0700344 df = defer.Deferred()
345 def vsg_for_vcpe_df(df):
A R Karthick19771192017-04-25 14:57:05 -0700346 if self.on_pod is True:
A R Karthick93ba8d02017-04-13 11:59:58 -0700347 vsgs = VSGAccess.get_vsgs()
348 compute_nodes = VSGAccess.get_compute_nodes()
349 time.sleep(14)
350 assert_not_equal(len(vsgs), 0)
351 assert_not_equal(len(compute_nodes), 0)
A R Karthick035d2e22017-04-25 13:53:00 -0700352 df.callback(0)
353 reactor.callLater(0,vsg_for_vcpe_df,df)
354 return df
Chetan Gaonker52418832017-01-26 23:03:13 +0000355
A R Karthick63751492017-03-22 09:28:01 -0700356 def test_vsg_for_login(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000357 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000358 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000359 1. Login to compute node VM
360 2. Get all vSGs
361 3. Verifying login to vSG is success
362 """
A R Karthick19771192017-04-25 14:57:05 -0700363 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700364 return
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700365 vsgs = VSGAccess.get_vsgs()
366 vsg_access_status = map(lambda vsg: vsg.check_access(), vsgs)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700367 status = filter(lambda st: st == False, vsg_access_status)
368 assert_equal(len(status), 0)
369
A R Karthick63751492017-03-22 09:28:01 -0700370 def test_vsg_for_default_route_through_testclient(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000371 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000372 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000373 1. Login to head node
374 2. Verifying for default route in lxc test client
375 """
A R Karthick19771192017-04-25 14:57:05 -0700376 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700377 return
A R Karthick63751492017-03-22 09:28:01 -0700378 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
379 cmd = "sudo lxc exec testclient -- route | grep default"
380 status, output = ssh_agent.run_cmd(cmd)
381 assert_equal(status, True)
382
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000383 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700384 def test_vsg_for_external_connectivity_through_testclient(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000385 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000386 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000387 1. Login to head node
388 2. On head node, executing ping to 8.8.8.8 from lxc test client
389 3. Verifying for the ping success
390 """
A R Karthick19771192017-04-25 14:57:05 -0700391 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700392 return
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000393 df = defer.Deferred()
394 def test_external_connectivity(df):
395 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
396 cmd = "sudo lxc exec testclient -- ping -c 3 8.8.8.8"
397 status, output = ssh_agent.run_cmd(cmd)
398 assert_equal( status, True)
399 df.callback(0)
400 reactor.callLater(0,test_external_connectivity,df)
401 return df
A R Karthick63751492017-03-22 09:28:01 -0700402
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000403 @deferred(30)
A R Karthick035d2e22017-04-25 13:53:00 -0700404 def test_vsg_for_external_connectivity(self):
405 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000406 Test Method:
A R Karthick035d2e22017-04-25 13:53:00 -0700407 1. Get dhcp IP to vcpe interface in cord-tester
408 2. Verifying vcpe interface gets dhcp IP
409 3. Ping to 8.8.8.8 and Verifying ping should success
410 4. Restoring management interface configuration in cord-tester
411 """
A R Karthick19771192017-04-25 14:57:05 -0700412 reserved = True
413 if self.on_pod:
414 reserved = self.on_ciab
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000415 df = defer.Deferred()
416 def test_external_connectivity(df):
417 self.vsg_for_external_connectivity(0, reserved = reserved)
418 df.callback(0)
419 reactor.callLater(0,test_external_connectivity,df)
420 return df
A R Karthick035d2e22017-04-25 13:53:00 -0700421
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000422 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700423 def test_vsg_for_external_connectivity_to_google(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000424 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000425 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000426 1. Get dhcp IP to vcpe interface in cord-tester
427 2. Verifying vcpe interface gets dhcp IP
428 3. Ping to www.google.com and Verifying ping should success
429 4. Restoring management interface configuration in cord-tester
430 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000431 df = defer.Deferred()
432 def test_external_connectivity(df):
433 host = 'www.google.com'
434 vcpe = self.dhcp_vcpes_reserved[0]
435 mgmt = 'eth0'
436 assert_not_equal(vcpe, None)
437 try:
438 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
439 assert_not_equal(vcpe_ip, None)
440 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
441 log.info('Sending icmp ping requests to %s' %host)
442 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
443 assert_equal(st, 0)
444 except Exception as error:
445 log.info('Got Unexpected error %s'%error)
446 raise
447 finally:
448 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
449 df.callback(0)
450 reactor.callLater(0,test_external_connectivity,df)
451 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000452
A R Karthickb2618052017-05-10 09:23:22 -0700453 def retrieve_content_from_host_to_validate_path_mtu(self, host):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000454 vcpe = self.dhcp_vcpes_reserved[0]
A R Karthickb2618052017-05-10 09:23:22 -0700455 mgmt = 'eth0'
456 assert_not_equal(vcpe, None)
457 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
458 assert_not_equal(vcpe_ip, None)
459 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
460 log.info('Initiating get requests to %s' %host)
461 r = requests.get('http://{}'.format(host))
462 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
463 return r.status_code
464
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000465 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000466 def test_vsg_to_retrieve_content_from_google_to_validate_path_mtu(self):
467 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000468 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000469 1. Get dhcp IP to vcpe interface in cord-tester
470 2. Verifying vcpe interface gets dhcp IP
471 3. Retrieve contents from www.google.com and Verify response status is 200 ok.
472 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
473 (Based on website response, size differs, needs check on MTU)
474 4. Restoring management interface configuration in cord-tester
475 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000476 df = defer.Deferred()
477 def test_external_connectivity(df):
478 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.google.com')
479 assert_equal(status_code, 200)
480 df.callback(0)
481 reactor.callLater(0,test_external_connectivity,df)
482 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000483
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000484 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000485 def test_vsg_to_retrieve_content_from_rediff_to_validate_path_mtu(self):
486 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000487 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000488 1. Get dhcp IP to vcpe interface in cord-tester
489 2. Verifying vcpe interface gets dhcp IP
490 3. Retrieve contents from www.rediff.com and Verify response status is 200 ok.
491 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
492 (Based on website response, size differs, needs check on MTU)
493 4. Restoring management interface configuration in cord-tester
494 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000495 df = defer.Deferred()
496 def test_external_connectivity(df):
497 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.rediff.com')
498 assert_equal(status_code, 200)
499 df.callback(0)
500 reactor.callLater(0,test_external_connectivity,df)
501 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000502
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000503 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000504 def test_vsg_to_retrieve_content_from_yahoo_to_validate_path_mtu(self):
505 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000506 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000507 1. Get dhcp IP to vcpe interface in cord-tester
508 2. Verifying vcpe interface gets dhcp IP
509 3. Retrieve contents from www.yahoo.com and Verify response status is 200 ok.
510 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
511 (Based on website response, size differs, needs check on MTU)
512 4. Restoring management interface configuration in cord-tester
513 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000514 df = defer.Deferred()
515 def test_external_connectivity(df):
516 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.yahoo.com')
517 assert_equal(status_code, 200)
518 df.callback(0)
519 reactor.callLater(0,test_external_connectivity,df)
520 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000521
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000522 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000523 def test_vsg_to_retrieve_content_from_facebook_to_validate_path_mtu(self):
524 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000525 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000526 1. Get dhcp IP to vcpe interface in cord-tester
527 2. Verifying vcpe interface gets dhcp IP
528 3. Retrieve contents from www.facebook.com and Verify response status is 200 ok.
529 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
530 (Based on website response, size differs, needs check on MTU)
531 4. Restoring management interface configuration in cord-tester
532 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000533 df = defer.Deferred()
534 def test_external_connectivity(df):
535 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.facebook.com')
536 assert_equal(status_code, 200)
537 df.callback(0)
538 reactor.callLater(0,test_external_connectivity,df)
539 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000540
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000541
542 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700543 def test_vsg_for_external_connectivity_to_invalid_host(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000544 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000545 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000546 1. Get dhcp IP to vcpe interface in cord-tester
547 2. Verifying vcpe interface gets dhcp IP
548 3. Ping to www.goglee.com and Verifying ping should not success
549 4. Restoring management interface configuration in cord-tester
550 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000551 df = defer.Deferred()
552 def test_external_connectivity(df):
553 host = 'www.goglee.com'
554 vcpe = self.dhcp_vcpes_reserved[0]
555 mgmt = 'eth0'
556 assert_not_equal(vcpe, None)
557 try:
558 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
559 assert_not_equal(vcpe_ip, None)
560 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
561 log.info('Sending icmp ping requests to non existent host %s' %host)
562 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
563 assert_not_equal(st, 0)
564 except Exception as error:
565 log.info('Got Unexpected error %s'%error)
566 raise
567 finally:
568 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
569 df.callback(0)
570 reactor.callLater(0,test_external_connectivity,df)
571 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000572
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000573 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700574 def test_vsg_for_external_connectivity_with_ttl_1(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000575 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000576 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000577 1. Get dhcp IP to vcpe interface in cord-tester
578 2. Verifying vcpe interface gets dhcp IP
579 3. Ping to 8.8.8.8 with ttl set to 1
580 4. Verifying ping should not success
581 5. Restoring management interface configuration in cord-tester
582 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000583 df = defer.Deferred()
584 def test_external_connectivity(df):
585 host = '8.8.8.8'
586 vcpe = self.dhcp_vcpes_reserved[0]
587 mgmt = 'eth0'
588 assert_not_equal(vcpe, None)
589 try:
590 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
591 assert_not_equal(vcpe_ip, None)
592 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
593 log.info('Sending icmp ping requests to host %s with ttl 1' %host)
594 st, _ = getstatusoutput('ping -c 1 -t 1 {}'.format(host))
595 assert_not_equal(st, 0)
596 except Exception as error:
597 log.info('Got Unexpected error %s'%error)
598 raise
599 finally:
600 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
601 df.callback(0)
602 reactor.callLater(0,test_external_connectivity,df)
603 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000604
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000605 @deferred(60)
A R Karthick63751492017-03-22 09:28:01 -0700606 def test_vsg_for_external_connectivity_with_wan_interface_toggle_in_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000607 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000608 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000609 1. Get dhcp IP to vcpe interface in cord-tester
610 2. Verifying vcpe interface gets dhcp IP
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700611 3. Ping to 8.8.8.8 and Verifying ping succeeds
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000612 4. Now down the WAN interface of vcpe
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700613 5. Ping to 8.8.8.8 and Verifying ping fails
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000614 6. Now Up the WAN interface of vcpe
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700615 7. Ping to 8.8.8.8 and Verifying ping succeeds
616 8. Restoring management interface configuration in cord-tester
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000617 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000618 df = defer.Deferred()
619 def test_external_connectivity(df):
620 if self.on_pod is False:
621 return
622 host = '8.8.8.8'
623 mgmt = 'eth0'
624 vcpe = self.dhcp_vcpes_reserved[0]
625 vcpe_name = self.container_vcpes_reserved[0]
626 assert_not_equal(vcpe_name, None)
627 assert_not_equal(vcpe, None)
628 #first get dhcp on the vcpe interface
629 try:
630 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
631 assert_not_equal(vcpe_ip, None)
632 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
633 log.info('Sending ICMP pings to host %s' %(host))
634 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
635 if st != 0:
636 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
637 assert_equal(st, 0)
638 #bring down the wan interface and check again
639 st = VSGAccess.vcpe_wan_down(vcpe_name)
640 if st is False:
641 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
642 assert_equal(st, True)
643 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
644 if st == 0:
645 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
646 assert_not_equal(st, 0)
647 st = VSGAccess.vcpe_wan_up(vcpe_name)
648 if st is False:
649 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
650 assert_equal(st, True)
651 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
652 assert_equal(st, 0)
653 except Exception as error:
654 log.info('Got Unexpected error %s'%error)
655 raise
656 finally:
657 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
658 df.callback(0)
659 reactor.callLater(0,test_external_connectivity,df)
660 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000661
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000662 @deferred(60)
A R Karthick63751492017-03-22 09:28:01 -0700663 def test_vsg_for_external_connectivity_with_lan_interface_toggle_in_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000664 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000665 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000666 1. Get dhcp IP to vcpe interface in cord-tester
667 2. Verifying vcpe interface gets dhcp IP
668 3. Ping to 8.8.8.8 and Verifying ping should success
669 4. Now down the LAN interface of vcpe
670 5. Ping to 8.8.8.8 and Verifying ping should not success
671 6. Now Up the LAN interface of vcpe
672 7. Ping to 8.8.8.8 and Verifying ping should success
673 8. Restoring management interface configuration in cord-tester
674 """
A R Karthick19771192017-04-25 14:57:05 -0700675 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700676 return
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000677 df = defer.Deferred()
678 def test_external_connectivity(df):
679 host = '8.8.8.8'
680 mgmt = 'eth0'
681 vcpe = self.dhcp_vcpes_reserved[0]
682 vcpe_name = self.container_vcpes_reserved[0]
683 assert_not_equal(vcpe, None)
684 assert_not_equal(vcpe_name, None)
685 #first get dhcp on the vcpe interface
686 try:
687 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
688 assert_not_equal(vcpe_ip, None)
689 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
690 log.info('Sending ICMP pings to host %s' %(host))
691 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
692 if st != 0:
693 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
694 assert_equal(st, 0)
695 #bring down the lan interface and check again
696 st = VSGAccess.vcpe_lan_down(vcpe_name)
697 if st is False:
698 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
699 assert_equal(st, True)
700 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
701 if st == 0:
702 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
703 assert_not_equal(st, 0)
704 st = VSGAccess.vcpe_lan_up(vcpe_name)
705 if st is False:
706 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
707 assert_equal(st, True)
708 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
709 assert_equal(st, 0)
710 except Exception as error:
711 log.info('Got Unexpected error %s'%error)
712 raise
713 finally:
714 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
715 df.callback(0)
716 reactor.callLater(0,test_external_connectivity,df)
717 return df
Chetan Gaonker52418832017-01-26 23:03:13 +0000718
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000719 @deferred(120)
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +0000720 def test_vsg_multiple_subscribers_for_same_vcpe_instance(self):
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000721 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000722 Test Method:
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000723 1. Create a vcpe instance
724 2. Create multiple vcpe interfaces in cord-tester with same s-tag and c-tag to access vcpe instance
725 3. Verify all the interfaces gets dhcp IP in same subnet
726 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000727 df = defer.Deferred()
728 def test_external_connectivity(df):
729 vcpe_intfs,containers = self.get_vcpe_containers_and_interfaces()
730 for vcpe in vcpe_intfs:
731 vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe)
732 assert_not_equal(vcpe_ip,None)
733 for vcpe in vcpe_intfs:
734 self.release_vcpe_interface_dhcp_ip(vcpe=vcpe)
735 df.callback(0)
736 reactor.callLater(0,test_external_connectivity,df)
737 return df
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000738
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000739 @deferred(120)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000740 def test_vsg_for_multiple_subscribers_with_same_vcpe_instance_and_validate_external_connectivity(self):
741 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000742 Test Method:
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000743 1. Create a vcpe instance
744 2. Create multiple vcpe interfaces in cord-tester with same s-tag and c-tag to access vcpe instance
745 3. Verify all the interfaces gets dhcp IP in same subnet
746 4. From cord-tester ping to external with vcpe interface option
747 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000748 df = defer.Deferred()
749 def test_external_connectivity(df):
750 host = '8.8.8.8'
751 vcpe_intfs, containers = self.get_vcpe_containers_and_interfaces()
752 try:
753 for vcpe in vcpe_intfs:
754 vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe)
755 assert_not_equal(vcpe_ip,None)
756 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_ip=False)
757 st, _ = getstatusoutput('ping -I {} -c 3 {}'.format(vcpe,host))
758 assert_equal(st, 0)
759 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_release=False)
760 except Exception as error:
761 log.info('Got Unexpected error %s'%error)
762 raise
763 finally:
764 for vcpe in vcpe_intfs:
765 self.release_vcpe_interface_dhcp_ip(vcpe=vcpe)
766 df.callback(0)
767 reactor.callLater(0,test_external_connectivity,df)
768 return df
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000769
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000770 @deferred(30)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000771 def test_vsg_vcpe_interface_and_validate_dhcp_ip_after_interface_toggle(self):
772 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000773 Test Method:
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000774 1. Create a vcpe instance
775 2. Create a vcpe interface in cord-tester
776 3. Verify the interface gets dhcp IP
777 4. Toggle the interface
778 5. Verify the interface gets dhcp IP
779 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000780 df = defer.Deferred()
781 def test_external_connectivity(df):
782 vcpe_intf = self.dhcp_vcpes_reserved[0]
783 host = '8.8.8.8'
784 try:
785 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
786 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
787 assert_equal(st, 0)
788 os.system('ifconfig {} down'.format(vcpe_intf))
789 time.sleep(1)
790 os.system('ifconfig {} up'.format(vcpe_intf))
791 time.sleep(1)
792 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
793 assert_equal(st, 0)
794 except Exception as error:
795 log.info('Got Unexpected error %s'%error)
796 raise
797 finally:
798 self.del_static_route_via_vcpe_interface([host], vcpe=vcpe_intf)
799 df.callback(0)
800 reactor.callLater(0,test_external_connectivity,df)
801 return df
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000802
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000803 @deferred(TIMEOUT)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000804 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 +0000805 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000806 Test Method:
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000807 1. Get vSG corresponding to vcpe
808 2. Get dhcp ip to vcpe interface
809 3. Add static route to destination route in test container
810 4. From test container ping to destination route and verify ping success
811 5. Login to compute node and execute command to pause vcpe container
812 6. From test container ping to destination route and verify ping success
813 """
814 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000815 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000816 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000817 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000818 df = defer.Deferred()
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000819 def test_external_connectivity(df):
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000820 if self.on_pod is False:
821 df.callback(0)
822 return
823 host = '8.8.8.8'
824 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
825 try:
826 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
827 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
828 assert_equal(st, False)
829 st, _ = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000830 clock = 0
831 status = False
832 while(clock <= 20):
833 time.sleep(5)
834 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
835 if st == False:
836 status = True
837 break
838 clock += 5
839 assert_equal(status, True)
840 except Exception as error:
841 log.info('Got Unexpected error %s'%error)
842 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
843 raise
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000844 finally:
845 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
846 df.callback(0)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000847 reactor.callLater(0, test_external_connectivity, df)
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000848 return df
849
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000850 @nottest #Setup getting distrubed if vSG VM restart
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000851 @deferred(TIMEOUT)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000852 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 +0000853 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000854 Test Method:
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000855 1. Get vSG corresponding to vcpe
856 2. Get dhcp ip to vcpe interface
857 3. Add static route to destination route in test container
858 4. From test container ping to destination route and verify ping success
859 5. Login to compute node and execute command to pause vcpe container
860 6. From test container ping to destination route and verify ping success
861 """
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000862 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000863 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000864 df = defer.Deferred()
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000865 def test_external_connectivity(df):
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000866 if self.on_pod is False:
867 df.callback(0)
868 return
869 host = '8.8.8.8'
870 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
871 try:
872 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
873 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
874 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000875 vsg.reboot()
876 clock = 0
877 status = False
878 while(clock <= 30):
879 time.sleep(5)
880 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
881 if st == False:
882 status = True
883 break
884 clock += 5
885 assert_equal(status, True)
886 except Exception as error:
887 log.info('Got Unexpected error %s'%error)
888 vsg.reboot()
889 raise
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000890 finally:
891 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
892 df.callback(0)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000893 reactor.callLater(0, test_external_connectivity, df)
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000894 return df
895
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000896 @deferred(60)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000897 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 +0000898 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000899 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000900 1. Get vSG corresponding to vcpe
901 2. Get dhcp ip to vcpe interface
902 3. Add static route to destination route in test container
903 4. From test container ping to destination route and verify ping success
904 5. Login to compute node and execute command to pause vcpe container
905 6. From test container ping to destination route and verify ping success
906 """
907 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000908 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000909 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000910 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000911 df = defer.Deferred()
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000912 def test_external_connectivity(df):
A R Karthick19771192017-04-25 14:57:05 -0700913 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700914 df.callback(0)
915 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000916 host = '8.8.8.8'
917 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
918 try:
919 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
920 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
921 assert_equal(st, False)
922 st, _ = vsg.run_cmd('sudo docker pause {}'.format(vcpe_name))
923 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
924 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000925 vsg.run_cmd('sudo docker unpause {}'.format(vcpe_name))
926 except Exception as error:
927 log.info('Got Unexpected error %s'%error)
928 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
929 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000930 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000931 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
932 df.callback(0)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000933 reactor.callLater(0, test_external_connectivity, df)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000934 return df
935
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000936 @deferred(30)
937 def test_vsg_firewall_with_deny_destination_ip_set(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000938 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000939 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000940 1. Get vSG corresponding to vcpe
941 2. Login to compute node
942 3. Execute iptable command on vcpe from compute node to deny a destination IP
943 4. From cord-tester ping to the denied IP address
944 5. Verifying that ping should not be successful
945 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000946 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000947 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000948 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000949 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000950 df = defer.Deferred()
951 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -0700952 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700953 df.callback(0)
954 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000955 host = '8.8.8.8'
956 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
957 try:
958 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
959 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
960 assert_equal(st, False)
961 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
962 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
963 assert_equal(st, True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000964 except Exception as error:
965 log.info('Got Unexpected error %s'%error)
966 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000967 finally:
968 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
969 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000970 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000971 df.callback(0)
972 reactor.callLater(0, vcpe_firewall, df)
973 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000974
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000975 @deferred(60)
976 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 +0000977 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000978 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000979 1. Get vSG corresponding to vcpe
980 2. Login to compute node
981 3. Execute iptable command on vcpe from compute node to deny a destination IP
982 4. From cord-tester ping to the denied IP address
983 5. Verifying that ping should not be successful
984 6. Delete the iptable rule in vcpe
985 7. From cord-tester ping to the denied IP address
986 8. Verifying the ping should success
987 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000988 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000989 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000990 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000991 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000992 df = defer.Deferred()
993 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -0700994 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700995 df.callback(0)
996 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000997 host = '8.8.8.8'
998 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
999 try:
1000 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1001 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1002 assert_equal(st, False)
1003 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1004 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1005 assert_equal(st, True)
1006 st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1007 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1008 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001009 except Exception as error:
1010 log.info('Got Unexpected error %s'%error)
1011 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1012 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001013 finally:
1014 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1015 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001016 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001017 df.callback(0)
1018 reactor.callLater(0, vcpe_firewall, df)
1019 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001020
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001021 @deferred(40)
1022 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 +00001023 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001024 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001025 1. Get vSG corresponding to vcpe
1026 2. Login to compute node
1027 3. Execute iptable command on vcpe from compute node to deny a destination IP
1028 4. From cord-tester ping to the denied IP address
1029 5. Verifying that ping should not be successful
1030 6. From cord-tester ping to the denied IP address other than the denied one
1031 7. Verifying the ping should success
1032 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001033 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001034 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001035 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001036 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001037 df = defer.Deferred()
1038 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001039 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001040 df.callback(0)
1041 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001042 host1 = '8.8.8.8'
1043 host2 = '204.79.197.203'
1044 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1045 try:
1046 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
1047 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1048 assert_equal(st, False)
1049 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1050 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1051 assert_equal(st, True)
1052 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1053 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001054 except Exception as error:
1055 log.info('Got Unexpected error %s'%error)
1056 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001057 finally:
1058 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1059 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001060 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001061 df.callback(0)
1062 reactor.callLater(0, vcpe_firewall, df)
1063 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001064
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001065 @deferred(60)
1066 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 +00001067 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001068 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001069 1. Get vSG corresponding to vcpe
1070 2. Login to compute node
1071 3. Execute iptable command on vcpe from compute node to deny a destination IP1
1072 4. From cord-tester ping to the denied IP address IP1
1073 5. Verifying that ping should not be successful
1074 6. Execute iptable command on vcpe from compute node to deny a destination IP2
1075 6. From cord-tester ping to the denied IP address IP2
1076 7. Verifying that ping should not be successful
1077 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001078 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001079 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001080 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001081 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001082 df = defer.Deferred()
1083 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001084 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001085 df.callback(0)
1086 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001087 host1 = '8.8.8.8'
1088 host2 = '204.79.197.203'
1089 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1090 try:
1091 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
1092 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1093 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001094 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1095 assert_equal(st, False)
1096 st,_ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1097 time.sleep(1)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001098 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1099 assert_equal(st, True)
1100 st, out = getstatusoutput('ping -c 1 {}'.format(host2))
1101 log.info('host2 ping output is %s'%out)
1102 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001103 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,host2))
1104 time.sleep(1)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001105 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1106 assert_equal(st,True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001107 except Exception as error:
1108 log.info('Got Unexpected error %s'%error)
1109 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001110 finally:
1111 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1112 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1113 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001114 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001115 df.callback(0)
1116 reactor.callLater(0, vcpe_firewall, df)
1117 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001118
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001119 @deferred(TIMEOUT)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001120 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 +00001121 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001122 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001123 1. Get vSG corresponding to vcpe
1124 2. Login to compute node
1125 3. Execute iptable command on vcpe from compute node to deny a destination IP1
1126 4. Execute iptable command on vcpe from compute node to deny a destination IP2
1127 5. From cord-tester ping to the denied IP address IP1
1128 6. Verifying that ping should not be successful
1129 7. From cord-tester ping to the denied IP address IP2
1130 8. Verifying that ping should not be successful
1131 9. Execute iptable command on vcpe from compute node to remove deny a destination IP2 rule
1132 10. From cord-tester ping to the denied IP address IP2
1133 11. Verifying the ping should success
1134 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001135 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001136 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001137 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001138 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001139 df = defer.Deferred()
1140 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001141 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001142 df.callback(0)
1143 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001144 host1 = '8.8.8.8'
1145 host2 = '204.79.197.203'
1146 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1147 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001148 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001149 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1150 assert_equal(st, False)
1151 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1152 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1153 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1154 assert_equal(st, True)
1155 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1156 assert_equal(st,True)
1157 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1158 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1159 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001160 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1161 assert_equal(st, True)
1162 except Exception as error:
1163 log.info('Got Unexpected error %s'%error)
1164 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001165 finally:
1166 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1167 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1168 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001169 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001170 df.callback(0)
1171 reactor.callLater(0, vcpe_firewall, df)
1172 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001173
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001174 @deferred(60)
1175 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 +00001176 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001177 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001178 1. Get vSG corresponding to vcpe
1179 2. Login to compute node
1180 3. Execute iptable command on vcpe from compute node to deny a destination IP
1181 5. From cord-tester ping to the denied IP address IP1
1182 6. Verifying that ping should not be successful
1183 9. Execute iptable command on vcpe from compute node to change the rule ID to 2 to deny the same destination IP
1184 10. From cord-tester ping to the denied IP address IP
1185 11. Verifying that ping should not be successful
1186 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001187 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001188 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001189 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001190 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001191 df = defer.Deferred()
1192 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001193 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001194 df.callback(0)
1195 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001196 host = '8.8.8.8'
1197 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1198 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001199 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001200 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1201 assert_equal(st, False)
1202 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1203 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1204 assert_equal(st, True)
1205 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP '.format(vcpe_name,host))
1206 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1207 assert_equal(st,True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001208 except Exception as error:
1209 log.info('Got Unexpected error %s'%error)
1210 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001211 finally:
1212 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1213 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001214 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001215 df.callback(0)
1216 reactor.callLater(0, vcpe_firewall, df)
1217 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001218
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001219 @deferred(50)
1220 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 +00001221 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001222 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001223 1. Get vSG corresponding to vcpe
1224 2. Login to compute node
1225 3. Execute iptable command on vcpe from compute node to deny a destination IP
1226 5. From cord-tester ping to the denied IP address IP1
1227 6. Verifying that ping should not be successful
1228 9. Execute iptable command on vcpe from compute node to accept the same destination IP
1229 10. From cord-tester ping to the accepted IP
1230 11. Verifying the ping should success
1231 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001232 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001233 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001234 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001235 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001236 df = defer.Deferred()
1237 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001238 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001239 df.callback(0)
1240 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001241 host = '8.8.8.8'
1242 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1243 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001244 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001245 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1246 assert_equal(st, False)
1247 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1248 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1249 assert_equal(st, True)
1250 st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -d {} -j ACCEPT'.format(vcpe_name,host))
1251 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1252 assert_equal(st,False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001253 except Exception as error:
1254 log.info('Got Unexpected error %s'%error)
1255 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001256 finally:
1257 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1258 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j ACCEPT'.format(vcpe_name,host))
1259 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001260 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001261 df.callback(0)
1262 reactor.callLater(0, vcpe_firewall, df)
1263 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001264
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001265 @deferred(60)
1266 def test_vsg_firewall_denying_destination_network(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001267 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001268 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001269 1. Get vSG corresponding to vcpe
1270 2. Login to compute node
1271 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet
1272 4. From cord-tester ping to the denied IP address IP1 in the denied subnet
1273 5. Verifying that ping should not be successful
1274 6. From cord-tester ping to the denied IP address IP2 in the denied subnet
1275 7. Verifying that ping should not be successful
1276 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001277 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001278 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001279 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001280 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001281 df = defer.Deferred()
1282 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001283 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001284 df.callback(0)
1285 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001286 network = '204.79.197.192/28'
1287 host1 = '204.79.197.203'
1288 host2 = '204.79.197.210'
1289 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1290 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001291 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001292 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1293 assert_equal(st, False)
1294 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network))
1295 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1296 assert_equal(st, True)
1297 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1298 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001299 except Exception as error:
1300 log.info('Got Unexpected error %s'%error)
1301 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001302 finally:
1303 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network))
1304 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001305 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001306 df.callback(0)
1307 reactor.callLater(0, vcpe_firewall, df)
1308 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001309
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001310 @deferred(60)
1311 def test_vsg_firewall_denying_destination_network_subnet_modification(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001312 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001313 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001314 1. Get vSG corresponding to vcpe
1315 2. Login to compute node
1316 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet
1317 4. From cord-tester ping to the denied IP address IP1 in the denied subnet
1318 5. Verifying that ping should not be successful
1319 6. From cord-tester ping to the denied IP address IP2 in the denied subnet
1320 7. Verifying that ping should not be successful
1321 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001322 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001323 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001324 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001325 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001326 df = defer.Deferred()
1327 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001328 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001329 df.callback(0)
1330 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001331 network1 = '204.79.197.192/28'
1332 network2 = '204.79.197.192/27'
1333 host1 = '204.79.197.203'
1334 host2 = '204.79.197.210'
1335 host3 = '204.79.197.224'
1336 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1337 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001338 self.add_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001339 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1340 assert_equal(st, False)
1341 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network1))
1342 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1343 assert_equal(st, True)
1344 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1345 assert_equal(st,False)
1346 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,network2))
1347 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1348 assert_equal(st, True)
1349 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1350 assert_equal(st, True)
1351 st, _ = getstatusoutput('ping -c 1 {}'.format(host3))
1352 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001353 except Exception as error:
1354 log.info('Got Unexpected error %s'%error)
1355 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001356 finally:
1357 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network1))
1358 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network2))
1359 self.del_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001360 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001361 df.callback(0)
1362 reactor.callLater(0, vcpe_firewall, df)
1363 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001364
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001365 @deferred(40)
1366 def test_vsg_firewall_with_deny_source_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001367 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001368 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001369 1. Get vSG corresponding to vcpe
1370 2. Login to compute node
1371 3. Execute iptable command on vcpe from compute node to deny a source IP
1372 4. From cord-tester ping to 8.8.8.8 from the denied IP
1373 5. Verifying that ping should not be successful
1374 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001375 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001376 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001377 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001378 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001379 df = defer.Deferred()
1380 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001381 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001382 df.callback(0)
1383 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001384 host = '8.8.8.8'
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001385 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1386 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001387 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1388 source_ip = get_ip(vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001389 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1390 assert_equal(st, False)
1391 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1392 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1393 assert_equal(st, True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001394 except Exception as error:
1395 log.info('Got Unexpected error %s'%error)
1396 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1397 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001398 finally:
1399 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1400 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001401 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001402 df.callback(0)
1403 reactor.callLater(0, vcpe_firewall, df)
1404 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001405
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001406 @deferred(40)
1407 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 +00001408 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001409 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001410 1. Get vSG corresponding to vcpe
1411 2. Login to compute node
1412 3. Execute iptable command on vcpe from compute node to deny a source IP
1413 4. From cord-tester ping to 8.8.8.8 from the denied IP
1414 5. Verifying that ping should not be successful
1415 6. Delete the iptable rule in vcpe
1416 7. From cord-tester ping to 8.8.8.8 from the denied IP
1417 8. Verifying the ping should success
1418 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001419 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001420 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001421 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001422 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001423 df = defer.Deferred()
1424 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001425 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001426 df.callback(0)
1427 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001428 host = '8.8.8.8'
1429 source_ip = get_ip(self.vcpe_dhcp)
1430 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1431 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001432 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1433 source_ip = get_ip(vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001434 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1435 assert_equal(st, False)
1436 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1437 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1438 assert_equal(st, True)
1439 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1440 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1441 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001442 except Exception as error:
1443 log.info('Got Unexpected error %s'%error)
1444 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1445 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001446 finally:
1447 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1448 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001449 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001450 df.callback(0)
1451 reactor.callLater(0, vcpe_firewall, df)
1452 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001453
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001454 @deferred(40)
1455 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 +00001456 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001457 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001458 1. Get vSG corresponding to vcpe
1459 2. Login to compute node
1460 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets
1461 4. From cord-tester ping to 8.8.8.8
1462 5. Verifying that ping should not be successful
1463 6. Delete the iptable rule
1464 7. From cord-tester ping to 8.8.8.8
1465 8. Verifying the ping should success
1466 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001467 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001468 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001469 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001470 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001471 df = defer.Deferred()
1472 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001473 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001474 df.callback(0)
1475 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001476 host = '8.8.8.8'
1477 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1478 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001479 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001480 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1481 assert_equal(st, False)
1482 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1483 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1484 assert_equal(st, True)
1485 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1486 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1487 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001488 except Exception as error:
1489 log.info('Got Unexpected error %s'%error)
1490 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1491 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001492 finally:
1493 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1494 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001495 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001496 df.callback(0)
1497 reactor.callLater(0, vcpe_firewall, df)
1498 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001499
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001500 @deferred(40)
1501 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 +00001502 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001503 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001504 1. Get vSG corresponding to vcpe
1505 2. Login to compute node
1506 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets
1507 4. From cord-tester ping to 8.8.8.8
1508 5. Verifying that ping should not be successful
1509 6. Delete the iptable rule
1510 7. From cord-tester ping to 8.8.8.8
1511 8. Verifying the ping should success
1512 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001513 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001514 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001515 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001516 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001517 df = defer.Deferred()
1518 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001519 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001520 df.callback(0)
1521 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001522 host = '8.8.8.8'
1523 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1524 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001525 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001526 st, _ = getstatusoutput('ping -c 1 {}'.format('8.8.8.8'))
1527 assert_equal(st, False)
1528 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1529 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1530 assert_equal(st, True)
1531 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1532 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1533 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001534 except Exception as error:
1535 log.info('Got Unexpected error %s'%error)
1536 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1537 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001538 finally:
1539 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1540 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001541 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001542 df.callback(0)
1543 reactor.callLater(0, vcpe_firewall, df)
1544 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001545
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001546 @deferred(40)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00001547 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 +00001548 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001549 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001550 1. Get vSG corresponding to vcpe
1551 2. Login to compute node
1552 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets
1553 4. From cord-tester ping to 8.8.8.8
1554 5. Verifying that ping should not be successful
1555 6. Insert another rule to accept the icmp-echo requests protocol packets
1556 7. From cord-tester ping to 8.8.8.8
1557 8. Verifying the ping should success
1558 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001559 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001560 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001561 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001562 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001563 df = defer.Deferred()
1564 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001565 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001566 df.callback(0)
1567 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001568 host = '8.8.8.8'
1569 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1570 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001571 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001572 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1573 assert_equal(st, False)
1574 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1575 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1576 assert_equal(st, True)
1577 st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name))
1578 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1579 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001580 except Exception as error:
1581 log.info('Got Unexpected error %s'%error)
1582 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001583 finally:
1584 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1585 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name))
1586 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001587 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001588 df.callback(0)
1589 reactor.callLater(0, vcpe_firewall, df)
1590 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001591
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001592 @deferred(40)
1593 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 +00001594 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001595 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001596 1. Get vSG corresponding to vcpe
1597 2. Login to compute node
1598 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets
1599 4. From cord-tester ping to 8.8.8.8
1600 5. Verifying the ping should not success
1601 6. Insert another rule to accept the icmp-echo requests protocol packets
1602 7. From cord-tester ping to 8.8.8.8
1603 8. Verifying the ping should success
1604 """
1605 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001606 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001607 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001608 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001609 df = defer.Deferred()
1610 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001611 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001612 df.callback(0)
1613 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001614 host = '8.8.8.8'
1615 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1616 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001617 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001618 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1619 assert_equal(st, False)
1620 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1621 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1622 assert_equal(st, True)
1623 st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name))
1624 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1625 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001626 except Exception as error:
1627 log.info('Got Unexpected error %s'%error)
1628 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001629 finally:
1630 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1631 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name))
1632 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001633 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001634 df.callback(0)
1635 reactor.callLater(0, vcpe_firewall, df)
1636 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001637
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001638 @deferred(40)
1639 def test_vsg_firewall_for_deny_icmp_protocol(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001640 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001641 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001642 1. Get vSG corresponding to vcpe
1643 2. Login to compute node
1644 3. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1645 4. From cord-tester ping to 8.8.8.8
1646 5. Verifying that ping should not be successful
1647 6. Delete the iptable rule
1648 7. From cord-tester ping to 8.8.8.8
1649 8. Verifying the ping should success
1650 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001651 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001652 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001653 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001654 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001655 df = defer.Deferred()
1656 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001657 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001658 df.callback(0)
1659 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001660 host = '8.8.8.8'
1661 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1662 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001663 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001664 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1665 assert_equal(st, False)
1666 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1667 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1668 assert_equal(st, True)
1669 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1670 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1671 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001672 except Exception as error:
1673 log.info('Got Unexpected error %s'%error)
1674 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1675 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001676 finally:
1677 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1678 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001679 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001680 df.callback(0)
1681 reactor.callLater(0, vcpe_firewall, df)
1682 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001683
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001684 @deferred(60)
1685 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 +00001686 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001687 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001688 1. Get vSG corresponding to vcpe
1689 2. Login to compute node
1690 3. Execute iptable command on vcpe from compute node to deny a destination IP
1691 4. From cord-tester ping to 8.8.8.8
1692 5. Verifying that ping should not be successful
1693 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1694 7. From cord-tester ping to 8.8.8.8
1695 8. Verifying the ping should success
1696 9. Delete the rule added in step 3
1697 10. From cord-tester ping to 8.8.8.8
1698 11. Verifying that ping should not be successful
1699 12. Delete the rule added in step 6
1700 13. From cord-tester ping to 8.8.8.8
1701 14. Verifying the ping should success
1702 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001703 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001704 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001705 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001706 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001707 df = defer.Deferred()
1708 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001709 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001710 df.callback(0)
1711 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001712 host = '8.8.8.8'
1713 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1714 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001715 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001716 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1717 assert_equal(st, False)
1718 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1719 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1720 assert_equal(st, True)
1721 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1722 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1723 assert_equal(st, True)
1724 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1725 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1726 assert_equal(st, True)
1727 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1728 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1729 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001730 except Exception as error:
1731 log.info('Got Unexpected error %s'%error)
1732 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1733 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1734 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001735 finally:
1736 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1737 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1738 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001739 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001740 df.callback(0)
1741 reactor.callLater(0, vcpe_firewall, df)
1742 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001743
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001744 @deferred(100)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001745 def test_vsg_firewall_flushing_all_configured_rules(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001746 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001747 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001748 1. Get vSG corresponding to vcpe
1749 2. Login to compute node
1750 3. Execute iptable command on vcpe from compute node to deny a destination IP
1751 4. From cord-tester ping to 8.8.8.8
1752 5. Verifying that ping should not be successful
1753 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1754 7. From cord-tester ping to 8.8.8.8
1755 8. Verifying the ping should success
1756 9. Flush all the iptable rules configuraed in vcpe
1757 10. Delete the rule added in step 6
1758 11. From cord-tester ping to 8.8.8.8
1759 12. Verifying the ping should success
1760 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001761 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001762 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001763 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001764 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001765 df = defer.Deferred()
1766 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001767 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001768 df.callback(0)
1769 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001770 host = '8.8.8.8'
1771 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1772 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001773 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001774 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1775 assert_equal(st, False)
1776 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1777 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1778 assert_equal(st, True)
1779 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1780 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1781 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001782 st, _ = vsg.run_cmd('sudo docker exec {} iptables -F FORWARD'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001783 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001784 assert_equal(st, True)
1785 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1786 status = False
1787 clock = 0
1788 while(clock <= 30):
1789 time.sleep(5)
1790 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1791 if st == False:
1792 status = True
1793 break
1794 clock += 5
1795 assert_equal(status, True)
1796 except Exception as error:
1797 log.info('Got Unexpected error %s'%error)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001798 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001799 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1800 raise
1801 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001802 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001803 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001804 df.callback(0)
1805 reactor.callLater(0, vcpe_firewall, df)
1806 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001807
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001808 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001809 def test_vsg_firewall_deny_all_ipv4_traffic(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001810 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001811 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001812 1. Get vSG corresponding to vcpe
1813 2. Login to compute node
1814 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic
1815 4. From cord-tester ping to 8.8.8.8
1816 5. Verifying that ping should not be successful
1817 6. Delete the iptable rule added
1818 7. From cord-tester ping to 8.8.8.8
1819 8. Verifying the ping should success
1820 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001821 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001822 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001823 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001824 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001825 df = defer.Deferred()
1826 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001827 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001828 df.callback(0)
1829 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001830 host = '8.8.8.8'
1831 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1832 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001833 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001834 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1835 assert_equal(st, False)
1836 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
1837 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1838 assert_equal(st, True)
1839 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1840 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1841 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001842 except Exception as error:
1843 log.info('Got Unexpected error %s'%error)
1844 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1845 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001846 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001847 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001848 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001849 df.callback(0)
1850 reactor.callLater(0, vcpe_firewall, df)
1851 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001852
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001853 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001854 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 +00001855 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001856 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001857 1. Get vSG corresponding to vcpe
1858 2. Login to compute node
1859 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic
1860 4. From cord-tester ping to 8.8.8.8
1861 5. Verifying that ping should not be successful
1862 6. Replace the deny rule added in step 3 with accept rule
1863 7. From cord-tester ping to 8.8.8.8
1864 8. Verifying the ping should success
1865 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001866 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001867 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001868 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001869 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001870 df = defer.Deferred()
1871 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001872 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001873 df.callback(0)
1874 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001875 host = '8.8.8.8'
1876 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1877 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001878 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001879 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1880 assert_equal(st, False)
1881 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
1882 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1883 assert_equal(st, True)
1884 st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -4 -j ACCEPT'.format(vcpe_name))
1885 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1886 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001887 except Exception as error:
1888 log.info('Got Unexpected error %s'%error)
1889 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001890 finally:
1891 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1892 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001893 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001894 df.callback(0)
1895 reactor.callLater(0, vcpe_firewall, df)
1896 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001897
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001898 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001899 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 +00001900 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001901 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001902 1. Get vSG corresponding to vcpe
1903 2. Login to compute node
1904 3. Execute iptable command on vcpe from compute node to deny all the traffic coming on lan interface inside vcpe container
1905 4. From cord-tester ping to 8.8.8.8
1906 5. Verifying the ping should not success
1907 6. Delete the iptable rule added
1908 7. From cord-tester ping to 8.8.8.8
1909 8. Verifying the ping should success
1910 """
1911 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001912 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001913 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001914 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001915 df = defer.Deferred()
1916 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001917 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001918 df.callback(0)
1919 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001920 host = '8.8.8.8'
1921 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1922 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001923 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001924 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1925 assert_equal(st, False)
1926 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -j DROP'.format(vcpe_name))
1927 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1928 assert_equal(st, True)
1929 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name))
1930 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1931 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001932 except Exception as error:
1933 log.info('Got Unexpected error %s'%error)
1934 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name))
1935 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001936 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001937 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001938 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001939 df.callback(0)
1940 reactor.callLater(0, vcpe_firewall, df)
1941 return df
1942
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001943 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001944 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 +00001945 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001946 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001947 1. Get vSG corresponding to vcpe
1948 2. Login to compute node
1949 3. Execute iptable command on vcpe from compute node to deny all the traffic going out of wan interface inside vcpe container
1950 4. From cord-tester ping to 8.8.8.8
1951 5. Verifying the ping should not success
1952 6. Delete the iptable rule added
1953 7. From cord-tester ping to 8.8.8.8
1954 8. Verifying the ping should success
1955 """
1956 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001957 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001958 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001959 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001960 df = defer.Deferred()
1961 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001962 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001963 df.callback(0)
1964 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001965 host = '8.8.8.8'
1966 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1967 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001968 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001969 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1970 assert_equal(st, False)
1971 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -o eth0 -j DROP'.format(vcpe_name))
1972 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1973 assert_equal(st, True)
1974 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name))
1975 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1976 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001977 except Exception as error:
1978 log.info('Got Unexpected error %s'%error)
1979 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name))
1980 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001981 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001982 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001983 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001984 df.callback(0)
1985 reactor.callLater(0, vcpe_firewall, df)
1986 return df
1987
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001988 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001989 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 +00001990 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001991 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001992 1. Get vSG corresponding to vcpe
1993 2. Login to compute node
1994 3. Execute iptable command on vcpe from compute node to deny all the traffic from lan to wan interface in vcpe
1995 4. From cord-tester ping to 8.8.8.8
1996 5. Verifying that ping should not be successful
1997 6. Delete the iptable rule added
1998 7. From cord-tester ping to 8.8.8.8
1999 8. Verifying the ping should success
2000 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002001 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002002 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002003 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002004 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002005 df = defer.Deferred()
2006 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07002007 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07002008 df.callback(0)
2009 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002010 host = '8.8.8.8'
2011 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2012 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002013 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002014 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2015 assert_equal(st, False)
2016 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
2017 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2018 assert_equal(st, True)
2019 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
2020 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2021 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002022 except Exception as error:
2023 log.info('Got Unexpected error %s'%error)
2024 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
2025 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002026 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002027 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002028 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002029 df.callback(0)
2030 reactor.callLater(0, vcpe_firewall, df)
2031 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00002032
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002033 @deferred(60)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002034 def test_vsg_firewall_deny_all_dns_traffic(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002035 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002036 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002037 1. Get vSG corresponding to vcpe
2038 2. Login to compute node
2039 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2040 4. From cord-tester ping to www.google.com
2041 5. Verifying the ping should not success
2042 6. Delete the iptable rule added
2043 7. From cord-tester ping to www.google.com
2044 8. Verifying the ping should success
2045 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002046 mgmt = 'eth0'
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002047 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002048 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002049 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002050 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002051 df = defer.Deferred()
2052 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07002053 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07002054 df.callback(0)
2055 return
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002056 host = 'google-public-dns-a.google.com'
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002057 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2058 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002059 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
2060 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe_intf, mgmt = mgmt)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002061 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002062 assert_not_equal(st, False)
2063 VSGAccess.restore_interface_config(mgmt, vcpe=vcpe_intf)
2064 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
2065 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe_intf, mgmt = mgmt)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002066 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2067 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002068 VSGAccess.restore_interface_config(mgmt, vcpe=vcpe_intf)
2069 except Exception as error:
2070 log.info('Got Unexpected error %s'%error)
2071 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
2072 VSGAccess.restore_interface_config(mgmt,vcpe=vcpe_intf)
2073 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002074 df.callback(0)
2075 reactor.callLater(0, vcpe_firewall, df)
2076 return df
2077
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002078 @deferred(60)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002079 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 +00002080 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002081 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00002082 1. Get vSG corresponding to vcpe
2083 2. Login to compute node
2084 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2085 4. From cord-tester ping to www.google.com
2086 5. Verifying that ping should not be successful
2087 6. Delete the iptable rule added
2088 7. From cord-tester ping to www.google.com
2089 8. Verifying the ping should success
2090 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002091 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002092 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002093 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002094 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002095 df = defer.Deferred()
2096 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07002097 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07002098 df.callback(0)
2099 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002100 host = '8.8.8.8'
2101 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2102 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002103 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002104 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2105 assert_equal(st, False)
2106 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
2107 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2108 assert_equal(st, True)
2109 st,output = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002110 clock = 0
2111 status = False
2112 while(clock <= 20 ):
2113 time.sleep(5)
2114 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2115 if st == False:
2116 status = True
2117 break
2118 clock += 5
2119 assert_equal(status, True)
2120 except Exception as error:
2121 log.info('Got Unexpected error %s'%error)
2122 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
2123 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002124 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002125 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002126 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002127 df.callback(0)
2128 reactor.callLater(0, vcpe_firewall, df)
2129 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00002130
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002131 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002132 def test_vsg_nat_dnat_modifying_destination_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002133 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002134 Test Method:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002135 1. Get vSG corresponding to vcpe
2136 2. Login to compute node
2137 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2138 4. From cord-tester ping to www.google.com
2139 5. Verifying the ping should not success
2140 6. Delete the iptable rule added
2141 7. From cord-tester ping to www.google.com
2142 8. Verifying the ping should success
2143 """
2144 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002145 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002146 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002147 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002148 df = defer.Deferred()
2149 def vcpe_firewall(df):
2150 host = '8.8.8.8'
2151 dst_ip = '123.123.123.123'
2152 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2153 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002154 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002155 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2156 assert_equal(st, False)
2157 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))
2158 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2159 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002160 except Exception as error:
2161 log.info('Got Unexpected error %s'%error)
2162 raise
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002163 finally:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002164
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002165 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))
2166 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002167 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002168 df.callback(0)
2169 reactor.callLater(0,vcpe_firewall,df)
2170 return df
2171
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002172 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002173 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 +00002174 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002175 Test Method:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002176 1. Get vSG corresponding to vcpe
2177 2. Login to compute node
2178 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2179 4. From cord-tester ping to www.google.com
2180 5. Verifying the ping should not success
2181 6. Delete the iptable rule added
2182 7. From cord-tester ping to www.google.com
2183 8. Verifying the ping should success
2184 """
2185 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002186 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002187 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002188 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002189 df = defer.Deferred()
2190 def vcpe_firewall(df):
2191 host = '8.8.8.8'
2192 dst_ip = '123.123.123.123'
2193 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2194 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002195 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002196 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2197 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002198 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 +00002199 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2200 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002201 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 +00002202 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2203 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002204 except Exception as error:
2205 log.info('Got Unexpected error %s'%error)
2206 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))
2207 raise
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002208 finally:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002209 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002210 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002211 df.callback(0)
2212 reactor.callLater(0,vcpe_firewall,df)
2213 return df
2214
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002215 @deferred(50)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002216 def test_vsg_dnat_change_modifying_destination_ip_address(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002217 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002218 Test Method:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002219 1. Get vSG corresponding to vcpe
2220 2. Login to compute node
2221 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2222 4. From cord-tester ping to www.google.com
2223 5. Verifying the ping should not success
2224 6. Delete the iptable rule added
2225 7. From cord-tester ping to www.google.com
2226 8. Verifying the ping should success
2227 """
2228 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002229 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002230 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002231 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002232 df = defer.Deferred()
2233 def vcpe_firewall(df):
2234 host = '8.8.8.8'
2235 dst_ip = '123.123.123.123'
2236 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2237 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002238 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002239 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2240 assert_equal(st, False)
2241 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))
2242 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2243 assert_equal(st, True)
2244 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))
2245 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2246 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002247 except Exception as error:
2248 log.info('Got Unexpected error %s'%error)
2249 raise
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002250 finally:
2251 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))
2252 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))
2253 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002254 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002255 df.callback(0)
2256 reactor.callLater(0,vcpe_firewall,df)
2257 return df
2258
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002259 def vsg_xos_subscriber_create(self, index, subscriber_info = None, volt_subscriber_info = None):
A R Karthick19771192017-04-25 14:57:05 -07002260 if self.on_pod is False:
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002261 return ''
2262 if subscriber_info is None:
A R Karthicked3a2ca2017-07-06 15:50:03 -07002263 subscriber_info = self.cord_subscriber.subscriber_info[index]
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002264 if volt_subscriber_info is None:
A R Karthicked3a2ca2017-07-06 15:50:03 -07002265 volt_subscriber_info = self.cord_subscriber.volt_subscriber_info[index]
A R Karthickd0b06792017-04-25 15:11:23 -07002266 s_tag = int(volt_subscriber_info['voltTenant']['s_tag'])
2267 c_tag = int(volt_subscriber_info['voltTenant']['c_tag'])
2268 vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag)
A R Karthicked3a2ca2017-07-06 15:50:03 -07002269 subId = self.cord_subscriber.subscriberCreate(index, subscriber_info, volt_subscriber_info)
2270 if subId:
A R Karthick97e08852017-04-26 10:06:38 -07002271 #if the vsg instance was already instantiated, then reduce delay
A R Karthicked3a2ca2017-07-06 15:50:03 -07002272 if c_tag % self.SUBSCRIBERS_PER_S_TAG == 0:
A R Karthick97e08852017-04-26 10:06:38 -07002273 delay = 350
2274 else:
2275 delay = 90
2276 log.info('Delaying %d seconds for the VCPE to be provisioned' %(delay))
2277 time.sleep(delay)
2278 log.info('Testing for external connectivity to VCPE %s' %(vcpe))
2279 self.vsg_for_external_connectivity(index)
A R Karthicked3a2ca2017-07-06 15:50:03 -07002280
2281 return subId
A R Karthick97e08852017-04-26 10:06:38 -07002282
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002283 def vsg_xos_subscriber_delete(self, index, subId = '', voltId = '', subscriber_info = None, volt_subscriber_info = None):
A R Karthick97e08852017-04-26 10:06:38 -07002284 if self.on_pod is False:
2285 return
A R Karthicked3a2ca2017-07-06 15:50:03 -07002286 self.cord_subscriber.subscriberDelete(index, subId = subId, voltId = voltId,
2287 subscriber_info = subscriber_info,
2288 volt_subscriber_info = volt_subscriber_info)
A R Karthick035d2e22017-04-25 13:53:00 -07002289
A R Karthicke29c8d42017-04-27 11:38:52 -07002290 def vsg_xos_subscriber_id(self, index):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002291 if self.on_pod is False:
2292 return ''
2293 return self.cord_subscriber.subscriberId(index)
A R Karthicke29c8d42017-04-27 11:38:52 -07002294
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002295 def test_vsg_xos_subscriber_create_reserved(self):
A.R Karthicka2960912017-05-18 18:52:55 -07002296 if self.on_pod is False:
2297 return
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002298 tags_reserved = [ (int(vcpe['s_tag']), int(vcpe['c_tag'])) for vcpe in self.vcpes_reserved ]
2299 volt_tenants = self.restApiXos.ApiGet('TENANT_VOLT')
2300 subscribers = self.restApiXos.ApiGet('TENANT_SUBSCRIBER')
2301 reserved_tenants = filter(lambda tenant: (int(tenant['s_tag']), int(tenant['c_tag'])) in tags_reserved, volt_tenants)
2302 reserved_config = []
2303 for tenant in reserved_tenants:
2304 for subscriber in subscribers:
2305 if int(subscriber['id']) == int(tenant['subscriber']):
2306 volt_subscriber_info = {}
2307 volt_subscriber_info['voltTenant'] = dict(s_tag = tenant['s_tag'],
2308 c_tag = tenant['c_tag'],
2309 subscriber = tenant['subscriber'])
2310 volt_subscriber_info['volt_id'] = tenant['id']
2311 volt_subscriber_info['account_num'] = subscriber['identity']['account_num']
2312 reserved_config.append( (subscriber, volt_subscriber_info) )
2313 break
2314 else:
2315 log.info('Subscriber not found for tenant %s, s_tag: %s, c_tag: %s' %(str(tenant['subscriber']),
2316 str(tenant['s_tag']),
2317 str(tenant['c_tag'])))
2318
2319 for subscriber_info, volt_subscriber_info in reserved_config:
2320 self.vsg_xos_subscriber_delete(0,
2321 subId = str(subscriber_info['id']),
2322 voltId = str(volt_subscriber_info['volt_id']),
2323 subscriber_info = subscriber_info,
2324 volt_subscriber_info = volt_subscriber_info)
2325 subId = self.vsg_xos_subscriber_create(0,
2326 subscriber_info = subscriber_info,
2327 volt_subscriber_info = volt_subscriber_info)
2328 log.info('Created reserved subscriber %s' %(subId))
2329
A R Karthick037cb982017-07-07 17:35:30 -07002330 def vsg_create(self, num_subscribers):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002331 if self.on_pod is False:
2332 return
A R Karthick037cb982017-07-07 17:35:30 -07002333 num_subscribers = min(num_subscribers, len(self.cord_subscriber.subscriber_info))
2334 for index in xrange(num_subscribers):
A R Karthicke29c8d42017-04-27 11:38:52 -07002335 #check if the index exists
2336 subId = self.vsg_xos_subscriber_id(index)
2337 if subId and subId != '0':
2338 self.vsg_xos_subscriber_delete(index, subId = subId)
2339 subId = self.vsg_xos_subscriber_create(index)
2340 log.info('Created Subscriber %s' %(subId))
2341
A R Karthick037cb982017-07-07 17:35:30 -07002342 def test_vsg_xos_subscriber_create_all(self):
2343 self.vsg_create(len(self.cord_subscriber.subscriber_info))
2344
2345 def vsg_delete(self, num_subscribers):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002346 if self.on_pod is False:
2347 return
A R Karthick037cb982017-07-07 17:35:30 -07002348 num_subscribers = min(num_subscribers, len(self.cord_subscriber.subscriber_info))
2349 for index in xrange(num_subscribers):
A R Karthicke29c8d42017-04-27 11:38:52 -07002350 subId = self.vsg_xos_subscriber_id(index)
2351 if subId and subId != '0':
2352 self.vsg_xos_subscriber_delete(index, subId = subId)
2353
A R Karthick037cb982017-07-07 17:35:30 -07002354 def test_vsg_xos_subscriber_delete_all(self):
2355 self.vsg_delete(len(self.cord_subscriber.subscriber_info))
2356
A R Karthicke29c8d42017-04-27 11:38:52 -07002357 def test_vsg_xos_subscriber_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002358 subId = self.vsg_xos_subscriber_create(0)
2359 if subId and subId != '0':
2360 self.vsg_xos_subscriber_delete(0, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002361
A R Karthicke29c8d42017-04-27 11:38:52 -07002362 def test_vsg_xos_subscriber_2_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002363 subId = self.vsg_xos_subscriber_create(1)
2364 if subId and subId != '0':
2365 self.vsg_xos_subscriber_delete(1, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002366
A R Karthicke29c8d42017-04-27 11:38:52 -07002367 def test_vsg_xos_subscriber_3_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002368 subId = self.vsg_xos_subscriber_create(2)
2369 if subId and subId != '0':
2370 self.vsg_xos_subscriber_delete(2, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002371
A R Karthicke29c8d42017-04-27 11:38:52 -07002372 def test_vsg_xos_subscriber_4_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002373 subId = self.vsg_xos_subscriber_create(3)
2374 if subId and subId != '0':
2375 self.vsg_xos_subscriber_delete(3, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002376
A R Karthicke29c8d42017-04-27 11:38:52 -07002377 def test_vsg_xos_subscriber_5_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002378 subId = self.vsg_xos_subscriber_create(4)
2379 if subId and subId != '0':
2380 self.vsg_xos_subscriber_delete(4, subId)
A.R Karthick282f0d32017-03-28 16:43:59 -07002381
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002382 @deferred(400)
2383 def test_vsg_xos_subscriber_external_connectivity_through_vcpe_instance(self, index=0):
2384 df = defer.Deferred()
2385 status = False
2386 def test_xos_subscriber(df):
2387 subId = self.vsg_xos_subscriber_id(index)
2388 if subId == '0':
2389 log.info('Creating vcpe instance ')
2390 subId = self.vsg_xos_subscriber_create(index)
2391 assert_not_equal(subId,'0')
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002392 vcpe = self.dhcp_vcpes[index]
2393 host = '8.8.8.8'
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002394 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2395 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2396 assert_equal(st, False)
2397 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2398 df.callback(0)
2399 reactor.callLater(0,test_xos_subscriber,df)
2400 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002401
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002402 #pass
2403 @deferred(50)
2404 def test_vsg_xos_subscriber_external_connectivity_without_creating_vcpe_instance(self, index=0):
2405 df = defer.Deferred()
2406 def test_xos_subscriber(df):
2407 subId = self.vsg_xos_subscriber_id(index)
2408 if subId != '0':
2409 log.info('deleting already existing vcpe instance ')
2410 self.vsg_xos_subscriber_delete(index, subId)
2411 vcpe = self.dhcp_vcpes[index]
2412 host = '8.8.8.8'
2413 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2414 st, out = getstatusoutput('route -n')
2415 log.info('route -n outpu-1-1-1--1-1-1-1-1-1-1 is %s'%out)
2416 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2417 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2418 assert_equal(st, True)
2419 df.callback(0)
2420 reactor.callLater(0,test_xos_subscriber,df)
2421 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002422
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002423 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002424 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 +00002425 df = defer.Deferred()
2426 def test_xos_subscriber(df):
2427 subId = self.vsg_xos_subscriber_id(index)
2428 if subId == '0':
2429 subId = self.vsg_xos_subscriber_create(index)
2430 assert_not_equal(subId,'0')
2431 vcpe = self.dhcp_vcpes[index]
2432 if subId and subId != '0':
2433 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2434 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2435 assert_equal(st, False)
2436 self.vsg_xos_subscriber_delete(index, subId)
2437 time.sleep(2)
2438 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2439 assert_equal(st, True)
2440 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2441 df.callback(0)
2442 reactor.callLater(0,test_xos_subscriber,df)
2443 return df
2444
2445 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002446 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 +00002447 df = defer.Deferred()
2448 def test_xos_subscriber(df):
2449 subId = self.vsg_xos_subscriber_id(index)
2450 if subId == '0':
2451 subId = self.vsg_xos_subscriber_create(index)
2452 assert_not_equal(subId,'0')
2453 vcpe_intf = self.dhcp_vcpes[index]
2454 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2455 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2456 assert_equal(st, False)
2457 vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
2458 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2459 st, _ = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
2460 assert_equal(st, True)
2461 time.sleep(5)
2462 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2463 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2464 assert_equal(st, False)
2465 df.callback(0)
2466 reactor.callLater(0,test_xos_subscriber,df)
2467 return df
2468
2469 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002470 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 +00002471 df = defer.Deferred()
2472 def test_xos_subscriber(df):
2473 subId = self.vsg_xos_subscriber_id(index)
2474 if subId == '0':
2475 subId = self.vsg_xos_subscriber_create(index)
2476 assert_not_equal(subId,'0')
2477 vcpe_intf = self.dhcp_vcpes[index]
2478 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2479 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2480 assert_equal(st, False)
2481 vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
2482 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2483 st, _ = vsg.run_cmd('sudo docker stop {}'.format(vcpe_name))
2484 assert_equal(st, True)
2485 time.sleep(3)
2486 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2487 assert_equal(st, True)
2488 st, _ = vsg.run_cmd('sudo docker start {}'.format(vcpe_name))
2489 assert_equal(st, True)
2490 time.sleep(5)
2491 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2492 assert_equal(st, False)
2493 df.callback(0)
2494 reactor.callLater(0,test_xos_subscriber,df)
2495 return df
2496
2497 #getting list out of range error while creating vcpe of index 6
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002498 def test_vsg_create_xos_subscribers_in_different_vsg_vm(self, index1=4, index2=6):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002499 indexes = list(index1,index2)
2500 subids = []
2501 for index in indexes:
2502 subId = self.vsg_xos_subscriber_id(index)
2503 if not subId:
2504 subId = self.vsg_xos_subscriber_create(index)
2505 assert_not_equal(subId,'0')
2506 subids.append(subId)
2507 log.info('succesfully created two vcpe instances in two different vSG VMs')
2508 self.vsg_xos_subscriber_delete(index1, subid[0])
2509 self.vsg_xos_subscriber_delete(index2, subid[1])
2510
2511 #Unable to reach external network via vcpes created by XOS
2512 @deferred(TIMEOUT+400)
2513 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_goes_down(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002514 """
2515 Test Method:
2516 1.Create two vcpe instances in two different vsg vms using XOS
2517 2.Verify external connectivity through vcpe instances from cord-tester
2518 3.Kill first vcpe instance
2519 4.Verify external network cant be reachable form first vcpe interface
2520 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002521 df = defer.Deferred()
2522 def test_xos_subscriber(df):
2523 host1 = '8.8.8.8'
2524 host2 = '4.2.2.2'
2525 vcpe_intf1 = self.dhcp_vcpes[0]
2526 vcpe_intf2 = self.dhcp_vcpes[1]
2527 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2528 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2529 subId1 = self.vsg_xos_subscriber_id(0)
2530 log.info('already existing subid of index 0 is %s'%subId1)
2531 if subId1 == '0':
2532 log.info('creating vcpe instance of index 0')
2533 subId1 = self.vsg_xos_subscriber_create(0)
2534 assert_not_equal(subId1,'0')
2535 subId2 = self.vsg_xos_subscriber_id(1)
2536 log.info('already existing subid of index 1 is %s'%subId2)
2537 if subId2 == '0':
2538 log.info('creating vcpe instance of index 1')
2539 subId2 = self.vsg_xos_subscriber_create(1)
2540 assert_not_equal(subId2,'0')
2541 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2542 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2543 try:
2544 for intf in [vcpe_intf1,vcpe_intf2]:
2545 host = host1 if intf is vcpe_intf1 else host2
2546 self.add_static_route_via_vcpe_interface([host],vcpe=intf)
2547 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2548 assert_equal(st, False)
2549 if intf is vcpe_intf2:
2550 self.vsg_xos_subscriber_delete(1, subId2)
2551 st, _ = vsg2.run_cmd('sudo docker kill {}'.format(vcpe_name2))
2552 time.sleep(2)
2553 self.add_static_route_via_vcpe_interface([host],vcpe=intf)
2554 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2555 assert_equal(st, False)
2556 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2557 assert_equal(st, True)
2558 except Exception as error:
2559 log.info('Got Unexpected error %s'%error)
2560 raise
2561 finally:
2562 self.vsg_xos_subscriber_delete(0, subId1)
2563 self.vsg_xos_subscriber_delete(1, subId2)
2564 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2565 self.del_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2566 df.callback(0)
2567 reactor.callLater(0,test_xos_subscriber,df)
2568 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002569
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002570 @deferred(TIMEOUT+400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002571 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 +00002572 """
2573 Test Method:
2574 1.Create two vcpe instances in two different vsg vms using XOS
2575 2.Verify external connectivity through vcpe instances from cord-tester
2576 3.Remove first vcpe instance
2577 4.Verify external network cant be reachable form first vcpe interface
2578 5.Add back the removed vcpe instance
2579 6.Verify external connectivity through vcpe instances from cord-tester
2580 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002581 df = defer.Deferred()
2582 def test_xos_subscriber(df,index=index):
2583 host = '8.8.8.8'
2584 subId = self.vsg_xos_subscriber_id(index)
2585 log.info('already existing subid of index 0 is %s'%subId)
2586 if subId == '0':
2587 log.info('creating vcpe instance of index %s'%index)
2588 subId = self.vsg_xos_subscriber_create(index)
2589 assert_not_equal(subId,'0')
2590 vcpe_intf = self.dhcp_vcpes[0]
2591 vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
2592 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2593 try:
2594 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2595 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2596 assert_equal(st, False)
2597 log.info('Deleting vcpe Instance of index %s'%index)
2598 self.vsg_xos_subscriber_delete(0, subId)
2599 st, _ = vsg.run_cmd('sudo docker kill {}'.format(vcpe_name))
2600 time.sleep(1)
2601 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2602 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2603 assert_equal(st, True)
2604 subId = self.vsg_xos_subscriber_create(index)
2605 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2606 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2607 assert_equal(st, False)
2608 except Exception as error:
2609 log.info('Got Unexpected error %s'%error)
2610 raise
2611 finally:
2612 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2613 self.vsg_xos_subscriber_delete(0, subId)
2614 df.callback(0)
2615 reactor.callLater(0,test_xos_subscriber,df)
2616 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002617
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002618 @deferred(TIMEOUT+400)
2619 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_restarts(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002620 """
2621 Test Method:
2622 1.Create two vcpe instances in two different vsg vms using XOS
2623 2.Verify external connectivity through vcpe instances from cord-tester
2624 3.Restart first vcpe instance
2625 4.Verify external network cant be reachable form first vcpe interface
2626 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002627 df = defer.Deferred()
2628 def test_xos_subscriber(df):
2629 host1 = '8.8.8.8'
2630 host2 = '4.2.2.2'
2631 subId1 = self.vsg_xos_subscriber_id(0)
2632 log.info('already existing subid of index 0 is %s'%subId1)
2633 if subId1 == '0':
2634 log.info('creating vcpe instance of index 0')
2635 subId1 = self.vsg_xos_subscriber_create(0)
2636 assert_not_equal(subId1,'0')
2637 subId2 = self.vsg_xos_subscriber_id(1)
2638 log.info('already existing subid of index 1 is %s'%subId2)
2639 if subId2 == '0':
2640 log.info('creating vcpe instance of index 1')
2641 subId2 = self.vsg_xos_subscriber_create(1)
2642 vcpe_intf1 = self.dhcp_vcpes[0]
2643 vcpe_intf2 = self.dhcp_vcpes[1]
2644 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2645 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2646 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2647 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2648 try:
2649 #checking external connectivity from vcpe interface 1 before vcpe 2 restart
2650 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2651 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2652 assert_equal(st, False)
2653 #checking external connectivity from vcpe interface 2 before vcpe 2 restart
2654 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2655 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2656 assert_equal(st, False)
2657 st, _ = vsg2.run_cmd('sudo docker restart {}'.format(vcpe_name2))
2658 time.sleep(10)
2659 #checking external connectivity from vcpe interface 1 after vcpe 2 restart
2660 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2661 assert_equal(st, False)
2662 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2663 time = 0
2664 status = False
2665 while(time <= 100):
2666 time.sleep(10)
2667 st,_ = getstatusoutput('ping -c 1 {}'.format(hos2))
2668 if st is False:
2669 status = True
2670 break
2671 time += 10
2672 assert_equal(status, True)
2673 except Exception as error:
2674 log.info('Got Unexpected error %s'%error)
2675 raise
2676 finally:
2677 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2678 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2679 self.vsg_xos_subscriber_delete(0, subId1)
2680 self.vsg_xos_subscriber_delete(1, subId2)
2681 df.callback(0)
2682 reactor.callLater(0,test_xos_subscriber,df)
2683 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002684
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002685 @deferred(500)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002686 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_is_paused(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002687 """
2688 Test Method:
2689 1.Create two vcpe instances in two different vsg vms using XOS
2690 2.Verify external connectivity through vcpe instances from cord-tester
2691 3.Pause running first vcpe instance
2692 4.Verify external network cant be reachable form first vcpe interface
2693 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002694 df = defer.Deferred()
2695 def test_xos_subscriber(df):
2696 host1 = '8.8.8.8'
2697 host2 = '4.2.2.2'
2698 subId1 = self.vsg_xos_subscriber_id(0)
2699 log.info('already existing subid of index 0 is %s'%subId1)
2700 if subId1 == '0':
2701 log.info('creating vcpe instance of index 0')
2702 subId1 = self.vsg_xos_subscriber_create(0)
2703 assert_not_equal(subId1,'0')
2704 subId2 = self.vsg_xos_subscriber_id(1)
2705 log.info('already existing subid of index 1 is %s'%subId2)
2706 if subId2 == '0':
2707 log.info('creating vcpe instance of index 1')
2708 subId2 = self.vsg_xos_subscriber_create(1)
2709 vcpe_intf1 = self.dhcp_vcpes[0]
2710 vcpe_intf2 = self.dhcp_vcpes[1]
2711 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2712 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2713 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2714 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2715 try:
2716 #checking external connectivity from vcpe interface 1 before vcpe 2 pause
2717 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2718 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2719 assert_equal(st, False)
2720 #checking external connectivity from vcpe interface 2 before vcpe 2 pause
2721 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2722 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2723 assert_equal(st, False)
2724 st, _ = vsg2.run_cmd('sudo docker pause {}'.format(vcpe_name2))
2725 time.sleep(1)
2726 #checking external connectivity from vcpe interface 1 after vcpe 2 pause
2727 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2728 assert_equal(st, False)
2729 #checking external connectivity from vcpe interface 2 after vcpe 2 pause
2730 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2731 assert_equal(st, True)
2732 except Exception as error:
2733 log.info('Got Unexpected error %s'%error)
2734 raise
2735 finally:
2736 log.info('In Finally block 3333333333333333')
2737 st, _ = vsg2.run_cmd('sudo docker unpause {}'.format(vcpe_name2))
2738 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2739 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2740 self.vsg_xos_subscriber_delete(0, subId1)
2741 self.vsg_xos_subscriber_delete(1, subId2)
2742 df.callback(0)
2743 reactor.callLater(0,test_xos_subscriber,df)
2744 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002745
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002746 @deferred(500)
2747 def test_vsg_xos_subscriber_external_connectivity_if_one_vcpe_stops(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002748 """
2749 Test Method:
2750 1.Create two vcpe instances in two different vsg vms using XOS
2751 2.Verify external connectivity through vcpe instances from cord-tester
2752 3.Stop running first vcpe instance
2753 4.Verify external network cant be reachable form first vcpe interface
2754 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002755 df = defer.Deferred()
2756 def test_xos_subscriber(df):
2757 host1 = '8.8.8.8'
2758 host2 = '4.2.2.2'
2759 subId1 = self.vsg_xos_subscriber_id(0)
2760 log.info('already existing subid of index 0 is %s'%subId1)
2761 if subId1 == '0':
2762 log.info('creating vcpe instance of index 0')
2763 subId1 = self.vsg_xos_subscriber_create(0)
2764 assert_not_equal(subId1,'0')
2765 subId2 = self.vsg_xos_subscriber_id(1)
2766 log.info('already existing subid of index 1 is %s'%subId2)
2767 if subId2 == '0':
2768 log.info('creating vcpe instance of index 1')
2769 subId2 = self.vsg_xos_subscriber_create(1)
2770 vcpe_intf1 = self.dhcp_vcpes[0]
2771 vcpe_intf2 = self.dhcp_vcpes[1]
2772 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2773 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2774 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2775 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2776 try:
2777 #checking external connectivity from vcpe interface 1 before vcpe 2 stop
2778 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2779 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2780 assert_equal(st, False)
2781 #checking external connectivity from vcpe interface 2 before vcpe 2 stop
2782 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2783 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2784 assert_equal(st, False)
2785 st, _ = vsg2.run_cmd('sudo docker stop {}'.format(vcpe_name2))
2786 time.sleep(5)
2787 #checking external connectivity from vcpe interface 1 after vcpe 2 stop
2788 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2789 assert_equal(st, False)
2790 #checking external connectivity from vcpe interface 1 after vcpe 2 stop
2791 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2792 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2793 assert_equal(st, True)
2794 except Exception as error:
2795 log.info('Got Unexpected error %s'%error)
2796 raise
2797 finally:
2798 st, _ = vsg2.run_cmd('sudo docker start {}'.format(vcpe_name2))
2799 time.sleep(10)
2800 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2801 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2802 self.vsg_xos_subscriber_delete(0, subId1)
2803 self.vsg_xos_subscriber_delete(1, subId2)
2804 df.callback(0)
2805 reactor.callLater(0,test_xos_subscriber,df)
2806 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002807
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002808 @deferred(420)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002809 def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_stopped(self, index=0):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002810 """
2811 Test Method:
2812 1.Create two vcpe instances in two different vsg vms using XOS
2813 2.Verify external connectivity through vcpe instances from cord-tester
2814 3.Bring down first vSG vm
2815 4.Verify external network cant be reachable form first vcpe interface
2816 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002817 df = defer.Deferred()
2818 def test_xos_subscriber(df,index=index):
2819 host = '8.8.8.8'
2820 subId = self.vsg_xos_subscriber_id(index)
2821 if subId == '0':
2822 log.info('creating vcpe instance of index 0')
2823 subId = self.vsg_xos_subscriber_create(index)
2824 assert_not_equal(subId,'0')
2825 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2826 vcpe_name = self.container_vcpes[index]
2827 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2828 try:
2829 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2830 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2831 assert_equal(st, False)
2832 log.info('Stopping vsg instance')
2833 vsg.stop()
2834 time.sleep(5)
2835 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2836 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2837 assert_equal(st, True)
2838 except Exception as error:
2839 log.info('Got Unexpected error %s'%error)
2840 raise
2841 finally:
2842 vsg.start()
2843 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2844 self.vsg_xos_subscriber_delete(index, subId)
2845 df.callback(0)
2846 reactor.callLater(0,test_xos_subscriber,df)
2847 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002848
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002849 @deferred(420)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002850 def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_restarted(self, index=0):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002851 """
2852 Test Method:
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002853 1.Create subscriber
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002854 2.Verify external connectivity through vcpe instances from cord-tester
2855 3.Bring down first vSG vm
2856 4.Verify external network cant be reachable form first vcpe interface
2857 """
2858 df = defer.Deferred()
2859 def test_xos_subscriber(df,index=index):
2860 host = '8.8.8.8'
2861 subId = self.vsg_xos_subscriber_id(index)
2862 if subId == '0':
2863 log.info('creating vcpe instance of index 0')
2864 subId = self.vsg_xos_subscriber_create(index)
2865 assert_not_equal(subId,'0')
2866 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2867 vcpe_name = self.container_vcpes[index]
2868 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2869 try:
2870 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2871 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2872 assert_equal(st, False)
2873 log.info('Restarting vsg instance')
2874 vsg.reboot()
2875 time.sleep(10)
2876 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2877 time = 0
2878 status = False
2879 while(time <= 100):
2880 time.sleep(10)
2881 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2882 if st is False:
2883 status = True
2884 break
2885 time += 10
2886 assert_equal(status, True)
2887 except Exception as error:
2888 log.info('Got Unexpected error %s'%error)
2889 raise
2890 finally:
2891 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2892 self.vsg_xos_subscriber_delete(index, subId)
2893 df.callback(0)
2894 reactor.callLater(0,test_xos_subscriber,df)
2895 return df
2896
2897 @deferred(780)
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002898 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 +00002899 """
2900 Test Method:
2901 1.Create two vcpe instances in two different vsg vms using XOS
2902 2.Verify external connectivity through vcpe instances from cord-tester
2903 3.Bring down first vSG vm
2904 4.Verify external network cant be reachable form first vcpe interface
2905 5.Bring down second vSG vm also
2906 6.Verify external network cant be reachable form first vcpe interface also
2907 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002908 df = defer.Deferred(df,index1=index1,index2=index2)
2909 def test_xos_subscriber(df,index=index):
2910 subId1 = self.vsg_xos_subscriber_create(index1)
2911 subId2 = self.vsg_xos_subscriber_create(index2)
2912 if subId1 == '0':
2913 self.vsg_xos_subscriber_delete(index1, subId1)
2914 assert_not_equal(subId1, '0')
2915 if subId2 == '0':
2916 self.vsg_xos_subscriber_delete(index2, subId2)
2917 assert_not_equal(subId2, '0')
2918 for index in [index1,index2]:
2919 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2920 vcpe_name = self.container_vcpes[index]
2921 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2922 try:
2923 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2924 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2925 assert_equal(st, False)
2926 log.info('Stopping vsg instance of index %s'%index)
2927 vsg.stop()
2928 time.sleep(5)
2929 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2930 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2931 assert_equal(st, True)
2932 except Exception as error:
2933 log.info('Got Unexpected error %s'%error)
2934 raise
2935 finally:
2936 vsg.start()
2937 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2938 df.callback(0)
2939 reactor.callLater(0,test_xos_subscriber,df)
2940 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002941
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002942 @deferred(420)
2943 def test_vsg_xos_subscriber_external_connectivity_with_creating_firewall_rule(self,index=0):
2944 """
2945 Alog:
2946 1.Cretae a vcpe instance using XOS
2947 2.Get dhcp IP to vcpe interface in cord-tester
2948 3.Verify external network can be reachable from cord-tester
2949 4.Add an iptable rule to drop packets destined to external network in vcpe
2950 5.Verify now external network cant be reachable
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002951 6.Delele the iptable in vcpe instance
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002952 7.Verify external network can be reachable from cord-tester
2953 """
2954 df = defer.Deferred()
2955 def test_xos_subscriber(df,index=index):
2956 log.info('cls.dhcp_vcpes is %s'%self.dhcp_vcpes)
2957 host = '8.8.8.8'
2958 subId = self.vsg_xos_subscriber_create(index)
2959 if subId == '0':
2960 subId = self.vsg_xos_subscriber_create(index)
2961 assert_not_equal(subId, '0')
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002962 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002963 vcpe_name = self.container_vcpes[index]
2964 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002965 try:
2966 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2967 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002968 #ssert_equal(st, False)
2969 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 +00002970 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2971 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002972 st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
2973 self.vsg_xos_subscriber_delete(index, subId)
2974 except Exception as error:
2975 log.info('Got Unexpected error %s'%error)
2976 raise
2977 finally:
2978 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002979 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002980 self.vsg_xos_subscriber_delete(index, subId)
2981 df.callback(0)
2982 reactor.callLater(0,test_xos_subscriber,df)
2983 return df
A R Karthick63751492017-03-22 09:28:01 -07002984
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002985 def test_vsg_for_packet_received_with_invalid_ip_fields(self):
2986 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002987 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002988 1.Create a vSG VM in compute node
2989 2.Create a vCPE container in vSG VM
2990 3.Ensure vSG VM and vCPE container created properly
2991 4.From subscriber, send a ping packet with invalid ip fields
2992 5.Verify that vSG drops the packet
2993 6.Verify ping fails
2994 """
A R Karthick63751492017-03-22 09:28:01 -07002995
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002996 def test_vsg_for_packet_received_with_invalid_mac_fields(self):
2997 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002998 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002999 1.Create a vSG VM in compute node
3000 2.Create a vCPE container in vSG VM
3001 3.Ensure vSG VM and vCPE container created properly
3002 4.From subscriber, send a ping packet with invalid mac fields
3003 5.Verify that vSG drops the packet
3004 6.Verify ping fails
3005 """
A R Karthick63751492017-03-22 09:28:01 -07003006
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003007 def test_vsg_for_vlan_id_mismatch_in_stag(self):
3008 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003009 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003010 1.Create a vSG VM in compute Node
3011 2.Create a vCPE container in vSG VM
3012 3.Ensure vSG VM and vCPE container created properly
3013 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag
3014 5.Verify that ping fails as the packet drops at VM entry
3015 6.Repeat step 4 with correct s-tag
3016 7.Verify that ping success
3017 """
A R Karthick63751492017-03-22 09:28:01 -07003018
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003019 def test_vsg_for_vlan_id_mismatch_in_ctag(self):
3020 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003021 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003022 1.Create a vSG VM in compute node
3023 2.Create a vCPE container in vSG VM
3024 3.Ensure vSG VM and vCPE container created properly
3025 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag
3026 5.Verify that ping fails as the packet drops at vCPE container entry
3027 6.Repeat step 4 with valid s-tag and c-tag
3028 7.Verify that ping success
3029 """
A R Karthick63751492017-03-22 09:28:01 -07003030
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003031 def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self):
3032 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003033 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003034 1.Create two vSG VMs in compute node
3035 2.Create a vCPE container in each vSG VM
3036 3.Ensure vSG VM and vCPE container created properly
3037 4.From subscriber one, send ping request with valid s and c tags
3038 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags
3039 6.Verify that ping success for only subscriber one and fails for two.
3040 """
A R Karthick63751492017-03-22 09:28:01 -07003041
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003042 def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self):
3043 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003044 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003045 1.Create a vSG VM in compute node
3046 2.Create two vCPE containers in vSG VM
3047 3.Ensure vSG VM and vCPE container created properly
3048 4.From subscriber one, send ping request with valid s and c tags
3049 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag
3050 6.Verify that ping success for only subscriber one and fails for two
3051 """
A R Karthick63751492017-03-22 09:28:01 -07003052
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003053 def test_vsg_for_out_of_range_vlanid_in_ctag(self):
3054 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003055 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003056 1.Create a vSG VM in compute node
3057 2.Create a vCPE container in vSG VM
3058 3.Ensure vSG VM and vCPE container created properly
3059 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 )
3060 4.Verify that ping fails as the ping packets drops at vCPE container entry
3061 """
A R Karthick63751492017-03-22 09:28:01 -07003062
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003063 def test_vsg_for_out_of_range_vlanid_in_stag(self):
3064 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003065 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003066 1.Create a vSG VM in compute node
3067 2.Create a vCPE container in vSG VM
3068 3.Ensure vSG VM and vCPE container created properly
3069 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
3070 4.Verify that ping fails as the ping packets drops at vSG VM entry
3071 """
A R Karthick63751492017-03-22 09:28:01 -07003072
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00003073 def test_vsg_for_extracting_all_compute_stats_from_all_vcpe_containers(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003074 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003075 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003076 1.Create a vSG VM in compute node
3077 2.Create 10 vCPE containers in VM
3078 3.Ensure vSG VM and vCPE containers created properly
3079 4.Login to all vCPE containers
3080 4.Get all compute stats from all vCPE containers
3081 5.Verify the stats # verification method need to add
3082 """
A R Karthick63751492017-03-22 09:28:01 -07003083
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00003084 def test_vsg_for_extracting_dns_stats_from_all_vcpe_containers(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003085 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003086 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003087 1.Create a vSG VM in compute node
3088 2.Create 10 vCPE containers in VM
3089 3.Ensure vSG VM and vCPE containers created properly
3090 4.From 10 subscribers, send ping to valid and invalid dns hosts
3091 5.Verify dns resolves and ping success for valid dns hosts
3092 6.Verify ping fails for invalid dns hosts
3093 7.Verify dns host name resolve flows in OvS
3094 8.Login to all 10 vCPE containers
3095 9.Extract all dns stats
3096 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios
3097 """
A R Karthick037cb982017-07-07 17:35:30 -07003098 pass