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