blob: da28f8d0442f4d508b0bc3be61e1666d20a6e45b [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 Gaonker52418832017-01-26 23:03:13 +000019from nose.tools import *
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +000020from twisted.internet import defer
21from nose.twistedtools import reactor, deferred
A.R Karthick33cfdbe2017-03-17 18:03:48 -070022from CordTestUtils import *
Chetan Gaonker52418832017-01-26 23:03:13 +000023from OltConfig import OltConfig
Chetan Gaonker52418832017-01-26 23:03:13 +000024from onosclidriver import OnosCliDriver
A.R Karthick9ccd0d02017-03-16 17:11:08 -070025from SSHTestAgent import SSHTestAgent
Chetan Gaonker52418832017-01-26 23:03:13 +000026from CordLogger import CordLogger
A R Karthickd0fdf3b2017-03-21 16:54:22 -070027from VSGAccess import VSGAccess
A R Karthick933f5b52017-03-27 15:27:16 -070028from CordTestUtils import log_test as log
A.R Karthicka9b594d2017-03-29 16:25:22 -070029from OnosCtrl import OnosCtrl
A.R Karthick282f0d32017-03-28 16:43:59 -070030
Chetan Gaonker52418832017-01-26 23:03:13 +000031log.setLevel('INFO')
32
33class vsg_exchange(CordLogger):
34 ONOS_INSTANCES = 3
35 V_INF1 = 'veth0'
36 device_id = 'of:' + get_mac()
Chetan Gaonker52418832017-01-26 23:03:13 +000037 TEST_IP = '8.8.8.8'
38 HOST = "10.1.0.1"
39 USER = "vagrant"
40 PASS = "vagrant"
A R Karthick63751492017-03-22 09:28:01 -070041 head_node = os.getenv('HEAD_NODE', 'prod')
A.R Karthick9ccd0d02017-03-16 17:11:08 -070042 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
A R Karthick03f40aa2017-03-20 19:33:55 -070043 test_path = os.path.dirname(os.path.realpath(__file__))
44 olt_conf_file = os.path.join(test_path, '..', 'setup/olt_config.json')
A.R Karthick282f0d32017-03-28 16:43:59 -070045 restApiXos = None
A R Karthick0a4ca3a2017-03-30 09:36:53 -070046 subscriber_account_num = 200
47 subscriber_s_tag = 304
48 subscriber_c_tag = 304
49 subscribers_per_s_tag = 8
50 subscriber_map = {}
A R Karthick9a16a112017-04-07 15:40:05 -070051 restore_methods = []
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +000052 TIMEOUT=120
A R Karthick0a4ca3a2017-03-30 09:36:53 -070053
54 @classmethod
55 def getSubscriberCredentials(cls, subId):
56 """Generate our own account num, s_tag and c_tags"""
57 if subId in cls.subscriber_map:
58 return cls.subscriber_map[subId]
59 account_num = cls.subscriber_account_num
60 cls.subscriber_account_num += 1
61 s_tag, c_tag = cls.subscriber_s_tag, cls.subscriber_c_tag
62 cls.subscriber_c_tag += 1
63 if cls.subscriber_c_tag % cls.subscribers_per_s_tag == 0:
64 cls.subscriber_s_tag += 1
65 cls.subscriber_map[subId] = account_num, s_tag, c_tag
66 return cls.subscriber_map[subId]
A.R Karthick282f0d32017-03-28 16:43:59 -070067
68 @classmethod
A.R Karthicka9b594d2017-03-29 16:25:22 -070069 def getXosCredentials(cls):
70 onos_cfg = OnosCtrl.get_config()
71 if onos_cfg is None:
72 return None
73 if 'apps' in onos_cfg and \
74 'org.opencord.vtn' in onos_cfg['apps'] and \
75 'cordvtn' in onos_cfg['apps']['org.opencord.vtn'] and \
76 'xos' in onos_cfg['apps']['org.opencord.vtn']['cordvtn']:
77 xos_cfg = onos_cfg['apps']['org.opencord.vtn']['cordvtn']['xos']
78 endpoint = xos_cfg['endpoint']
79 user = xos_cfg['user']
80 password = xos_cfg['password']
81 xos_endpoints = endpoint.split(':')
82 xos_host = xos_endpoints[1][len('//'):]
83 xos_port = xos_endpoints[2][:-1]
84 #log.info('xos_host: %s, port: %s, user: %s, password: %s' %(xos_host, xos_port, user, password))
85 return dict(host = xos_host, port = xos_port, user = user, password = password)
86
87 return None
88
89 @classmethod
A.R Karthick282f0d32017-03-28 16:43:59 -070090 def setUpCordApi(cls):
91 our_path = os.path.dirname(os.path.realpath(__file__))
92 cord_api_path = os.path.join(our_path, '..', 'cord-api')
93 framework_path = os.path.join(cord_api_path, 'Framework')
94 utils_path = os.path.join(framework_path, 'utils')
95 data_path = os.path.join(cord_api_path, 'Tests', 'data')
96 subscriber_cfg = os.path.join(data_path, 'Subscriber.json')
97 volt_tenant_cfg = os.path.join(data_path, 'VoltTenant.json')
98
99 with open(subscriber_cfg) as f:
100 subscriber_data = json.load(f)
101 subscriber_info = subscriber_data['SubscriberInfo']
A R Karthick0a4ca3a2017-03-30 09:36:53 -0700102 for i in xrange(len(subscriber_info)):
103 subscriber = subscriber_info[i]
104 account_num, _, _ = cls.getSubscriberCredentials('sub{}'.format(i))
A.R Karthick282f0d32017-03-28 16:43:59 -0700105 subscriber['identity']['account_num'] = str(account_num)
A.R Karthick282f0d32017-03-28 16:43:59 -0700106 cls.subscriber_info = subscriber_info
107
108 with open(volt_tenant_cfg) as f:
109 volt_tenant_data = json.load(f)
110 volt_subscriber_info = volt_tenant_data['voltSubscriberInfo']
111 assert_equal(len(volt_subscriber_info), len(cls.subscriber_info))
A R Karthick0a4ca3a2017-03-30 09:36:53 -0700112 for i in xrange(len(volt_subscriber_info)):
113 volt_subscriber = volt_subscriber_info[i]
114 account_num, s_tag, c_tag = cls.getSubscriberCredentials('sub{}'.format(i))
A.R Karthick282f0d32017-03-28 16:43:59 -0700115 volt_subscriber['account_num'] = account_num
A R Karthick0a4ca3a2017-03-30 09:36:53 -0700116 volt_subscriber['voltTenant']['s_tag'] = str(s_tag)
117 volt_subscriber['voltTenant']['c_tag'] = str(c_tag)
A.R Karthick282f0d32017-03-28 16:43:59 -0700118 cls.volt_subscriber_info = volt_subscriber_info
119
120 sys.path.append(utils_path)
121 sys.path.append(framework_path)
122 from restApi import restApi
123 restApiXos = restApi()
A.R Karthicka9b594d2017-03-29 16:25:22 -0700124 xos_credentials = cls.getXosCredentials()
125 if xos_credentials is None:
126 restApiXos.controllerIP = cls.HEAD_NODE
127 restApiXos.controllerPort = '9000'
128 else:
129 restApiXos.controllerIP = xos_credentials['host']
130 restApiXos.controllerPort = xos_credentials['port']
131 restApiXos.user = xos_credentials['user']
132 restApiXos.password = xos_credentials['password']
A.R Karthick282f0d32017-03-28 16:43:59 -0700133 cls.restApiXos = restApiXos
Chetan Gaonker52418832017-01-26 23:03:13 +0000134
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700135 @classmethod
136 def setUpClass(cls):
137 cls.controllers = get_controllers()
138 cls.controller = cls.controllers[0]
139 cls.cli = None
A R Karthick03f40aa2017-03-20 19:33:55 -0700140 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
141 cls.vcpes = cls.olt.get_vcpes()
142 cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp')
143 vcpe_dhcp = None
144 vcpe_dhcp_stag = None
145 vcpe_container = None
A R Karthick93ba8d02017-04-13 11:59:58 -0700146 cls.on_podd = running_on_podd()
A R Karthick03f40aa2017-03-20 19:33:55 -0700147 #cache the first dhcp vcpe in the class for quick testing
148 if cls.vcpes_dhcp:
149 vcpe_container = 'vcpe-{}-{}'.format(cls.vcpes_dhcp[0]['s_tag'], cls.vcpes_dhcp[0]['c_tag'])
150 vcpe_dhcp = 'vcpe0.{}.{}'.format(cls.vcpes_dhcp[0]['s_tag'], cls.vcpes_dhcp[0]['c_tag'])
A R Karthick93ba8d02017-04-13 11:59:58 -0700151 if cls.on_podd is False:
A R Karthick3d5ff792017-04-12 16:53:27 -0700152 vcpe_dhcp = 'vcpe0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700153 vcpe_dhcp_stag = 'vcpe0.{}'.format(cls.vcpes_dhcp[0]['s_tag'])
154 cls.vcpe_container = vcpe_container
155 cls.vcpe_dhcp = vcpe_dhcp
156 cls.vcpe_dhcp_stag = vcpe_dhcp_stag
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700157 VSGAccess.setUp()
A.R Karthick282f0d32017-03-28 16:43:59 -0700158 cls.setUpCordApi()
Chetan Gaonker52418832017-01-26 23:03:13 +0000159
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700160 @classmethod
161 def tearDownClass(cls):
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700162 VSGAccess.tearDown()
Chetan Gaonker52418832017-01-26 23:03:13 +0000163
Chetan Gaonker52418832017-01-26 23:03:13 +0000164 def cliEnter(self, controller = None):
165 retries = 0
166 while retries < 30:
167 self.cli = OnosCliDriver(controller = controller, connect = True)
168 if self.cli.handle:
169 break
170 else:
171 retries += 1
172 time.sleep(2)
173
174 def cliExit(self):
175 self.cli.disconnect()
176
177 def onos_shutdown(self, controller = None):
178 status = True
179 self.cliEnter(controller = controller)
180 try:
181 self.cli.shutdown(timeout = 10)
182 except:
183 log.info('Graceful shutdown of ONOS failed for controller: %s' %controller)
184 status = False
185
186 self.cliExit()
187 return status
188
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700189 def log_set(self, level = None, app = 'org.onosproject'):
190 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000191
A R Karthick9a16a112017-04-07 15:40:05 -0700192 @classmethod
193 def get_dhcp(cls, vcpe, mgmt = 'eth0'):
194 """Get DHCP for vcpe interface saving management settings"""
195
196 def put_dhcp():
197 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
198
199 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
200 if vcpe_ip is not None:
201 cls.restore_methods.append(put_dhcp)
202 return vcpe_ip
203
204 @classmethod
205 def config_restore(cls):
206 """Restore the vsg test configuration on test case failures"""
207 for restore_method in cls.restore_methods:
208 restore_method()
209
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000210 def get_vsg_vcpe_pair(self):
211 vcpes = self.vcpes_dhcp
212 vcpe_containers = []
213 vsg_vcpe = {}
214 for vcp in vcpes:
215 vcpe_container = 'vcpe-{}-{}'.format(vcp['s_tag'], vcp['c_tag'])
216 vcpe_containers.append(vcpe_container)
217 vsg = VSGAccess.get_vcpe_vsg(vcpe_container)
218 vsg_vcpe[vcpe_container]=str(vsg.get_ip())
219 return vsg_vcpe
220
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000221 def add_static_route_via_vcpe_interface(self, routes, vcpe=None):
222 if not vcpe:
223 vcpe = self.vcpe_dhcp
224 os.system('dhclient '+self.vcpe_dhcp)
225 cmds = []
226 for route in routes:
227 log.info('route is %s'%route)
228 cmd = 'ip route add ' + route + ' via 192.168.0.1 '+ 'dev ' + vcpe
229 cmds.append(cmd)
230 for cmd in cmds:
231 os.system(cmd)
232 return True
233
234 def del_static_route_via_vcpe_interface(self,routes,vcpe=None):
235 if not vcpe:
236 vcpe = self.vcpe_dhcp
237 cmds = []
238 for route in routes:
239 cmd = 'ip route del ' + route + ' via 192.168.0.1 ' + 'dev ' + vcpe
240 cmds.append(cmd)
241 for cmd in cmds:
242 os.system(cmd)
243 os.system('dhclient '+self.vcpe_dhcp+' -r')
244 return True
245
246 def restart_vcpe_container(self,vcpe=None):
247 vsg = VSGAccess.get_vcpe_vsg(self.vcpe_container)
248 log.info('restarting vcpe container')
249 vsg.run_cmd('sudo docker restart {}'.format(self.vcpe_container))
250 return True
251
A R Karthick63751492017-03-22 09:28:01 -0700252 def test_vsg_health(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000253 """
254 Algo:
255 1. Login to compute node VM
256 2. Get all vSGs
257 3. Ping to all vSGs
258 4. Verifying Ping success
259 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700260 status = True
261 if self.on_podd is True:
262 status = VSGAccess.health_check()
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700263 assert_equal(status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000264
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000265 def test_vsg_health_check(self, vsg_name='mysite_vsg-1', verify_status=True):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000266 """
267 Algo:
268 1. If vsg name not specified, Get vsg corresponding to vcpe
269 1. Login to compute mode VM
270 3. Ping to the vSG
271 4. Verifying Ping success
272 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700273 if self.on_podd is False:
274 return
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000275 if not vsg_name:
276 vcpe = self.vcpe_container
277 vsg = VSGAccess.get_vcpe_vsg(vcpe)
278 status = vsg.get_health()
279 assert_equal(status, verify_status)
280 else:
281 vsgs = VSGAccess.get_vsgs()
282 status = None
283 for vsg in vsgs:
284 if vsg.name == vsg_name:
285 status = vsg.get_health()
286 log.info('vsg health check status is %s'%status)
287 assert_equal(status,verify_status)
288
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000289 @deferred(TIMEOUT)
A R Karthick63751492017-03-22 09:28:01 -0700290 def test_vsg_for_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000291 """
292 Algo:
293 1. Get list of all compute nodes created using Openstack
294 2. Login to compute mode VM
295 3. Get all vSGs
296 4. Verifying atleast one compute node and one vSG created
297 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000298 df = defer.Deferred()
299 def vsg_for_vcpe_df(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700300 if self.on_podd is True:
301 vsgs = VSGAccess.get_vsgs()
302 compute_nodes = VSGAccess.get_compute_nodes()
303 time.sleep(14)
304 assert_not_equal(len(vsgs), 0)
305 assert_not_equal(len(compute_nodes), 0)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000306 df.callback(0)
307 reactor.callLater(0,vsg_for_vcpe_df,df)
308 return df
Chetan Gaonker52418832017-01-26 23:03:13 +0000309
A R Karthick63751492017-03-22 09:28:01 -0700310 def test_vsg_for_login(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000311 """
312 Algo:
313 1. Login to compute node VM
314 2. Get all vSGs
315 3. Verifying login to vSG is success
316 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700317 if self.on_podd is False:
318 return
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700319 vsgs = VSGAccess.get_vsgs()
320 vsg_access_status = map(lambda vsg: vsg.check_access(), vsgs)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700321 status = filter(lambda st: st == False, vsg_access_status)
322 assert_equal(len(status), 0)
323
A R Karthick63751492017-03-22 09:28:01 -0700324 def test_vsg_for_default_route_through_testclient(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000325 """
326 Algo:
327 1. Login to head node
328 2. Verifying for default route in lxc test client
329 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700330 if self.on_podd is False:
331 return
A R Karthick63751492017-03-22 09:28:01 -0700332 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
333 cmd = "sudo lxc exec testclient -- route | grep default"
334 status, output = ssh_agent.run_cmd(cmd)
335 assert_equal(status, True)
336
337 def test_vsg_for_external_connectivity_through_testclient(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000338 """
339 Algo:
340 1. Login to head node
341 2. On head node, executing ping to 8.8.8.8 from lxc test client
342 3. Verifying for the ping success
343 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700344 if self.on_podd is False:
345 return
A R Karthick63751492017-03-22 09:28:01 -0700346 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
347 cmd = "lxc exec testclient -- ping -c 3 8.8.8.8"
348 status, output = ssh_agent.run_cmd(cmd)
349 assert_equal( status, True)
350
351 def test_vsg_for_external_connectivity(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000352 """
353 Algo:
354 1. Get dhcp IP to vcpe interface in cord-tester
355 2. Verifying vcpe interface gets dhcp IP
356 3. Ping to 8.8.8.8 and Verifying ping should success
357 4. Restoring management interface configuration in cord-tester
358 """
A R Karthick03f40aa2017-03-20 19:33:55 -0700359 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700360 mgmt = 'eth0'
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000361 host = '8.8.8.8'
362 self.success = False
A R Karthick03f40aa2017-03-20 19:33:55 -0700363 assert_not_equal(vcpe, None)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000364 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700365 assert_not_equal(vcpe_ip, None)
366 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
367 log.info('Sending icmp echo requests to external network 8.8.8.8')
368 st, _ = getstatusoutput('ping -c 3 8.8.8.8')
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700369 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700370 assert_equal(st, 0)
Chetan Gaonker52418832017-01-26 23:03:13 +0000371
A R Karthick63751492017-03-22 09:28:01 -0700372 def test_vsg_for_external_connectivity_to_google(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000373 """
374 Algo:
375 1. Get dhcp IP to vcpe interface in cord-tester
376 2. Verifying vcpe interface gets dhcp IP
377 3. Ping to www.google.com and Verifying ping should success
378 4. Restoring management interface configuration in cord-tester
379 """
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000380 host = 'www.google.com'
A R Karthick03f40aa2017-03-20 19:33:55 -0700381 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700382 mgmt = 'eth0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700383 assert_not_equal(vcpe, None)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000384 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700385 assert_not_equal(vcpe_ip, None)
386 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
387 log.info('Sending icmp ping requests to %s' %host)
388 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700389 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700390 assert_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000391
A R Karthick63751492017-03-22 09:28:01 -0700392 def test_vsg_for_external_connectivity_to_invalid_host(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000393 """
394 Algo:
395 1. Get dhcp IP to vcpe interface in cord-tester
396 2. Verifying vcpe interface gets dhcp IP
397 3. Ping to www.goglee.com and Verifying ping should not success
398 4. Restoring management interface configuration in cord-tester
399 """
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000400 host = 'www.goglee.com'
A R Karthick03f40aa2017-03-20 19:33:55 -0700401 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700402 mgmt = 'eth0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700403 assert_not_equal(vcpe, None)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000404 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700405 assert_not_equal(vcpe_ip, None)
406 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
407 log.info('Sending icmp ping requests to non existent host %s' %host)
408 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700409 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700410 assert_not_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000411
A R Karthick63751492017-03-22 09:28:01 -0700412 def test_vsg_for_external_connectivity_with_ttl_1(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000413 """
414 Algo:
415 1. Get dhcp IP to vcpe interface in cord-tester
416 2. Verifying vcpe interface gets dhcp IP
417 3. Ping to 8.8.8.8 with ttl set to 1
418 4. Verifying ping should not success
419 5. Restoring management interface configuration in cord-tester
420 """
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000421 host = '8.8.8.8'
A R Karthick03f40aa2017-03-20 19:33:55 -0700422 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700423 mgmt = 'eth0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700424 assert_not_equal(vcpe, None)
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000425 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700426 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 host %s with ttl 1' %host)
429 st, _ = getstatusoutput('ping -c 1 -t 1 {}'.format(host))
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700430 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700431 assert_not_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000432
A R Karthick63751492017-03-22 09:28:01 -0700433 def test_vsg_for_external_connectivity_with_wan_interface_toggle_in_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000434 """
435 Algo:
436 1. Get dhcp IP to vcpe interface in cord-tester
437 2. Verifying vcpe interface gets dhcp IP
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700438 3. Ping to 8.8.8.8 and Verifying ping succeeds
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000439 4. Now down the WAN interface of vcpe
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700440 5. Ping to 8.8.8.8 and Verifying ping fails
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000441 6. Now Up the WAN interface of vcpe
A.R Karthick8f7f1b62017-04-06 18:25:07 -0700442 7. Ping to 8.8.8.8 and Verifying ping succeeds
443 8. Restoring management interface configuration in cord-tester
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000444 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700445 if self.on_podd is False:
446 return
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000447 host = '8.8.8.8'
A R Karthick03f40aa2017-03-20 19:33:55 -0700448 mgmt = 'eth0'
449 vcpe = self.vcpe_container
450 assert_not_equal(vcpe, None)
451 assert_not_equal(self.vcpe_dhcp, None)
452 #first get dhcp on the vcpe interface
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000453 vcpe_ip = VSGAccess.vcpe_get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
454 assert_not_equal(vcpe_ip, None)
455 log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
456 log.info('Sending ICMP pings to host %s' %(host))
457 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
458 if st != 0:
459 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
460 assert_equal(st, 0)
461 #bring down the wan interface and check again
462 st = VSGAccess.vcpe_wan_down(vcpe)
463 if st is False:
464 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
465 assert_equal(st, True)
466 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
467 if st == 0:
468 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
469 assert_not_equal(st, 0)
470 st = VSGAccess.vcpe_wan_up(vcpe)
471 if st is False:
472 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
473 assert_equal(st, True)
474 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
475 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
476 assert_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000477
A R Karthick63751492017-03-22 09:28:01 -0700478 def test_vsg_for_external_connectivity_with_lan_interface_toggle_in_vcpe(self):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000479 """
480 Algo:
481 1. Get dhcp IP to vcpe interface in cord-tester
482 2. Verifying vcpe interface gets dhcp IP
483 3. Ping to 8.8.8.8 and Verifying ping should success
484 4. Now down the LAN interface of vcpe
485 5. Ping to 8.8.8.8 and Verifying ping should not success
486 6. Now Up the LAN interface of vcpe
487 7. Ping to 8.8.8.8 and Verifying ping should success
488 8. Restoring management interface configuration in cord-tester
489 """
A R Karthick93ba8d02017-04-13 11:59:58 -0700490 if self.on_podd is False:
491 return
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000492 host = '8.8.8.8'
A R Karthick03f40aa2017-03-20 19:33:55 -0700493 mgmt = 'eth0'
494 vcpe = self.vcpe_container
495 assert_not_equal(vcpe, None)
496 assert_not_equal(self.vcpe_dhcp, None)
497 #first get dhcp on the vcpe interface
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000498 vcpe_ip = VSGAccess.vcpe_get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
499 assert_not_equal(vcpe_ip, None)
500 log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
501 log.info('Sending ICMP pings to host %s' %(host))
502 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
503 if st != 0:
504 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
505 assert_equal(st, 0)
506 #bring down the lan interface and check again
507 st = VSGAccess.vcpe_lan_down(vcpe)
508 if st is False:
509 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
510 assert_equal(st, True)
511 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
512 if st == 0:
513 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
514 assert_not_equal(st, 0)
515 st = VSGAccess.vcpe_lan_up(vcpe)
516 if st is False:
517 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
518 assert_equal(st, True)
519 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
520 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
521 assert_equal(st, 0)
Chetan Gaonker52418832017-01-26 23:03:13 +0000522
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000523 @deferred(TIMEOUT)
524 def test_vsg_for_external_connectivity_with_vcpe_container_paused(self,vcpe_name=None,vcpe_intf=None):
525 """
526 Algo:
527 1. Get vSG corresponding to vcpe
528 2. Get dhcp ip to vcpe interface
529 3. Add static route to destination route in test container
530 4. From test container ping to destination route and verify ping success
531 5. Login to compute node and execute command to pause vcpe container
532 6. From test container ping to destination route and verify ping success
533 """
534 if not vcpe_name:
535 vcpe_name = self.vcpe_container
536 if not vcpe_intf:
537 vcpe_intf = self.vcpe_dhcp
538 df = defer.Deferred()
539 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700540 if self.on_podd is False:
541 df.callback(0)
542 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000543 host = '8.8.8.8'
544 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
545 try:
546 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
547 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
548 assert_equal(st, False)
549 st, _ = vsg.run_cmd('sudo docker pause {}'.format(vcpe_name))
550 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
551 assert_equal(st, False)
552 finally:
553 vsg.run_cmd('sudo docker unpause'.format(vcpe_name))
554 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
555 df.callback(0)
556 reactor.callLater(0, vcpe_firewall, df)
557 return df
558
559 @deferred(TIMEOUT)
560 def test_vsg_firewall_with_deny_destination_ip(self, vcpe_name=None, vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000561 """
562 Algo:
563 1. Get vSG corresponding to vcpe
564 2. Login to compute node
565 3. Execute iptable command on vcpe from compute node to deny a destination IP
566 4. From cord-tester ping to the denied IP address
567 5. Verifying that ping should not be successful
568 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000569 if not vcpe_name:
570 vcpe_name = self.vcpe_container
571 if not vcpe_intf:
572 vcpe_intf = self.vcpe_dhcp
573 df = defer.Deferred()
574 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700575 if self.on_podd is False:
576 df.callback(0)
577 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000578 host = '8.8.8.8'
579 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
580 try:
581 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
582 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
583 assert_equal(st, False)
584 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
585 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
586 assert_equal(st, True)
587 finally:
588 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
589 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
590 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
591 df.callback(0)
592 reactor.callLater(0, vcpe_firewall, df)
593 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000594
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000595 @deferred(TIMEOUT)
596 def test_vsg_firewall_with_rule_add_and_delete_dest_ip(self,vcpe_name=None,vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000597 """
598 Algo:
599 1. Get vSG corresponding to vcpe
600 2. Login to compute node
601 3. Execute iptable command on vcpe from compute node to deny a destination IP
602 4. From cord-tester ping to the denied IP address
603 5. Verifying that ping should not be successful
604 6. Delete the iptable rule in vcpe
605 7. From cord-tester ping to the denied IP address
606 8. Verifying the ping should success
607 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000608 if not vcpe_name:
609 vcpe_name = self.vcpe_container
610 if not vcpe_intf:
611 vcpe_intf = self.vcpe_dhcp
612 df = defer.Deferred()
613 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700614 if self.on_podd is False:
615 df.callback(0)
616 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000617 host = '8.8.8.8'
618 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
619 try:
620 self.add_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
621 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
622 assert_equal(st, False)
623 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
624 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
625 assert_equal(st, True)
626 st,_ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
627 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
628 assert_equal(st, False)
629 finally:
630 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
631 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
632 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
633 df.callback(0)
634 reactor.callLater(0, vcpe_firewall, df)
635 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000636
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000637 @deferred(TIMEOUT)
638 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 +0000639 """
640 Algo:
641 1. Get vSG corresponding to vcpe
642 2. Login to compute node
643 3. Execute iptable command on vcpe from compute node to deny a destination IP
644 4. From cord-tester ping to the denied IP address
645 5. Verifying that ping should not be successful
646 6. From cord-tester ping to the denied IP address other than the denied one
647 7. Verifying the ping should success
648 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000649 if not vcpe_name:
650 vcpe_name = self.vcpe_container
651 if not vcpe_intf:
652 vcpe_intf = self.vcpe_dhcp
653 df = defer.Deferred()
654 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700655 if self.on_podd is False:
656 df.callback(0)
657 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000658 host1 = '8.8.8.8'
659 host2 = '204.79.197.203'
660 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
661 try:
662 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
663 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
664 assert_equal(st, False)
665 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
666 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
667 assert_equal(st, True)
668 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
669 assert_equal(st,False)
670 finally:
671 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
672 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
673 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
674 df.callback(0)
675 reactor.callLater(0, vcpe_firewall, df)
676 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000677
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000678 @deferred(TIMEOUT)
679 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 +0000680 """
681 Algo:
682 1. Get vSG corresponding to vcpe
683 2. Login to compute node
684 3. Execute iptable command on vcpe from compute node to deny a destination IP1
685 4. From cord-tester ping to the denied IP address IP1
686 5. Verifying that ping should not be successful
687 6. Execute iptable command on vcpe from compute node to deny a destination IP2
688 6. From cord-tester ping to the denied IP address IP2
689 7. Verifying that ping should not be successful
690 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000691 if not vcpe_name:
692 vcpe_name = self.vcpe_container
693 if not vcpe_intf:
694 vcpe_intf = self.vcpe_dhcp
695 df = defer.Deferred()
696 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700697 if self.on_podd is False:
698 df.callback(0)
699 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000700 host1 = '8.8.8.8'
701 host2 = '204.79.197.203'
702 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
703 try:
704 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
705 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
706 assert_equal(st, False)
707 st,_ = vsg.run_cmd('sudo docker exec {} iptables -F FORWARD'.format(vcpe_name))
708 time.sleep(2)
709 st,_ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
710 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
711 assert_equal(st, True)
712 st, out = getstatusoutput('ping -c 1 {}'.format(host2))
713 log.info('host2 ping output is %s'%out)
714 assert_equal(st, False)
715 st, _ = vsg.run_cmd('sudo docker exec {} iptables -A FORWARD -d {} -j DROP'.format(vcpe_name,host2))
716 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
717 assert_equal(st,True)
718 finally:
719 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
720 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
721 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
722 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
723 df.callback(0)
724 reactor.callLater(0, vcpe_firewall, df)
725 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000726
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000727 @deferred(TIMEOUT)
728 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 +0000729 """
730 Algo:
731 1. Get vSG corresponding to vcpe
732 2. Login to compute node
733 3. Execute iptable command on vcpe from compute node to deny a destination IP1
734 4. Execute iptable command on vcpe from compute node to deny a destination IP2
735 5. From cord-tester ping to the denied IP address IP1
736 6. Verifying that ping should not be successful
737 7. From cord-tester ping to the denied IP address IP2
738 8. Verifying that ping should not be successful
739 9. Execute iptable command on vcpe from compute node to remove deny a destination IP2 rule
740 10. From cord-tester ping to the denied IP address IP2
741 11. Verifying the ping should success
742 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000743 if not vcpe_name:
744 vcpe_name = self.vcpe_container
745 if not vcpe_intf:
746 vcpe_intf = self.vcpe_dhcp
747 df = defer.Deferred()
748 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700749 if self.on_podd is False:
750 df.callback(0)
751 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000752 host1 = '8.8.8.8'
753 host2 = '204.79.197.203'
754 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
755 try:
756 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=self.vcpe_dhcp)
757 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
758 assert_equal(st, False)
759 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host1))
760 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host2))
761 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
762 assert_equal(st, True)
763 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
764 assert_equal(st,True)
765 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
766 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
767 assert_equal(st,False)
768 finally:
769 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host1))
770 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host2))
771 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
772 log.info('restarting vcpe container')
773 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
774 df.callback(0)
775 reactor.callLater(0, vcpe_firewall, df)
776 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000777
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000778 @deferred(TIMEOUT)
779 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 +0000780 """
781 Algo:
782 1. Get vSG corresponding to vcpe
783 2. Login to compute node
784 3. Execute iptable command on vcpe from compute node to deny a destination IP
785 5. From cord-tester ping to the denied IP address IP1
786 6. Verifying that ping should not be successful
787 9. Execute iptable command on vcpe from compute node to change the rule ID to 2 to deny the same destination IP
788 10. From cord-tester ping to the denied IP address IP
789 11. Verifying that ping should not be successful
790 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000791 if not vcpe_name:
792 vcpe_name = self.vcpe_container
793 if not vcpe_intf:
794 vcpe_intf = self.vcpe_dhcp
795 df = defer.Deferred()
796 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700797 if self.on_podd is False:
798 df.callback(0)
799 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000800 host = '8.8.8.8'
801 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
802 try:
803 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
804 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
805 assert_equal(st, False)
806 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
807 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
808 assert_equal(st, True)
809 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP '.format(vcpe_name,host))
810 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
811 assert_equal(st,True)
812 finally:
813 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
814 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
815 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
816 df.callback(0)
817 reactor.callLater(0, vcpe_firewall, df)
818 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000819
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000820 @deferred(TIMEOUT)
821 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 +0000822 """
823 Algo:
824 1. Get vSG corresponding to vcpe
825 2. Login to compute node
826 3. Execute iptable command on vcpe from compute node to deny a destination IP
827 5. From cord-tester ping to the denied IP address IP1
828 6. Verifying that ping should not be successful
829 9. Execute iptable command on vcpe from compute node to accept the same destination IP
830 10. From cord-tester ping to the accepted IP
831 11. Verifying the ping should success
832 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000833 if not vcpe_name:
834 vcpe_name = self.vcpe_container
835 if not vcpe_intf:
836 vcpe_intf = self.vcpe_dhcp
837 df = defer.Deferred()
838 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700839 if self.on_podd is False:
840 df.callback(0)
841 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000842 host = '8.8.8.8'
843 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
844 try:
845 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
846 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
847 assert_equal(st, False)
848 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
849 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
850 assert_equal(st, True)
851 st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -d {} -j ACCEPT'.format(vcpe_name,host))
852 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
853 assert_equal(st,False)
854 finally:
855 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
856 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j ACCEPT'.format(vcpe_name,host))
857 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
858 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
859 df.callback(0)
860 reactor.callLater(0, vcpe_firewall, df)
861 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000862
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000863 @deferred(TIMEOUT) #Fail
864 def test_vsg_firewall_denying_destination_network(self,vcpe_name=None,vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000865 """
866 Algo:
867 1. Get vSG corresponding to vcpe
868 2. Login to compute node
869 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet
870 4. From cord-tester ping to the denied IP address IP1 in the denied subnet
871 5. Verifying that ping should not be successful
872 6. From cord-tester ping to the denied IP address IP2 in the denied subnet
873 7. Verifying that ping should not be successful
874 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000875 if not vcpe_name:
876 vcpe_name = self.vcpe_container
877 if not vcpe_intf:
878 vcpe_intf = self.vcpe_dhcp
879 df = defer.Deferred()
880 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700881 if self.on_podd is False:
882 df.callback(0)
883 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000884 network = '204.79.197.192/28'
885 host1 = '204.79.197.203'
886 host2 = '204.79.197.210'
887 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
888 try:
889 self.add_static_route_via_vcpe_interface([host1,host2],vcpe=self.vcpe_dhcp)
890 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
891 assert_equal(st, False)
892 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network))
893 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
894 assert_equal(st, True)
895 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
896 assert_equal(st,False)
897 finally:
898 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network))
899 self.del_static_route_via_vcpe_interface([host1,host2],vcpe=vcpe_intf)
900 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
901 df.callback(0)
902 reactor.callLater(0, vcpe_firewall, df)
903 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000904
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000905 @deferred(TIMEOUT)
906 def test_vsg_firewall_denying_destination_network_subnet_modification(self,vcpe_name=None,vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000907 """
908 Algo:
909 1. Get vSG corresponding to vcpe
910 2. Login to compute node
911 3. Execute iptable command on vcpe from compute node to deny a destination IP subnet
912 4. From cord-tester ping to the denied IP address IP1 in the denied subnet
913 5. Verifying that ping should not be successful
914 6. From cord-tester ping to the denied IP address IP2 in the denied subnet
915 7. Verifying that ping should not be successful
916 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000917 if not vcpe_name:
918 vcpe_name = self.vcpe_container
919 if not vcpe_intf:
920 vcpe_intf = self.vcpe_dhcp
921 df = defer.Deferred()
922 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700923 if self.on_podd is False:
924 df.callback(0)
925 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000926 network1 = '204.79.197.192/28'
927 network2 = '204.79.197.192/27'
928 host1 = '204.79.197.203'
929 host2 = '204.79.197.210'
930 host3 = '204.79.197.224'
931 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
932 try:
933 self.add_static_route_via_vcpe_interface([host1,host2,host3],vcpe=self.vcpe_dhcp)
934 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
935 assert_equal(st, False)
936 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,network1))
937 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
938 assert_equal(st, True)
939 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
940 assert_equal(st,False)
941 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD 2 -d {} -j DROP'.format(vcpe_name,network2))
942 st, _ = getstatusoutput('ping -c 1 {}'.format(host1))
943 assert_equal(st, True)
944 st, _ = getstatusoutput('ping -c 1 {}'.format(host2))
945 assert_equal(st, True)
946 st, _ = getstatusoutput('ping -c 1 {}'.format(host3))
947 assert_equal(st, False)
948 finally:
949 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network1))
950 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,network2))
951 self.del_static_route_via_vcpe_interface([host1,host2,host3],vcpe=vcpe_intf)
952 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
953 df.callback(0)
954 reactor.callLater(0, vcpe_firewall, df)
955 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000956
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000957 @deferred(TIMEOUT)
958 def test_vsg_firewall_with_deny_source_ip(self,vcpe_name=None,vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +0000959 """
960 Algo:
961 1. Get vSG corresponding to vcpe
962 2. Login to compute node
963 3. Execute iptable command on vcpe from compute node to deny a source IP
964 4. From cord-tester ping to 8.8.8.8 from the denied IP
965 5. Verifying that ping should not be successful
966 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000967 if not vcpe_name:
968 vcpe_name = self.vcpe_container
969 if not vcpe_intf:
970 vcpe_intf = self.vcpe_dhcp
971 df = defer.Deferred()
972 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -0700973 if self.on_podd is False:
974 df.callback(0)
975 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000976 host = '8.8.8.8'
977 #source_ip = get_ip(self.vcpe_dhcp)
978 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
979 try:
980 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
981 source_ip = get_ip(self.vcpe_dhcp)
982 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
983 assert_equal(st, False)
984 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
985 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
986 assert_equal(st, True)
987 finally:
988 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
989 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
990 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
991 df.callback(0)
992 reactor.callLater(0, vcpe_firewall, df)
993 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +0000994
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +0000995 @deferred(TIMEOUT)
996 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 +0000997 """
998 Algo:
999 1. Get vSG corresponding to vcpe
1000 2. Login to compute node
1001 3. Execute iptable command on vcpe from compute node to deny a source IP
1002 4. From cord-tester ping to 8.8.8.8 from the denied IP
1003 5. Verifying that ping should not be successful
1004 6. Delete the iptable rule in vcpe
1005 7. From cord-tester ping to 8.8.8.8 from the denied IP
1006 8. Verifying the ping should success
1007 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001008 if not vcpe_name:
1009 vcpe_name = self.vcpe_container
1010 if not vcpe_intf:
1011 vcpe_intf = self.vcpe_dhcp
1012 df = defer.Deferred()
1013 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001014 if self.on_podd is False:
1015 df.callback(0)
1016 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001017 host = '8.8.8.8'
1018 source_ip = get_ip(self.vcpe_dhcp)
1019 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1020 try:
1021 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1022 source_ip = get_ip(self.vcpe_dhcp)
1023 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1024 assert_equal(st, False)
1025 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1026 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1027 assert_equal(st, True)
1028 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1029 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1030 assert_equal(st, False)
1031 finally:
1032 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -s {} -j DROP'.format(vcpe_name,source_ip))
1033 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1034 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1035 df.callback(0)
1036 reactor.callLater(0, vcpe_firewall, df)
1037 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001038
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001039 @deferred(TIMEOUT)
1040 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 +00001041 """
1042 Algo:
1043 1. Get vSG corresponding to vcpe
1044 2. Login to compute node
1045 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets
1046 4. From cord-tester ping to 8.8.8.8
1047 5. Verifying that ping should not be successful
1048 6. Delete the iptable rule
1049 7. From cord-tester ping to 8.8.8.8
1050 8. Verifying the ping should success
1051 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001052 if not vcpe_name:
1053 vcpe_name = self.vcpe_container
1054 if not vcpe_intf:
1055 vcpe_intf = self.vcpe_dhcp
1056 df = defer.Deferred()
1057 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001058 if self.on_podd is False:
1059 df.callback(0)
1060 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001061 host = '8.8.8.8'
1062 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1063 try:
1064 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1065 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1066 assert_equal(st, False)
1067 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1068 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1069 assert_equal(st, True)
1070 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1071 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1072 assert_equal(st, False)
1073 finally:
1074 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1075 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1076 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1077 df.callback(0)
1078 reactor.callLater(0, vcpe_firewall, df)
1079 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001080
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001081 @deferred(TIMEOUT)
1082 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 +00001083 """
1084 Algo:
1085 1. Get vSG corresponding to vcpe
1086 2. Login to compute node
1087 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets
1088 4. From cord-tester ping to 8.8.8.8
1089 5. Verifying that ping should not be successful
1090 6. Delete the iptable rule
1091 7. From cord-tester ping to 8.8.8.8
1092 8. Verifying the ping should success
1093 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001094 if not vcpe_name:
1095 vcpe_name = self.vcpe_container
1096 if not vcpe_intf:
1097 vcpe_intf = self.vcpe_dhcp
1098 df = defer.Deferred()
1099 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001100 if self.on_podd is False:
1101 df.callback(0)
1102 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001103 host = '8.8.8.8'
1104 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1105 try:
1106 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1107 st, _ = getstatusoutput('ping -c 1 {}'.format('8.8.8.8'))
1108 assert_equal(st, False)
1109 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1110 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1111 assert_equal(st, True)
1112 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1113 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1114 assert_equal(st,False)
1115 finally:
1116 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1117 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1118 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1119 df.callback(0)
1120 reactor.callLater(0, vcpe_firewall, df)
1121 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001122
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001123 @deferred(TIMEOUT)
1124 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 +00001125 """
1126 Algo:
1127 1. Get vSG corresponding to vcpe
1128 2. Login to compute node
1129 3. Execute iptable command on vcpe from compute node to deny icmp echo-requests type protocol packets
1130 4. From cord-tester ping to 8.8.8.8
1131 5. Verifying that ping should not be successful
1132 6. Insert another rule to accept the icmp-echo requests protocol packets
1133 7. From cord-tester ping to 8.8.8.8
1134 8. Verifying the ping should success
1135 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001136 if not vcpe_name:
1137 vcpe_name = self.vcpe_container
1138 if not vcpe_intf:
1139 vcpe_intf = self.vcpe_dhcp
1140 df = defer.Deferred()
1141 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001142 if self.on_podd is False:
1143 df.callback(0)
1144 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001145 host = '8.8.8.8'
1146 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1147 try:
1148 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1149 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1150 assert_equal(st, False)
1151 st, _ = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1152 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1153 assert_equal(st, True)
1154 st, _ = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name))
1155 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1156 assert_equal(st,False)
1157 finally:
1158 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j DROP'.format(vcpe_name))
1159 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-request -j ACCEPT'.format(vcpe_name))
1160 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1161 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1162 df.callback(0)
1163 reactor.callLater(0, vcpe_firewall, df)
1164 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001165
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001166 @deferred(TIMEOUT)
1167 def test_vsg_firewall_changing_deny_rule_to_accept_rule_with_icmp_protocol_echo_reply_type(self,vcpe_name=None,vcpe_intf=None):
1168 """
1169 Algo:
1170 1. Get vSG corresponding to vcpe
1171 2. Login to compute node
1172 3. Execute iptable command on vcpe from compute node to deny icmp echo-reply type protocol packets
1173 4. From cord-tester ping to 8.8.8.8
1174 5. Verifying the ping should not success
1175 6. Insert another rule to accept the icmp-echo requests protocol packets
1176 7. From cord-tester ping to 8.8.8.8
1177 8. Verifying the ping should success
1178 """
1179 if not vcpe_name:
1180 vcpe_name = self.vcpe_container
1181 if not vcpe_intf:
1182 vcpe_intf = self.vcpe_dhcp
1183 df = defer.Deferred()
1184 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001185 if self.on_podd is False:
1186 df.callback(0)
1187 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001188 host = '8.8.8.8'
1189 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1190 try:
1191 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1192 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1193 assert_equal(st, False)
1194 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1195 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1196 assert_equal(st, True)
1197 st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name))
1198 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1199 assert_equal(st,False)
1200 finally:
1201 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j DROP'.format(vcpe_name))
1202 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp --icmp-type echo-reply -j ACCEPT'.format(vcpe_name))
1203 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1204 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1205 df.callback(0)
1206 reactor.callLater(0, vcpe_firewall, df)
1207 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001208
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001209 @deferred(TIMEOUT)
1210 def test_vsg_firewall_for_deny_icmp_protocol(self,vcpe_name=None,vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001211 """
1212 Algo:
1213 1. Get vSG corresponding to vcpe
1214 2. Login to compute node
1215 3. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1216 4. From cord-tester ping to 8.8.8.8
1217 5. Verifying that ping should not be successful
1218 6. Delete the iptable rule
1219 7. From cord-tester ping to 8.8.8.8
1220 8. Verifying the ping should success
1221 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001222 if not vcpe_name:
1223 vcpe_name = self.vcpe_container
1224 if not vcpe_intf:
1225 vcpe_intf = self.vcpe_dhcp
1226 df = defer.Deferred()
1227 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001228 if self.on_podd is False:
1229 df.callback(0)
1230 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001231 host = '8.8.8.8'
1232 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1233 try:
1234 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1235 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1236 assert_equal(st, False)
1237 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1238 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1239 assert_equal(st, True)
1240 st, _ = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1241 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1242 assert_equal(st,False)
1243 finally:
1244 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1245 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1246 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1247 df.callback(0)
1248 reactor.callLater(0, vcpe_firewall, df)
1249 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001250
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001251 @deferred(TIMEOUT)
1252 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 +00001253 """
1254 Algo:
1255 1. Get vSG corresponding to vcpe
1256 2. Login to compute node
1257 3. Execute iptable command on vcpe from compute node to deny a destination IP
1258 4. From cord-tester ping to 8.8.8.8
1259 5. Verifying that ping should not be successful
1260 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1261 7. From cord-tester ping to 8.8.8.8
1262 8. Verifying the ping should success
1263 9. Delete the rule added in step 3
1264 10. From cord-tester ping to 8.8.8.8
1265 11. Verifying that ping should not be successful
1266 12. Delete the rule added in step 6
1267 13. From cord-tester ping to 8.8.8.8
1268 14. Verifying the ping should success
1269 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001270 if not vcpe_name:
1271 vcpe_name = self.vcpe_container
1272 if not vcpe_intf:
1273 vcpe_intf = self.vcpe_dhcp
1274 df = defer.Deferred()
1275 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001276 if self.on_podd is False:
1277 df.callback(0)
1278 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001279 host = '8.8.8.8'
1280 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1281 try:
1282 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1283 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1284 assert_equal(st, False)
1285 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1286 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1287 assert_equal(st, True)
1288 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1289 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1290 assert_equal(st, True)
1291 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1292 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1293 assert_equal(st, True)
1294 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1295 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1296 assert_equal(st,False)
1297 finally:
1298 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1299 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p icmp -j DROP'.format(vcpe_name))
1300 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1301 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1302 df.callback(0)
1303 reactor.callLater(0, vcpe_firewall, df)
1304 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001305
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001306 @deferred(TIMEOUT) #Fail
1307 def test_vsg_firewall_flushing_all_configured_rules(self,vcpe_name=None,vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001308 """
1309 Algo:
1310 1. Get vSG corresponding to vcpe
1311 2. Login to compute node
1312 3. Execute iptable command on vcpe from compute node to deny a destination IP
1313 4. From cord-tester ping to 8.8.8.8
1314 5. Verifying that ping should not be successful
1315 6. Execute iptable command on vcpe from compute node to deny icmp protocol packets
1316 7. From cord-tester ping to 8.8.8.8
1317 8. Verifying the ping should success
1318 9. Flush all the iptable rules configuraed in vcpe
1319 10. Delete the rule added in step 6
1320 11. From cord-tester ping to 8.8.8.8
1321 12. Verifying the ping should success
1322 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001323 if not vcpe_name:
1324 vcpe_name = self.vcpe_container
1325 if not vcpe_intf:
1326 vcpe_intf = self.vcpe_dhcp
1327 df = defer.Deferred()
1328 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001329 if self.on_podd is False:
1330 df.callback(0)
1331 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001332 host = '8.8.8.8'
1333 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1334 try:
1335 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1336 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1337 assert_equal(st, False)
1338 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -d {} -j DROP'.format(vcpe_name,host))
1339 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1340 assert_equal(st, True)
1341 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p icmp -j DROP'.format(vcpe_name))
1342 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1343 assert_equal(st, True)
1344 st,output = vsg.run_cmd('sudo docker exec {} iptables -F FORWARD'.format(vcpe_name))
1345 time.sleep(1)
1346 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1347 assert_equal(st, False)
1348 finally:
1349 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -d {} -j DROP'.format(vcpe_name,host))
1350 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1351 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1352 df.callback(0)
1353 reactor.callLater(0, vcpe_firewall, df)
1354 return df
Anil Kumar Sankad47023a2017-03-29 21:11:09 +00001355
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001356 @deferred(TIMEOUT)
1357 def test_vsg_firewall_deny_all_ipv4_traffic(self,vcpe_name=None,vcpe_intf=None):
Anil Kumar Sanka72755c92017-04-06 17:19:02 +00001358 """
1359 Algo:
1360 1. Get vSG corresponding to vcpe
1361 2. Login to compute node
1362 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic
1363 4. From cord-tester ping to 8.8.8.8
1364 5. Verifying that ping should not be successful
1365 6. Delete the iptable rule added
1366 7. From cord-tester ping to 8.8.8.8
1367 8. Verifying the ping should success
1368 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001369 if not vcpe_name:
1370 vcpe_name = self.vcpe_container
1371 if not vcpe_intf:
1372 vcpe_intf = self.vcpe_dhcp
1373 df = defer.Deferred()
1374 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001375 if self.on_podd is False:
1376 df.callback(0)
1377 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001378 host = '8.8.8.8'
1379 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1380 try:
1381 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1382 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1383 assert_equal(st, False)
1384 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
1385 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1386 assert_equal(st, True)
1387 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1388 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1389 assert_equal(st, False)
1390 finally:
1391 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1392 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1393 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1394 df.callback(0)
1395 reactor.callLater(0, vcpe_firewall, df)
1396 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001397
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001398 @deferred(TIMEOUT)
1399 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 +00001400 """
1401 Algo:
1402 1. Get vSG corresponding to vcpe
1403 2. Login to compute node
1404 3. Execute iptable command on vcpe from compute node to deny all ipv4 Traffic
1405 4. From cord-tester ping to 8.8.8.8
1406 5. Verifying that ping should not be successful
1407 6. Replace the deny rule added in step 3 with accept rule
1408 7. From cord-tester ping to 8.8.8.8
1409 8. Verifying the ping should success
1410 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001411 if not vcpe_name:
1412 vcpe_name = self.vcpe_container
1413 if not vcpe_intf:
1414 vcpe_intf = self.vcpe_dhcp
1415 df = defer.Deferred()
1416 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001417 if self.on_podd is False:
1418 df.callback(0)
1419 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001420 host = '8.8.8.8'
1421 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1422 try:
1423 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1424 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1425 assert_equal(st, False)
1426 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
1427 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1428 assert_equal(st, True)
1429 st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -4 -j ACCEPT'.format(vcpe_name))
1430 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1431 assert_equal(st, False)
1432 finally:
1433 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1434 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1435 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1436 df.callback(0)
1437 reactor.callLater(0, vcpe_firewall, df)
1438 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001439
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001440 @deferred(TIMEOUT)
1441 def test_vsg_firewall_deny_all_traffic_coming_on_lan_interface_in_vcpe(self,vcpe_name=None,vcpe_intf=None):
1442 """
1443 Algo:
1444 1. Get vSG corresponding to vcpe
1445 2. Login to compute node
1446 3. Execute iptable command on vcpe from compute node to deny all the traffic coming on lan interface inside vcpe container
1447 4. From cord-tester ping to 8.8.8.8
1448 5. Verifying the ping should not success
1449 6. Delete the iptable rule added
1450 7. From cord-tester ping to 8.8.8.8
1451 8. Verifying the ping should success
1452 """
1453 if not vcpe_name:
1454 vcpe_name = self.vcpe_container
1455 if not vcpe_intf:
1456 vcpe_intf = self.vcpe_dhcp
1457 df = defer.Deferred()
1458 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001459 if self.on_podd is False:
1460 df.callback(0)
1461 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001462 host = '8.8.8.8'
1463 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1464 try:
1465 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1466 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1467 assert_equal(st, False)
1468 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -j DROP'.format(vcpe_name))
1469 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1470 assert_equal(st, True)
1471 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name))
1472 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1473 assert_equal(st, False)
1474 finally:
1475 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -j DROP'.format(vcpe_name))
1476 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1477 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1478 df.callback(0)
1479 reactor.callLater(0, vcpe_firewall, df)
1480 return df
1481
1482 @deferred(TIMEOUT)
1483 def test_vsg_firewall_deny_all_traffic_going_out_of_wan_interface_in_vcpe(self,vcpe_name=None,vcpe_intf=None):
1484 """
1485 Algo:
1486 1. Get vSG corresponding to vcpe
1487 2. Login to compute node
1488 3. Execute iptable command on vcpe from compute node to deny all the traffic going out of wan interface inside vcpe container
1489 4. From cord-tester ping to 8.8.8.8
1490 5. Verifying the ping should not success
1491 6. Delete the iptable rule added
1492 7. From cord-tester ping to 8.8.8.8
1493 8. Verifying the ping should success
1494 """
1495 if not vcpe_name:
1496 vcpe_name = self.vcpe_container
1497 if not vcpe_intf:
1498 vcpe_intf = self.vcpe_dhcp
1499 df = defer.Deferred()
1500 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001501 if self.on_podd is False:
1502 df.callback(0)
1503 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001504 host = '8.8.8.8'
1505 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1506 try:
1507 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1508 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1509 assert_equal(st, False)
1510 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -o eth0 -j DROP'.format(vcpe_name))
1511 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1512 assert_equal(st, True)
1513 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name))
1514 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1515 assert_equal(st, False)
1516 finally:
1517 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -o eth0 -j DROP'.format(vcpe_name))
1518 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1519 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1520 df.callback(0)
1521 reactor.callLater(0, vcpe_firewall, df)
1522 return df
1523
1524 @deferred(TIMEOUT)
1525 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 +00001526 """
1527 Algo:
1528 1. Get vSG corresponding to vcpe
1529 2. Login to compute node
1530 3. Execute iptable command on vcpe from compute node to deny all the traffic from lan to wan interface in vcpe
1531 4. From cord-tester ping to 8.8.8.8
1532 5. Verifying that ping should not be successful
1533 6. Delete the iptable rule added
1534 7. From cord-tester ping to 8.8.8.8
1535 8. Verifying the ping should success
1536 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001537 if not vcpe_name:
1538 vcpe_name = self.vcpe_container
1539 if not vcpe_intf:
1540 vcpe_intf = self.vcpe_dhcp
1541 df = defer.Deferred()
1542 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001543 if self.on_podd is False:
1544 df.callback(0)
1545 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001546 host = '8.8.8.8'
1547 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1548 try:
1549 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1550 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1551 assert_equal(st, False)
1552 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
1553 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1554 assert_equal(st, True)
1555 st,output = vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
1556 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1557 assert_equal(st, False)
1558 finally:
1559 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -i eth1 -o eth0 -j DROP'.format(vcpe_name))
1560 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1561 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1562 df.callback(0)
1563 reactor.callLater(0, vcpe_firewall, df)
1564 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001565
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001566
1567 #this test case needs modification.default route should be vcpe interface to run this test case
1568 @deferred(TIMEOUT)
1569 def test_vsg_firewall_deny_all_dns_traffic(self,vcpe_name=None,vcpe_intf=None):
1570 """
1571 Algo:
1572 1. Get vSG corresponding to vcpe
1573 2. Login to compute node
1574 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
1575 4. From cord-tester ping to www.google.com
1576 5. Verifying the ping should not success
1577 6. Delete the iptable rule added
1578 7. From cord-tester ping to www.google.com
1579 8. Verifying the ping should success
1580 """
1581 if not vcpe_name:
1582 vcpe_name = self.vcpe_container
1583 if not vcpe_intf:
1584 vcpe_intf = self.vcpe_dhcp
1585 df = defer.Deferred()
1586 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001587 if self.on_podd is False:
1588 df.callback(0)
1589 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001590 host = 'www.msn.com'
1591 host_ip = '131.253.33.203'
1592 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1593 try:
1594 self.add_static_route_via_vcpe_interface([host_ip],vcpe=self.vcpe_dhcp)
1595 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1596 assert_equal(st, False)
1597 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
1598 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1599 assert_equal(st, True)
1600 st,output = vsg.run_cmd('sudo docker exec {} iptables -R FORWARD 1 -p udp --dport 53 -j ACCEPT'.format(vcpe_name))
1601 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1602 assert_equal(st, False)
1603 finally:
1604 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -p udp --dport 53 -j DROP'.format(vcpe_name))
1605 self.del_static_route_via_vcpe_interface([host_ip],vcpe=vcpe_intf)
1606 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1607 df.callback(0)
1608 reactor.callLater(0, vcpe_firewall, df)
1609 return df
1610
1611 @deferred(TIMEOUT)
1612 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 +00001613 """
1614 Algo:
1615 1. Get vSG corresponding to vcpe
1616 2. Login to compute node
1617 3. Execute iptable command on vcpe from compute node to deny all dns Traffic
1618 4. From cord-tester ping to www.google.com
1619 5. Verifying that ping should not be successful
1620 6. Delete the iptable rule added
1621 7. From cord-tester ping to www.google.com
1622 8. Verifying the ping should success
1623 """
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001624 if not vcpe_name:
1625 vcpe_name = self.vcpe_container
1626 if not vcpe_intf:
1627 vcpe_intf = self.vcpe_dhcp
1628 df = defer.Deferred()
1629 def vcpe_firewall(df):
A R Karthick93ba8d02017-04-13 11:59:58 -07001630 if self.on_podd is False:
1631 df.callback(0)
1632 return
Anil Kumar Sankaa357c6a2017-04-12 17:52:24 +00001633 host = '8.8.8.8'
1634 vsg = VSGAccess.get_vcpe_vsg(vcpe_name)
1635 try:
1636 self.add_static_route_via_vcpe_interface([host],vcpe=self.vcpe_dhcp)
1637 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
1638 assert_equal(st, False)
1639 st,output = vsg.run_cmd('sudo docker exec {} iptables -I FORWARD -4 -j DROP'.format(vcpe_name))
1640 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1641 assert_equal(st, True)
1642 st,output = vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1643 time.sleep(3)
1644 st,_ = getstatusoutput('ping -c 1 {}'.format(host))
1645 assert_equal(st, False)
1646 finally:
1647 vsg.run_cmd('sudo docker exec {} iptables -D FORWARD -4 -j DROP'.format(vcpe_name))
1648 self.del_static_route_via_vcpe_interface([host],vcpe=vcpe_intf)
1649 vsg.run_cmd('sudo docker restart {}'.format(vcpe_name))
1650 df.callback(0)
1651 reactor.callLater(0, vcpe_firewall, df)
1652 return df
Anil Kumar Sanka966c1932017-03-31 00:48:31 +00001653
A.R Karthick282f0d32017-03-28 16:43:59 -07001654 def test_vsg_xos_subscriber(self):
A R Karthick93ba8d02017-04-13 11:59:58 -07001655 if self.on_podd is False:
1656 return
A.R Karthick282f0d32017-03-28 16:43:59 -07001657 subscriber_info = self.subscriber_info[0]
1658 volt_subscriber_info = self.volt_subscriber_info[0]
1659 result = self.restApiXos.ApiPost('TENANT_SUBSCRIBER', subscriber_info)
1660 assert_equal(result, True)
1661 result = self.restApiXos.ApiGet('TENANT_SUBSCRIBER')
1662 assert_not_equal(result, None)
1663 subId = self.restApiXos.getSubscriberId(result, volt_subscriber_info['account_num'])
1664 assert_not_equal(subId, '0')
1665 log.info('Subscriber ID for account num %d = %s' %(volt_subscriber_info['account_num'], subId))
1666 volt_tenant = volt_subscriber_info['voltTenant']
1667 #update the subscriber id in the tenant info before making the rest
1668 volt_tenant['subscriber'] = subId
1669 result = self.restApiXos.ApiPost('TENANT_VOLT', volt_tenant)
1670 assert_equal(result, True)
1671
Chetan Gaonker52418832017-01-26 23:03:13 +00001672 def test_vsg_for_dns_service(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001673 """
1674 Algo:
1675 1. Create a test client in Prod VM
1676 2. Create a vCPE container in vSG VM inside compute Node
1677 3. Ensure vSG VM and vCPE container created properly
1678 4. Enable dns service in vCPE ( if not by default )
1679 5. Send ping request from test client to valid domain address say, 'www.google'com
1680 6. Verify that dns should resolve ping should success
1681 7. Now send ping request to invalid domain address say 'www.invalidaddress'.com'
1682 8. Verify that dns resolve should fail and hence ping
1683 """
A R Karthick63751492017-03-22 09:28:01 -07001684
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001685 def test_vsg_for_10_subscribers_for_same_service(self):
1686 """
1687 Algo:
1688 1.Create a vSG VM in compute node
1689 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
1690 3.Ensure vSG VM and vCPE container created properly
1691 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP
1692 5.Verify that ping success for all 10 subscribers
1693 """
A R Karthick63751492017-03-22 09:28:01 -07001694
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001695 def test_vsg_for_10_subscribers_for_same_service_ping_invalid_ip(self):
1696 """
1697 Algo:
1698 1.Create a vSG VM in compute Node
1699 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
1700 3.Ensure vSG VM and vCPE container created properly
1701 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP
1702 5.Verify that ping fails for all 10 subscribers
1703 """
A R Karthick63751492017-03-22 09:28:01 -07001704
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001705 def test_vsg_for_10_subscribers_for_same_service_ping_valid_and_invalid_ip(self):
1706 """
1707 Algo:
1708 1.Create a vSG VM in VM
1709 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
1710 3.Ensure vSG VM and vCPE container created properly
1711 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP
1712 5.Verify that ping success for all 5 subscribers
1713 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP
1714 7.Verify that ping fails for all 5 subscribers
1715 """
A R Karthick63751492017-03-22 09:28:01 -07001716
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001717 def test_vsg_for_100_subscribers_for_same_service(self):
1718 """
1719 Algo:
1720 1.Create a vSG VM in compute node
1721 2.Create 100 vCPE containers for 100 subscribers, in vSG VM
1722 3.Ensure vSG VM and vCPE container created properly
1723 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP
1724 5.Verify that ping success for all 100 subscribers
1725 """
A R Karthick63751492017-03-22 09:28:01 -07001726
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001727 def test_vsg_for_100_subscribers_for_same_service_ping_invalid_ip(self):
1728 """
1729 Algo:
1730 1.Create a vSG VM in compute Node
1731 2.Create 10 vCPE containers for 100 subscribers, in vSG VM
1732 3.Ensure vSG VM and vCPE container created properly
1733 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP
1734 5.Verify that ping fails for all 100 subscribers
1735 """
A R Karthick63751492017-03-22 09:28:01 -07001736
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001737 def test_vsg_for_100_subscribers_for_same_service_ping_valid_and_invalid_ip(self):
1738 """
1739 Algo:
1740 1.Create a vSG VM in VM
1741 2.Create 10 vCPE containers for 100 subscribers, in vSG VM
1742 3.Ensure vSG VM and vCPE container created properly
1743 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP
1744 5.Verify that ping success for all 5 subscribers
1745 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP
1746 7.Verify that ping fails for all 5 subscribers
1747 """
A R Karthick63751492017-03-22 09:28:01 -07001748
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001749 def test_vsg_for_packet_received_with_invalid_ip_fields(self):
1750 """
1751 Algo:
1752 1.Create a vSG VM in compute node
1753 2.Create a vCPE container in vSG VM
1754 3.Ensure vSG VM and vCPE container created properly
1755 4.From subscriber, send a ping packet with invalid ip fields
1756 5.Verify that vSG drops the packet
1757 6.Verify ping fails
1758 """
A R Karthick63751492017-03-22 09:28:01 -07001759
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001760 def test_vsg_for_packet_received_with_invalid_mac_fields(self):
1761 """
1762 Algo:
1763 1.Create a vSG VM in compute node
1764 2.Create a vCPE container in vSG VM
1765 3.Ensure vSG VM and vCPE container created properly
1766 4.From subscriber, send a ping packet with invalid mac fields
1767 5.Verify that vSG drops the packet
1768 6.Verify ping fails
1769 """
A R Karthick63751492017-03-22 09:28:01 -07001770
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001771 def test_vsg_for_vlan_id_mismatch_in_stag(self):
1772 """
1773 Algo:
1774 1.Create a vSG VM in compute Node
1775 2.Create a vCPE container in vSG VM
1776 3.Ensure vSG VM and vCPE container created properly
1777 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag
1778 5.Verify that ping fails as the packet drops at VM entry
1779 6.Repeat step 4 with correct s-tag
1780 7.Verify that ping success
1781 """
A R Karthick63751492017-03-22 09:28:01 -07001782
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001783 def test_vsg_for_vlan_id_mismatch_in_ctag(self):
1784 """
1785 Algo:
1786 1.Create a vSG VM in compute node
1787 2.Create a vCPE container in vSG VM
1788 3.Ensure vSG VM and vCPE container created properly
1789 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag
1790 5.Verify that ping fails as the packet drops at vCPE container entry
1791 6.Repeat step 4 with valid s-tag and c-tag
1792 7.Verify that ping success
1793 """
A R Karthick63751492017-03-22 09:28:01 -07001794
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001795 def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self):
1796 """
1797 Algo:
1798 1.Create two vSG VMs in compute node
1799 2.Create a vCPE container in each vSG VM
1800 3.Ensure vSG VM and vCPE container created properly
1801 4.From subscriber one, send ping request with valid s and c tags
1802 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags
1803 6.Verify that ping success for only subscriber one and fails for two.
1804 """
A R Karthick63751492017-03-22 09:28:01 -07001805
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001806 def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self):
1807 """
1808 Algo:
1809 1.Create a vSG VM in compute node
1810 2.Create two vCPE containers in vSG VM
1811 3.Ensure vSG VM and vCPE container created properly
1812 4.From subscriber one, send ping request with valid s and c tags
1813 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag
1814 6.Verify that ping success for only subscriber one and fails for two
1815 """
A R Karthick63751492017-03-22 09:28:01 -07001816
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001817 def test_vsg_for_out_of_range_vlanid_in_ctag(self):
1818 """
1819 Algo:
1820 1.Create a vSG VM in compute node
1821 2.Create a vCPE container in vSG VM
1822 3.Ensure vSG VM and vCPE container created properly
1823 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 )
1824 4.Verify that ping fails as the ping packets drops at vCPE container entry
1825 """
A R Karthick63751492017-03-22 09:28:01 -07001826
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001827 def test_vsg_for_out_of_range_vlanid_in_stag(self):
1828 """
1829 Algo:
1830 1.Create a vSG VM in compute node
1831 2.Create a vCPE container in vSG VM
1832 3.Ensure vSG VM and vCPE container created properly
1833 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
1834 4.Verify that ping fails as the ping packets drops at vSG VM entry
1835 """
A R Karthick63751492017-03-22 09:28:01 -07001836
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001837 def test_vsg_without_creating_vcpe_instance(self):
1838 """
1839 Algo:
1840 1.Create a vSG VM in compute Node
1841 2.Ensure vSG VM created properly
1842 3.Do not create vCPE container inside vSG VM
1843 4.From a subscriber, send ping to external valid IP
1844 5.Verify that ping fails as the ping packet drops at vSG VM entry itself.
1845 """
A R Karthick63751492017-03-22 09:28:01 -07001846
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001847 def test_vsg_for_remove_vcpe_instance(self):
1848 """
1849 Algo:
1850 1.Create a vSG VM in compute node
1851 2.Create a vCPE container in vSG VM
1852 3.Ensure vSG VM and vCPE container created properly
1853 4.From subscriber, send ping request with valid s-tag and c-tag
1854 5.Verify that ping success
1855 6.Verify ping success flows in OvS switch in compute node
1856 7.Now remove the vCPE container in vSG VM
1857 8.Ensure that the container removed properly
1858 9.Repeat step 4
1859 10.Verify that now, ping fails
1860 """
A R Karthick63751492017-03-22 09:28:01 -07001861
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001862 def test_vsg_for_restart_vcpe_instance(self):
1863 """
1864 Algo:
1865 1.Create a vSG VM in compute node
1866 2.Create a vCPE container in vSG VM
1867 3.Ensure vSG VM and vCPE container created properly
1868 4.From subscriber, send ping request with valid s-tag and c-tag
1869 5.Verify that ping success
1870 6.Verify ping success flows in OvS switch in compute node
1871 7.Now restart the vCPE container in vSG VM
1872 8.Ensure that the container came up after restart
1873 9.Repeat step 4
1874 10.Verify that now,ping gets success and flows added in OvS
1875 """
A R Karthick63751492017-03-22 09:28:01 -07001876
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001877 def test_vsg_for_restart_vsg_vm(self):
1878 """
1879 Algo:
1880 1.Create a vSG VM in compute node
1881 2.Create a vCPE container in vSG VM
1882 3.Ensure vSG VM and vCPE container created properly
1883 4.From subscriber, send ping request with valid s-tag and c-tag
1884 5.Verify that ping success
1885 6.Verify ping success flows in OvS switch in compute node
1886 7.Now restart the vSG VM
1887 8.Ensure that the vSG comes up properly after restart
1888 9.Verify that vCPE container comes up after vSG restart
1889 10.Repeat step 4
1890 11.Verify that now,ping gets success and flows added in OvS
1891 """
A R Karthick63751492017-03-22 09:28:01 -07001892
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001893 def test_vsg_for_pause_vcpe_instance(self):
1894 """
1895 Algo:
1896 1.Create a vSG VM in compute node
1897 2.Create a vCPE container in vSG VM
1898 3.Ensure vSG VM and vCPE container created properly
1899 4.From subscriber, send ping request with valid s-tag and c-tag
1900 5.Verify that ping success
1901 6.Verify ping success flows in OvS switch in compute node
1902 7.Now pause vCPE container in vSG VM for a while
1903 8.Ensure that the container state is pause
1904 9.Repeat step 4
1905 10.Verify that now,ping fails now and verify flows in OvS
1906 11.Now resume the container
1907 12.Now repeat step 4 again
1908 13.Verify that now, ping gets success
1909 14.Verify ping success flows in OvS
1910 """
A R Karthick63751492017-03-22 09:28:01 -07001911
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001912 def test_vsg_for_extract_all_compute_stats_from_all_vcpe_containers(self):
1913 """
1914 Algo:
1915 1.Create a vSG VM in compute node
1916 2.Create 10 vCPE containers in VM
1917 3.Ensure vSG VM and vCPE containers created properly
1918 4.Login to all vCPE containers
1919 4.Get all compute stats from all vCPE containers
1920 5.Verify the stats # verification method need to add
1921 """
A R Karthick63751492017-03-22 09:28:01 -07001922
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001923 def test_vsg_for_extract_dns_stats_from_all_vcpe_containers(self):
1924 """
1925 Algo:
1926 1.Create a vSG VM in compute node
1927 2.Create 10 vCPE containers in VM
1928 3.Ensure vSG VM and vCPE containers created properly
1929 4.From 10 subscribers, send ping to valid and invalid dns hosts
1930 5.Verify dns resolves and ping success for valid dns hosts
1931 6.Verify ping fails for invalid dns hosts
1932 7.Verify dns host name resolve flows in OvS
1933 8.Login to all 10 vCPE containers
1934 9.Extract all dns stats
1935 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios
1936 """
A R Karthick63751492017-03-22 09:28:01 -07001937
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001938 def test_vsg_for_subscriber_access_two_vsg_services(self):
1939 """
1940 # Intention is to verify if subscriber can reach internet via two vSG VMs
1941 Algo:
1942 1.Create two vSG VMs for two services in compute node
1943 2.Create one vCPE container in each VM for one subscriber
1944 3.Ensure VMs and containers created properly
1945 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
1946 5.Verify ping gets success
1947 6.Verify ping success flows in OvS
1948 7.Now repeat step 4 with stag corresponds to vSG-2 VM
1949 8.Verify that ping again success
1950 9.Verify ping success flows in OvS
1951 """
A R Karthick63751492017-03-22 09:28:01 -07001952
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001953 def test_vsg_for_subscriber_access_service2_if_service1_goes_down(self):
1954 """
1955 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down
1956 Algo:
1957 1.Create two vSG VMs for two services in compute node
1958 2.Create one vCPE container in each VM for one subscriber
1959 3.Ensure VMs and containers created properly
1960 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
1961 5.Verify ping gets success
1962 6.Verify ping success flows in OvS
1963 7.Down the vSG-1 VM
1964 8.Now repeat step 4
1965 9.Verify that ping fails as vSG-1 is down
1966 10.Repeat step 4 with stag corresponding to vSG-2
1967 9.Verify ping success and flows added in OvS
1968 """
A R Karthick63751492017-03-22 09:28:01 -07001969
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001970 def test_vsg_for_subscriber_access_service2_if_service1_goes_restart(self):
1971 """
1972 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts
1973 Algo:
1974 1.Create two vSG VMs for two services in compute node
1975 2.Create one vCPE container in each VM for one subscriber
1976 3.Ensure VMs and containers created properly
1977 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
1978 5.Verify ping gets success
1979 6.Verify ping success flows added in OvS
1980 7.Now restart vSG-1 VM
1981 8.Now repeat step 4 while vSG-1 VM restarts
1982 9.Verify that ping fails as vSG-1 is restarting
1983 10.Repeat step 4 with stag corresponding to vSG-2 while vSG-1 VM restarts
1984 11.Verify ping success and flows added in OvS
1985 """
A R Karthick63751492017-03-22 09:28:01 -07001986
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00001987 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_goes_down(self):
1988 """
1989 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down
1990 Algo:
1991 1.Create a vSG VM in compute node
1992 2.Create two vCPE containers corresponds to two subscribers in vSG VM
1993 3.Ensure VM and containers created properly
1994 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
1995 5.Verify ping gets success
1996 6.Verify ping success flows added in OvS
1997 7.Now stop vCPE-1 container
1998 8.Now repeat step 4
1999 9.Verify that ping fails as vCPE-1 container is down
2000 10.Repeat step 4 with ctag corresponding to vCPE-2 container
2001 11.Verify ping success and flows added in OvS
2002 """
A R Karthick63751492017-03-22 09:28:01 -07002003
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002004 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_restart(self):
2005 """
2006 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts
2007 Algo:
2008 1.Create a vSG VM in compute node
2009 2.Create two vCPE containers corresponds to two subscribers in vSG VM
2010 3.Ensure VM and containers created properly
2011 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
2012 5.Verify ping gets success
2013 6.Verify ping success flows added in OvS
2014 7.Now restart vCPE-1 container
2015 8.Now repeat step 4 while vCPE-1 restarts
2016 9.Verify that ping fails as vCPE-1 container is restarts
2017 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 restarts
2018 11..Verify ping success and flows added in OvS
2019 """
A R Karthick63751492017-03-22 09:28:01 -07002020
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002021 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_pause(self):
2022 """
2023 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 paused
2024 Algo:
2025 1.Create a vSG VM in compute node
2026 2.Create two vCPE containers corresponds to two subscribers in vSG VM
2027 3.Ensure VM and containers created properly
2028 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
2029 5.Verify ping gets success
2030 6.Verify ping success flows added in OvS
2031 7.Now pause vCPE-1 container
2032 8.Now repeat step 4 while vCPE-1 in pause state
2033 9.Verify that ping fails as vCPE-1 container in pause state
2034 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 in pause state
2035 11.Verify ping success and flows added in OvS
2036 """
2037 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_removed(self):
2038 """
2039 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 removed
2040 Algo:
2041 1.Create a vSG VM in compute node
2042 2.Create two vCPE containers corresponds to two subscribers in vSG VM
2043 3.Ensure VM and containers created properly
2044 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
2045 5.Verify ping gets success
2046 6.Verify ping success flows added in OvS
2047 7.Now remove vCPE-1 container
2048 8.Now repeat step 4
2049 9.Verify that ping fails as vCPE-1 container removed
2050 10.Repeat step 4 with ctag corresponding to vCPE-2 container
2051 11.Verify ping success and flows added in OvS
2052 """
A R Karthick63751492017-03-22 09:28:01 -07002053
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002054 def test_vsg_for_vcpe_instance_removed_and_added_again(self):
2055 """
2056 Algo:
2057 1.Create a vSG VM in compute node
2058 2.Create a vCPE container in vSG VM
2059 3.Ensure VM and containers created properly
2060 4.From subscriber end, send ping to public IP
2061 5.Verify ping gets success
2062 6.Verify ping success flows added in OvS
2063 7.Now remove vCPE container in vSG VM
2064 8.Now repeat step 4
2065 9.Verify that ping fails as vCPE container removed
2066 10.Create the vCPE container again for the same subscriber
2067 11.Ensure that vCPE created now
2068 12.Now repeat step 4
2069 13.Verify ping success and flows added in OvS
2070 """
A R Karthick63751492017-03-22 09:28:01 -07002071
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +00002072 def test_vsg_for_vsg_vm_removed_and_added_again(self):
2073 """
2074 Algo:
2075 1.Create a vSG VM in compute node
2076 2.Create a vCPE container in vSG VM
2077 3.Ensure VM and containers created properly
2078 4.From subscriber end, send ping to public IP
2079 5.Verify ping gets success
2080 6.Verify ping success flows added in OvS
2081 7.Now remove vSG VM
2082 8.Now repeat step 4
2083 9.Verify that ping fails as vSG VM not exists
2084 10.Create the vSG VM and vCPE container in VM again
2085 11.Ensure that vSG and vCPE created
2086 12.Now repeat step 4
2087 13.Verify ping success and flows added in OvS
2088 """
2089
2090 #Test vSG - Subscriber Configuration
2091 def test_vsg_for_configuring_new_subscriber_in_vcpe(self):
2092 """
2093 Algo:
2094 1.Create a vSG VM in compute node
2095 2.Create a vCPE container in vSG VM
2096 3.Ensure VM and containers created properly
2097 4.Configure a subscriber in XOS and assign a service id
2098 5.Set the admin privileges to the subscriber
2099 6.Verify subscriber configuration is success
2100 """
2101 def test_vsg_for_adding_subscriber_devices_in_vcpe(self):
2102 """
2103 Algo:
2104 1.Create a vSG VM in compute node
2105 2.Create a vCPE container in vSG VM
2106 3.Ensure VM and containers created properly
2107 4.Configure a subscriber in XOS and assign a service id
2108 5.Verify subscriber successfully configured in vCPE
2109 6.Now add devices( Mac addresses ) under the subscriber admin group
2110 7.Verify all devices ( Macs ) added successfully
2111 """
2112 def test_vsg_for_removing_subscriber_devices_in_vcpe(self):
2113 """
2114 Algo:
2115 1.Create a vSG VM in compute node
2116 2.Create a vCPE container in vSG VM
2117 3.Ensure VM and containers created properly
2118 4.Configure a subscriber in XOS and assign a service id
2119 5.Verify subscriber successfully configured
2120 6.Now add devices( Mac addresses ) under the subscriber admin group
2121 7.Verify all devices ( Macs ) added successfully
2122 8.Now remove All the added devices in XOS
2123 9.Verify all the devices removed
2124 """
2125 def test_vsg_for_modify_subscriber_devices_in_vcpe(self):
2126 """
2127 Algo:
2128 1.Create a vSG VM in compute node
2129 2.Create a vCPE container in vSG VM
2130 3.Ensure VM and containers created properly
2131 4.Configure a user in XOS and assign a service id
2132 5.Verify subscriber successfully configured in vCPE.
2133 6.Now add devices( Mac addresses ) under the subscriber admin group
2134 7.Verify all devices ( Macs ) added successfully
2135 8.Now remove few devices in XOS
2136 9.Verify devices removed successfully
2137 10.Now add few additional devices in XOS under the same subscriber admin group
2138 11.Verify newly added devices successfully added
2139 """
2140 def test_vsg_for_vcpe_login_fails_with_incorrect_subscriber_credentials(self):
2141 """
2142 Algo:
2143 1.Create a vSG VM in compute node
2144 2.Create a vCPE container in vSG VM
2145 3.Ensure VM and containers created properly
2146 4.Configure a subscriber in XOS and assign a service id
2147 5.Verify subscriber successfully configured
2148 6.Now add devices( Mac addresses ) under the subscriber admin group
2149 7.Verify all devices ( Macs ) added successfully
2150 8.Login vCPE with credentials with which subscriber configured
2151 9.Verify subscriber successfully logged in
2152 10.Logout and login again with incorrect credentials ( either user name or password )
2153 11.Verify login attempt to vCPE fails wtih incorrect credentials
2154 """
2155 def test_vsg_for_subscriber_configuration_in_vcpe_retain_after_vcpe_restart(self):
2156 """
2157 Algo:
2158 1.Create a vSG VM in compute node
2159 2.Create a vCPE container in vSG VM
2160 3.Ensure VM and containers created properly
2161 4.Configure a subscriber in XOS and assign a service id
2162 5.Verify subscriber successfully configured
2163 6.Now add devices( Mac addresses ) under the subscriber admin group
2164 7.Verify all devices ( Macs ) added successfully
2165 8.Restart vCPE ( locate backup config path while restart )
2166 9.Verify subscriber details in vCPE after restart should be same as before the restart
2167 """
2168 def test_vsg_for_create_multiple_vcpe_instances_and_configure_subscriber_in_each_instance(self):
2169 """
2170 Algo:
2171 1.Create a vSG VM in compute node
2172 2.Create 2 vCPE containers in vSG VM
2173 3.Ensure VM and containers created properly
2174 4.Configure a subscriber in XOS for each vCPE instance and assign a service id
2175 5.Verify subscribers successfully configured
2176 6.Now login vCPE-2 with subscriber-1 credentials
2177 7.Verify login fails
2178 8.Now login vCPE-1 with subscriber-2 credentials
2179 9.Verify login fails
2180 10.Now login vCPE-1 with subscriber-1 and vCPE-2 with subscriber-2 credentials
2181 11.Verify that both the subscribers able to login to their respective vCPE containers
2182 """
2183 def test_vsg_for_same_subscriber_can_be_configured_for_multiple_services(self):
2184 """
2185 Algo:
2186 1.Create 2 vSG VMs in compute node
2187 2.Create a vCPE container in each vSG VM
2188 3.Ensure VMs and containers created properly
2189 4.Configure same subscriber in XOS for each vCPE instance and assign a service id
2190 5.Verify subscriber successfully configured
2191 6.Now login vCPE-1 with subscriber credentials
2192 7.Verify login success
2193 8.Now login vCPE-2 with the same subscriber credentials
2194 9.Verify login success
2195 """
2196
2197 #Test Example Service
2198 def test_vsg_for_subcriber_avail_example_service_running_in_apache_server(self):
2199 """
2200 Algo:
2201 1.Create a vSG VM in compute node
2202 2.Create a vCPE container in each vSG VM
2203 3.Ensure VM and container created properly
2204 4.Configure a subscriber in XOS for the vCPE instance and assign a service id
2205 5.On-board an example service into cord pod
2206 6.Create a VM in compute node and run the example service ( Apache server )
2207 7.Configure the example service with service specific and subscriber specific messages
2208 8.Verify example service on-boarded successfully
2209 9.Verify example service running in VM
2210 10.Run a curl command from subscriber to reach example service
2211 11.Verify subscriber can successfully reach example service via vSG
2212 12.Verify that service specific and subscriber specific messages
2213 """
2214 def test_vsg_for_subcriber_avail_example_service_running_in_apache_server_after_service_restart(self):
2215 """
2216 Algo:
2217 1.Create a vSG VM in compute node
2218 2.Create a vCPE container in each vSG VM
2219 3.Ensure VM and container created properly
2220 4.Configure a subscriber in XOS for the vCPE instance and assign a service id
2221 5.On-board an example service into cord pod
2222 6.Create a VM in compute node and run the example service ( Apache server )
2223 7.Configure the example service with service specific and subscriber specific messages
2224 8.Verify example service on-boarded successfully
2225 9.Verify example service running in VM
2226 10.Run a curl command from subscriber to reach example service
2227 11.Verify subscriber can successfully reach example service via vSG
2228 12.Verify that service specific and subscriber specific messages
2229 13.Restart example service running in VM
2230 14.Repeat step 10
2231 15.Verify the same results as mentioned in steps 11, 12
2232 """
2233
2234 #vCPE Firewall Functionality
2235 def test_vsg_firewall_for_creating_acl_rule_based_on_source_ip(self):
2236 """
2237 Algo:
2238 1.Create a vSG VM in compute node
2239 2.Create vCPE container in the VM
2240 3.Ensure vSG VM and vCPE container created properly
2241 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP
2242 5.Bound the acl rule to WAN interface of vCPE
2243 6.Verify configuration in vCPE is success
2244 8.Verify flows added in OvS
2245 """
2246 def test_vsg_firewall_for_creating_acl_rule_based_on_destination_ip(self):
2247 """
2248 Algo:
2249 1.Create a vSG VM in compute node
2250 2.Create vCPE container in the VM
2251 3.Ensure vSG VM and vCPE container created properly
2252 4.Configure ac acl rule in vCPE to deny IP traffic to a destination ip
2253 5.Bound the acl rule to WAN interface of vCPE
2254 6.Verify configuration in vCPE is success
2255 8.Verify flows added in OvS
2256 """
2257 def test_vsg_firewall_for_acl_deny_rule_based_on_source_ip_traffic(self):
2258 """
2259 Algo:
2260 1.Create a vSG VM in compute node
2261 2.Create vCPE container in the VM
2262 3.Ensure vSG VM and vCPE container created properly
2263 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP
2264 5.Bound the acl rule to WAN interface of vCPE
2265 6.From subscriber, send ping to the denied IP address
2266 7.Verify that ping fails as vCPE denies ping response
2267 8.Verify flows added in OvS
2268 """
2269 def test_vsg_firewall_for_acl_deny_rule_based_on_destination_ip_traffic(self):
2270 """
2271 Algo:
2272 1.Create a vSG VM in compute node
2273 2.Create vCPE container in the VM
2274 3.Ensure vSG VM and vCPE container created properly
2275 4.Configure ac acl rule in vCPE to deny IP traffic to a destination IP
2276 5.Bound the acl rule to WAN interface of vCPE
2277 6.From subscriber, send ping to the denied IP address
2278 7.Verify that ping fails as vCPE drops the ping request at WAN interface
2279 8.Verify flows added in OvS
2280 """
Chetan Gaonker52418832017-01-26 23:03:13 +00002281
2282 def test_vsg_dnsmasq(self):
2283 pass
2284
2285 def test_vsg_with_external_parental_control_family_shield_for_filter(self):
2286 pass
2287
2288 def test_vsg_with_external_parental_control_with_answerx(self):
2289 pass
2290
2291 def test_vsg_for_subscriber_upstream_bandwidth(self):
2292 pass
2293
2294 def test_vsg_for_subscriber_downstream_bandwidth(self):
2295 pass
2296
2297 def test_vsg_for_diagnostic_run_of_traceroute(self):
2298 pass
2299
2300 def test_vsg_for_diagnostic_run_of_tcpdump(self):
2301 pass
2302
2303 def test_vsg_for_iptable_rules(self):
2304 pass
2305
2306 def test_vsg_for_iptables_with_neutron(self):
2307 pass