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