blob: 6fa22f122acea20245000151af1e08d45c489f5e [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 Karthick19771192017-04-25 14:57:05 -070030from CordTestConfig import setup_module, running_on_ciab
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 Karthick282f0d32017-03-28 16:43:59 -070065 def setUpCordApi(cls):
A R Karthick035d2e22017-04-25 13:53:00 -070066 num_subscribers = max(cls.NUM_SUBSCRIBERS, 5)
A R Karthicked3a2ca2017-07-06 15:50:03 -070067 cls.cord_subscriber = CordSubscriberUtils(num_subscribers,
68 account_num = cls.SUBSCRIBER_ACCOUNT_NUM,
69 s_tag = cls.SUBSCRIBER_S_TAG,
70 c_tag = cls.SUBSCRIBER_C_TAG,
71 subscribers_per_s_tag = cls.SUBSCRIBERS_PER_S_TAG)
72 cls.restApiXos = XosUtils.getRestApi()
A R Karthick97e08852017-04-26 10:06:38 -070073
74 @classmethod
A R Karthickb0cec7c2017-04-21 10:42:54 -070075 def closeVCPEAccess(cls, volt_subscriber_info):
A R Karthick5d30b3c2017-04-27 10:25:40 -070076 OnosCtrl.uninstall_app(cls.APP_NAME, onos_ip = cls.HEAD_NODE)
A.R Karthickb145da82017-04-20 14:45:43 -070077
78 @classmethod
A R Karthickb0cec7c2017-04-21 10:42:54 -070079 def openVCPEAccess(cls, volt_subscriber_info):
A.R Karthickb145da82017-04-20 14:45:43 -070080 """
A R Karthickb0cec7c2017-04-21 10:42:54 -070081 This code is used to configure leaf switch for head node access to compute node over fabric.
82 Care is to be taken to avoid overwriting existing/default vcpe flows.
83 The access is opened for generated subscriber info which should not overlap.
84 We target the fabric onos instance on head node.
A.R Karthickb145da82017-04-20 14:45:43 -070085 """
A R Karthickb608d402017-06-02 11:48:41 -070086 version = Onos.getVersion(onos_ip = cls.HEAD_NODE)
87 app_version = '1.0-SNAPSHOT'
88 major = int(version.split('.')[0])
89 minor = int(version.split('.')[1])
90 if major > 1:
91 app_version = '2.0-SNAPSHOT'
92 elif major == 1 and minor > 10:
93 app_version = '2.0-SNAPSHOT'
94 cls.APP_FILE = os.path.join(cls.test_path, '..', 'apps/xconnect-{}.oar'.format(app_version))
A.R Karthickb145da82017-04-20 14:45:43 -070095 OnosCtrl.install_app(cls.APP_FILE, onos_ip = cls.HEAD_NODE)
96 time.sleep(2)
A R Karthickb0cec7c2017-04-21 10:42:54 -070097 s_tags = map(lambda tenant: int(tenant['voltTenant']['s_tag']), volt_subscriber_info)
98 #only get unique vlan tags
99 s_tags = list(set(s_tags))
A.R Karthickb145da82017-04-20 14:45:43 -0700100 devices = OnosCtrl.get_device_ids(controller = cls.HEAD_NODE)
A R Karthickb0cec7c2017-04-21 10:42:54 -0700101 if devices:
102 device_config = {}
103 for device in devices:
104 device_config[device] = []
105 for s_tag in s_tags:
106 xconnect_config = {'vlan': s_tag, 'ports' : [ cls.FABRIC_PORT_HEAD_NODE, cls.FABRIC_PORT_COMPUTE_NODE ] }
107 device_config[device].append(xconnect_config)
A.R Karthickb145da82017-04-20 14:45:43 -0700108
A R Karthickb0cec7c2017-04-21 10:42:54 -0700109 cfg = { 'apps' : { 'org.ciena.xconnect' : { 'xconnectTestConfig' : device_config } } }
110 OnosCtrl.config(cfg, controller = cls.HEAD_NODE)
A.R Karthickb145da82017-04-20 14:45:43 -0700111
112 @classmethod
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700113 def setUpClass(cls):
114 cls.controllers = get_controllers()
115 cls.controller = cls.controllers[0]
116 cls.cli = None
A R Karthick19771192017-04-25 14:57:05 -0700117 cls.on_pod = running_on_pod()
118 cls.on_ciab = running_on_ciab()
A R Karthick03f40aa2017-03-20 19:33:55 -0700119 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
120 cls.vcpes = cls.olt.get_vcpes()
121 cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp')
A R Karthick035d2e22017-04-25 13:53:00 -0700122 cls.vcpes_reserved = cls.olt.get_vcpes_by_type('reserved')
123 cls.dhcp_vcpes_reserved = [ 'vcpe{}.{}.{}'.format(i, cls.vcpes_reserved[i]['s_tag'], cls.vcpes_reserved[i]['c_tag'])
124 for i in xrange(len(cls.vcpes_reserved)) ]
125 cls.untagged_dhcp_vcpes_reserved = [ 'vcpe{}'.format(i) for i in xrange(len(cls.vcpes_reserved)) ]
126 cls.container_vcpes_reserved = [ 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag']) for vcpe in cls.vcpes_reserved ]
127 vcpe_dhcp_reserved = None
128 vcpe_container_reserved = None
129 if cls.vcpes_reserved:
130 vcpe_dhcp_reserved = cls.dhcp_vcpes_reserved[0]
A R Karthick19771192017-04-25 14:57:05 -0700131 if cls.on_pod is False:
A R Karthick035d2e22017-04-25 13:53:00 -0700132 vcpe_dhcp_reserved = cls.untagged_dhcp_vcpes_reserved[0]
133 vcpe_container_reserved = cls.container_vcpes_reserved[0]
134
135 cls.vcpe_dhcp_reserved = vcpe_dhcp_reserved
136 cls.vcpe_container_reserved = vcpe_container_reserved
137 dhcp_vcpe_offset = len(cls.vcpes_reserved)
A R Karthick927129c2017-04-25 14:08:02 -0700138 cls.dhcp_vcpes = [ 'vcpe{}.{}.{}'.format(i+dhcp_vcpe_offset, cls.vcpes_dhcp[i]['s_tag'], cls.vcpes_dhcp[i]['c_tag'])
139 for i in xrange(len(cls.vcpes_dhcp)) ]
140 cls.untagged_dhcp_vcpes = [ 'vcpe{}'.format(i+dhcp_vcpe_offset) for i in xrange(len(cls.vcpes_dhcp)) ]
141 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 -0700142 vcpe_dhcp = None
A R Karthick03f40aa2017-03-20 19:33:55 -0700143 vcpe_container = None
144 #cache the first dhcp vcpe in the class for quick testing
145 if cls.vcpes_dhcp:
A R Karthick035d2e22017-04-25 13:53:00 -0700146 vcpe_container = cls.container_vcpes[0]
147 vcpe_dhcp = cls.dhcp_vcpes[0]
A R Karthick19771192017-04-25 14:57:05 -0700148 if cls.on_pod is False:
A R Karthick035d2e22017-04-25 13:53:00 -0700149 vcpe_dhcp = cls.untagged_dhcp_vcpes[0]
150 cls.vcpe_container = vcpe_container_reserved or vcpe_container
151 cls.vcpe_dhcp = vcpe_dhcp_reserved or vcpe_dhcp
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700152 VSGAccess.setUp()
A.R Karthick282f0d32017-03-28 16:43:59 -0700153 cls.setUpCordApi()
A R Karthick19771192017-04-25 14:57:05 -0700154 if cls.on_pod is True:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700155 cls.openVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Chetan Gaonker52418832017-01-26 23:03:13 +0000156
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700157 @classmethod
158 def tearDownClass(cls):
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700159 VSGAccess.tearDown()
A R Karthick19771192017-04-25 14:57:05 -0700160 if cls.on_pod is True:
A R Karthicked3a2ca2017-07-06 15:50:03 -0700161 cls.closeVCPEAccess(cls.cord_subscriber.volt_subscriber_info)
Chetan Gaonker52418832017-01-26 23:03:13 +0000162
Chetan Gaonker52418832017-01-26 23:03:13 +0000163 def onos_shutdown(self, controller = None):
164 status = True
A R Karthickb608d402017-06-02 11:48:41 -0700165 cli = Onos.cliEnter(onos_ip = controller)
Chetan Gaonker52418832017-01-26 23:03:13 +0000166 try:
A R Karthickb608d402017-06-02 11:48:41 -0700167 cli.shutdown(timeout = 10)
Chetan Gaonker52418832017-01-26 23:03:13 +0000168 except:
169 log.info('Graceful shutdown of ONOS failed for controller: %s' %controller)
170 status = False
171
A R Karthickb608d402017-06-02 11:48:41 -0700172 Onos.cliExit(cli)
Chetan Gaonker52418832017-01-26 23:03:13 +0000173 return status
174
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700175 def log_set(self, level = None, app = 'org.onosproject'):
176 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000177
A R Karthick9a16a112017-04-07 15:40:05 -0700178 @classmethod
179 def get_dhcp(cls, vcpe, mgmt = 'eth0'):
180 """Get DHCP for vcpe interface saving management settings"""
181
182 def put_dhcp():
183 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
184
185 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
186 if vcpe_ip is not None:
187 cls.restore_methods.append(put_dhcp)
188 return vcpe_ip
189
190 @classmethod
191 def config_restore(cls):
192 """Restore the vsg test configuration on test case failures"""
193 for restore_method in cls.restore_methods:
194 restore_method()
195
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000196 def get_vsg_vcpe_pair(self):
197 vcpes = self.vcpes_dhcp
198 vcpe_containers = []
199 vsg_vcpe = {}
200 for vcp in vcpes:
201 vcpe_container = 'vcpe-{}-{}'.format(vcp['s_tag'], vcp['c_tag'])
202 vcpe_containers.append(vcpe_container)
203 vsg = VSGAccess.get_vcpe_vsg(vcpe_container)
204 vsg_vcpe[vcpe_container]=str(vsg.get_ip())
205 return vsg_vcpe
206
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000207 def get_vcpe_containers_and_interfaces(self):
208 vcpe_containers = {}
209 vcpe_interfaces = []
210 vcpes = self.vcpes_dhcp
211 count = 0
212 for vcpe in vcpes:
213 vcpe_intf = 'vcpe{}.{}.{}'.format(count,vcpe['s_tag'],vcpe['c_tag'])
214 vcpe_interfaces.append(vcpe_intf)
215 vcpe_container = 'vcpe-{}-{}'.format(vcpe['s_tag'], vcpe['c_tag'])
216 vcpe_containers[vcpe_intf] = vcpe_container
217 count += 1
218 log.info('vcpe interfaces are %s'%vcpe_interfaces)
219 log.info('vcpe containers are %s'%vcpe_containers)
220 return vcpe_interfaces,vcpe_containers
221
222 def get_vcpe_interface_dhcp_ip(self,vcpe=None):
223 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000224 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000225 st, _ = getstatusoutput('dhclient {}'.format(vcpe))
226 vcpe_ip = get_ip(vcpe)
227 return vcpe_ip
228
229 def release_vcpe_interface_dhcp_ip(self,vcpe=None):
230 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000231 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000232 st, _ = getstatusoutput('dhclient {} -r'.format(vcpe))
233 vcpe_ip = get_ip(vcpe)
234 assert_equal(vcpe_ip, None)
235
236 def add_static_route_via_vcpe_interface(self, routes, vcpe=None,dhcp_ip=True):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000237 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000238 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000239 if dhcp_ip:
A R Karthick035d2e22017-04-25 13:53:00 -0700240 os.system('dhclient '+vcpe)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000241 time.sleep(1)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000242 for route in routes:
A R Karthick035d2e22017-04-25 13:53:00 -0700243 log.info('route is %s'%route)
244 cmd = 'ip route add ' + route + ' via 192.168.0.1 '+ 'dev ' + vcpe
A R Karthick035d2e22017-04-25 13:53:00 -0700245 os.system(cmd)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000246 return True
247
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000248 def del_static_route_via_vcpe_interface(self,routes,vcpe=None,dhcp_release=True):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000249 if not vcpe:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000250 vcpe = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000251 cmds = []
252 for route in routes:
A R Karthick035d2e22017-04-25 13:53:00 -0700253 cmd = 'ip route del ' + route + ' via 192.168.0.1 ' + 'dev ' + vcpe
254 os.system(cmd)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +0000255 if dhcp_release:
A R Karthick035d2e22017-04-25 13:53:00 -0700256 os.system('dhclient '+vcpe+' -r')
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000257 return True
258
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000259 def vsg_for_external_connectivity(self, subscriber_index, reserved = False):
260 if reserved is True:
261 if self.on_pod is True:
262 vcpe = self.dhcp_vcpes_reserved[subscriber_index]
263 else:
264 vcpe = self.untagged_dhcp_vcpes_reserved[subscriber_index]
265 else:
266 if self.on_pod is True:
267 vcpe = self.dhcp_vcpes[subscriber_index]
268 else:
269 vcpe = self.untagged_dhcp_vcpes[subscriber_index]
270 mgmt = 'eth0'
271 host = '8.8.8.8'
272 self.success = False
273 assert_not_equal(vcpe, None)
274 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
275 assert_not_equal(vcpe_ip, None)
276 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
277 log.info('Sending icmp echo requests to external network 8.8.8.8')
278 st, _ = getstatusoutput('ping -c 3 8.8.8.8')
279 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
280 assert_equal(st, 0)
281
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000282 def get_vsg_health_check(self, vsg_name=None):
283 if self.on_pod is False:
284 return
285 if vsg_name is None:
286 vcpe = self.container_vcpes_reserved[0]
287 vsg = VSGAccess.get_vcpe_vsg(vcpe)
288 status = vsg.get_health()
289 return status
290 else:
291 vsgs = VSGAccess.get_vsgs()
292 for vsg in vsgs:
293 if vsg.name == vsg_name:
294 status = vsg.get_health()
295 return status
296 return None
297
A R Karthick63751492017-03-22 09:28:01 -0700298 def test_vsg_health(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000299 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000300 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000301 1. Login to compute node VM
302 2. Get all vSGs
303 3. Ping to all vSGs
304 4. Verifying Ping success
305 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700306 status = True
A R Karthick19771192017-04-25 14:57:05 -0700307 if self.on_pod is True:
A R Karthick93ba8d02017-04-13 11:59:58 -0700308 status = VSGAccess.health_check()
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700309 assert_equal(status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000310
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000311 def test_vsg_health_check(self, vsg_name=None, verify_status=True):
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. If vsg name not specified, Get vsg corresponding to vcpe
315 1. Login to compute mode VM
316 3. Ping to the vSG
317 4. Verifying Ping success
318 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000319 st = self.get_vsg_health_check(vsg_name=vsg_name)
320 assert_equal(st,verify_status)
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000321
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000322 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700323 def test_vsg_for_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000324 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000325 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000326 1. Get list of all compute nodes created using Openstack
327 2. Login to compute mode VM
328 3. Get all vSGs
329 4. Verifying atleast one compute node and one vSG created
330 """
A R Karthick035d2e22017-04-25 13:53:00 -0700331 df = defer.Deferred()
332 def vsg_for_vcpe_df(df):
A R Karthick19771192017-04-25 14:57:05 -0700333 if self.on_pod is True:
A R Karthick93ba8d02017-04-13 11:59:58 -0700334 vsgs = VSGAccess.get_vsgs()
335 compute_nodes = VSGAccess.get_compute_nodes()
336 time.sleep(14)
337 assert_not_equal(len(vsgs), 0)
338 assert_not_equal(len(compute_nodes), 0)
A R Karthick035d2e22017-04-25 13:53:00 -0700339 df.callback(0)
340 reactor.callLater(0,vsg_for_vcpe_df,df)
341 return df
Chetan Gaonker52418832017-01-26 23:03:13 +0000342
A R Karthick63751492017-03-22 09:28:01 -0700343 def test_vsg_for_login(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000344 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000345 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000346 1. Login to compute node VM
347 2. Get all vSGs
348 3. Verifying login to vSG is success
349 """
A R Karthick19771192017-04-25 14:57:05 -0700350 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700351 return
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700352 vsgs = VSGAccess.get_vsgs()
353 vsg_access_status = map(lambda vsg: vsg.check_access(), vsgs)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700354 status = filter(lambda st: st == False, vsg_access_status)
355 assert_equal(len(status), 0)
356
A R Karthick63751492017-03-22 09:28:01 -0700357 def test_vsg_for_default_route_through_testclient(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000358 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000359 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000360 1. Login to head node
361 2. Verifying for default route in lxc test client
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 Karthick63751492017-03-22 09:28:01 -0700365 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
366 cmd = "sudo lxc exec testclient -- route | grep default"
367 status, output = ssh_agent.run_cmd(cmd)
368 assert_equal(status, True)
369
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000370 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700371 def test_vsg_for_external_connectivity_through_testclient(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000372 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000373 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000374 1. Login to head node
375 2. On head node, executing ping to 8.8.8.8 from lxc test client
376 3. Verifying for the ping success
377 """
A R Karthick19771192017-04-25 14:57:05 -0700378 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700379 return
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000380 df = defer.Deferred()
381 def test_external_connectivity(df):
382 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
383 cmd = "sudo lxc exec testclient -- ping -c 3 8.8.8.8"
384 status, output = ssh_agent.run_cmd(cmd)
385 assert_equal( status, True)
386 df.callback(0)
387 reactor.callLater(0,test_external_connectivity,df)
388 return df
A R Karthick63751492017-03-22 09:28:01 -0700389
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000390 @deferred(30)
A R Karthick035d2e22017-04-25 13:53:00 -0700391 def test_vsg_for_external_connectivity(self):
392 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000393 Test Method:
A R Karthick035d2e22017-04-25 13:53:00 -0700394 1. Get dhcp IP to vcpe interface in cord-tester
395 2. Verifying vcpe interface gets dhcp IP
396 3. Ping to 8.8.8.8 and Verifying ping should success
397 4. Restoring management interface configuration in cord-tester
398 """
A R Karthick19771192017-04-25 14:57:05 -0700399 reserved = True
400 if self.on_pod:
401 reserved = self.on_ciab
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000402 df = defer.Deferred()
403 def test_external_connectivity(df):
404 self.vsg_for_external_connectivity(0, reserved = reserved)
405 df.callback(0)
406 reactor.callLater(0,test_external_connectivity,df)
407 return df
A R Karthick035d2e22017-04-25 13:53:00 -0700408
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000409 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700410 def test_vsg_for_external_connectivity_to_google(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000411 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000412 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000413 1. Get dhcp IP to vcpe interface in cord-tester
414 2. Verifying vcpe interface gets dhcp IP
415 3. Ping to www.google.com and Verifying ping should success
416 4. Restoring management interface configuration in cord-tester
417 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000418 df = defer.Deferred()
419 def test_external_connectivity(df):
420 host = 'www.google.com'
421 vcpe = self.dhcp_vcpes_reserved[0]
422 mgmt = 'eth0'
423 assert_not_equal(vcpe, None)
424 try:
425 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
426 assert_not_equal(vcpe_ip, None)
427 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
428 log.info('Sending icmp ping requests to %s' %host)
429 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
430 assert_equal(st, 0)
431 except Exception as error:
432 log.info('Got Unexpected error %s'%error)
433 raise
434 finally:
435 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
436 df.callback(0)
437 reactor.callLater(0,test_external_connectivity,df)
438 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000439
A R Karthickb2618052017-05-10 09:23:22 -0700440 def retrieve_content_from_host_to_validate_path_mtu(self, host):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000441 vcpe = self.dhcp_vcpes_reserved[0]
A R Karthickb2618052017-05-10 09:23:22 -0700442 mgmt = 'eth0'
443 assert_not_equal(vcpe, None)
444 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
445 assert_not_equal(vcpe_ip, None)
446 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
447 log.info('Initiating get requests to %s' %host)
448 r = requests.get('http://{}'.format(host))
449 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
450 return r.status_code
451
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000452 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000453 def test_vsg_to_retrieve_content_from_google_to_validate_path_mtu(self):
454 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000455 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000456 1. Get dhcp IP to vcpe interface in cord-tester
457 2. Verifying vcpe interface gets dhcp IP
458 3. Retrieve contents from www.google.com and Verify response status is 200 ok.
459 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
460 (Based on website response, size differs, needs check on MTU)
461 4. Restoring management interface configuration in cord-tester
462 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000463 df = defer.Deferred()
464 def test_external_connectivity(df):
465 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.google.com')
466 assert_equal(status_code, 200)
467 df.callback(0)
468 reactor.callLater(0,test_external_connectivity,df)
469 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000470
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000471 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000472 def test_vsg_to_retrieve_content_from_rediff_to_validate_path_mtu(self):
473 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000474 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000475 1. Get dhcp IP to vcpe interface in cord-tester
476 2. Verifying vcpe interface gets dhcp IP
477 3. Retrieve contents from www.rediff.com and Verify response status is 200 ok.
478 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
479 (Based on website response, size differs, needs check on MTU)
480 4. Restoring management interface configuration in cord-tester
481 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000482 df = defer.Deferred()
483 def test_external_connectivity(df):
484 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.rediff.com')
485 assert_equal(status_code, 200)
486 df.callback(0)
487 reactor.callLater(0,test_external_connectivity,df)
488 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000489
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000490 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000491 def test_vsg_to_retrieve_content_from_yahoo_to_validate_path_mtu(self):
492 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000493 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000494 1. Get dhcp IP to vcpe interface in cord-tester
495 2. Verifying vcpe interface gets dhcp IP
496 3. Retrieve contents from www.yahoo.com and Verify response status is 200 ok.
497 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
498 (Based on website response, size differs, needs check on MTU)
499 4. Restoring management interface configuration in cord-tester
500 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000501 df = defer.Deferred()
502 def test_external_connectivity(df):
503 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.yahoo.com')
504 assert_equal(status_code, 200)
505 df.callback(0)
506 reactor.callLater(0,test_external_connectivity,df)
507 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000508
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000509 @deferred(30)
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000510 def test_vsg_to_retrieve_content_from_facebook_to_validate_path_mtu(self):
511 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000512 Test Method:
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000513 1. Get dhcp IP to vcpe interface in cord-tester
514 2. Verifying vcpe interface gets dhcp IP
515 3. Retrieve contents from www.facebook.com and Verify response status is 200 ok.
516 4. This validates path mtu for end to end traffic with request to retrieve web contents in cord framework.
517 (Based on website response, size differs, needs check on MTU)
518 4. Restoring management interface configuration in cord-tester
519 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000520 df = defer.Deferred()
521 def test_external_connectivity(df):
522 status_code = self.retrieve_content_from_host_to_validate_path_mtu('www.facebook.com')
523 assert_equal(status_code, 200)
524 df.callback(0)
525 reactor.callLater(0,test_external_connectivity,df)
526 return df
Chetan Gaonker0bf76312017-05-09 16:48:10 +0000527
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000528
529 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700530 def test_vsg_for_external_connectivity_to_invalid_host(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000531 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000532 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000533 1. Get dhcp IP to vcpe interface in cord-tester
534 2. Verifying vcpe interface gets dhcp IP
535 3. Ping to www.goglee.com and Verifying ping should not success
536 4. Restoring management interface configuration in cord-tester
537 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000538 df = defer.Deferred()
539 def test_external_connectivity(df):
540 host = 'www.goglee.com'
541 vcpe = self.dhcp_vcpes_reserved[0]
542 mgmt = 'eth0'
543 assert_not_equal(vcpe, None)
544 try:
545 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
546 assert_not_equal(vcpe_ip, None)
547 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
548 log.info('Sending icmp ping requests to non existent host %s' %host)
549 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
550 assert_not_equal(st, 0)
551 except Exception as error:
552 log.info('Got Unexpected error %s'%error)
553 raise
554 finally:
555 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
556 df.callback(0)
557 reactor.callLater(0,test_external_connectivity,df)
558 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000559
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000560 @deferred(30)
A R Karthick63751492017-03-22 09:28:01 -0700561 def test_vsg_for_external_connectivity_with_ttl_1(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000562 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000563 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000564 1. Get dhcp IP to vcpe interface in cord-tester
565 2. Verifying vcpe interface gets dhcp IP
566 3. Ping to 8.8.8.8 with ttl set to 1
567 4. Verifying ping should not success
568 5. Restoring management interface configuration in cord-tester
569 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000570 df = defer.Deferred()
571 def test_external_connectivity(df):
572 host = '8.8.8.8'
573 vcpe = self.dhcp_vcpes_reserved[0]
574 mgmt = 'eth0'
575 assert_not_equal(vcpe, None)
576 try:
577 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
578 assert_not_equal(vcpe_ip, None)
579 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
580 log.info('Sending icmp ping requests to host %s with ttl 1' %host)
581 st, _ = getstatusoutput('ping -c 1 -t 1 {}'.format(host))
582 assert_not_equal(st, 0)
583 except Exception as error:
584 log.info('Got Unexpected error %s'%error)
585 raise
586 finally:
587 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
588 df.callback(0)
589 reactor.callLater(0,test_external_connectivity,df)
590 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000591
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000592 @deferred(60)
A R Karthick63751492017-03-22 09:28:01 -0700593 def test_vsg_for_external_connectivity_with_wan_interface_toggle_in_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000594 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000595 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000596 1. Get dhcp IP to vcpe interface in cord-tester
597 2. Verifying vcpe interface gets dhcp IP
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700598 3. Ping to 8.8.8.8 and Verifying ping succeeds
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000599 4. Now down the WAN interface of vcpe
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700600 5. Ping to 8.8.8.8 and Verifying ping fails
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000601 6. Now Up the WAN interface of vcpe
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700602 7. Ping to 8.8.8.8 and Verifying ping succeeds
603 8. Restoring management interface configuration in cord-tester
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000604 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000605 df = defer.Deferred()
606 def test_external_connectivity(df):
607 if self.on_pod is False:
608 return
609 host = '8.8.8.8'
610 mgmt = 'eth0'
611 vcpe = self.dhcp_vcpes_reserved[0]
612 vcpe_name = self.container_vcpes_reserved[0]
613 assert_not_equal(vcpe_name, None)
614 assert_not_equal(vcpe, None)
615 #first get dhcp on the vcpe interface
616 try:
617 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
618 assert_not_equal(vcpe_ip, None)
619 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
620 log.info('Sending ICMP pings to host %s' %(host))
621 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
622 if st != 0:
623 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
624 assert_equal(st, 0)
625 #bring down the wan interface and check again
626 st = VSGAccess.vcpe_wan_down(vcpe_name)
627 if st is False:
628 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
629 assert_equal(st, True)
630 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
631 if st == 0:
632 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
633 assert_not_equal(st, 0)
634 st = VSGAccess.vcpe_wan_up(vcpe_name)
635 if st is False:
636 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
637 assert_equal(st, True)
638 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
639 assert_equal(st, 0)
640 except Exception as error:
641 log.info('Got Unexpected error %s'%error)
642 raise
643 finally:
644 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
645 df.callback(0)
646 reactor.callLater(0,test_external_connectivity,df)
647 return df
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000648
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000649 @deferred(60)
A R Karthick63751492017-03-22 09:28:01 -0700650 def test_vsg_for_external_connectivity_with_lan_interface_toggle_in_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000651 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000652 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000653 1. Get dhcp IP to vcpe interface in cord-tester
654 2. Verifying vcpe interface gets dhcp IP
655 3. Ping to 8.8.8.8 and Verifying ping should success
656 4. Now down the LAN interface of vcpe
657 5. Ping to 8.8.8.8 and Verifying ping should not success
658 6. Now Up the LAN interface of vcpe
659 7. Ping to 8.8.8.8 and Verifying ping should success
660 8. Restoring management interface configuration in cord-tester
661 """
A R Karthick19771192017-04-25 14:57:05 -0700662 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700663 return
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000664 df = defer.Deferred()
665 def test_external_connectivity(df):
666 host = '8.8.8.8'
667 mgmt = 'eth0'
668 vcpe = self.dhcp_vcpes_reserved[0]
669 vcpe_name = self.container_vcpes_reserved[0]
670 assert_not_equal(vcpe, None)
671 assert_not_equal(vcpe_name, None)
672 #first get dhcp on the vcpe interface
673 try:
674 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
675 assert_not_equal(vcpe_ip, None)
676 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
677 log.info('Sending ICMP pings to host %s' %(host))
678 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
679 if st != 0:
680 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
681 assert_equal(st, 0)
682 #bring down the lan interface and check again
683 st = VSGAccess.vcpe_lan_down(vcpe_name)
684 if st is False:
685 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
686 assert_equal(st, True)
687 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
688 if st == 0:
689 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
690 assert_not_equal(st, 0)
691 st = VSGAccess.vcpe_lan_up(vcpe_name)
692 if st is False:
693 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
694 assert_equal(st, True)
695 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
696 assert_equal(st, 0)
697 except Exception as error:
698 log.info('Got Unexpected error %s'%error)
699 raise
700 finally:
701 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
702 df.callback(0)
703 reactor.callLater(0,test_external_connectivity,df)
704 return df
Chetan Gaonker52418832017-01-26 23:03:13 +0000705
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000706 @deferred(120)
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +0000707 def test_vsg_multiple_subscribers_for_same_vcpe_instance(self):
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000708 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000709 Test Method:
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000710 1. Create a vcpe instance
711 2. Create multiple vcpe interfaces in cord-tester with same s-tag and c-tag to access vcpe instance
712 3. Verify all the interfaces gets dhcp IP in same subnet
713 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000714 df = defer.Deferred()
715 def test_external_connectivity(df):
716 vcpe_intfs,containers = self.get_vcpe_containers_and_interfaces()
717 for vcpe in vcpe_intfs:
718 vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe)
719 assert_not_equal(vcpe_ip,None)
720 for vcpe in vcpe_intfs:
721 self.release_vcpe_interface_dhcp_ip(vcpe=vcpe)
722 df.callback(0)
723 reactor.callLater(0,test_external_connectivity,df)
724 return df
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000725
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000726 @deferred(120)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000727 def test_vsg_for_multiple_subscribers_with_same_vcpe_instance_and_validate_external_connectivity(self):
728 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000729 Test Method:
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000730 1. Create a vcpe instance
731 2. Create multiple vcpe interfaces in cord-tester with same s-tag and c-tag to access vcpe instance
732 3. Verify all the interfaces gets dhcp IP in same subnet
733 4. From cord-tester ping to external with vcpe interface option
734 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000735 df = defer.Deferred()
736 def test_external_connectivity(df):
737 host = '8.8.8.8'
738 vcpe_intfs, containers = self.get_vcpe_containers_and_interfaces()
739 try:
740 for vcpe in vcpe_intfs:
741 vcpe_ip = self.get_vcpe_interface_dhcp_ip(vcpe=vcpe)
742 assert_not_equal(vcpe_ip,None)
743 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_ip=False)
744 st, _ = getstatusoutput('ping -I {} -c 3 {}'.format(vcpe,host))
745 assert_equal(st, 0)
746 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe,dhcp_release=False)
747 except Exception as error:
748 log.info('Got Unexpected error %s'%error)
749 raise
750 finally:
751 for vcpe in vcpe_intfs:
752 self.release_vcpe_interface_dhcp_ip(vcpe=vcpe)
753 df.callback(0)
754 reactor.callLater(0,test_external_connectivity,df)
755 return df
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000756
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000757 @deferred(30)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000758 def test_vsg_vcpe_interface_and_validate_dhcp_ip_after_interface_toggle(self):
759 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000760 Test Method:
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000761 1. Create a vcpe instance
762 2. Create a vcpe interface in cord-tester
763 3. Verify the interface gets dhcp IP
764 4. Toggle the interface
765 5. Verify the interface gets dhcp IP
766 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000767 df = defer.Deferred()
768 def test_external_connectivity(df):
769 vcpe_intf = self.dhcp_vcpes_reserved[0]
770 host = '8.8.8.8'
771 try:
772 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
773 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
774 assert_equal(st, 0)
775 os.system('ifconfig {} down'.format(vcpe_intf))
776 time.sleep(1)
777 os.system('ifconfig {} up'.format(vcpe_intf))
778 time.sleep(1)
779 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
780 assert_equal(st, 0)
781 except Exception as error:
782 log.info('Got Unexpected error %s'%error)
783 raise
784 finally:
785 self.del_static_route_via_vcpe_interface([host], vcpe=vcpe_intf)
786 df.callback(0)
787 reactor.callLater(0,test_external_connectivity,df)
788 return df
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +0000789
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000790 @deferred(TIMEOUT)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000791 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 +0000792 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000793 Test Method:
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000794 1. Get vSG corresponding to vcpe
795 2. Get dhcp ip to vcpe interface
796 3. Add static route to destination route in test container
797 4. From test container ping to destination route and verify ping success
798 5. Login to compute node and execute command to pause vcpe container
799 6. From test container ping to destination route and verify ping success
800 """
801 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000802 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000803 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000804 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000805 df = defer.Deferred()
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000806 def test_external_connectivity(df):
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000807 if self.on_pod is False:
808 df.callback(0)
809 return
810 host = '8.8.8.8'
811 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
812 try:
813 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
814 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
815 assert_equal(st, False)
816 st, _ = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000817 clock = 0
818 status = False
819 while(clock <= 20):
820 time.sleep(5)
821 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
822 if st == False:
823 status = True
824 break
825 clock += 5
826 assert_equal(status, True)
827 except Exception as error:
828 log.info('Got Unexpected error %s'%error)
829 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
830 raise
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000831 finally:
832 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
833 df.callback(0)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000834 reactor.callLater(0, test_external_connectivity, df)
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000835 return df
836
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000837 @nottest #Setup getting distrubed if vSG VM restart
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000838 @deferred(TIMEOUT)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000839 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 +0000840 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000841 Test Method:
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000842 1. Get vSG corresponding to vcpe
843 2. Get dhcp ip to vcpe interface
844 3. Add static route to destination route in test container
845 4. From test container ping to destination route and verify ping success
846 5. Login to compute node and execute command to pause vcpe container
847 6. From test container ping to destination route and verify ping success
848 """
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000849 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000850 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000851 df = defer.Deferred()
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000852 def test_external_connectivity(df):
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000853 if self.on_pod is False:
854 df.callback(0)
855 return
856 host = '8.8.8.8'
857 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
858 try:
859 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
860 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
861 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000862 vsg.reboot()
863 clock = 0
864 status = False
865 while(clock <= 30):
866 time.sleep(5)
867 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
868 if st == False:
869 status = True
870 break
871 clock += 5
872 assert_equal(status, True)
873 except Exception as error:
874 log.info('Got Unexpected error %s'%error)
875 vsg.reboot()
876 raise
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000877 finally:
878 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
879 df.callback(0)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000880 reactor.callLater(0, test_external_connectivity, df)
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +0000881 return df
882
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000883 @deferred(60)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000884 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 +0000885 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000886 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000887 1. Get vSG corresponding to vcpe
888 2. Get dhcp ip to vcpe interface
889 3. Add static route to destination route in test container
890 4. From test container ping to destination route and verify ping success
891 5. Login to compute node and execute command to pause vcpe container
892 6. From test container ping to destination route and verify ping success
893 """
894 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000895 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000896 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000897 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000898 df = defer.Deferred()
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000899 def test_external_connectivity(df):
A R Karthick19771192017-04-25 14:57:05 -0700900 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700901 df.callback(0)
902 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000903 host = '8.8.8.8'
904 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
905 try:
906 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
907 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
908 assert_equal(st, False)
909 st, _ = vsg.run_cmd('sudo docker pause {}'.format(vcpe_name))
910 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
911 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000912 vsg.run_cmd('sudo docker unpause {}'.format(vcpe_name))
913 except Exception as error:
914 log.info('Got Unexpected error %s'%error)
915 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
916 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000917 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000918 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
919 df.callback(0)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +0000920 reactor.callLater(0, test_external_connectivity, df)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000921 return df
922
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000923 @deferred(30)
924 def test_vsg_firewall_with_deny_destination_ip_set(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000925 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000926 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000927 1. Get vSG corresponding to vcpe
928 2. Login to compute node
929 3. Execute iptable command on vcpe from compute node to deny a destination IP
930 4. From cord-tester ping to the denied IP address
931 5. Verifying that ping should not be successful
932 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000933 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000934 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000935 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000936 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000937 df = defer.Deferred()
938 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -0700939 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700940 df.callback(0)
941 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000942 host = '8.8.8.8'
943 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
944 try:
945 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
946 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
947 assert_equal(st, False)
948 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
949 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
950 assert_equal(st, True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000951 except Exception as error:
952 log.info('Got Unexpected error %s'%error)
953 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000954 finally:
955 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
956 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000957 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000958 df.callback(0)
959 reactor.callLater(0, vcpe_firewall, df)
960 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000961
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000962 @deferred(60)
963 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 +0000964 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +0000965 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000966 1. Get vSG corresponding to vcpe
967 2. Login to compute node
968 3. Execute iptable command on vcpe from compute node to deny a destination IP
969 4. From cord-tester ping to the denied IP address
970 5. Verifying that ping should not be successful
971 6. Delete the iptable rule in vcpe
972 7. From cord-tester ping to the denied IP address
973 8. Verifying the ping should success
974 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000975 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000976 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000977 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000978 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000979 df = defer.Deferred()
980 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -0700981 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -0700982 df.callback(0)
983 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000984 host = '8.8.8.8'
985 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
986 try:
987 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
988 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
989 assert_equal(st, False)
990 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
991 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
992 assert_equal(st, True)
993 st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
994 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
995 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +0000996 except Exception as error:
997 log.info('Got Unexpected error %s'%error)
998 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
999 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001000 finally:
1001 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1002 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001003 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001004 df.callback(0)
1005 reactor.callLater(0, vcpe_firewall, df)
1006 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001007
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001008 @deferred(40)
1009 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 +00001010 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001011 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001012 1. Get vSG corresponding to vcpe
1013 2. Login to compute node
1014 3. Execute iptable command on vcpe from compute node to deny a destination IP
1015 4. From cord-tester ping to the denied IP address
1016 5. Verifying that ping should not be successful
1017 6. From cord-tester ping to the denied IP address other than the denied one
1018 7. Verifying the ping should success
1019 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001020 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001021 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001022 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001023 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001024 df = defer.Deferred()
1025 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001026 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001027 df.callback(0)
1028 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001029 host1 = '8.8.8.8'
1030 host2 = '204.79.197.203'
1031 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1032 try:
1033 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
1034 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1035 assert_equal(st, False)
1036 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1037 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1038 assert_equal(st, True)
1039 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1040 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001041 except Exception as error:
1042 log.info('Got Unexpected error %s'%error)
1043 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001044 finally:
1045 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1046 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001047 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001048 df.callback(0)
1049 reactor.callLater(0, vcpe_firewall, df)
1050 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001051
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001052 @deferred(60)
1053 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 +00001054 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001055 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001056 1. Get vSG corresponding to vcpe
1057 2. Login to compute node
1058 3. Execute iptable command on vcpe from compute node to deny a destination IP1
1059 4. From cord-tester ping to the denied IP address IP1
1060 5. Verifying that ping should not be successful
1061 6. Execute iptable command on vcpe from compute node to deny a destination IP2
1062 6. From cord-tester ping to the denied IP address IP2
1063 7. Verifying that ping should not be successful
1064 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001065 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001066 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001067 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001068 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001069 df = defer.Deferred()
1070 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001071 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001072 df.callback(0)
1073 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001074 host1 = '8.8.8.8'
1075 host2 = '204.79.197.203'
1076 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1077 try:
1078 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
1079 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1080 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001081 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1082 assert_equal(st, False)
1083 st,_ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1084 time.sleep(1)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001085 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1086 assert_equal(st, True)
1087 st, out = getstatusoutput('ping -c 1 {}'.format(host2))
1088 log.info('host2 ping output is %s'%out)
1089 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001090 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,host2))
1091 time.sleep(1)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001092 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1093 assert_equal(st,True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001094 except Exception as error:
1095 log.info('Got Unexpected error %s'%error)
1096 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001097 finally:
1098 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1099 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1100 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001101 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001102 df.callback(0)
1103 reactor.callLater(0, vcpe_firewall, df)
1104 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001105
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001106 @deferred(TIMEOUT)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001107 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 +00001108 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001109 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001110 1. Get vSG corresponding to vcpe
1111 2. Login to compute node
1112 3. Execute iptable command on vcpe from compute node to deny a destination IP1
1113 4. Execute iptable command on vcpe from compute node to deny a destination IP2
1114 5. From cord-tester ping to the denied IP address IP1
1115 6. Verifying that ping should not be successful
1116 7. From cord-tester ping to the denied IP address IP2
1117 8. Verifying that ping should not be successful
1118 9. Execute iptable command on vcpe from compute node to remove deny a destination IP2 rule
1119 10. From cord-tester ping to the denied IP address IP2
1120 11. Verifying the ping should success
1121 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001122 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001123 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001124 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001125 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001126 df = defer.Deferred()
1127 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001128 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001129 df.callback(0)
1130 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001131 host1 = '8.8.8.8'
1132 host2 = '204.79.197.203'
1133 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1134 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001135 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001136 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1137 assert_equal(st, False)
1138 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1139 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1140 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1141 assert_equal(st, True)
1142 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1143 assert_equal(st,True)
1144 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1145 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1146 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001147 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1148 assert_equal(st, True)
1149 except Exception as error:
1150 log.info('Got Unexpected error %s'%error)
1151 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001152 finally:
1153 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
1154 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
1155 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001156 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001157 df.callback(0)
1158 reactor.callLater(0, vcpe_firewall, df)
1159 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001160
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001161 @deferred(60)
1162 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 +00001163 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001164 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001165 1. Get vSG corresponding to vcpe
1166 2. Login to compute node
1167 3. Execute iptable command on vcpe from compute node to deny a destination IP
1168 5. From cord-tester ping to the denied IP address IP1
1169 6. Verifying that ping should not be successful
1170 9. Execute iptable command on vcpe from compute node to change the rule ID to 2 to deny the same destination IP
1171 10. From cord-tester ping to the denied IP address IP
1172 11. Verifying that ping should not be successful
1173 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001174 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001175 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001176 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001177 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001178 df = defer.Deferred()
1179 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001180 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001181 df.callback(0)
1182 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001183 host = '8.8.8.8'
1184 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1185 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001186 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001187 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1188 assert_equal(st, False)
1189 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1190 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1191 assert_equal(st, True)
1192 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP '.format(vcpe_name,host))
1193 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1194 assert_equal(st,True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001195 except Exception as error:
1196 log.info('Got Unexpected error %s'%error)
1197 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001198 finally:
1199 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1200 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001201 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001202 df.callback(0)
1203 reactor.callLater(0, vcpe_firewall, df)
1204 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001205
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001206 @deferred(50)
1207 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 +00001208 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001209 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001210 1. Get vSG corresponding to vcpe
1211 2. Login to compute node
1212 3. Execute iptable command on vcpe from compute node to deny a destination IP
1213 5. From cord-tester ping to the denied IP address IP1
1214 6. Verifying that ping should not be successful
1215 9. Execute iptable command on vcpe from compute node to accept the same destination IP
1216 10. From cord-tester ping to the accepted IP
1217 11. Verifying the ping should success
1218 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001219 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001220 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001221 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001222 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001223 df = defer.Deferred()
1224 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001225 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001226 df.callback(0)
1227 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001228 host = '8.8.8.8'
1229 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1230 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001231 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001232 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1233 assert_equal(st, False)
1234 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1235 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1236 assert_equal(st, True)
1237 st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -d {} -j ACCEPT'.format(vcpe_name,host))
1238 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1239 assert_equal(st,False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001240 except Exception as error:
1241 log.info('Got Unexpected error %s'%error)
1242 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001243 finally:
1244 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1245 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j ACCEPT'.format(vcpe_name,host))
1246 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001247 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001248 df.callback(0)
1249 reactor.callLater(0, vcpe_firewall, df)
1250 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001251
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001252 @deferred(60)
1253 def test_vsg_firewall_denying_destination_network(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001254 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001255 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001256 1. Get vSG corresponding to vcpe
1257 2. Login to compute node
1258 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet
1259 4. From cord-tester ping to the denied IP address IP1 in the denied subnet
1260 5. Verifying that ping should not be successful
1261 6. From cord-tester ping to the denied IP address IP2 in the denied subnet
1262 7. Verifying that ping should not be successful
1263 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001264 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001265 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001266 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001267 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001268 df = defer.Deferred()
1269 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001270 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001271 df.callback(0)
1272 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001273 network = '204.79.197.192/28'
1274 host1 = '204.79.197.203'
1275 host2 = '204.79.197.210'
1276 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1277 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001278 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001279 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1280 assert_equal(st, False)
1281 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network))
1282 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1283 assert_equal(st, True)
1284 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1285 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001286 except Exception as error:
1287 log.info('Got Unexpected error %s'%error)
1288 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001289 finally:
1290 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network))
1291 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001292 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001293 df.callback(0)
1294 reactor.callLater(0, vcpe_firewall, df)
1295 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001296
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001297 @deferred(60)
1298 def test_vsg_firewall_denying_destination_network_subnet_modification(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001299 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001300 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001301 1. Get vSG corresponding to vcpe
1302 2. Login to compute node
1303 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet
1304 4. From cord-tester ping to the denied IP address IP1 in the denied subnet
1305 5. Verifying that ping should not be successful
1306 6. From cord-tester ping to the denied IP address IP2 in the denied subnet
1307 7. Verifying that ping should not be successful
1308 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001309 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001310 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001311 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001312 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001313 df = defer.Deferred()
1314 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001315 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001316 df.callback(0)
1317 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001318 network1 = '204.79.197.192/28'
1319 network2 = '204.79.197.192/27'
1320 host1 = '204.79.197.203'
1321 host2 = '204.79.197.210'
1322 host3 = '204.79.197.224'
1323 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1324 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001325 self.add_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001326 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1327 assert_equal(st, False)
1328 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network1))
1329 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1330 assert_equal(st, True)
1331 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1332 assert_equal(st,False)
1333 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,network2))
1334 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
1335 assert_equal(st, True)
1336 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
1337 assert_equal(st, True)
1338 st, _ = getstatusoutput('ping -c 1 {}'.format(host3))
1339 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001340 except Exception as error:
1341 log.info('Got Unexpected error %s'%error)
1342 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001343 finally:
1344 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network1))
1345 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network2))
1346 self.del_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001347 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001348 df.callback(0)
1349 reactor.callLater(0, vcpe_firewall, df)
1350 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001351
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001352 @deferred(40)
1353 def test_vsg_firewall_with_deny_source_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001354 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001355 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001356 1. Get vSG corresponding to vcpe
1357 2. Login to compute node
1358 3. Execute iptable command on vcpe from compute node to deny a source IP
1359 4. From cord-tester ping to 8.8.8.8 from the denied IP
1360 5. Verifying that ping should not be successful
1361 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001362 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001363 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001364 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001365 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001366 df = defer.Deferred()
1367 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001368 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001369 df.callback(0)
1370 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001371 host = '8.8.8.8'
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001372 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1373 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001374 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1375 source_ip = get_ip(vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001376 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1377 assert_equal(st, False)
1378 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1379 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1380 assert_equal(st, True)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001381 except Exception as error:
1382 log.info('Got Unexpected error %s'%error)
1383 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1384 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001385 finally:
1386 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1387 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001388 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001389 df.callback(0)
1390 reactor.callLater(0, vcpe_firewall, df)
1391 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001392
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001393 @deferred(40)
1394 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 +00001395 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001396 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001397 1. Get vSG corresponding to vcpe
1398 2. Login to compute node
1399 3. Execute iptable command on vcpe from compute node to deny a source IP
1400 4. From cord-tester ping to 8.8.8.8 from the denied IP
1401 5. Verifying that ping should not be successful
1402 6. Delete the iptable rule in vcpe
1403 7. From cord-tester ping to 8.8.8.8 from the denied IP
1404 8. Verifying the ping should success
1405 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001406 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001407 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001408 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001409 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001410 df = defer.Deferred()
1411 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001412 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001413 df.callback(0)
1414 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001415 host = '8.8.8.8'
1416 source_ip = get_ip(self.vcpe_dhcp)
1417 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1418 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001419 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1420 source_ip = get_ip(vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001421 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1422 assert_equal(st, False)
1423 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1424 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1425 assert_equal(st, True)
1426 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1427 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1428 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001429 except Exception as error:
1430 log.info('Got Unexpected error %s'%error)
1431 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1432 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001433 finally:
1434 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1435 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001436 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001437 df.callback(0)
1438 reactor.callLater(0, vcpe_firewall, df)
1439 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001440
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001441 @deferred(40)
1442 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 +00001443 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001444 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001445 1. Get vSG corresponding to vcpe
1446 2. Login to compute node
1447 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets
1448 4. From cord-tester ping to 8.8.8.8
1449 5. Verifying that ping should not be successful
1450 6. Delete the iptable rule
1451 7. From cord-tester ping to 8.8.8.8
1452 8. Verifying the ping should success
1453 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001454 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001455 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001456 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001457 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001458 df = defer.Deferred()
1459 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001460 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001461 df.callback(0)
1462 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001463 host = '8.8.8.8'
1464 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1465 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001466 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001467 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1468 assert_equal(st, False)
1469 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1470 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1471 assert_equal(st, True)
1472 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1473 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1474 assert_equal(st, False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001475 except Exception as error:
1476 log.info('Got Unexpected error %s'%error)
1477 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1478 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001479 finally:
1480 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1481 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001482 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001483 df.callback(0)
1484 reactor.callLater(0, vcpe_firewall, df)
1485 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001486
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001487 @deferred(40)
1488 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 +00001489 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001490 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001491 1. Get vSG corresponding to vcpe
1492 2. Login to compute node
1493 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets
1494 4. From cord-tester ping to 8.8.8.8
1495 5. Verifying that ping should not be successful
1496 6. Delete the iptable rule
1497 7. From cord-tester ping to 8.8.8.8
1498 8. Verifying the ping should success
1499 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001500 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001501 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001502 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001503 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001504 df = defer.Deferred()
1505 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001506 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001507 df.callback(0)
1508 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001509 host = '8.8.8.8'
1510 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1511 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001512 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001513 st, _ = getstatusoutput('ping -c 1 {}'.format('8.8.8.8'))
1514 assert_equal(st, False)
1515 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1516 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1517 assert_equal(st, True)
1518 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1519 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1520 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001521 except Exception as error:
1522 log.info('Got Unexpected error %s'%error)
1523 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1524 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001525 finally:
1526 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1527 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001528 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001529 df.callback(0)
1530 reactor.callLater(0, vcpe_firewall, df)
1531 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001532
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001533 @deferred(40)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00001534 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 +00001535 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001536 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001537 1. Get vSG corresponding to vcpe
1538 2. Login to compute node
1539 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets
1540 4. From cord-tester ping to 8.8.8.8
1541 5. Verifying that ping should not be successful
1542 6. Insert another rule to accept the icmp-echo requests protocol packets
1543 7. From cord-tester ping to 8.8.8.8
1544 8. Verifying the ping should success
1545 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001546 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001547 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001548 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001549 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001550 df = defer.Deferred()
1551 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001552 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001553 df.callback(0)
1554 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001555 host = '8.8.8.8'
1556 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1557 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001558 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001559 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1560 assert_equal(st, False)
1561 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1562 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1563 assert_equal(st, True)
1564 st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name))
1565 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1566 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001567 except Exception as error:
1568 log.info('Got Unexpected error %s'%error)
1569 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001570 finally:
1571 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1572 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name))
1573 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001574 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001575 df.callback(0)
1576 reactor.callLater(0, vcpe_firewall, df)
1577 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001578
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001579 @deferred(40)
1580 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 +00001581 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001582 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001583 1. Get vSG corresponding to vcpe
1584 2. Login to compute node
1585 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets
1586 4. From cord-tester ping to 8.8.8.8
1587 5. Verifying the ping should not success
1588 6. Insert another rule to accept the icmp-echo requests protocol packets
1589 7. From cord-tester ping to 8.8.8.8
1590 8. Verifying the ping should success
1591 """
1592 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001593 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001594 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001595 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001596 df = defer.Deferred()
1597 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001598 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001599 df.callback(0)
1600 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001601 host = '8.8.8.8'
1602 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1603 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001604 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001605 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1606 assert_equal(st, False)
1607 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1608 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1609 assert_equal(st, True)
1610 st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name))
1611 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1612 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001613 except Exception as error:
1614 log.info('Got Unexpected error %s'%error)
1615 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001616 finally:
1617 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1618 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name))
1619 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001620 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001621 df.callback(0)
1622 reactor.callLater(0, vcpe_firewall, df)
1623 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001624
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001625 @deferred(40)
1626 def test_vsg_firewall_for_deny_icmp_protocol(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001627 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001628 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001629 1. Get vSG corresponding to vcpe
1630 2. Login to compute node
1631 3. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1632 4. From cord-tester ping to 8.8.8.8
1633 5. Verifying that ping should not be successful
1634 6. Delete the iptable rule
1635 7. From cord-tester ping to 8.8.8.8
1636 8. Verifying the ping should success
1637 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001638 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001639 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001640 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001641 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001642 df = defer.Deferred()
1643 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001644 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001645 df.callback(0)
1646 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001647 host = '8.8.8.8'
1648 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1649 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001650 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001651 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1652 assert_equal(st, False)
1653 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1654 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1655 assert_equal(st, True)
1656 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1657 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1658 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001659 except Exception as error:
1660 log.info('Got Unexpected error %s'%error)
1661 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1662 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001663 finally:
1664 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1665 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001666 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001667 df.callback(0)
1668 reactor.callLater(0, vcpe_firewall, df)
1669 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001670
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001671 @deferred(60)
1672 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 +00001673 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001674 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001675 1. Get vSG corresponding to vcpe
1676 2. Login to compute node
1677 3. Execute iptable command on vcpe from compute node to deny a destination IP
1678 4. From cord-tester ping to 8.8.8.8
1679 5. Verifying that ping should not be successful
1680 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1681 7. From cord-tester ping to 8.8.8.8
1682 8. Verifying the ping should success
1683 9. Delete the rule added in step 3
1684 10. From cord-tester ping to 8.8.8.8
1685 11. Verifying that ping should not be successful
1686 12. Delete the rule added in step 6
1687 13. From cord-tester ping to 8.8.8.8
1688 14. Verifying the ping should success
1689 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001690 if not vcpe_name:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001691 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001692 if not vcpe_intf:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001693 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001694 df = defer.Deferred()
1695 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001696 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001697 df.callback(0)
1698 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001699 host = '8.8.8.8'
1700 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1701 try:
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001702 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001703 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1704 assert_equal(st, False)
1705 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1706 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1707 assert_equal(st, True)
1708 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1709 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1710 assert_equal(st, True)
1711 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1712 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1713 assert_equal(st, True)
1714 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1715 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1716 assert_equal(st,False)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001717 except Exception as error:
1718 log.info('Got Unexpected error %s'%error)
1719 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1720 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1721 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001722 finally:
1723 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1724 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1725 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001726 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001727 df.callback(0)
1728 reactor.callLater(0, vcpe_firewall, df)
1729 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001730
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001731 @deferred(100)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001732 def test_vsg_firewall_flushing_all_configured_rules(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001733 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001734 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001735 1. Get vSG corresponding to vcpe
1736 2. Login to compute node
1737 3. Execute iptable command on vcpe from compute node to deny a destination IP
1738 4. From cord-tester ping to 8.8.8.8
1739 5. Verifying that ping should not be successful
1740 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1741 7. From cord-tester ping to 8.8.8.8
1742 8. Verifying the ping should success
1743 9. Flush all the iptable rules configuraed in vcpe
1744 10. Delete the rule added in step 6
1745 11. From cord-tester ping to 8.8.8.8
1746 12. Verifying the ping should success
1747 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001748 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001749 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001750 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001751 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001752 df = defer.Deferred()
1753 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001754 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001755 df.callback(0)
1756 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001757 host = '8.8.8.8'
1758 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1759 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001760 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001761 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1762 assert_equal(st, False)
1763 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1764 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1765 assert_equal(st, True)
1766 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1767 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1768 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001769 st, _ = vsg.run_cmd('sudo docker exec {} iptables -F FORWARD'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001770 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001771 assert_equal(st, True)
1772 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1773 status = False
1774 clock = 0
1775 while(clock <= 30):
1776 time.sleep(5)
1777 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1778 if st == False:
1779 status = True
1780 break
1781 clock += 5
1782 assert_equal(status, True)
1783 except Exception as error:
1784 log.info('Got Unexpected error %s'%error)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001785 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001786 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1787 raise
1788 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001789 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001790 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001791 df.callback(0)
1792 reactor.callLater(0, vcpe_firewall, df)
1793 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001794
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001795 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001796 def test_vsg_firewall_deny_all_ipv4_traffic(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001797 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001798 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001799 1. Get vSG corresponding to vcpe
1800 2. Login to compute node
1801 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic
1802 4. From cord-tester ping to 8.8.8.8
1803 5. Verifying that ping should not be successful
1804 6. Delete the iptable rule added
1805 7. From cord-tester ping to 8.8.8.8
1806 8. Verifying the ping should success
1807 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001808 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001809 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001810 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001811 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001812 df = defer.Deferred()
1813 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001814 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001815 df.callback(0)
1816 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001817 host = '8.8.8.8'
1818 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1819 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001820 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001821 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1822 assert_equal(st, False)
1823 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
1824 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1825 assert_equal(st, True)
1826 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1827 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1828 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001829 except Exception as error:
1830 log.info('Got Unexpected error %s'%error)
1831 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1832 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001833 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001834 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001835 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001836 df.callback(0)
1837 reactor.callLater(0, vcpe_firewall, df)
1838 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001839
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001840 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001841 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 +00001842 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001843 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001844 1. Get vSG corresponding to vcpe
1845 2. Login to compute node
1846 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic
1847 4. From cord-tester ping to 8.8.8.8
1848 5. Verifying that ping should not be successful
1849 6. Replace the deny rule added in step 3 with accept rule
1850 7. From cord-tester ping to 8.8.8.8
1851 8. Verifying the ping should success
1852 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001853 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001854 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001855 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001856 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001857 df = defer.Deferred()
1858 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001859 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001860 df.callback(0)
1861 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001862 host = '8.8.8.8'
1863 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1864 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001865 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001866 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1867 assert_equal(st, False)
1868 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
1869 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1870 assert_equal(st, True)
1871 st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -4 -j ACCEPT'.format(vcpe_name))
1872 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1873 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001874 except Exception as error:
1875 log.info('Got Unexpected error %s'%error)
1876 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001877 finally:
1878 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1879 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001880 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001881 df.callback(0)
1882 reactor.callLater(0, vcpe_firewall, df)
1883 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001884
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001885 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001886 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 +00001887 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001888 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001889 1. Get vSG corresponding to vcpe
1890 2. Login to compute node
1891 3. Execute iptable command on vcpe from compute node to deny all the traffic coming on lan interface inside vcpe container
1892 4. From cord-tester ping to 8.8.8.8
1893 5. Verifying the ping should not success
1894 6. Delete the iptable rule added
1895 7. From cord-tester ping to 8.8.8.8
1896 8. Verifying the ping should success
1897 """
1898 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001899 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001900 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001901 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001902 df = defer.Deferred()
1903 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001904 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001905 df.callback(0)
1906 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001907 host = '8.8.8.8'
1908 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1909 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001910 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001911 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1912 assert_equal(st, False)
1913 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -j DROP'.format(vcpe_name))
1914 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1915 assert_equal(st, True)
1916 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name))
1917 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1918 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001919 except Exception as error:
1920 log.info('Got Unexpected error %s'%error)
1921 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name))
1922 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001923 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001924 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001925 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001926 df.callback(0)
1927 reactor.callLater(0, vcpe_firewall, df)
1928 return df
1929
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001930 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001931 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 +00001932 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001933 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001934 1. Get vSG corresponding to vcpe
1935 2. Login to compute node
1936 3. Execute iptable command on vcpe from compute node to deny all the traffic going out of wan interface inside vcpe container
1937 4. From cord-tester ping to 8.8.8.8
1938 5. Verifying the ping should not success
1939 6. Delete the iptable rule added
1940 7. From cord-tester ping to 8.8.8.8
1941 8. Verifying the ping should success
1942 """
1943 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001944 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001945 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001946 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001947 df = defer.Deferred()
1948 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001949 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001950 df.callback(0)
1951 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001952 host = '8.8.8.8'
1953 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1954 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001955 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001956 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1957 assert_equal(st, False)
1958 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -o eth0 -j DROP'.format(vcpe_name))
1959 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1960 assert_equal(st, True)
1961 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name))
1962 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1963 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001964 except Exception as error:
1965 log.info('Got Unexpected error %s'%error)
1966 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name))
1967 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001968 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001969 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001970 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001971 df.callback(0)
1972 reactor.callLater(0, vcpe_firewall, df)
1973 return df
1974
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001975 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00001976 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 +00001977 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00001978 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001979 1. Get vSG corresponding to vcpe
1980 2. Login to compute node
1981 3. Execute iptable command on vcpe from compute node to deny all the traffic from lan to wan interface in vcpe
1982 4. From cord-tester ping to 8.8.8.8
1983 5. Verifying that ping should not be successful
1984 6. Delete the iptable rule added
1985 7. From cord-tester ping to 8.8.8.8
1986 8. Verifying the ping should success
1987 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001988 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001989 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001990 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00001991 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001992 df = defer.Deferred()
1993 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07001994 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07001995 df.callback(0)
1996 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001997 host = '8.8.8.8'
1998 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1999 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002000 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002001 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2002 assert_equal(st, False)
2003 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
2004 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2005 assert_equal(st, True)
2006 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
2007 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2008 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002009 except Exception as error:
2010 log.info('Got Unexpected error %s'%error)
2011 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
2012 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002013 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002014 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002015 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002016 df.callback(0)
2017 reactor.callLater(0, vcpe_firewall, df)
2018 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00002019
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002020 @deferred(60)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002021 def test_vsg_firewall_deny_all_dns_traffic(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002022 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002023 Test Method:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002024 1. Get vSG corresponding to vcpe
2025 2. Login to compute node
2026 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2027 4. From cord-tester ping to www.google.com
2028 5. Verifying the ping should not success
2029 6. Delete the iptable rule added
2030 7. From cord-tester ping to www.google.com
2031 8. Verifying the ping should success
2032 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002033 mgmt = 'eth0'
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002034 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002035 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002036 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002037 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002038 df = defer.Deferred()
2039 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07002040 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07002041 df.callback(0)
2042 return
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002043 host = 'google-public-dns-a.google.com'
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002044 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2045 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002046 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
2047 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe_intf, mgmt = mgmt)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002048 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002049 assert_not_equal(st, False)
2050 VSGAccess.restore_interface_config(mgmt, vcpe=vcpe_intf)
2051 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
2052 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe_intf, mgmt = mgmt)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002053 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2054 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002055 VSGAccess.restore_interface_config(mgmt, vcpe=vcpe_intf)
2056 except Exception as error:
2057 log.info('Got Unexpected error %s'%error)
2058 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
2059 VSGAccess.restore_interface_config(mgmt,vcpe=vcpe_intf)
2060 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002061 df.callback(0)
2062 reactor.callLater(0, vcpe_firewall, df)
2063 return df
2064
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002065 @deferred(60)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002066 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 +00002067 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002068 Test Method:
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00002069 1. Get vSG corresponding to vcpe
2070 2. Login to compute node
2071 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2072 4. From cord-tester ping to www.google.com
2073 5. Verifying that ping should not be successful
2074 6. Delete the iptable rule added
2075 7. From cord-tester ping to www.google.com
2076 8. Verifying the ping should success
2077 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002078 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002079 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002080 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002081 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002082 df = defer.Deferred()
2083 def vcpe_firewall(df):
A R Karthick19771192017-04-25 14:57:05 -07002084 if self.on_pod is False:
A R Karthick93ba8d02017-04-13 11:59:58 -07002085 df.callback(0)
2086 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002087 host = '8.8.8.8'
2088 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2089 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002090 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002091 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2092 assert_equal(st, False)
2093 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
2094 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2095 assert_equal(st, True)
2096 st,output = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002097 clock = 0
2098 status = False
2099 while(clock <= 20 ):
2100 time.sleep(5)
2101 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2102 if st == False:
2103 status = True
2104 break
2105 clock += 5
2106 assert_equal(status, True)
2107 except Exception as error:
2108 log.info('Got Unexpected error %s'%error)
2109 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
2110 raise
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002111 finally:
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002112 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002113 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00002114 df.callback(0)
2115 reactor.callLater(0, vcpe_firewall, df)
2116 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00002117
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002118 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002119 def test_vsg_nat_dnat_modifying_destination_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002120 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002121 Test Method:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002122 1. Get vSG corresponding to vcpe
2123 2. Login to compute node
2124 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2125 4. From cord-tester ping to www.google.com
2126 5. Verifying the ping should not success
2127 6. Delete the iptable rule added
2128 7. From cord-tester ping to www.google.com
2129 8. Verifying the ping should success
2130 """
2131 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002132 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002133 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002134 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002135 df = defer.Deferred()
2136 def vcpe_firewall(df):
2137 host = '8.8.8.8'
2138 dst_ip = '123.123.123.123'
2139 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2140 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002141 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002142 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2143 assert_equal(st, False)
2144 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))
2145 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2146 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002147 except Exception as error:
2148 log.info('Got Unexpected error %s'%error)
2149 raise
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002150 finally:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002151
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002152 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))
2153 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002154 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002155 df.callback(0)
2156 reactor.callLater(0,vcpe_firewall,df)
2157 return df
2158
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002159 @deferred(40)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002160 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 +00002161 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002162 Test Method:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002163 1. Get vSG corresponding to vcpe
2164 2. Login to compute node
2165 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2166 4. From cord-tester ping to www.google.com
2167 5. Verifying the ping should not success
2168 6. Delete the iptable rule added
2169 7. From cord-tester ping to www.google.com
2170 8. Verifying the ping should success
2171 """
2172 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002173 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002174 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002175 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002176 df = defer.Deferred()
2177 def vcpe_firewall(df):
2178 host = '8.8.8.8'
2179 dst_ip = '123.123.123.123'
2180 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2181 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002182 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002183 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2184 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002185 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 +00002186 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2187 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002188 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 +00002189 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2190 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002191 except Exception as error:
2192 log.info('Got Unexpected error %s'%error)
2193 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))
2194 raise
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002195 finally:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002196 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002197 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002198 df.callback(0)
2199 reactor.callLater(0,vcpe_firewall,df)
2200 return df
2201
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002202 @deferred(50)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002203 def test_vsg_dnat_change_modifying_destination_ip_address(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002204 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002205 Test Method:
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002206 1. Get vSG corresponding to vcpe
2207 2. Login to compute node
2208 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
2209 4. From cord-tester ping to www.google.com
2210 5. Verifying the ping should not success
2211 6. Delete the iptable rule added
2212 7. From cord-tester ping to www.google.com
2213 8. Verifying the ping should success
2214 """
2215 if not vcpe_name:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002216 vcpe_name = self.container_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002217 if not vcpe_intf:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002218 vcpe_intf = self.dhcp_vcpes_reserved[0]
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002219 df = defer.Deferred()
2220 def vcpe_firewall(df):
2221 host = '8.8.8.8'
2222 dst_ip = '123.123.123.123'
2223 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2224 try:
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002225 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002226 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2227 assert_equal(st, False)
2228 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))
2229 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2230 assert_equal(st, True)
2231 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))
2232 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2233 assert_equal(st, False)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002234 except Exception as error:
2235 log.info('Got Unexpected error %s'%error)
2236 raise
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002237 finally:
2238 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))
2239 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))
2240 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002241 #vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
Anil Kumar Sanka5fa8d8b2017-04-18 22:01:48 +00002242 df.callback(0)
2243 reactor.callLater(0,vcpe_firewall,df)
2244 return df
2245
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002246 def vsg_xos_subscriber_create(self, index, subscriber_info = None, volt_subscriber_info = None):
A R Karthick19771192017-04-25 14:57:05 -07002247 if self.on_pod is False:
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002248 return ''
2249 if subscriber_info is None:
A R Karthicked3a2ca2017-07-06 15:50:03 -07002250 subscriber_info = self.cord_subscriber.subscriber_info[index]
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002251 if volt_subscriber_info is None:
A R Karthicked3a2ca2017-07-06 15:50:03 -07002252 volt_subscriber_info = self.cord_subscriber.volt_subscriber_info[index]
A R Karthickd0b06792017-04-25 15:11:23 -07002253 s_tag = int(volt_subscriber_info['voltTenant']['s_tag'])
2254 c_tag = int(volt_subscriber_info['voltTenant']['c_tag'])
2255 vcpe = 'vcpe-{}-{}'.format(s_tag, c_tag)
A R Karthicked3a2ca2017-07-06 15:50:03 -07002256 subId = self.cord_subscriber.subscriberCreate(index, subscriber_info, volt_subscriber_info)
2257 if subId:
A R Karthick97e08852017-04-26 10:06:38 -07002258 #if the vsg instance was already instantiated, then reduce delay
A R Karthicked3a2ca2017-07-06 15:50:03 -07002259 if c_tag % self.SUBSCRIBERS_PER_S_TAG == 0:
A R Karthick97e08852017-04-26 10:06:38 -07002260 delay = 350
2261 else:
2262 delay = 90
2263 log.info('Delaying %d seconds for the VCPE to be provisioned' %(delay))
2264 time.sleep(delay)
2265 log.info('Testing for external connectivity to VCPE %s' %(vcpe))
2266 self.vsg_for_external_connectivity(index)
A R Karthicked3a2ca2017-07-06 15:50:03 -07002267
2268 return subId
A R Karthick97e08852017-04-26 10:06:38 -07002269
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002270 def vsg_xos_subscriber_delete(self, index, subId = '', voltId = '', subscriber_info = None, volt_subscriber_info = None):
A R Karthick97e08852017-04-26 10:06:38 -07002271 if self.on_pod is False:
2272 return
A R Karthicked3a2ca2017-07-06 15:50:03 -07002273 self.cord_subscriber.subscriberDelete(index, subId = subId, voltId = voltId,
2274 subscriber_info = subscriber_info,
2275 volt_subscriber_info = volt_subscriber_info)
A R Karthick035d2e22017-04-25 13:53:00 -07002276
A R Karthicke29c8d42017-04-27 11:38:52 -07002277 def vsg_xos_subscriber_id(self, index):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002278 if self.on_pod is False:
2279 return ''
2280 return self.cord_subscriber.subscriberId(index)
A R Karthicke29c8d42017-04-27 11:38:52 -07002281
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002282 def test_vsg_xos_subscriber_create_reserved(self):
A.R Karthicka2960912017-05-18 18:52:55 -07002283 if self.on_pod is False:
2284 return
A.R Karthicka3fa2f92017-05-18 18:51:36 -07002285 tags_reserved = [ (int(vcpe['s_tag']), int(vcpe['c_tag'])) for vcpe in self.vcpes_reserved ]
2286 volt_tenants = self.restApiXos.ApiGet('TENANT_VOLT')
2287 subscribers = self.restApiXos.ApiGet('TENANT_SUBSCRIBER')
2288 reserved_tenants = filter(lambda tenant: (int(tenant['s_tag']), int(tenant['c_tag'])) in tags_reserved, volt_tenants)
2289 reserved_config = []
2290 for tenant in reserved_tenants:
2291 for subscriber in subscribers:
2292 if int(subscriber['id']) == int(tenant['subscriber']):
2293 volt_subscriber_info = {}
2294 volt_subscriber_info['voltTenant'] = dict(s_tag = tenant['s_tag'],
2295 c_tag = tenant['c_tag'],
2296 subscriber = tenant['subscriber'])
2297 volt_subscriber_info['volt_id'] = tenant['id']
2298 volt_subscriber_info['account_num'] = subscriber['identity']['account_num']
2299 reserved_config.append( (subscriber, volt_subscriber_info) )
2300 break
2301 else:
2302 log.info('Subscriber not found for tenant %s, s_tag: %s, c_tag: %s' %(str(tenant['subscriber']),
2303 str(tenant['s_tag']),
2304 str(tenant['c_tag'])))
2305
2306 for subscriber_info, volt_subscriber_info in reserved_config:
2307 self.vsg_xos_subscriber_delete(0,
2308 subId = str(subscriber_info['id']),
2309 voltId = str(volt_subscriber_info['volt_id']),
2310 subscriber_info = subscriber_info,
2311 volt_subscriber_info = volt_subscriber_info)
2312 subId = self.vsg_xos_subscriber_create(0,
2313 subscriber_info = subscriber_info,
2314 volt_subscriber_info = volt_subscriber_info)
2315 log.info('Created reserved subscriber %s' %(subId))
2316
A R Karthicke29c8d42017-04-27 11:38:52 -07002317 def test_vsg_xos_subscriber_create_all(self):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002318 if self.on_pod is False:
2319 return
2320 for index in xrange(len(self.cord_subscriber.subscriber_info)):
A R Karthicke29c8d42017-04-27 11:38:52 -07002321 #check if the index exists
2322 subId = self.vsg_xos_subscriber_id(index)
2323 if subId and subId != '0':
2324 self.vsg_xos_subscriber_delete(index, subId = subId)
2325 subId = self.vsg_xos_subscriber_create(index)
2326 log.info('Created Subscriber %s' %(subId))
2327
2328 def test_vsg_xos_subscriber_delete_all(self):
A R Karthicked3a2ca2017-07-06 15:50:03 -07002329 if self.on_pod is False:
2330 return
2331 for index in xrange(len(self.cord_subscriber.subscriber_info)):
A R Karthicke29c8d42017-04-27 11:38:52 -07002332 subId = self.vsg_xos_subscriber_id(index)
2333 if subId and subId != '0':
2334 self.vsg_xos_subscriber_delete(index, subId = subId)
2335
2336 def test_vsg_xos_subscriber_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002337 subId = self.vsg_xos_subscriber_create(0)
2338 if subId and subId != '0':
2339 self.vsg_xos_subscriber_delete(0, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002340
A R Karthicke29c8d42017-04-27 11:38:52 -07002341 def test_vsg_xos_subscriber_2_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002342 subId = self.vsg_xos_subscriber_create(1)
2343 if subId and subId != '0':
2344 self.vsg_xos_subscriber_delete(1, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002345
A R Karthicke29c8d42017-04-27 11:38:52 -07002346 def test_vsg_xos_subscriber_3_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002347 subId = self.vsg_xos_subscriber_create(2)
2348 if subId and subId != '0':
2349 self.vsg_xos_subscriber_delete(2, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002350
A R Karthicke29c8d42017-04-27 11:38:52 -07002351 def test_vsg_xos_subscriber_4_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002352 subId = self.vsg_xos_subscriber_create(3)
2353 if subId and subId != '0':
2354 self.vsg_xos_subscriber_delete(3, subId)
A R Karthick035d2e22017-04-25 13:53:00 -07002355
A R Karthicke29c8d42017-04-27 11:38:52 -07002356 def test_vsg_xos_subscriber_5_create_and_delete(self):
A R Karthick5d30b3c2017-04-27 10:25:40 -07002357 subId = self.vsg_xos_subscriber_create(4)
2358 if subId and subId != '0':
2359 self.vsg_xos_subscriber_delete(4, subId)
A.R Karthick282f0d32017-03-28 16:43:59 -07002360
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002361 @deferred(400)
2362 def test_vsg_xos_subscriber_external_connectivity_through_vcpe_instance(self, index=0):
2363 df = defer.Deferred()
2364 status = False
2365 def test_xos_subscriber(df):
2366 subId = self.vsg_xos_subscriber_id(index)
2367 if subId == '0':
2368 log.info('Creating vcpe instance ')
2369 subId = self.vsg_xos_subscriber_create(index)
2370 assert_not_equal(subId,'0')
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002371 vcpe = self.dhcp_vcpes[index]
2372 host = '8.8.8.8'
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002373 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2374 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2375 assert_equal(st, False)
2376 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2377 df.callback(0)
2378 reactor.callLater(0,test_xos_subscriber,df)
2379 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002380
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002381 #pass
2382 @deferred(50)
2383 def test_vsg_xos_subscriber_external_connectivity_without_creating_vcpe_instance(self, index=0):
2384 df = defer.Deferred()
2385 def test_xos_subscriber(df):
2386 subId = self.vsg_xos_subscriber_id(index)
2387 if subId != '0':
2388 log.info('deleting already existing vcpe instance ')
2389 self.vsg_xos_subscriber_delete(index, subId)
2390 vcpe = self.dhcp_vcpes[index]
2391 host = '8.8.8.8'
2392 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2393 st, out = getstatusoutput('route -n')
2394 log.info('route -n outpu-1-1-1--1-1-1-1-1-1-1 is %s'%out)
2395 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2396 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2397 assert_equal(st, True)
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 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002403 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 +00002404 df = defer.Deferred()
2405 def test_xos_subscriber(df):
2406 subId = self.vsg_xos_subscriber_id(index)
2407 if subId == '0':
2408 subId = self.vsg_xos_subscriber_create(index)
2409 assert_not_equal(subId,'0')
2410 vcpe = self.dhcp_vcpes[index]
2411 if subId and subId != '0':
2412 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe)
2413 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2414 assert_equal(st, False)
2415 self.vsg_xos_subscriber_delete(index, subId)
2416 time.sleep(2)
2417 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2418 assert_equal(st, True)
2419 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe)
2420 df.callback(0)
2421 reactor.callLater(0,test_xos_subscriber,df)
2422 return df
2423
2424 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002425 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 +00002426 df = defer.Deferred()
2427 def test_xos_subscriber(df):
2428 subId = self.vsg_xos_subscriber_id(index)
2429 if subId == '0':
2430 subId = self.vsg_xos_subscriber_create(index)
2431 assert_not_equal(subId,'0')
2432 vcpe_intf = self.dhcp_vcpes[index]
2433 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2434 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2435 assert_equal(st, False)
2436 vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
2437 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2438 st, _ = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
2439 assert_equal(st, True)
2440 time.sleep(5)
2441 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2442 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2443 assert_equal(st, False)
2444 df.callback(0)
2445 reactor.callLater(0,test_xos_subscriber,df)
2446 return df
2447
2448 @deferred(400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002449 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 +00002450 df = defer.Deferred()
2451 def test_xos_subscriber(df):
2452 subId = self.vsg_xos_subscriber_id(index)
2453 if subId == '0':
2454 subId = self.vsg_xos_subscriber_create(index)
2455 assert_not_equal(subId,'0')
2456 vcpe_intf = self.dhcp_vcpes[index]
2457 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2458 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2459 assert_equal(st, False)
2460 vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
2461 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2462 st, _ = vsg.run_cmd('sudo docker stop {}'.format(vcpe_name))
2463 assert_equal(st, True)
2464 time.sleep(3)
2465 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2466 assert_equal(st, True)
2467 st, _ = vsg.run_cmd('sudo docker start {}'.format(vcpe_name))
2468 assert_equal(st, True)
2469 time.sleep(5)
2470 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2471 assert_equal(st, False)
2472 df.callback(0)
2473 reactor.callLater(0,test_xos_subscriber,df)
2474 return df
2475
2476 #getting list out of range error while creating vcpe of index 6
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002477 def test_vsg_create_xos_subscribers_in_different_vsg_vm(self, index1=4, index2=6):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002478 indexes = list(index1,index2)
2479 subids = []
2480 for index in indexes:
2481 subId = self.vsg_xos_subscriber_id(index)
2482 if not subId:
2483 subId = self.vsg_xos_subscriber_create(index)
2484 assert_not_equal(subId,'0')
2485 subids.append(subId)
2486 log.info('succesfully created two vcpe instances in two different vSG VMs')
2487 self.vsg_xos_subscriber_delete(index1, subid[0])
2488 self.vsg_xos_subscriber_delete(index2, subid[1])
2489
2490 #Unable to reach external network via vcpes created by XOS
2491 @deferred(TIMEOUT+400)
2492 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_goes_down(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002493 """
2494 Test Method:
2495 1.Create two vcpe instances in two different vsg vms using XOS
2496 2.Verify external connectivity through vcpe instances from cord-tester
2497 3.Kill first vcpe instance
2498 4.Verify external network cant be reachable form first vcpe interface
2499 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002500 df = defer.Deferred()
2501 def test_xos_subscriber(df):
2502 host1 = '8.8.8.8'
2503 host2 = '4.2.2.2'
2504 vcpe_intf1 = self.dhcp_vcpes[0]
2505 vcpe_intf2 = self.dhcp_vcpes[1]
2506 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2507 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2508 subId1 = self.vsg_xos_subscriber_id(0)
2509 log.info('already existing subid of index 0 is %s'%subId1)
2510 if subId1 == '0':
2511 log.info('creating vcpe instance of index 0')
2512 subId1 = self.vsg_xos_subscriber_create(0)
2513 assert_not_equal(subId1,'0')
2514 subId2 = self.vsg_xos_subscriber_id(1)
2515 log.info('already existing subid of index 1 is %s'%subId2)
2516 if subId2 == '0':
2517 log.info('creating vcpe instance of index 1')
2518 subId2 = self.vsg_xos_subscriber_create(1)
2519 assert_not_equal(subId2,'0')
2520 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2521 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2522 try:
2523 for intf in [vcpe_intf1,vcpe_intf2]:
2524 host = host1 if intf is vcpe_intf1 else host2
2525 self.add_static_route_via_vcpe_interface([host],vcpe=intf)
2526 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2527 assert_equal(st, False)
2528 if intf is vcpe_intf2:
2529 self.vsg_xos_subscriber_delete(1, subId2)
2530 st, _ = vsg2.run_cmd('sudo docker kill {}'.format(vcpe_name2))
2531 time.sleep(2)
2532 self.add_static_route_via_vcpe_interface([host],vcpe=intf)
2533 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2534 assert_equal(st, False)
2535 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2536 assert_equal(st, True)
2537 except Exception as error:
2538 log.info('Got Unexpected error %s'%error)
2539 raise
2540 finally:
2541 self.vsg_xos_subscriber_delete(0, subId1)
2542 self.vsg_xos_subscriber_delete(1, subId2)
2543 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2544 self.del_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2545 df.callback(0)
2546 reactor.callLater(0,test_xos_subscriber,df)
2547 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002548
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002549 @deferred(TIMEOUT+400)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002550 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 +00002551 """
2552 Test Method:
2553 1.Create two vcpe instances in two different vsg vms using XOS
2554 2.Verify external connectivity through vcpe instances from cord-tester
2555 3.Remove first vcpe instance
2556 4.Verify external network cant be reachable form first vcpe interface
2557 5.Add back the removed vcpe instance
2558 6.Verify external connectivity through vcpe instances from cord-tester
2559 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002560 df = defer.Deferred()
2561 def test_xos_subscriber(df,index=index):
2562 host = '8.8.8.8'
2563 subId = self.vsg_xos_subscriber_id(index)
2564 log.info('already existing subid of index 0 is %s'%subId)
2565 if subId == '0':
2566 log.info('creating vcpe instance of index %s'%index)
2567 subId = self.vsg_xos_subscriber_create(index)
2568 assert_not_equal(subId,'0')
2569 vcpe_intf = self.dhcp_vcpes[0]
2570 vcpe_name = 'vcpe-{}-{}'.format(vcpe_intf.split('.')[1],vcpe_intf.split('.')[2])
2571 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2572 try:
2573 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2574 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2575 assert_equal(st, False)
2576 log.info('Deleting vcpe Instance of index %s'%index)
2577 self.vsg_xos_subscriber_delete(0, subId)
2578 st, _ = vsg.run_cmd('sudo docker kill {}'.format(vcpe_name))
2579 time.sleep(1)
2580 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2581 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2582 assert_equal(st, True)
2583 subId = self.vsg_xos_subscriber_create(index)
2584 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2585 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
2586 assert_equal(st, False)
2587 except Exception as error:
2588 log.info('Got Unexpected error %s'%error)
2589 raise
2590 finally:
2591 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2592 self.vsg_xos_subscriber_delete(0, subId)
2593 df.callback(0)
2594 reactor.callLater(0,test_xos_subscriber,df)
2595 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002596
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002597 @deferred(TIMEOUT+400)
2598 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_restarts(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002599 """
2600 Test Method:
2601 1.Create two vcpe instances in two different vsg vms using XOS
2602 2.Verify external connectivity through vcpe instances from cord-tester
2603 3.Restart first vcpe instance
2604 4.Verify external network cant be reachable form first vcpe interface
2605 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002606 df = defer.Deferred()
2607 def test_xos_subscriber(df):
2608 host1 = '8.8.8.8'
2609 host2 = '4.2.2.2'
2610 subId1 = self.vsg_xos_subscriber_id(0)
2611 log.info('already existing subid of index 0 is %s'%subId1)
2612 if subId1 == '0':
2613 log.info('creating vcpe instance of index 0')
2614 subId1 = self.vsg_xos_subscriber_create(0)
2615 assert_not_equal(subId1,'0')
2616 subId2 = self.vsg_xos_subscriber_id(1)
2617 log.info('already existing subid of index 1 is %s'%subId2)
2618 if subId2 == '0':
2619 log.info('creating vcpe instance of index 1')
2620 subId2 = self.vsg_xos_subscriber_create(1)
2621 vcpe_intf1 = self.dhcp_vcpes[0]
2622 vcpe_intf2 = self.dhcp_vcpes[1]
2623 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2624 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2625 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2626 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2627 try:
2628 #checking external connectivity from vcpe interface 1 before vcpe 2 restart
2629 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2630 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2631 assert_equal(st, False)
2632 #checking external connectivity from vcpe interface 2 before vcpe 2 restart
2633 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2634 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2635 assert_equal(st, False)
2636 st, _ = vsg2.run_cmd('sudo docker restart {}'.format(vcpe_name2))
2637 time.sleep(10)
2638 #checking external connectivity from vcpe interface 1 after vcpe 2 restart
2639 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2640 assert_equal(st, False)
2641 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2642 time = 0
2643 status = False
2644 while(time <= 100):
2645 time.sleep(10)
2646 st,_ = getstatusoutput('ping -c 1 {}'.format(hos2))
2647 if st is False:
2648 status = True
2649 break
2650 time += 10
2651 assert_equal(status, True)
2652 except Exception as error:
2653 log.info('Got Unexpected error %s'%error)
2654 raise
2655 finally:
2656 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2657 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2658 self.vsg_xos_subscriber_delete(0, subId1)
2659 self.vsg_xos_subscriber_delete(1, subId2)
2660 df.callback(0)
2661 reactor.callLater(0,test_xos_subscriber,df)
2662 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002663
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002664 @deferred(500)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002665 def test_vsg_xos_multiple_subscribers_external_connectivity_if_one_vcpe_is_paused(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002666 """
2667 Test Method:
2668 1.Create two vcpe instances in two different vsg vms using XOS
2669 2.Verify external connectivity through vcpe instances from cord-tester
2670 3.Pause running first vcpe instance
2671 4.Verify external network cant be reachable form first vcpe interface
2672 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002673 df = defer.Deferred()
2674 def test_xos_subscriber(df):
2675 host1 = '8.8.8.8'
2676 host2 = '4.2.2.2'
2677 subId1 = self.vsg_xos_subscriber_id(0)
2678 log.info('already existing subid of index 0 is %s'%subId1)
2679 if subId1 == '0':
2680 log.info('creating vcpe instance of index 0')
2681 subId1 = self.vsg_xos_subscriber_create(0)
2682 assert_not_equal(subId1,'0')
2683 subId2 = self.vsg_xos_subscriber_id(1)
2684 log.info('already existing subid of index 1 is %s'%subId2)
2685 if subId2 == '0':
2686 log.info('creating vcpe instance of index 1')
2687 subId2 = self.vsg_xos_subscriber_create(1)
2688 vcpe_intf1 = self.dhcp_vcpes[0]
2689 vcpe_intf2 = self.dhcp_vcpes[1]
2690 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2691 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2692 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2693 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2694 try:
2695 #checking external connectivity from vcpe interface 1 before vcpe 2 pause
2696 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2697 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2698 assert_equal(st, False)
2699 #checking external connectivity from vcpe interface 2 before vcpe 2 pause
2700 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2701 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2702 assert_equal(st, False)
2703 st, _ = vsg2.run_cmd('sudo docker pause {}'.format(vcpe_name2))
2704 time.sleep(1)
2705 #checking external connectivity from vcpe interface 1 after vcpe 2 pause
2706 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2707 assert_equal(st, False)
2708 #checking external connectivity from vcpe interface 2 after vcpe 2 pause
2709 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2710 assert_equal(st, True)
2711 except Exception as error:
2712 log.info('Got Unexpected error %s'%error)
2713 raise
2714 finally:
2715 log.info('In Finally block 3333333333333333')
2716 st, _ = vsg2.run_cmd('sudo docker unpause {}'.format(vcpe_name2))
2717 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2718 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2719 self.vsg_xos_subscriber_delete(0, subId1)
2720 self.vsg_xos_subscriber_delete(1, subId2)
2721 df.callback(0)
2722 reactor.callLater(0,test_xos_subscriber,df)
2723 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002724
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002725 @deferred(500)
2726 def test_vsg_xos_subscriber_external_connectivity_if_one_vcpe_stops(self):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002727 """
2728 Test Method:
2729 1.Create two vcpe instances in two different vsg vms using XOS
2730 2.Verify external connectivity through vcpe instances from cord-tester
2731 3.Stop running first vcpe instance
2732 4.Verify external network cant be reachable form first vcpe interface
2733 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002734 df = defer.Deferred()
2735 def test_xos_subscriber(df):
2736 host1 = '8.8.8.8'
2737 host2 = '4.2.2.2'
2738 subId1 = self.vsg_xos_subscriber_id(0)
2739 log.info('already existing subid of index 0 is %s'%subId1)
2740 if subId1 == '0':
2741 log.info('creating vcpe instance of index 0')
2742 subId1 = self.vsg_xos_subscriber_create(0)
2743 assert_not_equal(subId1,'0')
2744 subId2 = self.vsg_xos_subscriber_id(1)
2745 log.info('already existing subid of index 1 is %s'%subId2)
2746 if subId2 == '0':
2747 log.info('creating vcpe instance of index 1')
2748 subId2 = self.vsg_xos_subscriber_create(1)
2749 vcpe_intf1 = self.dhcp_vcpes[0]
2750 vcpe_intf2 = self.dhcp_vcpes[1]
2751 vcpe_name1 = 'vcpe-{}-{}'.format(vcpe_intf1.split('.')[1],vcpe_intf1.split('.')[2])
2752 vcpe_name2 = 'vcpe-{}-{}'.format(vcpe_intf2.split('.')[1],vcpe_intf2.split('.')[2])
2753 vsg1 = VSGAccess.get_vcpe_vsg(vcpe_name1)
2754 vsg2 = VSGAccess.get_vcpe_vsg(vcpe_name2)
2755 try:
2756 #checking external connectivity from vcpe interface 1 before vcpe 2 stop
2757 self.add_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2758 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2759 assert_equal(st, False)
2760 #checking external connectivity from vcpe interface 2 before vcpe 2 stop
2761 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2762 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2763 assert_equal(st, False)
2764 st, _ = vsg2.run_cmd('sudo docker stop {}'.format(vcpe_name2))
2765 time.sleep(5)
2766 #checking external connectivity from vcpe interface 1 after vcpe 2 stop
2767 st,_ = getstatusoutput('ping -c 1 {}'.format(host1))
2768 assert_equal(st, False)
2769 #checking external connectivity from vcpe interface 1 after vcpe 2 stop
2770 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2771 st,_ = getstatusoutput('ping -c 1 {}'.format(host2))
2772 assert_equal(st, True)
2773 except Exception as error:
2774 log.info('Got Unexpected error %s'%error)
2775 raise
2776 finally:
2777 st, _ = vsg2.run_cmd('sudo docker start {}'.format(vcpe_name2))
2778 time.sleep(10)
2779 self.del_static_route_via_vcpe_interface([host1],vcpe=vcpe_intf1)
2780 self.add_static_route_via_vcpe_interface([host2],vcpe=vcpe_intf2)
2781 self.vsg_xos_subscriber_delete(0, subId1)
2782 self.vsg_xos_subscriber_delete(1, subId2)
2783 df.callback(0)
2784 reactor.callLater(0,test_xos_subscriber,df)
2785 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002786
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002787 @deferred(420)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002788 def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_stopped(self, index=0):
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002789 """
2790 Test Method:
2791 1.Create two vcpe instances in two different vsg vms using XOS
2792 2.Verify external connectivity through vcpe instances from cord-tester
2793 3.Bring down first vSG vm
2794 4.Verify external network cant be reachable form first vcpe interface
2795 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002796 df = defer.Deferred()
2797 def test_xos_subscriber(df,index=index):
2798 host = '8.8.8.8'
2799 subId = self.vsg_xos_subscriber_id(index)
2800 if subId == '0':
2801 log.info('creating vcpe instance of index 0')
2802 subId = self.vsg_xos_subscriber_create(index)
2803 assert_not_equal(subId,'0')
2804 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2805 vcpe_name = self.container_vcpes[index]
2806 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2807 try:
2808 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2809 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2810 assert_equal(st, False)
2811 log.info('Stopping vsg instance')
2812 vsg.stop()
2813 time.sleep(5)
2814 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2815 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2816 assert_equal(st, True)
2817 except Exception as error:
2818 log.info('Got Unexpected error %s'%error)
2819 raise
2820 finally:
2821 vsg.start()
2822 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2823 self.vsg_xos_subscriber_delete(index, subId)
2824 df.callback(0)
2825 reactor.callLater(0,test_xos_subscriber,df)
2826 return df
Anil Kumar Sanka5bb352a2017-05-16 22:24:01 +00002827
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002828 @deferred(420)
Chetan Gaonkere1f66382017-06-02 21:34:07 +00002829 def test_vsg_xos_subscriber_external_connectivity_after_vsg_vm_is_restarted(self, index=0):
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002830 """
2831 Test Method:
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002832 1.Create subscriber
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002833 2.Verify external connectivity through vcpe instances from cord-tester
2834 3.Bring down first vSG vm
2835 4.Verify external network cant be reachable form first vcpe interface
2836 """
2837 df = defer.Deferred()
2838 def test_xos_subscriber(df,index=index):
2839 host = '8.8.8.8'
2840 subId = self.vsg_xos_subscriber_id(index)
2841 if subId == '0':
2842 log.info('creating vcpe instance of index 0')
2843 subId = self.vsg_xos_subscriber_create(index)
2844 assert_not_equal(subId,'0')
2845 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2846 vcpe_name = self.container_vcpes[index]
2847 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2848 try:
2849 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2850 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2851 assert_equal(st, False)
2852 log.info('Restarting vsg instance')
2853 vsg.reboot()
2854 time.sleep(10)
2855 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2856 time = 0
2857 status = False
2858 while(time <= 100):
2859 time.sleep(10)
2860 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2861 if st is False:
2862 status = True
2863 break
2864 time += 10
2865 assert_equal(status, True)
2866 except Exception as error:
2867 log.info('Got Unexpected error %s'%error)
2868 raise
2869 finally:
2870 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2871 self.vsg_xos_subscriber_delete(index, subId)
2872 df.callback(0)
2873 reactor.callLater(0,test_xos_subscriber,df)
2874 return df
2875
2876 @deferred(780)
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002877 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 +00002878 """
2879 Test Method:
2880 1.Create two vcpe instances in two different vsg vms using XOS
2881 2.Verify external connectivity through vcpe instances from cord-tester
2882 3.Bring down first vSG vm
2883 4.Verify external network cant be reachable form first vcpe interface
2884 5.Bring down second vSG vm also
2885 6.Verify external network cant be reachable form first vcpe interface also
2886 """
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002887 df = defer.Deferred(df,index1=index1,index2=index2)
2888 def test_xos_subscriber(df,index=index):
2889 subId1 = self.vsg_xos_subscriber_create(index1)
2890 subId2 = self.vsg_xos_subscriber_create(index2)
2891 if subId1 == '0':
2892 self.vsg_xos_subscriber_delete(index1, subId1)
2893 assert_not_equal(subId1, '0')
2894 if subId2 == '0':
2895 self.vsg_xos_subscriber_delete(index2, subId2)
2896 assert_not_equal(subId2, '0')
2897 for index in [index1,index2]:
2898 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
2899 vcpe_name = self.container_vcpes[index]
2900 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
2901 try:
2902 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2903 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2904 assert_equal(st, False)
2905 log.info('Stopping vsg instance of index %s'%index)
2906 vsg.stop()
2907 time.sleep(5)
2908 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2909 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2910 assert_equal(st, True)
2911 except Exception as error:
2912 log.info('Got Unexpected error %s'%error)
2913 raise
2914 finally:
2915 vsg.start()
2916 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2917 df.callback(0)
2918 reactor.callLater(0,test_xos_subscriber,df)
2919 return df
Anil Kumar Sanka52a39f82017-05-10 17:39:31 +00002920
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002921 @deferred(420)
2922 def test_vsg_xos_subscriber_external_connectivity_with_creating_firewall_rule(self,index=0):
2923 """
2924 Alog:
2925 1.Cretae a vcpe instance using XOS
2926 2.Get dhcp IP to vcpe interface in cord-tester
2927 3.Verify external network can be reachable from cord-tester
2928 4.Add an iptable rule to drop packets destined to external network in vcpe
2929 5.Verify now external network cant be reachable
Chetan Gaonkerfe1048f2017-06-13 20:16:25 +00002930 6.Delele the iptable in vcpe instance
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002931 7.Verify external network can be reachable from cord-tester
2932 """
2933 df = defer.Deferred()
2934 def test_xos_subscriber(df,index=index):
2935 log.info('cls.dhcp_vcpes is %s'%self.dhcp_vcpes)
2936 host = '8.8.8.8'
2937 subId = self.vsg_xos_subscriber_create(index)
2938 if subId == '0':
2939 subId = self.vsg_xos_subscriber_create(index)
2940 assert_not_equal(subId, '0')
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002941 vcpe_intf = self.dhcp_vcpes[index] #'vcpe{}.{}.{}'.format(s_tag, c_tag)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002942 vcpe_name = self.container_vcpes[index]
2943 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002944 try:
2945 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
2946 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002947 #ssert_equal(st, False)
2948 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 +00002949 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
2950 assert_equal(st, True)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002951 st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
2952 self.vsg_xos_subscriber_delete(index, subId)
2953 except Exception as error:
2954 log.info('Got Unexpected error %s'%error)
2955 raise
2956 finally:
2957 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00002958 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
Anil Kumar Sanka5db80d02017-06-02 21:10:19 +00002959 self.vsg_xos_subscriber_delete(index, subId)
2960 df.callback(0)
2961 reactor.callLater(0,test_xos_subscriber,df)
2962 return df
A R Karthick63751492017-03-22 09:28:01 -07002963
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002964 def test_vsg_for_packet_received_with_invalid_ip_fields(self):
2965 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002966 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002967 1.Create a vSG VM in compute node
2968 2.Create a vCPE container in vSG VM
2969 3.Ensure vSG VM and vCPE container created properly
2970 4.From subscriber, send a ping packet with invalid ip fields
2971 5.Verify that vSG drops the packet
2972 6.Verify ping fails
2973 """
A R Karthick63751492017-03-22 09:28:01 -07002974
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002975 def test_vsg_for_packet_received_with_invalid_mac_fields(self):
2976 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002977 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002978 1.Create a vSG VM in compute node
2979 2.Create a vCPE container in vSG VM
2980 3.Ensure vSG VM and vCPE container created properly
2981 4.From subscriber, send a ping packet with invalid mac fields
2982 5.Verify that vSG drops the packet
2983 6.Verify ping fails
2984 """
A R Karthick63751492017-03-22 09:28:01 -07002985
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002986 def test_vsg_for_vlan_id_mismatch_in_stag(self):
2987 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00002988 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002989 1.Create a vSG VM in compute Node
2990 2.Create a vCPE container in vSG VM
2991 3.Ensure vSG VM and vCPE container created properly
2992 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag
2993 5.Verify that ping fails as the packet drops at VM entry
2994 6.Repeat step 4 with correct s-tag
2995 7.Verify that ping success
2996 """
A R Karthick63751492017-03-22 09:28:01 -07002997
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002998 def test_vsg_for_vlan_id_mismatch_in_ctag(self):
2999 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003000 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003001 1.Create a vSG VM in compute node
3002 2.Create a vCPE container in vSG VM
3003 3.Ensure vSG VM and vCPE container created properly
3004 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag
3005 5.Verify that ping fails as the packet drops at vCPE container entry
3006 6.Repeat step 4 with valid s-tag and c-tag
3007 7.Verify that ping success
3008 """
A R Karthick63751492017-03-22 09:28:01 -07003009
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003010 def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self):
3011 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003012 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003013 1.Create two vSG VMs in compute node
3014 2.Create a vCPE container in each vSG VM
3015 3.Ensure vSG VM and vCPE container created properly
3016 4.From subscriber one, send ping request with valid s and c tags
3017 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags
3018 6.Verify that ping success for only subscriber one and fails for two.
3019 """
A R Karthick63751492017-03-22 09:28:01 -07003020
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003021 def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self):
3022 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003023 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003024 1.Create a vSG VM in compute node
3025 2.Create two vCPE containers in vSG VM
3026 3.Ensure vSG VM and vCPE container created properly
3027 4.From subscriber one, send ping request with valid s and c tags
3028 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag
3029 6.Verify that ping success for only subscriber one and fails for two
3030 """
A R Karthick63751492017-03-22 09:28:01 -07003031
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003032 def test_vsg_for_out_of_range_vlanid_in_ctag(self):
3033 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003034 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003035 1.Create a vSG VM in compute node
3036 2.Create a vCPE container in vSG VM
3037 3.Ensure vSG VM and vCPE container created properly
3038 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 )
3039 4.Verify that ping fails as the ping packets drops at vCPE container entry
3040 """
A R Karthick63751492017-03-22 09:28:01 -07003041
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003042 def test_vsg_for_out_of_range_vlanid_in_stag(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 a vCPE container in vSG VM
3047 3.Ensure vSG VM and vCPE container created properly
3048 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
3049 4.Verify that ping fails as the ping packets drops at vSG VM entry
3050 """
A R Karthick63751492017-03-22 09:28:01 -07003051
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00003052 def test_vsg_for_extracting_all_compute_stats_from_all_vcpe_containers(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003053 """
Chetan Gaonker72f3c4e2017-05-10 18:16:49 +00003054 Test Method:
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003055 1.Create a vSG VM in compute node
3056 2.Create 10 vCPE containers in VM
3057 3.Ensure vSG VM and vCPE containers created properly
3058 4.Login to all vCPE containers
3059 4.Get all compute stats from all vCPE containers
3060 5.Verify the stats # verification method need to add
3061 """
A R Karthick63751492017-03-22 09:28:01 -07003062
Anil Kumar Sankaf6a9f392017-05-06 00:18:31 +00003063 def test_vsg_for_extracting_dns_stats_from_all_vcpe_containers(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00003064 """
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 10 vCPE containers in VM
3068 3.Ensure vSG VM and vCPE containers created properly
3069 4.From 10 subscribers, send ping to valid and invalid dns hosts
3070 5.Verify dns resolves and ping success for valid dns hosts
3071 6.Verify ping fails for invalid dns hosts
3072 7.Verify dns host name resolve flows in OvS
3073 8.Login to all 10 vCPE containers
3074 9.Extract all dns stats
3075 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios
3076 """