blob: a5b26b496745763da44fe8f0f5884ae252c3bce4 [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
Chetan Gaonker52418832017-01-26 23:03:13 +000017from nose.tools import *
18from scapy.all import *
A.R Karthick33cfdbe2017-03-17 18:03:48 -070019from CordTestUtils import *
Chetan Gaonker52418832017-01-26 23:03:13 +000020from OltConfig import OltConfig
Chetan Gaonker52418832017-01-26 23:03:13 +000021from onosclidriver import OnosCliDriver
A.R Karthick9ccd0d02017-03-16 17:11:08 -070022from SSHTestAgent import SSHTestAgent
Chetan Gaonker52418832017-01-26 23:03:13 +000023from CordLogger import CordLogger
A R Karthickd0fdf3b2017-03-21 16:54:22 -070024from VSGAccess import VSGAccess
25
Chetan Gaonker52418832017-01-26 23:03:13 +000026log.setLevel('INFO')
27
28class vsg_exchange(CordLogger):
29 ONOS_INSTANCES = 3
30 V_INF1 = 'veth0'
31 device_id = 'of:' + get_mac()
Chetan Gaonker52418832017-01-26 23:03:13 +000032 TEST_IP = '8.8.8.8'
33 HOST = "10.1.0.1"
34 USER = "vagrant"
35 PASS = "vagrant"
A.R Karthick9ccd0d02017-03-16 17:11:08 -070036 head_node = os.environ['HEAD_NODE']
37 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
A R Karthick03f40aa2017-03-20 19:33:55 -070038 test_path = os.path.dirname(os.path.realpath(__file__))
39 olt_conf_file = os.path.join(test_path, '..', 'setup/olt_config.json')
Chetan Gaonker52418832017-01-26 23:03:13 +000040
A.R Karthick33cfdbe2017-03-17 18:03:48 -070041 @classmethod
42 def setUpClass(cls):
43 cls.controllers = get_controllers()
44 cls.controller = cls.controllers[0]
45 cls.cli = None
A R Karthick03f40aa2017-03-20 19:33:55 -070046 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
47 cls.vcpes = cls.olt.get_vcpes()
48 cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp')
49 vcpe_dhcp = None
50 vcpe_dhcp_stag = None
51 vcpe_container = None
52 #cache the first dhcp vcpe in the class for quick testing
53 if cls.vcpes_dhcp:
54 vcpe_container = 'vcpe-{}-{}'.format(cls.vcpes_dhcp[0]['s_tag'], cls.vcpes_dhcp[0]['c_tag'])
55 vcpe_dhcp = 'vcpe0.{}.{}'.format(cls.vcpes_dhcp[0]['s_tag'], cls.vcpes_dhcp[0]['c_tag'])
56 vcpe_dhcp_stag = 'vcpe0.{}'.format(cls.vcpes_dhcp[0]['s_tag'])
57 cls.vcpe_container = vcpe_container
58 cls.vcpe_dhcp = vcpe_dhcp
59 cls.vcpe_dhcp_stag = vcpe_dhcp_stag
A R Karthickd0fdf3b2017-03-21 16:54:22 -070060 VSGAccess.setUp()
Chetan Gaonker52418832017-01-26 23:03:13 +000061
A.R Karthick33cfdbe2017-03-17 18:03:48 -070062 @classmethod
63 def tearDownClass(cls):
A R Karthickd0fdf3b2017-03-21 16:54:22 -070064 VSGAccess.tearDown()
Chetan Gaonker52418832017-01-26 23:03:13 +000065
Chetan Gaonker52418832017-01-26 23:03:13 +000066 def cliEnter(self, controller = None):
67 retries = 0
68 while retries < 30:
69 self.cli = OnosCliDriver(controller = controller, connect = True)
70 if self.cli.handle:
71 break
72 else:
73 retries += 1
74 time.sleep(2)
75
76 def cliExit(self):
77 self.cli.disconnect()
78
79 def onos_shutdown(self, controller = None):
80 status = True
81 self.cliEnter(controller = controller)
82 try:
83 self.cli.shutdown(timeout = 10)
84 except:
85 log.info('Graceful shutdown of ONOS failed for controller: %s' %controller)
86 status = False
87
88 self.cliExit()
89 return status
90
A.R Karthick9ccd0d02017-03-16 17:11:08 -070091 def log_set(self, level = None, app = 'org.onosproject'):
92 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
Chetan Gaonker52418832017-01-26 23:03:13 +000093
Chetan Gaonker52418832017-01-26 23:03:13 +000094 def test_vsg_vm(self):
A R Karthickd0fdf3b2017-03-21 16:54:22 -070095 status = VSGAccess.health_check()
96 assert_equal(status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +000097
98 def test_vsg_for_default_route_to_vsg_vm(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -070099 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
Chetan Gaonker52418832017-01-26 23:03:13 +0000100 cmd = "sudo lxc exec testclient -- route | grep default"
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700101 status, output = ssh_agent.run_cmd(cmd)
102 assert_equal(status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000103
104 def test_vsg_vm_for_vcpe(self):
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700105 vsgs = VSGAccess.get_vsgs()
106 compute_nodes = VSGAccess.get_compute_nodes()
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700107 assert_not_equal(len(vsgs), 0)
108 assert_not_equal(len(compute_nodes), 0)
Chetan Gaonker52418832017-01-26 23:03:13 +0000109
110 def test_vsg_for_external_connectivity(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700111 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
Chetan Gaonker52418832017-01-26 23:03:13 +0000112 cmd = "lxc exec testclient -- ping -c 3 8.8.8.8"
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700113 status, output = ssh_agent.run_cmd(cmd)
114 assert_equal( status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000115
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000116 def test_vsg_vm_for_login_to_vsg(self):
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700117 vsgs = VSGAccess.get_vsgs()
118 vsg_access_status = map(lambda vsg: vsg.check_access(), vsgs)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700119 status = filter(lambda st: st == False, vsg_access_status)
120 assert_equal(len(status), 0)
121
Chetan Gaonker1b564fe2017-03-21 19:19:12 +0000122 def test_vsg_external_connectivity_sending_icmp_echo_requests(self):
A R Karthick03f40aa2017-03-20 19:33:55 -0700123 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700124 mgmt = 'eth0'
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000125 host = '8.8.8.8'
126 self.success = False
A R Karthick03f40aa2017-03-20 19:33:55 -0700127 assert_not_equal(vcpe, None)
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700128 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700129 assert_not_equal(vcpe_ip, None)
130 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
131 log.info('Sending icmp echo requests to external network 8.8.8.8')
132 st, _ = getstatusoutput('ping -c 3 8.8.8.8')
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700133 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700134 assert_equal(st, 0)
Chetan Gaonker52418832017-01-26 23:03:13 +0000135
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000136 def test_vsg_external_connectivity_pinging_to_google(self):
137 host = 'www.google.com'
A R Karthick03f40aa2017-03-20 19:33:55 -0700138 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700139 mgmt = 'eth0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700140 assert_not_equal(vcpe, None)
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700141 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700142 assert_not_equal(vcpe_ip, None)
143 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
144 log.info('Sending icmp ping requests to %s' %host)
145 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700146 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700147 assert_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000148
149 def test_vsg_external_connectivity_pinging_to_non_existing_website(self):
150 host = 'www.goglee.com'
A R Karthick03f40aa2017-03-20 19:33:55 -0700151 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700152 mgmt = 'eth0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700153 assert_not_equal(vcpe, None)
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700154 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700155 assert_not_equal(vcpe_ip, None)
156 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
157 log.info('Sending icmp ping requests to non existent host %s' %host)
158 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700159 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700160 assert_not_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000161
162 def test_vsg_external_connectivity_ping_to_google_with_ttl_1(self):
163 host = '8.8.8.8'
A R Karthick03f40aa2017-03-20 19:33:55 -0700164 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700165 mgmt = 'eth0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700166 assert_not_equal(vcpe, None)
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700167 vcpe_ip = VSGAccess.vcpe_get_dhcp(vcpe, mgmt = mgmt)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700168 assert_not_equal(vcpe_ip, None)
169 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
170 log.info('Sending icmp ping requests to host %s with ttl 1' %host)
171 st, _ = getstatusoutput('ping -c 1 -t 1 {}'.format(host))
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700172 VSGAccess.restore_interface_config(mgmt, vcpe = vcpe)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700173 assert_not_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000174
Chetan Gaonker1b564fe2017-03-21 19:19:12 +0000175 def test_vsg_for_external_connectivity_with_wan_interface_toggle_in_vcpe_container(self):
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000176 host = '8.8.8.8'
A R Karthick03f40aa2017-03-20 19:33:55 -0700177 mgmt = 'eth0'
178 vcpe = self.vcpe_container
179 assert_not_equal(vcpe, None)
180 assert_not_equal(self.vcpe_dhcp, None)
181 #first get dhcp on the vcpe interface
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700182 vcpe_ip = VSGAccess.vcpe_get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
A R Karthick03f40aa2017-03-20 19:33:55 -0700183 assert_not_equal(vcpe_ip, None)
184 log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
185 log.info('Sending ICMP pings to host %s' %(host))
186 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
187 if st != 0:
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700188 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700189 assert_equal(st, 0)
190 #bring down the wan interface and check again
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700191 st = VSGAccess.vcpe_wan_down(vcpe)
A R Karthick03f40aa2017-03-20 19:33:55 -0700192 if st is False:
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700193 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700194 assert_equal(st, True)
195 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
196 if st == 0:
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700197 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700198 assert_not_equal(st, 0)
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700199 st = VSGAccess.vcpe_wan_up(vcpe)
A R Karthick03f40aa2017-03-20 19:33:55 -0700200 if st is False:
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700201 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700202 assert_equal(st, True)
203 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700204 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700205 assert_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000206
Chetan Gaonker1b564fe2017-03-21 19:19:12 +0000207 def test_vsg_for_external_connectivity_with_lan_interface_toggle_in_vcpe_container(self):
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000208 host = '8.8.8.8'
A R Karthick03f40aa2017-03-20 19:33:55 -0700209 mgmt = 'eth0'
210 vcpe = self.vcpe_container
211 assert_not_equal(vcpe, None)
212 assert_not_equal(self.vcpe_dhcp, None)
213 #first get dhcp on the vcpe interface
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700214 vcpe_ip = VSGAccess.vcpe_get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
A R Karthick03f40aa2017-03-20 19:33:55 -0700215 assert_not_equal(vcpe_ip, None)
216 log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
217 log.info('Sending ICMP pings to host %s' %(host))
218 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
219 if st != 0:
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700220 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700221 assert_equal(st, 0)
222 #bring down the lan interface and check again
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700223 st = VSGAccess.vcpe_lan_down(vcpe)
A R Karthick03f40aa2017-03-20 19:33:55 -0700224 if st is False:
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700225 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700226 assert_equal(st, True)
227 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
228 if st == 0:
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700229 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700230 assert_not_equal(st, 0)
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700231 st = VSGAccess.vcpe_lan_up(vcpe)
A R Karthick03f40aa2017-03-20 19:33:55 -0700232 if st is False:
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700233 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700234 assert_equal(st, True)
235 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
A R Karthickd0fdf3b2017-03-21 16:54:22 -0700236 VSGAccess.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700237 assert_equal(st, 0)
Chetan Gaonker52418832017-01-26 23:03:13 +0000238
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +0000239 def test_vsg_for_ping_from_vsg_to_external_network(self):
240 """
241 Algo:
242 1.Create a vSG VM in compute node
243 2.Ensure VM created properly
244 3.Verify login to VM success
245 4.Do ping to external network from vSG VM
246 5.Verify that ping gets success
247 6.Verify ping success flows added in OvS
248 """
249 def test_vsg_for_ping_from_vcpe_to_external_network(self):
250 """
251 Algo:
252 1.Create a vSG VM in compute node
253 2.Create a vCPE container inside VM
254 3.Verify both VM and Container created properly
255 4.Verify login to vCPE container success
256 5.Do ping to external network from vCPE container
257 6.Verify that ping gets success
258 7.Verify ping success flows added in OvS
259 """
260
Chetan Gaonker52418832017-01-26 23:03:13 +0000261 def test_vsg_for_dns_service(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +0000262 """
263 Algo:
264 1. Create a test client in Prod VM
265 2. Create a vCPE container in vSG VM inside compute Node
266 3. Ensure vSG VM and vCPE container created properly
267 4. Enable dns service in vCPE ( if not by default )
268 5. Send ping request from test client to valid domain address say, 'www.google'com
269 6. Verify that dns should resolve ping should success
270 7. Now send ping request to invalid domain address say 'www.invalidaddress'.com'
271 8. Verify that dns resolve should fail and hence ping
272 """
273 def test_vsg_for_10_subscribers_for_same_service(self):
274 """
275 Algo:
276 1.Create a vSG VM in compute node
277 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
278 3.Ensure vSG VM and vCPE container created properly
279 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP
280 5.Verify that ping success for all 10 subscribers
281 """
282 def test_vsg_for_10_subscribers_for_same_service_ping_invalid_ip(self):
283 """
284 Algo:
285 1.Create a vSG VM in compute Node
286 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
287 3.Ensure vSG VM and vCPE container created properly
288 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP
289 5.Verify that ping fails for all 10 subscribers
290 """
291 def test_vsg_for_10_subscribers_for_same_service_ping_valid_and_invalid_ip(self):
292 """
293 Algo:
294 1.Create a vSG VM in VM
295 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
296 3.Ensure vSG VM and vCPE container created properly
297 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP
298 5.Verify that ping success for all 5 subscribers
299 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP
300 7.Verify that ping fails for all 5 subscribers
301 """
302 def test_vsg_for_100_subscribers_for_same_service(self):
303 """
304 Algo:
305 1.Create a vSG VM in compute node
306 2.Create 100 vCPE containers for 100 subscribers, in vSG VM
307 3.Ensure vSG VM and vCPE container created properly
308 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP
309 5.Verify that ping success for all 100 subscribers
310 """
311 def test_vsg_for_100_subscribers_for_same_service_ping_invalid_ip(self):
312 """
313 Algo:
314 1.Create a vSG VM in compute Node
315 2.Create 10 vCPE containers for 100 subscribers, in vSG VM
316 3.Ensure vSG VM and vCPE container created properly
317 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP
318 5.Verify that ping fails for all 100 subscribers
319 """
320 def test_vsg_for_100_subscribers_for_same_service_ping_valid_and_invalid_ip(self):
321 """
322 Algo:
323 1.Create a vSG VM in VM
324 2.Create 10 vCPE containers for 100 subscribers, in vSG VM
325 3.Ensure vSG VM and vCPE container created properly
326 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP
327 5.Verify that ping success for all 5 subscribers
328 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP
329 7.Verify that ping fails for all 5 subscribers
330 """
331 def test_vsg_for_packet_received_with_invalid_ip_fields(self):
332 """
333 Algo:
334 1.Create a vSG VM in compute node
335 2.Create a vCPE container in vSG VM
336 3.Ensure vSG VM and vCPE container created properly
337 4.From subscriber, send a ping packet with invalid ip fields
338 5.Verify that vSG drops the packet
339 6.Verify ping fails
340 """
341 def test_vsg_for_packet_received_with_invalid_mac_fields(self):
342 """
343 Algo:
344 1.Create a vSG VM in compute node
345 2.Create a vCPE container in vSG VM
346 3.Ensure vSG VM and vCPE container created properly
347 4.From subscriber, send a ping packet with invalid mac fields
348 5.Verify that vSG drops the packet
349 6.Verify ping fails
350 """
351 def test_vsg_for_vlan_id_mismatch_in_stag(self):
352 """
353 Algo:
354 1.Create a vSG VM in compute Node
355 2.Create a vCPE container in vSG VM
356 3.Ensure vSG VM and vCPE container created properly
357 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag
358 5.Verify that ping fails as the packet drops at VM entry
359 6.Repeat step 4 with correct s-tag
360 7.Verify that ping success
361 """
362 def test_vsg_for_vlan_id_mismatch_in_ctag(self):
363 """
364 Algo:
365 1.Create a vSG VM in compute node
366 2.Create a vCPE container in vSG VM
367 3.Ensure vSG VM and vCPE container created properly
368 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag
369 5.Verify that ping fails as the packet drops at vCPE container entry
370 6.Repeat step 4 with valid s-tag and c-tag
371 7.Verify that ping success
372 """
373 def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self):
374 """
375 Algo:
376 1.Create two vSG VMs in compute node
377 2.Create a vCPE container in each vSG VM
378 3.Ensure vSG VM and vCPE container created properly
379 4.From subscriber one, send ping request with valid s and c tags
380 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags
381 6.Verify that ping success for only subscriber one and fails for two.
382 """
383 def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self):
384 """
385 Algo:
386 1.Create a vSG VM in compute node
387 2.Create two vCPE containers in vSG VM
388 3.Ensure vSG VM and vCPE container created properly
389 4.From subscriber one, send ping request with valid s and c tags
390 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag
391 6.Verify that ping success for only subscriber one and fails for two
392 """
393 def test_vsg_for_out_of_range_vlanid_in_ctag(self):
394 """
395 Algo:
396 1.Create a vSG VM in compute node
397 2.Create a vCPE container in vSG VM
398 3.Ensure vSG VM and vCPE container created properly
399 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 )
400 4.Verify that ping fails as the ping packets drops at vCPE container entry
401 """
402 def test_vsg_for_out_of_range_vlanid_in_stag(self):
403 """
404 Algo:
405 1.Create a vSG VM in compute node
406 2.Create a vCPE container in vSG VM
407 3.Ensure vSG VM and vCPE container created properly
408 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
409 4.Verify that ping fails as the ping packets drops at vSG VM entry
410 """
411 def test_vsg_without_creating_vcpe_instance(self):
412 """
413 Algo:
414 1.Create a vSG VM in compute Node
415 2.Ensure vSG VM created properly
416 3.Do not create vCPE container inside vSG VM
417 4.From a subscriber, send ping to external valid IP
418 5.Verify that ping fails as the ping packet drops at vSG VM entry itself.
419 """
420 def test_vsg_for_remove_vcpe_instance(self):
421 """
422 Algo:
423 1.Create a vSG VM in compute node
424 2.Create a vCPE container in vSG VM
425 3.Ensure vSG VM and vCPE container created properly
426 4.From subscriber, send ping request with valid s-tag and c-tag
427 5.Verify that ping success
428 6.Verify ping success flows in OvS switch in compute node
429 7.Now remove the vCPE container in vSG VM
430 8.Ensure that the container removed properly
431 9.Repeat step 4
432 10.Verify that now, ping fails
433 """
434 def test_vsg_for_restart_vcpe_instance(self):
435 """
436 Algo:
437 1.Create a vSG VM in compute node
438 2.Create a vCPE container in vSG VM
439 3.Ensure vSG VM and vCPE container created properly
440 4.From subscriber, send ping request with valid s-tag and c-tag
441 5.Verify that ping success
442 6.Verify ping success flows in OvS switch in compute node
443 7.Now restart the vCPE container in vSG VM
444 8.Ensure that the container came up after restart
445 9.Repeat step 4
446 10.Verify that now,ping gets success and flows added in OvS
447 """
448 def test_vsg_for_restart_vsg_vm(self):
449 """
450 Algo:
451 1.Create a vSG VM in compute node
452 2.Create a vCPE container in vSG VM
453 3.Ensure vSG VM and vCPE container created properly
454 4.From subscriber, send ping request with valid s-tag and c-tag
455 5.Verify that ping success
456 6.Verify ping success flows in OvS switch in compute node
457 7.Now restart the vSG VM
458 8.Ensure that the vSG comes up properly after restart
459 9.Verify that vCPE container comes up after vSG restart
460 10.Repeat step 4
461 11.Verify that now,ping gets success and flows added in OvS
462 """
463 def test_vsg_for_pause_vcpe_instance(self):
464 """
465 Algo:
466 1.Create a vSG VM in compute node
467 2.Create a vCPE container in vSG VM
468 3.Ensure vSG VM and vCPE container created properly
469 4.From subscriber, send ping request with valid s-tag and c-tag
470 5.Verify that ping success
471 6.Verify ping success flows in OvS switch in compute node
472 7.Now pause vCPE container in vSG VM for a while
473 8.Ensure that the container state is pause
474 9.Repeat step 4
475 10.Verify that now,ping fails now and verify flows in OvS
476 11.Now resume the container
477 12.Now repeat step 4 again
478 13.Verify that now, ping gets success
479 14.Verify ping success flows in OvS
480 """
481 def test_vsg_for_extract_all_compute_stats_from_all_vcpe_containers(self):
482 """
483 Algo:
484 1.Create a vSG VM in compute node
485 2.Create 10 vCPE containers in VM
486 3.Ensure vSG VM and vCPE containers created properly
487 4.Login to all vCPE containers
488 4.Get all compute stats from all vCPE containers
489 5.Verify the stats # verification method need to add
490 """
491 def test_vsg_for_extract_dns_stats_from_all_vcpe_containers(self):
492 """
493 Algo:
494 1.Create a vSG VM in compute node
495 2.Create 10 vCPE containers in VM
496 3.Ensure vSG VM and vCPE containers created properly
497 4.From 10 subscribers, send ping to valid and invalid dns hosts
498 5.Verify dns resolves and ping success for valid dns hosts
499 6.Verify ping fails for invalid dns hosts
500 7.Verify dns host name resolve flows in OvS
501 8.Login to all 10 vCPE containers
502 9.Extract all dns stats
503 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios
504 """
505 def test_vsg_for_subscriber_access_two_vsg_services(self):
506 """
507 # Intention is to verify if subscriber can reach internet via two vSG VMs
508 Algo:
509 1.Create two vSG VMs for two services in compute node
510 2.Create one vCPE container in each VM for one subscriber
511 3.Ensure VMs and containers created properly
512 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
513 5.Verify ping gets success
514 6.Verify ping success flows in OvS
515 7.Now repeat step 4 with stag corresponds to vSG-2 VM
516 8.Verify that ping again success
517 9.Verify ping success flows in OvS
518 """
519 def test_vsg_for_subscriber_access_service2_if_service1_goes_down(self):
520 """
521 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down
522 Algo:
523 1.Create two vSG VMs for two services in compute node
524 2.Create one vCPE container in each VM for one subscriber
525 3.Ensure VMs and containers created properly
526 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
527 5.Verify ping gets success
528 6.Verify ping success flows in OvS
529 7.Down the vSG-1 VM
530 8.Now repeat step 4
531 9.Verify that ping fails as vSG-1 is down
532 10.Repeat step 4 with stag corresponding to vSG-2
533 9.Verify ping success and flows added in OvS
534 """
535 def test_vsg_for_subscriber_access_service2_if_service1_goes_restart(self):
536 """
537 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts
538 Algo:
539 1.Create two vSG VMs for two services in compute node
540 2.Create one vCPE container in each VM for one subscriber
541 3.Ensure VMs and containers created properly
542 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
543 5.Verify ping gets success
544 6.Verify ping success flows added in OvS
545 7.Now restart vSG-1 VM
546 8.Now repeat step 4 while vSG-1 VM restarts
547 9.Verify that ping fails as vSG-1 is restarting
548 10.Repeat step 4 with stag corresponding to vSG-2 while vSG-1 VM restarts
549 11.Verify ping success and flows added in OvS
550 """
551 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_goes_down(self):
552 """
553 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down
554 Algo:
555 1.Create a vSG VM in compute node
556 2.Create two vCPE containers corresponds to two subscribers in vSG VM
557 3.Ensure VM and containers created properly
558 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
559 5.Verify ping gets success
560 6.Verify ping success flows added in OvS
561 7.Now stop vCPE-1 container
562 8.Now repeat step 4
563 9.Verify that ping fails as vCPE-1 container is down
564 10.Repeat step 4 with ctag corresponding to vCPE-2 container
565 11.Verify ping success and flows added in OvS
566 """
567 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_restart(self):
568 """
569 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts
570 Algo:
571 1.Create a vSG VM in compute node
572 2.Create two vCPE containers corresponds to two subscribers in vSG VM
573 3.Ensure VM and containers created properly
574 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
575 5.Verify ping gets success
576 6.Verify ping success flows added in OvS
577 7.Now restart vCPE-1 container
578 8.Now repeat step 4 while vCPE-1 restarts
579 9.Verify that ping fails as vCPE-1 container is restarts
580 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 restarts
581 11..Verify ping success and flows added in OvS
582 """
583 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_pause(self):
584 """
585 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 paused
586 Algo:
587 1.Create a vSG VM in compute node
588 2.Create two vCPE containers corresponds to two subscribers in vSG VM
589 3.Ensure VM and containers created properly
590 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
591 5.Verify ping gets success
592 6.Verify ping success flows added in OvS
593 7.Now pause vCPE-1 container
594 8.Now repeat step 4 while vCPE-1 in pause state
595 9.Verify that ping fails as vCPE-1 container in pause state
596 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 in pause state
597 11.Verify ping success and flows added in OvS
598 """
599 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_removed(self):
600 """
601 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 removed
602 Algo:
603 1.Create a vSG VM in compute node
604 2.Create two vCPE containers corresponds to two subscribers in vSG VM
605 3.Ensure VM and containers created properly
606 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
607 5.Verify ping gets success
608 6.Verify ping success flows added in OvS
609 7.Now remove vCPE-1 container
610 8.Now repeat step 4
611 9.Verify that ping fails as vCPE-1 container removed
612 10.Repeat step 4 with ctag corresponding to vCPE-2 container
613 11.Verify ping success and flows added in OvS
614 """
615 def test_vsg_for_vcpe_instance_removed_and_added_again(self):
616 """
617 Algo:
618 1.Create a vSG VM in compute node
619 2.Create a vCPE container in vSG VM
620 3.Ensure VM and containers created properly
621 4.From subscriber end, send ping to public IP
622 5.Verify ping gets success
623 6.Verify ping success flows added in OvS
624 7.Now remove vCPE container in vSG VM
625 8.Now repeat step 4
626 9.Verify that ping fails as vCPE container removed
627 10.Create the vCPE container again for the same subscriber
628 11.Ensure that vCPE created now
629 12.Now repeat step 4
630 13.Verify ping success and flows added in OvS
631 """
632 def test_vsg_for_vsg_vm_removed_and_added_again(self):
633 """
634 Algo:
635 1.Create a vSG VM in compute node
636 2.Create a vCPE container in vSG VM
637 3.Ensure VM and containers created properly
638 4.From subscriber end, send ping to public IP
639 5.Verify ping gets success
640 6.Verify ping success flows added in OvS
641 7.Now remove vSG VM
642 8.Now repeat step 4
643 9.Verify that ping fails as vSG VM not exists
644 10.Create the vSG VM and vCPE container in VM again
645 11.Ensure that vSG and vCPE created
646 12.Now repeat step 4
647 13.Verify ping success and flows added in OvS
648 """
649
650 #Test vSG - Subscriber Configuration
651 def test_vsg_for_configuring_new_subscriber_in_vcpe(self):
652 """
653 Algo:
654 1.Create a vSG VM in compute node
655 2.Create a vCPE container in vSG VM
656 3.Ensure VM and containers created properly
657 4.Configure a subscriber in XOS and assign a service id
658 5.Set the admin privileges to the subscriber
659 6.Verify subscriber configuration is success
660 """
661 def test_vsg_for_adding_subscriber_devices_in_vcpe(self):
662 """
663 Algo:
664 1.Create a vSG VM in compute node
665 2.Create a vCPE container in vSG VM
666 3.Ensure VM and containers created properly
667 4.Configure a subscriber in XOS and assign a service id
668 5.Verify subscriber successfully configured in vCPE
669 6.Now add devices( Mac addresses ) under the subscriber admin group
670 7.Verify all devices ( Macs ) added successfully
671 """
672 def test_vsg_for_removing_subscriber_devices_in_vcpe(self):
673 """
674 Algo:
675 1.Create a vSG VM in compute node
676 2.Create a vCPE container in vSG VM
677 3.Ensure VM and containers created properly
678 4.Configure a subscriber in XOS and assign a service id
679 5.Verify subscriber successfully configured
680 6.Now add devices( Mac addresses ) under the subscriber admin group
681 7.Verify all devices ( Macs ) added successfully
682 8.Now remove All the added devices in XOS
683 9.Verify all the devices removed
684 """
685 def test_vsg_for_modify_subscriber_devices_in_vcpe(self):
686 """
687 Algo:
688 1.Create a vSG VM in compute node
689 2.Create a vCPE container in vSG VM
690 3.Ensure VM and containers created properly
691 4.Configure a user in XOS and assign a service id
692 5.Verify subscriber successfully configured in vCPE.
693 6.Now add devices( Mac addresses ) under the subscriber admin group
694 7.Verify all devices ( Macs ) added successfully
695 8.Now remove few devices in XOS
696 9.Verify devices removed successfully
697 10.Now add few additional devices in XOS under the same subscriber admin group
698 11.Verify newly added devices successfully added
699 """
700 def test_vsg_for_vcpe_login_fails_with_incorrect_subscriber_credentials(self):
701 """
702 Algo:
703 1.Create a vSG VM in compute node
704 2.Create a vCPE container in vSG VM
705 3.Ensure VM and containers created properly
706 4.Configure a subscriber in XOS and assign a service id
707 5.Verify subscriber successfully configured
708 6.Now add devices( Mac addresses ) under the subscriber admin group
709 7.Verify all devices ( Macs ) added successfully
710 8.Login vCPE with credentials with which subscriber configured
711 9.Verify subscriber successfully logged in
712 10.Logout and login again with incorrect credentials ( either user name or password )
713 11.Verify login attempt to vCPE fails wtih incorrect credentials
714 """
715 def test_vsg_for_subscriber_configuration_in_vcpe_retain_after_vcpe_restart(self):
716 """
717 Algo:
718 1.Create a vSG VM in compute node
719 2.Create a vCPE container in vSG VM
720 3.Ensure VM and containers created properly
721 4.Configure a subscriber in XOS and assign a service id
722 5.Verify subscriber successfully configured
723 6.Now add devices( Mac addresses ) under the subscriber admin group
724 7.Verify all devices ( Macs ) added successfully
725 8.Restart vCPE ( locate backup config path while restart )
726 9.Verify subscriber details in vCPE after restart should be same as before the restart
727 """
728 def test_vsg_for_create_multiple_vcpe_instances_and_configure_subscriber_in_each_instance(self):
729 """
730 Algo:
731 1.Create a vSG VM in compute node
732 2.Create 2 vCPE containers in vSG VM
733 3.Ensure VM and containers created properly
734 4.Configure a subscriber in XOS for each vCPE instance and assign a service id
735 5.Verify subscribers successfully configured
736 6.Now login vCPE-2 with subscriber-1 credentials
737 7.Verify login fails
738 8.Now login vCPE-1 with subscriber-2 credentials
739 9.Verify login fails
740 10.Now login vCPE-1 with subscriber-1 and vCPE-2 with subscriber-2 credentials
741 11.Verify that both the subscribers able to login to their respective vCPE containers
742 """
743 def test_vsg_for_same_subscriber_can_be_configured_for_multiple_services(self):
744 """
745 Algo:
746 1.Create 2 vSG VMs in compute node
747 2.Create a vCPE container in each vSG VM
748 3.Ensure VMs and containers created properly
749 4.Configure same subscriber in XOS for each vCPE instance and assign a service id
750 5.Verify subscriber successfully configured
751 6.Now login vCPE-1 with subscriber credentials
752 7.Verify login success
753 8.Now login vCPE-2 with the same subscriber credentials
754 9.Verify login success
755 """
756
757 #Test Example Service
758 def test_vsg_for_subcriber_avail_example_service_running_in_apache_server(self):
759 """
760 Algo:
761 1.Create a vSG VM in compute node
762 2.Create a vCPE container in each vSG VM
763 3.Ensure VM and container created properly
764 4.Configure a subscriber in XOS for the vCPE instance and assign a service id
765 5.On-board an example service into cord pod
766 6.Create a VM in compute node and run the example service ( Apache server )
767 7.Configure the example service with service specific and subscriber specific messages
768 8.Verify example service on-boarded successfully
769 9.Verify example service running in VM
770 10.Run a curl command from subscriber to reach example service
771 11.Verify subscriber can successfully reach example service via vSG
772 12.Verify that service specific and subscriber specific messages
773 """
774 def test_vsg_for_subcriber_avail_example_service_running_in_apache_server_after_service_restart(self):
775 """
776 Algo:
777 1.Create a vSG VM in compute node
778 2.Create a vCPE container in each vSG VM
779 3.Ensure VM and container created properly
780 4.Configure a subscriber in XOS for the vCPE instance and assign a service id
781 5.On-board an example service into cord pod
782 6.Create a VM in compute node and run the example service ( Apache server )
783 7.Configure the example service with service specific and subscriber specific messages
784 8.Verify example service on-boarded successfully
785 9.Verify example service running in VM
786 10.Run a curl command from subscriber to reach example service
787 11.Verify subscriber can successfully reach example service via vSG
788 12.Verify that service specific and subscriber specific messages
789 13.Restart example service running in VM
790 14.Repeat step 10
791 15.Verify the same results as mentioned in steps 11, 12
792 """
793
794 #vCPE Firewall Functionality
795 def test_vsg_firewall_for_creating_acl_rule_based_on_source_ip(self):
796 """
797 Algo:
798 1.Create a vSG VM in compute node
799 2.Create vCPE container in the VM
800 3.Ensure vSG VM and vCPE container created properly
801 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP
802 5.Bound the acl rule to WAN interface of vCPE
803 6.Verify configuration in vCPE is success
804 8.Verify flows added in OvS
805 """
806 def test_vsg_firewall_for_creating_acl_rule_based_on_destination_ip(self):
807 """
808 Algo:
809 1.Create a vSG VM in compute node
810 2.Create vCPE container in the VM
811 3.Ensure vSG VM and vCPE container created properly
812 4.Configure ac acl rule in vCPE to deny IP traffic to a destination ip
813 5.Bound the acl rule to WAN interface of vCPE
814 6.Verify configuration in vCPE is success
815 8.Verify flows added in OvS
816 """
817 def test_vsg_firewall_for_acl_deny_rule_based_on_source_ip_traffic(self):
818 """
819 Algo:
820 1.Create a vSG VM in compute node
821 2.Create vCPE container in the VM
822 3.Ensure vSG VM and vCPE container created properly
823 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP
824 5.Bound the acl rule to WAN interface of vCPE
825 6.From subscriber, send ping to the denied IP address
826 7.Verify that ping fails as vCPE denies ping response
827 8.Verify flows added in OvS
828 """
829 def test_vsg_firewall_for_acl_deny_rule_based_on_destination_ip_traffic(self):
830 """
831 Algo:
832 1.Create a vSG VM in compute node
833 2.Create vCPE container in the VM
834 3.Ensure vSG VM and vCPE container created properly
835 4.Configure ac acl rule in vCPE to deny IP traffic to a destination IP
836 5.Bound the acl rule to WAN interface of vCPE
837 6.From subscriber, send ping to the denied IP address
838 7.Verify that ping fails as vCPE drops the ping request at WAN interface
839 8.Verify flows added in OvS
840 """
Chetan Gaonker52418832017-01-26 23:03:13 +0000841
842 def test_vsg_dnsmasq(self):
843 pass
844
845 def test_vsg_with_external_parental_control_family_shield_for_filter(self):
846 pass
847
848 def test_vsg_with_external_parental_control_with_answerx(self):
849 pass
850
851 def test_vsg_for_subscriber_upstream_bandwidth(self):
852 pass
853
854 def test_vsg_for_subscriber_downstream_bandwidth(self):
855 pass
856
857 def test_vsg_for_diagnostic_run_of_traceroute(self):
858 pass
859
860 def test_vsg_for_diagnostic_run_of_tcpdump(self):
861 pass
862
863 def test_vsg_for_iptable_rules(self):
864 pass
865
866 def test_vsg_for_iptables_with_neutron(self):
867 pass