blob: 7fc720eb40d43a68d5ba486c4c5ce3c6a96bdc52 [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#
15import unittest
16from nose.tools import *
17from scapy.all import *
A.R Karthickbe7768c2017-03-17 11:39:41 -070018from CordTestUtils import get_mac, get_controllers
19from OnosCtrl import OnosCtrl
Chetan Gaonker52418832017-01-26 23:03:13 +000020from OltConfig import OltConfig
21from socket import socket
22from OnosFlowCtrl import OnosFlowCtrl
23from nose.twistedtools import reactor, deferred
24from twisted.internet import defer
25from onosclidriver import OnosCliDriver
26from CordContainer import Container, Onos, Quagga
27from CordTestServer import cord_test_onos_restart, cord_test_onos_shutdown
A.R Karthick9ccd0d02017-03-16 17:11:08 -070028from SSHTestAgent import SSHTestAgent
Chetan Gaonker52418832017-01-26 23:03:13 +000029from portmaps import g_subscriber_port_map
30from scapy.all import *
31import time, monotonic
32from OnosLog import OnosLog
33from CordLogger import CordLogger
Chetan Gaonker52418832017-01-26 23:03:13 +000034import os
35import json
36import random
37import collections
38import paramiko
39from paramiko import SSHClient
A.R Karthick9ccd0d02017-03-16 17:11:08 -070040from neutronclient.v2_0 import client as neutron_client
41from novaclient import client as nova_client
Chetan Gaonker52418832017-01-26 23:03:13 +000042log.setLevel('INFO')
43
44class vsg_exchange(CordLogger):
45 ONOS_INSTANCES = 3
46 V_INF1 = 'veth0'
47 device_id = 'of:' + get_mac()
Chetan Gaonker52418832017-01-26 23:03:13 +000048 TEST_IP = '8.8.8.8'
49 HOST = "10.1.0.1"
50 USER = "vagrant"
51 PASS = "vagrant"
A.R Karthick9ccd0d02017-03-16 17:11:08 -070052 head_node = os.environ['HEAD_NODE']
53 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
Chetan Gaonker52418832017-01-26 23:03:13 +000054
55 def setUp(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -070056 super(vsg_exchange, self).setUp()
A.R Karthickbe7768c2017-03-17 11:39:41 -070057 self.controllers = get_controllers()
A.R Karthick9ccd0d02017-03-16 17:11:08 -070058 self.controller = self.controllers[0]
59 self.cli = None
Chetan Gaonker52418832017-01-26 23:03:13 +000060
61 def tearDown(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -070062 super(vsg_exchange, self).tearDown()
Chetan Gaonker52418832017-01-26 23:03:13 +000063
Chetan Gaonker52418832017-01-26 23:03:13 +000064 def cliEnter(self, controller = None):
65 retries = 0
66 while retries < 30:
67 self.cli = OnosCliDriver(controller = controller, connect = True)
68 if self.cli.handle:
69 break
70 else:
71 retries += 1
72 time.sleep(2)
73
74 def cliExit(self):
75 self.cli.disconnect()
76
77 def onos_shutdown(self, controller = None):
78 status = True
79 self.cliEnter(controller = controller)
80 try:
81 self.cli.shutdown(timeout = 10)
82 except:
83 log.info('Graceful shutdown of ONOS failed for controller: %s' %controller)
84 status = False
85
86 self.cliExit()
87 return status
88
A.R Karthick9ccd0d02017-03-16 17:11:08 -070089 def log_set(self, level = None, app = 'org.onosproject'):
90 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
Chetan Gaonker52418832017-01-26 23:03:13 +000091
A.R Karthick9ccd0d02017-03-16 17:11:08 -070092 def get_nova_credentials_v2(self):
Chetan Gaonker52418832017-01-26 23:03:13 +000093 credential = {}
A.R Karthick9ccd0d02017-03-16 17:11:08 -070094 credential['username'] = os.environ['OS_USERNAME']
95 credential['api_key'] = os.environ['OS_PASSWORD']
96 credential['auth_url'] = os.environ['OS_AUTH_URL']
97 credential['project_id'] = os.environ['OS_TENANT_NAME']
Chetan Gaonker52418832017-01-26 23:03:13 +000098 return credential
99
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700100 def get_compute_nodes(self):
101 credentials = self.get_nova_credentials_v2()
102 nvclient = nova_client.Client('2', **credentials)
103 return nvclient.hypervisors.list()
Chetan Gaonker52418832017-01-26 23:03:13 +0000104
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700105 def get_vsgs(self, active = True):
106 credentials = self.get_nova_credentials_v2()
107 nvclient = nova_client.Client('2', **credentials)
108 vsgs = nvclient.servers.list(search_opts = {'all_tenants': 1})
109 if active is True:
110 return filter(lambda vsg: vsg.status == True, vsgs)
111 return vsgs
112
113 def get_vsg_ip(self, vm_name):
114 vsgs = self.get_vsgs()
115 vm = filter(lambda vsg: vsg.name == vm_name, vsgs)
116 if vm:
117 if vm.networks.has_key('management'):
118 ips = vm.networks['management']
119 if len(ips) > 0:
120 return ips[0]
121 return None
122
123 def get_compute_node(self, vsg):
124 return vsg._info['OS-EXT-SRV-ATTR:hypervisor_hostname']
125
126 #ping the vsg through the compute node.
127 #the ssh key is already used by SSHTestAgent in cord-tester
128 def get_vsg_health(self, vsg):
129 compute_node = self.get_compute_node(vsg)
130 vsg_ip = self.get_vsg_ip(vsg.name)
131 if vsg_ip is None:
132 return False
133 ssh_agent = SSHTestAgent(compute_node)
134 st, _ = ssh_agent.run_cmd('ping -c 1 {}'.format(vsg_ip))
135 return st
136
137 #returns 0 if all active vsgs are reachable through the compute node
Chetan Gaonker52418832017-01-26 23:03:13 +0000138 def health_check(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700139 vsgs = self.get_vsgs()
140 vsg_status = []
141 for vsg in vsgs:
142 vsg_status.append(self.get_vsg_health(vsg))
143 unreachable = filter(lambda st: st == False, vsg_status)
144 return len(unreachable) == 0
Chetan Gaonker52418832017-01-26 23:03:13 +0000145
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700146 #use SSHTestAgent to talk to the vsg through the compute node like in get_vsg_health
147 # def connect_ssh(vsg_ip, private_key_file=None, user='ubuntu'):
148 # key = ssh.RSAKey.from_private_key_file(private_key_file)
149 # client = ssh.SSHClient()
150 # client.set_missing_host_key_policy(ssh.WarningPolicy())
151 # client.connect(ip, username=user, pkey=key, timeout=5)
152 # return client
Chetan Gaonker52418832017-01-26 23:03:13 +0000153
154 def test_vsg_vm(self):
155 status = self.health_check()
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700156 assert_equal( status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000157
158 def test_vsg_for_default_route_to_vsg_vm(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700159 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
Chetan Gaonker52418832017-01-26 23:03:13 +0000160 cmd = "sudo lxc exec testclient -- route | grep default"
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700161 status, output = ssh_agent.run_cmd(cmd)
162 assert_equal(status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000163
164 def test_vsg_vm_for_vcpe(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700165 vsgs = self.get_vsgs()
166 compute_nodes = self.get_compute_nodes()
167 assert_not_equal(len(vsgs), 0)
168 assert_not_equal(len(compute_nodes), 0)
Chetan Gaonker52418832017-01-26 23:03:13 +0000169
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700170 #TODO: use cord-test container itself to dhclient on vcpe interfaces
171 #using the info from OltConfig().get_vcpes()
172 #deleting default through eth0, fetching ip through dhclient on vcpe,
173 #and testing for dhcp ip on vcpe0 and default route on vcpe0 before pinging 8.8.8.8
Chetan Gaonker52418832017-01-26 23:03:13 +0000174 def test_vsg_for_external_connectivity(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700175 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
Chetan Gaonker52418832017-01-26 23:03:13 +0000176 cmd = "lxc exec testclient -- ping -c 3 8.8.8.8"
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700177 status, output = ssh_agent.run_cmd(cmd)
178 assert_equal( status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000179
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700180 #below tests need to be changed to login to vsg through the compute node as in health check
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000181 def test_vsg_vm_for_login_to_vsg(self):
182 client = SSHClient()
183 client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
184 keyfile = open('/root/id_rsa','r')
185 key = str(keyfile.read())
186 keyfile.close()
187 log.info('read key is %s'%key)
188 key = paramiko.RSAKey.from_private_key(StringIO(key), password=None)
189 client.connect( '10.1.0.17', username = 'ubuntu', pkey=key, password=None)
190 cmd = "ls"
191 stdin, stdout, stderr = client.exec_command(cmd)
192 status = stdout.channel.recv_exit_status()
193 assert_equal( status, False)
194 log.info('ls output at compute node is %s'%stdout.read())
195 client.connect( '172.27.0.2', username = 'ubuntu', pkey=key, password=None)
196 cmd = "pwd"
197 stdin, stdout, stderr = client.exec_command(cmd)
198 status = stdout.channel.recv_exit_status()
199 assert_equal( status, False)
200 log.info('ls output at compute node is %s'%stdout.read())
Chetan Gaonker52418832017-01-26 23:03:13 +0000201
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700202 #these need to first get dhcp through dhclient on vcpe interfaces (using OltConfig get_vcpes())
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000203 def test_vsg_external_connectivity_with_sending_icmp_echo_requests(self):
204 host = '8.8.8.8'
205 self.success = False
206 def mac_recv_task():
207 def recv_cb(pkt):
208 log.info('Recieved icmp echo reply as expected')
209 self.success = True
210 sniff(count=1, timeout=5,
211 lfilter = lambda p: IP in p and p[ICMP].type==0, #p[IP].src == host,
212 prn = recv_cb, iface = 'vcpe0.222.111')
213 t = threading.Thread(target = mac_recv_task)
214 t.start()
215 L3 = IP(dst = host)
216 pkt = L3/ICMP()
217 log.info('Sending icmp echo requests to external network')
218 send(pkt, count=3, iface = 'vcpe0.222.111')
219 t.join()
220 assert_equal(self.success, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000221
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000222 def test_vsg_external_connectivity_sending_icmp_ping_on_different_interface(self):
223 host = '8.8.8.8'
224 self.success = False
225 def mac_recv_task():
226 def recv_cb(pkt):
227 log.info('Recieved icmp echo reply which is not expected')
228 self.success = True
229 sniff(count=1, timeout=5,
230 lfilter = lambda p: IP in p and p[ICMP].type == 0,
231 prn = recv_cb, iface = 'vcpe0.222.112')
232 t = threading.Thread(target = mac_recv_task)
233 t.start()
234 L3 = IP(dst = host)
235 pkt = L3/ICMP()
236 log.info('Sending icmp echo requests to external network')
237 send(pkt, count=3, iface = 'vcpe0.222.112')
238 t.join()
239 assert_equal(self.success, False)
240
241 def test_vsg_external_connectivity_pinging_with_single_tag_negative_scenario(self):
242 host = '8.8.8.8'
243 self.success = False
244 def mac_recv_task():
245 def recv_cb(pkt):
246 log.info('Recieved icmp echo reply which is not expected')
247 self.success = True
248 sniff(count=1, timeout=5,
249 lfilter = lambda p: IP in p and p[ICMP].type == 0,
250 prn = recv_cb, iface = 'vcpe0.222')
251 t = threading.Thread(target = mac_recv_task)
252 t.start()
253 L3 = IP(dst = host)
254 pkt = L3/ICMP()
255 log.info('Sending icmp echo requests to external network')
256 send(pkt, count=3, iface = 'vcpe0.222')
257 t.join()
258 assert_equal(self.success, False)
259
260 def test_vsg_external_connectivity_pinging_to_google(self):
261 host = 'www.google.com'
262 self.success = False
263 def mac_recv_task():
264 def recv_cb(pkt):
265 log.info('Recieved icmp echo reply as expected')
266 self.success = True
267 sniff(count=3, timeout=5,
268 lfilter = lambda p: IP in p and p[ICMP].type== 0,
269 prn = recv_cb, iface = 'vcpe0.222.111')
270 t = threading.Thread(target = mac_recv_task)
271 t.start()
272 L3 = IP(dst = host)
273 pkt = L3/ICMP()
274 log.info('Sending icmp ping requests to google.com')
275 send(pkt, count=3, iface = 'vcpe0.222.111')
276 t.join()
277 assert_equal(self.success, True)
278
279 def test_vsg_external_connectivity_pinging_to_non_existing_website(self):
280 host = 'www.goglee.com'
281 self.success = False
282 def mac_recv_task():
283 def recv_cb(pkt):
284 log.info('Recieved icmp echo reply which is not expected')
285 self.success = True
286 sniff(count=1, timeout=5,
287 lfilter = lambda p: IP in p and p[ICMP].type == 0,
288 prn = recv_cb, iface = 'vcpe0.222.111')
289 t = threading.Thread(target = mac_recv_task)
290 t.start()
291 L3 = IP(dst = host)
292 pkt = L3/ICMP()
293 log.info('Sending icmp ping requests to non existing website')
294 send(pkt, count=3, iface = 'vcpe0.222.111')
295 t.join()
296 assert_equal(self.success, False)
297
298 def test_vsg_external_connectivity_ping_to_google_with_ttl_1(self):
299 host = '8.8.8.8'
300 self.success = False
301 def mac_recv_task():
302 def recv_cb(pkt):
303 log.info('icmp ping reply received Pkt is %s' %pkt.show())
304 #log.info('icmp ping reply received Pkt is %s' %pkt[ICMP])
305 self.success = True
306 sniff(count=1, timeout=5,
307 lfilter = lambda p: IP in p and p[ICMP].type == 0,
308 prn = recv_cb, iface = 'vcpe0.222.111')
309 t = threading.Thread(target = mac_recv_task)
310 t.start()
311 L3 = IP(dst = host, ttl=1)
312 pkt = L3/ICMP()
313 log.info('Sending icmp ping requests to external network with ip ttl value set to 1')
314 send(pkt, count=3, iface = 'vcpe0.222.111')
315 t.join()
316 assert_equal(self.success, False)
317
318 def test_vsg_for_external_connectivity_with_wan_interface_down_and_making_up_in_vcpe_container(self):
319 host = '8.8.8.8'
320 self.success = False
321 def mac_recv_task():
322 def recv_cb(pkt):
323 log.info('icmp ping reply received')
324 self.success = True
325 sniff(count=1, timeout=5,
326 lfilter = lambda p: ICMP in p and p[ICMP].type == 0,
327 prn = recv_cb, iface = 'vcpe0.222.111')
328 t1 = threading.Thread(target = mac_recv_task)
329 t2 = threading.Thread(target = mac_recv_task)
330 t3 = threading.Thread(target = mac_recv_task)
331 t1.start()
332 L3 = IP(dst = host)
333 pkt = L3/ICMP()
334 log.info('Sending icmp ping requests to external network before wan interface on vpce container does down')
335 send(pkt, count=3, iface = 'vcpe0.222.111')
336 t1.join()
337 assert_equal(self.success, True)
338 #logging into vcpe and down wan interface
339 self.success = False
340 t2.start()
341 log.info('Sending icmp ping requests to external network after wan interface on vpce container does down')
342 send(pkt, count=3, iface = 'vcpe0.222.111')
343 t2.join()
344 assert_equal(self.success, False)
345 #logging into vcpe and bringing up wan interface
346 t3.start()
347 log.info('Sending icmp ping requests to external network after wan interface on vpce container comes up')
348 send(pkt, count=3, iface = 'vcpe0.222.111')
349 t3.join()
350 assert_equal(self.success, True)
351
352 def test_vsg_for_external_connectivity_with_lan_interface_down_and_up_in_vcpe_container(self):
353 host = '8.8.8.8'
354 self.success = False
355 def mac_recv_task():
356 def recv_cb(pkt):
357 log.info('icmp ping reply received Pkt is %s' %pkt.show())
358 self.success = True
359 sniff(count=1, timeout=5,
360 lfilter = lambda p: ICMP in p and p[ICMP].type == 1,
361 prn = recv_cb, iface = 'vcpe0.222.111')
362 t1 = threading.Thread(target = mac_recv_task)
363 t2 = threading.Thread(target = mac_recv_task)
364 t3 = threading.Thread(target = mac_recv_task)
365 t1.start()
366 L3 = IP(dst = host)
367 pkt = L3/ICMP()
368 log.info('Sending icmp ping requests to external network before lan interface on vpce container does down')
369 send(pkt, count=3, iface = 'vcpe0.222.111')
370 t1.join()
371 assert_equal(self.success, True)
372 #logging into vcpe and down lan interface
373 self.success = False
374 t2.start()
375 log.info('Sending icmp ping requests to external network after lan interface on vpce container does down')
376 send(pkt, count=3, iface = 'vcpe0.222.111')
377 t2.join()
378 assert_equal(self.success, False)
379 #logging into vcpe and bringing up lan interface
380 t3.start()
381 log.info('Sending icmp ping requests to external network after lan interface on vpce container comes up')
382 send(pkt, count=3, iface = 'vcpe0.222.111')
383 t3.join()
384 assert_equal(self.success, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000385
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +0000386 def test_vsg_for_ping_from_vsg_to_external_network(self):
387 """
388 Algo:
389 1.Create a vSG VM in compute node
390 2.Ensure VM created properly
391 3.Verify login to VM success
392 4.Do ping to external network from vSG VM
393 5.Verify that ping gets success
394 6.Verify ping success flows added in OvS
395 """
396 def test_vsg_for_ping_from_vcpe_to_external_network(self):
397 """
398 Algo:
399 1.Create a vSG VM in compute node
400 2.Create a vCPE container inside VM
401 3.Verify both VM and Container created properly
402 4.Verify login to vCPE container success
403 5.Do ping to external network from vCPE container
404 6.Verify that ping gets success
405 7.Verify ping success flows added in OvS
406 """
407
Chetan Gaonker52418832017-01-26 23:03:13 +0000408 def test_vsg_for_dns_service(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +0000409 """
410 Algo:
411 1. Create a test client in Prod VM
412 2. Create a vCPE container in vSG VM inside compute Node
413 3. Ensure vSG VM and vCPE container created properly
414 4. Enable dns service in vCPE ( if not by default )
415 5. Send ping request from test client to valid domain address say, 'www.google'com
416 6. Verify that dns should resolve ping should success
417 7. Now send ping request to invalid domain address say 'www.invalidaddress'.com'
418 8. Verify that dns resolve should fail and hence ping
419 """
420 def test_vsg_for_10_subscribers_for_same_service(self):
421 """
422 Algo:
423 1.Create a vSG VM in compute node
424 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
425 3.Ensure vSG VM and vCPE container created properly
426 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP
427 5.Verify that ping success for all 10 subscribers
428 """
429 def test_vsg_for_10_subscribers_for_same_service_ping_invalid_ip(self):
430 """
431 Algo:
432 1.Create a vSG VM in compute Node
433 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
434 3.Ensure vSG VM and vCPE container created properly
435 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP
436 5.Verify that ping fails for all 10 subscribers
437 """
438 def test_vsg_for_10_subscribers_for_same_service_ping_valid_and_invalid_ip(self):
439 """
440 Algo:
441 1.Create a vSG VM in VM
442 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
443 3.Ensure vSG VM and vCPE container created properly
444 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP
445 5.Verify that ping success for all 5 subscribers
446 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP
447 7.Verify that ping fails for all 5 subscribers
448 """
449 def test_vsg_for_100_subscribers_for_same_service(self):
450 """
451 Algo:
452 1.Create a vSG VM in compute node
453 2.Create 100 vCPE containers for 100 subscribers, in vSG VM
454 3.Ensure vSG VM and vCPE container created properly
455 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP
456 5.Verify that ping success for all 100 subscribers
457 """
458 def test_vsg_for_100_subscribers_for_same_service_ping_invalid_ip(self):
459 """
460 Algo:
461 1.Create a vSG VM in compute Node
462 2.Create 10 vCPE containers for 100 subscribers, in vSG VM
463 3.Ensure vSG VM and vCPE container created properly
464 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP
465 5.Verify that ping fails for all 100 subscribers
466 """
467 def test_vsg_for_100_subscribers_for_same_service_ping_valid_and_invalid_ip(self):
468 """
469 Algo:
470 1.Create a vSG VM in VM
471 2.Create 10 vCPE containers for 100 subscribers, in vSG VM
472 3.Ensure vSG VM and vCPE container created properly
473 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP
474 5.Verify that ping success for all 5 subscribers
475 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP
476 7.Verify that ping fails for all 5 subscribers
477 """
478 def test_vsg_for_packet_received_with_invalid_ip_fields(self):
479 """
480 Algo:
481 1.Create a vSG VM in compute node
482 2.Create a vCPE container in vSG VM
483 3.Ensure vSG VM and vCPE container created properly
484 4.From subscriber, send a ping packet with invalid ip fields
485 5.Verify that vSG drops the packet
486 6.Verify ping fails
487 """
488 def test_vsg_for_packet_received_with_invalid_mac_fields(self):
489 """
490 Algo:
491 1.Create a vSG VM in compute node
492 2.Create a vCPE container in vSG VM
493 3.Ensure vSG VM and vCPE container created properly
494 4.From subscriber, send a ping packet with invalid mac fields
495 5.Verify that vSG drops the packet
496 6.Verify ping fails
497 """
498 def test_vsg_for_vlan_id_mismatch_in_stag(self):
499 """
500 Algo:
501 1.Create a vSG VM in compute Node
502 2.Create a vCPE container in vSG VM
503 3.Ensure vSG VM and vCPE container created properly
504 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag
505 5.Verify that ping fails as the packet drops at VM entry
506 6.Repeat step 4 with correct s-tag
507 7.Verify that ping success
508 """
509 def test_vsg_for_vlan_id_mismatch_in_ctag(self):
510 """
511 Algo:
512 1.Create a vSG VM in compute node
513 2.Create a vCPE container in vSG VM
514 3.Ensure vSG VM and vCPE container created properly
515 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag
516 5.Verify that ping fails as the packet drops at vCPE container entry
517 6.Repeat step 4 with valid s-tag and c-tag
518 7.Verify that ping success
519 """
520 def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self):
521 """
522 Algo:
523 1.Create two vSG VMs in compute node
524 2.Create a vCPE container in each vSG VM
525 3.Ensure vSG VM and vCPE container created properly
526 4.From subscriber one, send ping request with valid s and c tags
527 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags
528 6.Verify that ping success for only subscriber one and fails for two.
529 """
530 def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self):
531 """
532 Algo:
533 1.Create a vSG VM in compute node
534 2.Create two vCPE containers in vSG VM
535 3.Ensure vSG VM and vCPE container created properly
536 4.From subscriber one, send ping request with valid s and c tags
537 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag
538 6.Verify that ping success for only subscriber one and fails for two
539 """
540 def test_vsg_for_out_of_range_vlanid_in_ctag(self):
541 """
542 Algo:
543 1.Create a vSG VM in compute node
544 2.Create a vCPE container in vSG VM
545 3.Ensure vSG VM and vCPE container created properly
546 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 )
547 4.Verify that ping fails as the ping packets drops at vCPE container entry
548 """
549 def test_vsg_for_out_of_range_vlanid_in_stag(self):
550 """
551 Algo:
552 1.Create a vSG VM in compute node
553 2.Create a vCPE container in vSG VM
554 3.Ensure vSG VM and vCPE container created properly
555 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
556 4.Verify that ping fails as the ping packets drops at vSG VM entry
557 """
558 def test_vsg_without_creating_vcpe_instance(self):
559 """
560 Algo:
561 1.Create a vSG VM in compute Node
562 2.Ensure vSG VM created properly
563 3.Do not create vCPE container inside vSG VM
564 4.From a subscriber, send ping to external valid IP
565 5.Verify that ping fails as the ping packet drops at vSG VM entry itself.
566 """
567 def test_vsg_for_remove_vcpe_instance(self):
568 """
569 Algo:
570 1.Create a vSG VM in compute node
571 2.Create a vCPE container in vSG VM
572 3.Ensure vSG VM and vCPE container created properly
573 4.From subscriber, send ping request with valid s-tag and c-tag
574 5.Verify that ping success
575 6.Verify ping success flows in OvS switch in compute node
576 7.Now remove the vCPE container in vSG VM
577 8.Ensure that the container removed properly
578 9.Repeat step 4
579 10.Verify that now, ping fails
580 """
581 def test_vsg_for_restart_vcpe_instance(self):
582 """
583 Algo:
584 1.Create a vSG VM in compute node
585 2.Create a vCPE container in vSG VM
586 3.Ensure vSG VM and vCPE container created properly
587 4.From subscriber, send ping request with valid s-tag and c-tag
588 5.Verify that ping success
589 6.Verify ping success flows in OvS switch in compute node
590 7.Now restart the vCPE container in vSG VM
591 8.Ensure that the container came up after restart
592 9.Repeat step 4
593 10.Verify that now,ping gets success and flows added in OvS
594 """
595 def test_vsg_for_restart_vsg_vm(self):
596 """
597 Algo:
598 1.Create a vSG VM in compute node
599 2.Create a vCPE container in vSG VM
600 3.Ensure vSG VM and vCPE container created properly
601 4.From subscriber, send ping request with valid s-tag and c-tag
602 5.Verify that ping success
603 6.Verify ping success flows in OvS switch in compute node
604 7.Now restart the vSG VM
605 8.Ensure that the vSG comes up properly after restart
606 9.Verify that vCPE container comes up after vSG restart
607 10.Repeat step 4
608 11.Verify that now,ping gets success and flows added in OvS
609 """
610 def test_vsg_for_pause_vcpe_instance(self):
611 """
612 Algo:
613 1.Create a vSG VM in compute node
614 2.Create a vCPE container in vSG VM
615 3.Ensure vSG VM and vCPE container created properly
616 4.From subscriber, send ping request with valid s-tag and c-tag
617 5.Verify that ping success
618 6.Verify ping success flows in OvS switch in compute node
619 7.Now pause vCPE container in vSG VM for a while
620 8.Ensure that the container state is pause
621 9.Repeat step 4
622 10.Verify that now,ping fails now and verify flows in OvS
623 11.Now resume the container
624 12.Now repeat step 4 again
625 13.Verify that now, ping gets success
626 14.Verify ping success flows in OvS
627 """
628 def test_vsg_for_extract_all_compute_stats_from_all_vcpe_containers(self):
629 """
630 Algo:
631 1.Create a vSG VM in compute node
632 2.Create 10 vCPE containers in VM
633 3.Ensure vSG VM and vCPE containers created properly
634 4.Login to all vCPE containers
635 4.Get all compute stats from all vCPE containers
636 5.Verify the stats # verification method need to add
637 """
638 def test_vsg_for_extract_dns_stats_from_all_vcpe_containers(self):
639 """
640 Algo:
641 1.Create a vSG VM in compute node
642 2.Create 10 vCPE containers in VM
643 3.Ensure vSG VM and vCPE containers created properly
644 4.From 10 subscribers, send ping to valid and invalid dns hosts
645 5.Verify dns resolves and ping success for valid dns hosts
646 6.Verify ping fails for invalid dns hosts
647 7.Verify dns host name resolve flows in OvS
648 8.Login to all 10 vCPE containers
649 9.Extract all dns stats
650 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios
651 """
652 def test_vsg_for_subscriber_access_two_vsg_services(self):
653 """
654 # Intention is to verify if subscriber can reach internet via two vSG VMs
655 Algo:
656 1.Create two vSG VMs for two services in compute node
657 2.Create one vCPE container in each VM for one subscriber
658 3.Ensure VMs and containers created properly
659 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
660 5.Verify ping gets success
661 6.Verify ping success flows in OvS
662 7.Now repeat step 4 with stag corresponds to vSG-2 VM
663 8.Verify that ping again success
664 9.Verify ping success flows in OvS
665 """
666 def test_vsg_for_subscriber_access_service2_if_service1_goes_down(self):
667 """
668 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down
669 Algo:
670 1.Create two vSG VMs for two services in compute node
671 2.Create one vCPE container in each VM for one subscriber
672 3.Ensure VMs and containers created properly
673 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
674 5.Verify ping gets success
675 6.Verify ping success flows in OvS
676 7.Down the vSG-1 VM
677 8.Now repeat step 4
678 9.Verify that ping fails as vSG-1 is down
679 10.Repeat step 4 with stag corresponding to vSG-2
680 9.Verify ping success and flows added in OvS
681 """
682 def test_vsg_for_subscriber_access_service2_if_service1_goes_restart(self):
683 """
684 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts
685 Algo:
686 1.Create two vSG VMs for two services in compute node
687 2.Create one vCPE container in each VM for one subscriber
688 3.Ensure VMs and containers created properly
689 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
690 5.Verify ping gets success
691 6.Verify ping success flows added in OvS
692 7.Now restart vSG-1 VM
693 8.Now repeat step 4 while vSG-1 VM restarts
694 9.Verify that ping fails as vSG-1 is restarting
695 10.Repeat step 4 with stag corresponding to vSG-2 while vSG-1 VM restarts
696 11.Verify ping success and flows added in OvS
697 """
698 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_goes_down(self):
699 """
700 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down
701 Algo:
702 1.Create a vSG VM in compute node
703 2.Create two vCPE containers corresponds to two subscribers in vSG VM
704 3.Ensure VM and containers created properly
705 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
706 5.Verify ping gets success
707 6.Verify ping success flows added in OvS
708 7.Now stop vCPE-1 container
709 8.Now repeat step 4
710 9.Verify that ping fails as vCPE-1 container is down
711 10.Repeat step 4 with ctag corresponding to vCPE-2 container
712 11.Verify ping success and flows added in OvS
713 """
714 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_restart(self):
715 """
716 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts
717 Algo:
718 1.Create a vSG VM in compute node
719 2.Create two vCPE containers corresponds to two subscribers in vSG VM
720 3.Ensure VM and containers created properly
721 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
722 5.Verify ping gets success
723 6.Verify ping success flows added in OvS
724 7.Now restart vCPE-1 container
725 8.Now repeat step 4 while vCPE-1 restarts
726 9.Verify that ping fails as vCPE-1 container is restarts
727 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 restarts
728 11..Verify ping success and flows added in OvS
729 """
730 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_pause(self):
731 """
732 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 paused
733 Algo:
734 1.Create a vSG VM in compute node
735 2.Create two vCPE containers corresponds to two subscribers in vSG VM
736 3.Ensure VM and containers created properly
737 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
738 5.Verify ping gets success
739 6.Verify ping success flows added in OvS
740 7.Now pause vCPE-1 container
741 8.Now repeat step 4 while vCPE-1 in pause state
742 9.Verify that ping fails as vCPE-1 container in pause state
743 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 in pause state
744 11.Verify ping success and flows added in OvS
745 """
746 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_removed(self):
747 """
748 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 removed
749 Algo:
750 1.Create a vSG VM in compute node
751 2.Create two vCPE containers corresponds to two subscribers in vSG VM
752 3.Ensure VM and containers created properly
753 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
754 5.Verify ping gets success
755 6.Verify ping success flows added in OvS
756 7.Now remove vCPE-1 container
757 8.Now repeat step 4
758 9.Verify that ping fails as vCPE-1 container removed
759 10.Repeat step 4 with ctag corresponding to vCPE-2 container
760 11.Verify ping success and flows added in OvS
761 """
762 def test_vsg_for_vcpe_instance_removed_and_added_again(self):
763 """
764 Algo:
765 1.Create a vSG VM in compute node
766 2.Create a vCPE container in vSG VM
767 3.Ensure VM and containers created properly
768 4.From subscriber end, send ping to public IP
769 5.Verify ping gets success
770 6.Verify ping success flows added in OvS
771 7.Now remove vCPE container in vSG VM
772 8.Now repeat step 4
773 9.Verify that ping fails as vCPE container removed
774 10.Create the vCPE container again for the same subscriber
775 11.Ensure that vCPE created now
776 12.Now repeat step 4
777 13.Verify ping success and flows added in OvS
778 """
779 def test_vsg_for_vsg_vm_removed_and_added_again(self):
780 """
781 Algo:
782 1.Create a vSG VM in compute node
783 2.Create a vCPE container in vSG VM
784 3.Ensure VM and containers created properly
785 4.From subscriber end, send ping to public IP
786 5.Verify ping gets success
787 6.Verify ping success flows added in OvS
788 7.Now remove vSG VM
789 8.Now repeat step 4
790 9.Verify that ping fails as vSG VM not exists
791 10.Create the vSG VM and vCPE container in VM again
792 11.Ensure that vSG and vCPE created
793 12.Now repeat step 4
794 13.Verify ping success and flows added in OvS
795 """
796
797 #Test vSG - Subscriber Configuration
798 def test_vsg_for_configuring_new_subscriber_in_vcpe(self):
799 """
800 Algo:
801 1.Create a vSG VM in compute node
802 2.Create a vCPE container in vSG VM
803 3.Ensure VM and containers created properly
804 4.Configure a subscriber in XOS and assign a service id
805 5.Set the admin privileges to the subscriber
806 6.Verify subscriber configuration is success
807 """
808 def test_vsg_for_adding_subscriber_devices_in_vcpe(self):
809 """
810 Algo:
811 1.Create a vSG VM in compute node
812 2.Create a vCPE container in vSG VM
813 3.Ensure VM and containers created properly
814 4.Configure a subscriber in XOS and assign a service id
815 5.Verify subscriber successfully configured in vCPE
816 6.Now add devices( Mac addresses ) under the subscriber admin group
817 7.Verify all devices ( Macs ) added successfully
818 """
819 def test_vsg_for_removing_subscriber_devices_in_vcpe(self):
820 """
821 Algo:
822 1.Create a vSG VM in compute node
823 2.Create a vCPE container in vSG VM
824 3.Ensure VM and containers created properly
825 4.Configure a subscriber in XOS and assign a service id
826 5.Verify subscriber successfully configured
827 6.Now add devices( Mac addresses ) under the subscriber admin group
828 7.Verify all devices ( Macs ) added successfully
829 8.Now remove All the added devices in XOS
830 9.Verify all the devices removed
831 """
832 def test_vsg_for_modify_subscriber_devices_in_vcpe(self):
833 """
834 Algo:
835 1.Create a vSG VM in compute node
836 2.Create a vCPE container in vSG VM
837 3.Ensure VM and containers created properly
838 4.Configure a user in XOS and assign a service id
839 5.Verify subscriber successfully configured in vCPE.
840 6.Now add devices( Mac addresses ) under the subscriber admin group
841 7.Verify all devices ( Macs ) added successfully
842 8.Now remove few devices in XOS
843 9.Verify devices removed successfully
844 10.Now add few additional devices in XOS under the same subscriber admin group
845 11.Verify newly added devices successfully added
846 """
847 def test_vsg_for_vcpe_login_fails_with_incorrect_subscriber_credentials(self):
848 """
849 Algo:
850 1.Create a vSG VM in compute node
851 2.Create a vCPE container in vSG VM
852 3.Ensure VM and containers created properly
853 4.Configure a subscriber in XOS and assign a service id
854 5.Verify subscriber successfully configured
855 6.Now add devices( Mac addresses ) under the subscriber admin group
856 7.Verify all devices ( Macs ) added successfully
857 8.Login vCPE with credentials with which subscriber configured
858 9.Verify subscriber successfully logged in
859 10.Logout and login again with incorrect credentials ( either user name or password )
860 11.Verify login attempt to vCPE fails wtih incorrect credentials
861 """
862 def test_vsg_for_subscriber_configuration_in_vcpe_retain_after_vcpe_restart(self):
863 """
864 Algo:
865 1.Create a vSG VM in compute node
866 2.Create a vCPE container in vSG VM
867 3.Ensure VM and containers created properly
868 4.Configure a subscriber in XOS and assign a service id
869 5.Verify subscriber successfully configured
870 6.Now add devices( Mac addresses ) under the subscriber admin group
871 7.Verify all devices ( Macs ) added successfully
872 8.Restart vCPE ( locate backup config path while restart )
873 9.Verify subscriber details in vCPE after restart should be same as before the restart
874 """
875 def test_vsg_for_create_multiple_vcpe_instances_and_configure_subscriber_in_each_instance(self):
876 """
877 Algo:
878 1.Create a vSG VM in compute node
879 2.Create 2 vCPE containers in vSG VM
880 3.Ensure VM and containers created properly
881 4.Configure a subscriber in XOS for each vCPE instance and assign a service id
882 5.Verify subscribers successfully configured
883 6.Now login vCPE-2 with subscriber-1 credentials
884 7.Verify login fails
885 8.Now login vCPE-1 with subscriber-2 credentials
886 9.Verify login fails
887 10.Now login vCPE-1 with subscriber-1 and vCPE-2 with subscriber-2 credentials
888 11.Verify that both the subscribers able to login to their respective vCPE containers
889 """
890 def test_vsg_for_same_subscriber_can_be_configured_for_multiple_services(self):
891 """
892 Algo:
893 1.Create 2 vSG VMs in compute node
894 2.Create a vCPE container in each vSG VM
895 3.Ensure VMs and containers created properly
896 4.Configure same subscriber in XOS for each vCPE instance and assign a service id
897 5.Verify subscriber successfully configured
898 6.Now login vCPE-1 with subscriber credentials
899 7.Verify login success
900 8.Now login vCPE-2 with the same subscriber credentials
901 9.Verify login success
902 """
903
904 #Test Example Service
905 def test_vsg_for_subcriber_avail_example_service_running_in_apache_server(self):
906 """
907 Algo:
908 1.Create a vSG VM in compute node
909 2.Create a vCPE container in each vSG VM
910 3.Ensure VM and container created properly
911 4.Configure a subscriber in XOS for the vCPE instance and assign a service id
912 5.On-board an example service into cord pod
913 6.Create a VM in compute node and run the example service ( Apache server )
914 7.Configure the example service with service specific and subscriber specific messages
915 8.Verify example service on-boarded successfully
916 9.Verify example service running in VM
917 10.Run a curl command from subscriber to reach example service
918 11.Verify subscriber can successfully reach example service via vSG
919 12.Verify that service specific and subscriber specific messages
920 """
921 def test_vsg_for_subcriber_avail_example_service_running_in_apache_server_after_service_restart(self):
922 """
923 Algo:
924 1.Create a vSG VM in compute node
925 2.Create a vCPE container in each vSG VM
926 3.Ensure VM and container created properly
927 4.Configure a subscriber in XOS for the vCPE instance and assign a service id
928 5.On-board an example service into cord pod
929 6.Create a VM in compute node and run the example service ( Apache server )
930 7.Configure the example service with service specific and subscriber specific messages
931 8.Verify example service on-boarded successfully
932 9.Verify example service running in VM
933 10.Run a curl command from subscriber to reach example service
934 11.Verify subscriber can successfully reach example service via vSG
935 12.Verify that service specific and subscriber specific messages
936 13.Restart example service running in VM
937 14.Repeat step 10
938 15.Verify the same results as mentioned in steps 11, 12
939 """
940
941 #vCPE Firewall Functionality
942 def test_vsg_firewall_for_creating_acl_rule_based_on_source_ip(self):
943 """
944 Algo:
945 1.Create a vSG VM in compute node
946 2.Create vCPE container in the VM
947 3.Ensure vSG VM and vCPE container created properly
948 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP
949 5.Bound the acl rule to WAN interface of vCPE
950 6.Verify configuration in vCPE is success
951 8.Verify flows added in OvS
952 """
953 def test_vsg_firewall_for_creating_acl_rule_based_on_destination_ip(self):
954 """
955 Algo:
956 1.Create a vSG VM in compute node
957 2.Create vCPE container in the VM
958 3.Ensure vSG VM and vCPE container created properly
959 4.Configure ac acl rule in vCPE to deny IP traffic to a destination ip
960 5.Bound the acl rule to WAN interface of vCPE
961 6.Verify configuration in vCPE is success
962 8.Verify flows added in OvS
963 """
964 def test_vsg_firewall_for_acl_deny_rule_based_on_source_ip_traffic(self):
965 """
966 Algo:
967 1.Create a vSG VM in compute node
968 2.Create vCPE container in the VM
969 3.Ensure vSG VM and vCPE container created properly
970 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP
971 5.Bound the acl rule to WAN interface of vCPE
972 6.From subscriber, send ping to the denied IP address
973 7.Verify that ping fails as vCPE denies ping response
974 8.Verify flows added in OvS
975 """
976 def test_vsg_firewall_for_acl_deny_rule_based_on_destination_ip_traffic(self):
977 """
978 Algo:
979 1.Create a vSG VM in compute node
980 2.Create vCPE container in the VM
981 3.Ensure vSG VM and vCPE container created properly
982 4.Configure ac acl rule in vCPE to deny IP traffic to a destination IP
983 5.Bound the acl rule to WAN interface of vCPE
984 6.From subscriber, send ping to the denied IP address
985 7.Verify that ping fails as vCPE drops the ping request at WAN interface
986 8.Verify flows added in OvS
987 """
Chetan Gaonker52418832017-01-26 23:03:13 +0000988
989 def test_vsg_dnsmasq(self):
990 pass
991
992 def test_vsg_with_external_parental_control_family_shield_for_filter(self):
993 pass
994
995 def test_vsg_with_external_parental_control_with_answerx(self):
996 pass
997
998 def test_vsg_for_subscriber_upstream_bandwidth(self):
999 pass
1000
1001 def test_vsg_for_subscriber_downstream_bandwidth(self):
1002 pass
1003
1004 def test_vsg_for_diagnostic_run_of_traceroute(self):
1005 pass
1006
1007 def test_vsg_for_diagnostic_run_of_tcpdump(self):
1008 pass
1009
1010 def test_vsg_for_iptable_rules(self):
1011 pass
1012
1013 def test_vsg_for_iptables_with_neutron(self):
1014 pass