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