blob: b76dd722a40f66dffce62fe47709fe0c0d1b96e4 [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 Karthick33cfdbe2017-03-17 18:03:48 -070018from CordTestUtils import *
A.R Karthickbe7768c2017-03-17 11:39:41 -070019from 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
A.R Karthick33cfdbe2017-03-17 18:03:48 -070035import shutil
Chetan Gaonker52418832017-01-26 23:03:13 +000036import json
37import random
38import collections
39import paramiko
A R Karthick03f40aa2017-03-20 19:33:55 -070040import re
Chetan Gaonker52418832017-01-26 23:03:13 +000041from paramiko import SSHClient
A.R Karthick9ccd0d02017-03-16 17:11:08 -070042from neutronclient.v2_0 import client as neutron_client
43from novaclient import client as nova_client
Chetan Gaonker52418832017-01-26 23:03:13 +000044log.setLevel('INFO')
45
46class vsg_exchange(CordLogger):
47 ONOS_INSTANCES = 3
48 V_INF1 = 'veth0'
49 device_id = 'of:' + get_mac()
Chetan Gaonker52418832017-01-26 23:03:13 +000050 TEST_IP = '8.8.8.8'
51 HOST = "10.1.0.1"
52 USER = "vagrant"
53 PASS = "vagrant"
A.R Karthick9ccd0d02017-03-16 17:11:08 -070054 head_node = os.environ['HEAD_NODE']
55 HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node
A R Karthick03f40aa2017-03-20 19:33:55 -070056 test_path = os.path.dirname(os.path.realpath(__file__))
57 olt_conf_file = os.path.join(test_path, '..', 'setup/olt_config.json')
58 ip_addr_pattern = re.compile('[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/[0-9]{1,2}$')
Chetan Gaonker52418832017-01-26 23:03:13 +000059
A.R Karthick33cfdbe2017-03-17 18:03:48 -070060 @classmethod
61 def setUpClass(cls):
62 cls.controllers = get_controllers()
63 cls.controller = cls.controllers[0]
64 cls.cli = None
65 cls.interface_map = {}
A R Karthick03f40aa2017-03-20 19:33:55 -070066 cls.vcpe_map = {}
67 cls.olt = OltConfig(olt_conf_file = cls.olt_conf_file)
68 cls.vcpes = cls.olt.get_vcpes()
69 cls.vcpes_dhcp = cls.olt.get_vcpes_by_type('dhcp')
70 vcpe_dhcp = None
71 vcpe_dhcp_stag = None
72 vcpe_container = None
73 #cache the first dhcp vcpe in the class for quick testing
74 if cls.vcpes_dhcp:
75 vcpe_container = 'vcpe-{}-{}'.format(cls.vcpes_dhcp[0]['s_tag'], cls.vcpes_dhcp[0]['c_tag'])
76 vcpe_dhcp = 'vcpe0.{}.{}'.format(cls.vcpes_dhcp[0]['s_tag'], cls.vcpes_dhcp[0]['c_tag'])
77 vcpe_dhcp_stag = 'vcpe0.{}'.format(cls.vcpes_dhcp[0]['s_tag'])
78 cls.vcpe_container = vcpe_container
79 cls.vcpe_dhcp = vcpe_dhcp
80 cls.vcpe_dhcp_stag = vcpe_dhcp_stag
A.R Karthick33cfdbe2017-03-17 18:03:48 -070081 try:
82 shutil.copy('/etc/resolv.conf', '/etc/resolv.conf.orig')
83 except:
84 pass
Chetan Gaonker52418832017-01-26 23:03:13 +000085
A.R Karthick33cfdbe2017-03-17 18:03:48 -070086 @classmethod
87 def tearDownClass(cls):
88 try:
89 shutil.copy('/etc/resolv.conf.orig', '/etc/resolv.conf')
90 except:
91 pass
Chetan Gaonker52418832017-01-26 23:03:13 +000092
Chetan Gaonker52418832017-01-26 23:03:13 +000093 def cliEnter(self, controller = None):
94 retries = 0
95 while retries < 30:
96 self.cli = OnosCliDriver(controller = controller, connect = True)
97 if self.cli.handle:
98 break
99 else:
100 retries += 1
101 time.sleep(2)
102
103 def cliExit(self):
104 self.cli.disconnect()
105
106 def onos_shutdown(self, controller = None):
107 status = True
108 self.cliEnter(controller = controller)
109 try:
110 self.cli.shutdown(timeout = 10)
111 except:
112 log.info('Graceful shutdown of ONOS failed for controller: %s' %controller)
113 status = False
114
115 self.cliExit()
116 return status
117
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700118 def log_set(self, level = None, app = 'org.onosproject'):
119 CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000120
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700121 def get_nova_credentials_v2(self):
Chetan Gaonker52418832017-01-26 23:03:13 +0000122 credential = {}
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700123 credential['username'] = os.environ['OS_USERNAME']
124 credential['api_key'] = os.environ['OS_PASSWORD']
125 credential['auth_url'] = os.environ['OS_AUTH_URL']
126 credential['project_id'] = os.environ['OS_TENANT_NAME']
Chetan Gaonker52418832017-01-26 23:03:13 +0000127 return credential
128
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700129 def get_compute_nodes(self):
130 credentials = self.get_nova_credentials_v2()
131 nvclient = nova_client.Client('2', **credentials)
132 return nvclient.hypervisors.list()
Chetan Gaonker52418832017-01-26 23:03:13 +0000133
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700134 def get_vsgs(self, active = True):
135 credentials = self.get_nova_credentials_v2()
136 nvclient = nova_client.Client('2', **credentials)
137 vsgs = nvclient.servers.list(search_opts = {'all_tenants': 1})
138 if active is True:
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700139 return filter(lambda vsg: vsg.status == 'ACTIVE', vsgs)
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700140 return vsgs
141
A R Karthick3e13f132017-03-21 14:15:53 -0700142 def get_vsg_ip(self, vm_name, vcpe = None):
143 if vcpe is not None:
144 if vcpe in self.vcpe_map:
145 return self.vcpe_map[vcpe]['vsg_ip']
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700146 vsgs = self.get_vsgs()
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700147 vms = filter(lambda vsg: vsg.name == vm_name, vsgs)
148 if vms:
149 vm = vms[0]
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700150 if vm.networks.has_key('management'):
151 ips = vm.networks['management']
152 if len(ips) > 0:
153 return ips[0]
154 return None
155
156 def get_compute_node(self, vsg):
157 return vsg._info['OS-EXT-SRV-ATTR:hypervisor_hostname']
158
A R Karthick03f40aa2017-03-20 19:33:55 -0700159 def run_cmd_compute(self, compute, cmd, timeout = 5):
160 ssh_agent = SSHTestAgent(compute)
161 st, output = ssh_agent.run_cmd(cmd, timeout = timeout)
162 if st == True and output:
163 output = output.strip()
164 else:
165 output = None
166
167 return st, output
168
169 def run_cmd_vsg(self, compute, vsg_ip, cmd, timeout = 5, mgmt = 'eth0'):
170 last_gw = self.open_compute(mgmt)
171 ssh_agent = SSHTestAgent(compute)
172 ssh_cmd = 'ssh {} {}'.format(vsg_ip, cmd)
173 st, output = ssh_agent.run_cmd(ssh_cmd, timeout = timeout)
174 if st == True and output:
175 output = output.strip()
176 else:
177 output = None
178 self.close_compute(last_gw, mgmt)
179 return st, output
180
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700181 #ping the vsg through the compute node.
182 #the ssh key is already used by SSHTestAgent in cord-tester
183 def get_vsg_health(self, vsg):
184 compute_node = self.get_compute_node(vsg)
185 vsg_ip = self.get_vsg_ip(vsg.name)
186 if vsg_ip is None:
187 return False
A R Karthick03f40aa2017-03-20 19:33:55 -0700188 cmd = 'ping -c 1 {}'.format(vsg_ip)
189 st, _ = self.run_cmd_compute(compute_node, cmd)
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700190 return st
191
192 #returns 0 if all active vsgs are reachable through the compute node
Chetan Gaonker52418832017-01-26 23:03:13 +0000193 def health_check(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700194 vsgs = self.get_vsgs()
195 vsg_status = []
196 for vsg in vsgs:
197 vsg_status.append(self.get_vsg_health(vsg))
198 unreachable = filter(lambda st: st == False, vsg_status)
199 return len(unreachable) == 0
Chetan Gaonker52418832017-01-26 23:03:13 +0000200
A R Karthick03f40aa2017-03-20 19:33:55 -0700201 #find the vsg hosting the vcpe service
202 def get_vcpe_vsg(self, vcpe):
203 if vcpe in self.vcpe_map:
204 return self.vcpe_map[vcpe]['vsg']
205 vsgs = self.get_vsgs()
206 for vsg in vsgs:
207 vsg_ip = self.get_vsg_ip(vsg.name)
208 compute_node = self.get_compute_node(vsg)
209 cmd = 'sudo docker exec {} ls 2>/dev/null'.format(vcpe)
210 st, _ = self.run_cmd_vsg(compute_node, vsg_ip, cmd, timeout = 30)
211 if st == True:
212 return vsg
213 return None
214
215 def save_vcpe_config(self, vsg, vcpe):
216 if vcpe not in self.vcpe_map:
217 cmd_gw = "sudo docker exec %s ip route show | grep default | head -1 | awk '{print $3}'" %(vcpe)
218 vsg_ip = self.get_vsg_ip(vsg.name)
219 if vsg_ip is None:
220 return False
221 compute_node = self.get_compute_node(vsg)
222 st, output = self.run_cmd_vsg(compute_node, vsg_ip, cmd_gw, timeout = 30)
223 if st == False or not output:
224 return False
225 gw = output
226 cmd_wan = "sudo docker exec %s ip addr show eth0 |grep inet |head -1 | tr -s ' ' | awk '{print $2}' | awk '{print $1}'" %(vcpe)
227 cmd_lan = "sudo docker exec %s ip addr show eth1 |grep inet |head -1 | tr -s ' ' | awk '{print $2}' | awk '{print $1}'" %(vcpe)
228 st, output = self.run_cmd_vsg(compute_node, vsg_ip, cmd_wan, timeout = 30)
229 ip_wan = '0.0.0.0/24'
230 ip_lan = '0.0.0.0/24'
231 if st and output:
232 if self.ip_addr_pattern.match(output):
233 ip_wan = output
234
235 st, output = self.run_cmd_vsg(compute_node, vsg_ip, cmd_lan, timeout = 30)
236 if st and output:
237 if self.ip_addr_pattern.match(output):
238 ip_lan = output
239
240 self.vcpe_map[vcpe] = { 'vsg': vsg, 'vsg_ip': vsg_ip, 'gw': gw, 'wan': ip_wan, 'lan': ip_lan }
241
242 return True
243
244 def restore_vcpe_config(self, vcpe, gw = True, wan = False, lan = False):
245 if vcpe in self.vcpe_map:
246 vsg = self.vcpe_map[vcpe]['vsg']
247 vsg_ip = self.vcpe_map[vcpe]['vsg_ip']
248 compute_node = self.get_compute_node(vsg)
249 cmds = []
250 if gw is True:
251 #restore default gw
252 gw = self.vcpe_map[vcpe]['gw']
253 cmds.append('sudo docker exec {} ip link set eth0 up'.format(vcpe))
254 cmds.append('sudo docker exec {} route add default gw {} dev eth0'.format(vcpe, gw))
255 if wan is True:
256 ip_wan = self.vcpe_map[vcpe]['wan']
257 cmds.append('sudo docker exec {} ip addr set {} dev eth0'.format(vcpe, ip_wan))
258 if lan is True:
259 ip_lan = self.vcpe_map[vcpe]['lan']
260 cmds.append('sudo docker exec {} ip addr set {} dev eth1'.format(vcpe, ip_lan))
261 ret_status = True
262 for cmd in cmds:
263 st, _ = self.run_cmd_vsg(compute_node, vsg_ip, cmd, timeout = 30)
264 if st == False:
265 ret_status = False
266 return ret_status
267 return False
268
269 def get_vcpe_gw(self, vcpe):
270 if vcpe in self.vcpe_map:
271 return self.vcpe_map[vcpe]['gw']
272 return None
273
274 def get_vcpe_wan(self, vcpe):
275 if vcpe in self.vcpe_map:
276 return self.vcpe_map[vcpe]['wan']
277 return None
278
279 def get_vcpe_lan(self, vcpe):
280 if vcpe in self.vcpe_map:
281 return self.vcpe_map[vcpe]['lan']
282 return None
283
284 def vcpe_wan_up(self, vcpe, vsg = None):
285 if vsg is None:
286 vsg = self.get_vcpe_vsg(vcpe)
287 if vsg is None:
288 return False
289 return self.restore_vcpe_config(vcpe)
290
291 def vcpe_lan_up(self, vcpe, vsg = None):
292 if vsg is None:
293 vsg = self.get_vcpe_vsg(vcpe)
294 if vsg is None:
295 return False
A R Karthick3e13f132017-03-21 14:15:53 -0700296 vsg_ip = self.get_vsg_ip(vsg.name, vcpe = vcpe)
A R Karthick03f40aa2017-03-20 19:33:55 -0700297 compute_node = self.get_compute_node(vsg)
298 cmd = 'sudo docker exec {} ip link set eth1 up'.format(vcpe)
299 st, _ = self.run_cmd_vsg(compute_node, vsg_ip, cmd, timeout = 30)
300 return st
301
302 #we cannot access compute node if the vcpe port gets dhcp as default would be through fabric
303 def vcpe_port_down(self, vcpe, port, vsg = None):
304 if vsg is None:
305 vsg = self.get_vcpe_vsg(vcpe)
306 if vsg is None:
307 return False
308 if not self.save_vcpe_config(vsg, vcpe):
309 return False
A R Karthick3e13f132017-03-21 14:15:53 -0700310 vsg_ip = self.get_vsg_ip(vsg.name, vcpe = vcpe)
A R Karthick03f40aa2017-03-20 19:33:55 -0700311 compute_node = self.get_compute_node(vsg)
312 cmd = 'sudo docker exec {} ip link set {} down'.format(vcpe, port)
313 st, _ = self.run_cmd_vsg(compute_node, vsg_ip, cmd, timeout = 30)
314 if st is False:
315 self.restore_vcpe_config(vcpe)
316 return False
317 return st
318
319 def vcpe_wan_down(self, vcpe, vsg = None):
320 return self.vcpe_port_down(vcpe, 'eth0', vsg = vsg)
321
322 def vcpe_lan_down(self, vcpe, vsg = None):
323 return self.vcpe_port_down(vcpe, 'eth1', vsg = vsg)
324
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700325 #use SSHTestAgent to talk to the vsg through the compute node like in get_vsg_health
326 # def connect_ssh(vsg_ip, private_key_file=None, user='ubuntu'):
327 # key = ssh.RSAKey.from_private_key_file(private_key_file)
328 # client = ssh.SSHClient()
329 # client.set_missing_host_key_policy(ssh.WarningPolicy())
330 # client.connect(ip, username=user, pkey=key, timeout=5)
331 # return client
Chetan Gaonker52418832017-01-26 23:03:13 +0000332
333 def test_vsg_vm(self):
334 status = self.health_check()
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700335 assert_equal( status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000336
337 def test_vsg_for_default_route_to_vsg_vm(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700338 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
Chetan Gaonker52418832017-01-26 23:03:13 +0000339 cmd = "sudo lxc exec testclient -- route | grep default"
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700340 status, output = ssh_agent.run_cmd(cmd)
341 assert_equal(status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000342
343 def test_vsg_vm_for_vcpe(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700344 vsgs = self.get_vsgs()
345 compute_nodes = self.get_compute_nodes()
346 assert_not_equal(len(vsgs), 0)
347 assert_not_equal(len(compute_nodes), 0)
Chetan Gaonker52418832017-01-26 23:03:13 +0000348
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700349 #TODO: use cord-test container itself to dhclient on vcpe interfaces
350 #using the info from OltConfig().get_vcpes()
351 #deleting default through eth0, fetching ip through dhclient on vcpe,
352 #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 +0000353 def test_vsg_for_external_connectivity(self):
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700354 ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS)
Chetan Gaonker52418832017-01-26 23:03:13 +0000355 cmd = "lxc exec testclient -- ping -c 3 8.8.8.8"
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700356 status, output = ssh_agent.run_cmd(cmd)
357 assert_equal( status, True)
Chetan Gaonker52418832017-01-26 23:03:13 +0000358
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700359 def check_vsg_access(self, vsg):
360 compute_node = self.get_compute_node(vsg)
361 vsg_ip = self.get_vsg_ip(vsg.name)
362 if vsg_ip is None:
363 return False
364 ssh_agent = SSHTestAgent(compute_node)
365 st, _ = ssh_agent.run_cmd('ls', timeout=10)
366 if st == False:
367 return st
368 st, _ = ssh_agent.run_cmd('ssh {} ls'.format(vsg_ip), timeout=30)
369 return st
370
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000371 def test_vsg_vm_for_login_to_vsg(self):
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700372 vsgs = self.get_vsgs()
373 vsg_access_status = map(self.check_vsg_access, vsgs)
374 status = filter(lambda st: st == False, vsg_access_status)
375 assert_equal(len(status), 0)
376
377 def save_interface_config(self, intf):
378 if intf not in self.interface_map:
379 ip = get_ip(intf)
380 if ip is None:
381 ip = '0.0.0.0'
382 default_gw, default_gw_device = get_default_gw()
383 if default_gw_device != intf:
384 default_gw = '0.0.0.0'
385 self.interface_map[intf] = { 'ip' : ip, 'gw': default_gw }
386 #bounce the interface to remove default gw
387 cmds = ['ifconfig {} 0 down'.format(intf),
388 'ifconfig {} 0 up'.format(intf)
389 ]
390 for cmd in cmds:
391 os.system(cmd)
392
A R Karthick03f40aa2017-03-20 19:33:55 -0700393 #open up access to compute node
394 def open_compute(self, intf = 'eth0'):
395 if intf in self.interface_map:
396 gw = self.interface_map[intf]['gw']
397 ip = self.interface_map[intf]['ip']
398 if gw != '0.0.0.0':
399 current_gw, _ = get_default_gw()
400 cmds = [ 'route del default gw {}'.format(current_gw),
401 'ifconfig {} {} up'.format(intf, ip),
402 'route add default gw {}'.format(gw) ]
403 for cmd in cmds:
404 os.system(cmd)
405 shutil.copy('/etc/resolv.conf', '/etc/resolv.conf.lastdhcp')
406 shutil.copy('/etc/resolv.conf.orig', '/etc/resolv.conf')
407 return current_gw
408
409 return None
410
411 def close_compute(self, restore_gw, intf = 'eth0'):
412 if restore_gw:
413 cmds = [ 'route del default gw 0.0.0.0',
414 'route add default gw {}'.format(restore_gw),
415 'cp /etc/resolv.conf.lastdhcp /etc/resolv.conf',
416 'rm -f /etc/resolv.conf.lastdhcp'
417 ]
418 for cmd in cmds:
419 os.system(cmd)
420
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700421 def restore_interface_config(self, intf, vcpe = None):
422 if intf in self.interface_map:
423 ip = self.interface_map[intf]['ip']
424 gw = self.interface_map[intf]['gw']
425 del self.interface_map[intf]
426 cmds = []
427 if vcpe is not None:
428 shutil.copy('/etc/resolv.conf.orig', '/etc/resolv.conf')
429 #bounce the vcpes to clear default gw
430 cmds.append('ifconfig {} 0 down'.format(vcpe))
431 cmds.append('ifconfig {} 0 up'.format(vcpe))
432 cmds.append('ifconfig {} {} up'.format(intf, ip))
433 if gw and gw != '0.0.0.0':
434 cmds.append('route add default gw {} dev {}'.format(gw, intf))
435 for cmd in cmds:
436 os.system(cmd)
437
438 def vcpe_get_dhcp(self, vcpe, mgmt = 'eth0'):
439 self.save_interface_config(mgmt)
A R Karthick03f40aa2017-03-20 19:33:55 -0700440 getstatusoutput('pkill -9 dhclient')
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700441 st, output = getstatusoutput('dhclient -q {}'.format(vcpe))
A R Karthick03f40aa2017-03-20 19:33:55 -0700442 getstatusoutput('pkill -9 dhclient')
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700443 vcpe_ip = get_ip(vcpe)
444 if vcpe_ip is None:
445 self.restore_interface_config(mgmt)
446 return None
447 if output:
448 #workaround for docker container apparmor that prevents moving dhclient resolv.conf
449 start = output.find('/etc/resolv.conf')
450 if start >= 0:
451 end = output.find("'", start)
452 dns_file = output[start:end]
453 if os.access(dns_file, os.F_OK):
454 shutil.copy(dns_file, '/etc/resolv.conf')
455
456 default_gw, default_gw_device = get_default_gw()
457 if default_gw and default_gw_device == vcpe:
458 return vcpe_ip
459 self.restore_interface_config(mgmt, vcpe = vcpe)
460 return None
Chetan Gaonker52418832017-01-26 23:03:13 +0000461
A.R Karthick9ccd0d02017-03-16 17:11:08 -0700462 #these need to first get dhcp through dhclient on vcpe interfaces (using OltConfig get_vcpes())
Chetan Gaonker1b564fe2017-03-21 19:19:12 +0000463 def test_vsg_external_connectivity_sending_icmp_echo_requests(self):
A R Karthick03f40aa2017-03-20 19:33:55 -0700464 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700465 mgmt = 'eth0'
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000466 host = '8.8.8.8'
467 self.success = False
A R Karthick03f40aa2017-03-20 19:33:55 -0700468 assert_not_equal(vcpe, None)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700469 vcpe_ip = self.vcpe_get_dhcp(vcpe, mgmt = mgmt)
470 assert_not_equal(vcpe_ip, None)
471 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
472 log.info('Sending icmp echo requests to external network 8.8.8.8')
473 st, _ = getstatusoutput('ping -c 3 8.8.8.8')
474 self.restore_interface_config(mgmt, vcpe = vcpe)
475 assert_equal(st, 0)
Chetan Gaonker52418832017-01-26 23:03:13 +0000476
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000477 def test_vsg_external_connectivity_sending_icmp_ping_on_different_interface(self):
478 host = '8.8.8.8'
479 self.success = False
480 def mac_recv_task():
481 def recv_cb(pkt):
482 log.info('Recieved icmp echo reply which is not expected')
483 self.success = True
484 sniff(count=1, timeout=5,
485 lfilter = lambda p: IP in p and p[ICMP].type == 0,
486 prn = recv_cb, iface = 'vcpe0.222.112')
487 t = threading.Thread(target = mac_recv_task)
488 t.start()
489 L3 = IP(dst = host)
490 pkt = L3/ICMP()
491 log.info('Sending icmp echo requests to external network')
492 send(pkt, count=3, iface = 'vcpe0.222.112')
493 t.join()
494 assert_equal(self.success, False)
495
496 def test_vsg_external_connectivity_pinging_with_single_tag_negative_scenario(self):
497 host = '8.8.8.8'
498 self.success = False
A R Karthick03f40aa2017-03-20 19:33:55 -0700499 assert_not_equal(self.vcpe_dhcp_stag, None)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000500 def mac_recv_task():
501 def recv_cb(pkt):
502 log.info('Recieved icmp echo reply which is not expected')
503 self.success = True
504 sniff(count=1, timeout=5,
A R Karthick03f40aa2017-03-20 19:33:55 -0700505 lfilter = lambda p: IP in p and p[ICMP].type == 0,
506 prn = recv_cb, iface = self.vcpe_dhcp_stag)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000507 t = threading.Thread(target = mac_recv_task)
508 t.start()
509 L3 = IP(dst = host)
510 pkt = L3/ICMP()
511 log.info('Sending icmp echo requests to external network')
A R Karthick03f40aa2017-03-20 19:33:55 -0700512 send(pkt, count=3, iface = self.vcpe_dhcp_stag)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000513 t.join()
514 assert_equal(self.success, False)
515
516 def test_vsg_external_connectivity_pinging_to_google(self):
517 host = 'www.google.com'
A R Karthick03f40aa2017-03-20 19:33:55 -0700518 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700519 mgmt = 'eth0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700520 assert_not_equal(vcpe, None)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700521 vcpe_ip = self.vcpe_get_dhcp(vcpe, mgmt = mgmt)
522 assert_not_equal(vcpe_ip, None)
523 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
524 log.info('Sending icmp ping requests to %s' %host)
525 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
526 self.restore_interface_config(mgmt, vcpe = vcpe)
527 assert_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000528
529 def test_vsg_external_connectivity_pinging_to_non_existing_website(self):
530 host = 'www.goglee.com'
A R Karthick03f40aa2017-03-20 19:33:55 -0700531 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700532 mgmt = 'eth0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700533 assert_not_equal(vcpe, None)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700534 vcpe_ip = self.vcpe_get_dhcp(vcpe, mgmt = mgmt)
535 assert_not_equal(vcpe_ip, None)
536 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
537 log.info('Sending icmp ping requests to non existent host %s' %host)
538 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
539 self.restore_interface_config(mgmt, vcpe = vcpe)
540 assert_not_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000541
542 def test_vsg_external_connectivity_ping_to_google_with_ttl_1(self):
543 host = '8.8.8.8'
A R Karthick03f40aa2017-03-20 19:33:55 -0700544 vcpe = self.vcpe_dhcp
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700545 mgmt = 'eth0'
A R Karthick03f40aa2017-03-20 19:33:55 -0700546 assert_not_equal(vcpe, None)
A.R Karthick33cfdbe2017-03-17 18:03:48 -0700547 vcpe_ip = self.vcpe_get_dhcp(vcpe, mgmt = mgmt)
548 assert_not_equal(vcpe_ip, None)
549 log.info('Got DHCP IP %s for %s' %(vcpe_ip, vcpe))
550 log.info('Sending icmp ping requests to host %s with ttl 1' %host)
551 st, _ = getstatusoutput('ping -c 1 -t 1 {}'.format(host))
552 self.restore_interface_config(mgmt, vcpe = vcpe)
553 assert_not_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000554
Chetan Gaonker1b564fe2017-03-21 19:19:12 +0000555 def test_vsg_for_external_connectivity_with_wan_interface_toggle_in_vcpe_container(self):
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000556 host = '8.8.8.8'
A R Karthick03f40aa2017-03-20 19:33:55 -0700557 mgmt = 'eth0'
558 vcpe = self.vcpe_container
559 assert_not_equal(vcpe, None)
560 assert_not_equal(self.vcpe_dhcp, None)
561 #first get dhcp on the vcpe interface
562 vcpe_ip = self.vcpe_get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
563 assert_not_equal(vcpe_ip, None)
564 log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
565 log.info('Sending ICMP pings to host %s' %(host))
566 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
567 if st != 0:
568 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
569 assert_equal(st, 0)
570 #bring down the wan interface and check again
571 st = self.vcpe_wan_down(vcpe)
572 if st is False:
573 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
574 assert_equal(st, True)
575 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
576 if st == 0:
577 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
578 assert_not_equal(st, 0)
579 st = self.vcpe_wan_up(vcpe)
580 if st is False:
581 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
582 assert_equal(st, True)
583 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
A R Karthick3e13f132017-03-21 14:15:53 -0700584 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700585 assert_equal(st, 0)
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000586
Chetan Gaonker1b564fe2017-03-21 19:19:12 +0000587 def test_vsg_for_external_connectivity_with_lan_interface_toggle_in_vcpe_container(self):
Anil Kumar Sanka87115b02017-03-14 17:46:47 +0000588 host = '8.8.8.8'
A R Karthick03f40aa2017-03-20 19:33:55 -0700589 mgmt = 'eth0'
590 vcpe = self.vcpe_container
591 assert_not_equal(vcpe, None)
592 assert_not_equal(self.vcpe_dhcp, None)
593 #first get dhcp on the vcpe interface
594 vcpe_ip = self.vcpe_get_dhcp(self.vcpe_dhcp, mgmt = mgmt)
595 assert_not_equal(vcpe_ip, None)
596 log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp))
597 log.info('Sending ICMP pings to host %s' %(host))
598 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
599 if st != 0:
600 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
601 assert_equal(st, 0)
602 #bring down the lan interface and check again
603 st = self.vcpe_lan_down(vcpe)
604 if st is False:
605 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
606 assert_equal(st, True)
607 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
608 if st == 0:
609 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
610 assert_not_equal(st, 0)
611 st = self.vcpe_lan_up(vcpe)
612 if st is False:
613 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
614 assert_equal(st, True)
615 st, _ = getstatusoutput('ping -c 1 {}'.format(host))
A R Karthick3e13f132017-03-21 14:15:53 -0700616 self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp)
A R Karthick03f40aa2017-03-20 19:33:55 -0700617 assert_equal(st, 0)
Chetan Gaonker52418832017-01-26 23:03:13 +0000618
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +0000619 def test_vsg_for_ping_from_vsg_to_external_network(self):
620 """
621 Algo:
622 1.Create a vSG VM in compute node
623 2.Ensure VM created properly
624 3.Verify login to VM success
625 4.Do ping to external network from vSG VM
626 5.Verify that ping gets success
627 6.Verify ping success flows added in OvS
628 """
629 def test_vsg_for_ping_from_vcpe_to_external_network(self):
630 """
631 Algo:
632 1.Create a vSG VM in compute node
633 2.Create a vCPE container inside VM
634 3.Verify both VM and Container created properly
635 4.Verify login to vCPE container success
636 5.Do ping to external network from vCPE container
637 6.Verify that ping gets success
638 7.Verify ping success flows added in OvS
639 """
640
Chetan Gaonker52418832017-01-26 23:03:13 +0000641 def test_vsg_for_dns_service(self):
Anil Kumar Sanka1213d4c2017-02-23 22:50:48 +0000642 """
643 Algo:
644 1. Create a test client in Prod VM
645 2. Create a vCPE container in vSG VM inside compute Node
646 3. Ensure vSG VM and vCPE container created properly
647 4. Enable dns service in vCPE ( if not by default )
648 5. Send ping request from test client to valid domain address say, 'www.google'com
649 6. Verify that dns should resolve ping should success
650 7. Now send ping request to invalid domain address say 'www.invalidaddress'.com'
651 8. Verify that dns resolve should fail and hence ping
652 """
653 def test_vsg_for_10_subscribers_for_same_service(self):
654 """
655 Algo:
656 1.Create a vSG VM in compute node
657 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
658 3.Ensure vSG VM and vCPE container created properly
659 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP
660 5.Verify that ping success for all 10 subscribers
661 """
662 def test_vsg_for_10_subscribers_for_same_service_ping_invalid_ip(self):
663 """
664 Algo:
665 1.Create a vSG VM in compute Node
666 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
667 3.Ensure vSG VM and vCPE container created properly
668 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP
669 5.Verify that ping fails for all 10 subscribers
670 """
671 def test_vsg_for_10_subscribers_for_same_service_ping_valid_and_invalid_ip(self):
672 """
673 Algo:
674 1.Create a vSG VM in VM
675 2.Create 10 vCPE containers for 10 subscribers, in vSG VM
676 3.Ensure vSG VM and vCPE container created properly
677 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP
678 5.Verify that ping success for all 5 subscribers
679 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP
680 7.Verify that ping fails for all 5 subscribers
681 """
682 def test_vsg_for_100_subscribers_for_same_service(self):
683 """
684 Algo:
685 1.Create a vSG VM in compute node
686 2.Create 100 vCPE containers for 100 subscribers, in vSG VM
687 3.Ensure vSG VM and vCPE container created properly
688 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP
689 5.Verify that ping success for all 100 subscribers
690 """
691 def test_vsg_for_100_subscribers_for_same_service_ping_invalid_ip(self):
692 """
693 Algo:
694 1.Create a vSG VM in compute Node
695 2.Create 10 vCPE containers for 100 subscribers, in vSG VM
696 3.Ensure vSG VM and vCPE container created properly
697 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP
698 5.Verify that ping fails for all 100 subscribers
699 """
700 def test_vsg_for_100_subscribers_for_same_service_ping_valid_and_invalid_ip(self):
701 """
702 Algo:
703 1.Create a vSG VM in VM
704 2.Create 10 vCPE containers for 100 subscribers, in vSG VM
705 3.Ensure vSG VM and vCPE container created properly
706 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP
707 5.Verify that ping success for all 5 subscribers
708 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP
709 7.Verify that ping fails for all 5 subscribers
710 """
711 def test_vsg_for_packet_received_with_invalid_ip_fields(self):
712 """
713 Algo:
714 1.Create a vSG VM in compute node
715 2.Create a vCPE container in vSG VM
716 3.Ensure vSG VM and vCPE container created properly
717 4.From subscriber, send a ping packet with invalid ip fields
718 5.Verify that vSG drops the packet
719 6.Verify ping fails
720 """
721 def test_vsg_for_packet_received_with_invalid_mac_fields(self):
722 """
723 Algo:
724 1.Create a vSG VM in compute node
725 2.Create a vCPE container in vSG VM
726 3.Ensure vSG VM and vCPE container created properly
727 4.From subscriber, send a ping packet with invalid mac fields
728 5.Verify that vSG drops the packet
729 6.Verify ping fails
730 """
731 def test_vsg_for_vlan_id_mismatch_in_stag(self):
732 """
733 Algo:
734 1.Create a vSG VM in compute Node
735 2.Create a vCPE container in vSG VM
736 3.Ensure vSG VM and vCPE container created properly
737 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag
738 5.Verify that ping fails as the packet drops at VM entry
739 6.Repeat step 4 with correct s-tag
740 7.Verify that ping success
741 """
742 def test_vsg_for_vlan_id_mismatch_in_ctag(self):
743 """
744 Algo:
745 1.Create a vSG VM in compute node
746 2.Create a vCPE container in vSG VM
747 3.Ensure vSG VM and vCPE container created properly
748 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag
749 5.Verify that ping fails as the packet drops at vCPE container entry
750 6.Repeat step 4 with valid s-tag and c-tag
751 7.Verify that ping success
752 """
753 def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self):
754 """
755 Algo:
756 1.Create two vSG VMs in compute node
757 2.Create a vCPE container in each vSG VM
758 3.Ensure vSG VM and vCPE container created properly
759 4.From subscriber one, send ping request with valid s and c tags
760 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags
761 6.Verify that ping success for only subscriber one and fails for two.
762 """
763 def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self):
764 """
765 Algo:
766 1.Create a vSG VM in compute node
767 2.Create two vCPE containers in vSG VM
768 3.Ensure vSG VM and vCPE container created properly
769 4.From subscriber one, send ping request with valid s and c tags
770 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag
771 6.Verify that ping success for only subscriber one and fails for two
772 """
773 def test_vsg_for_out_of_range_vlanid_in_ctag(self):
774 """
775 Algo:
776 1.Create a vSG VM in compute node
777 2.Create a vCPE container in vSG VM
778 3.Ensure vSG VM and vCPE container created properly
779 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 )
780 4.Verify that ping fails as the ping packets drops at vCPE container entry
781 """
782 def test_vsg_for_out_of_range_vlanid_in_stag(self):
783 """
784 Algo:
785 1.Create a vSG VM in compute node
786 2.Create a vCPE container in vSG VM
787 3.Ensure vSG VM and vCPE container created properly
788 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
789 4.Verify that ping fails as the ping packets drops at vSG VM entry
790 """
791 def test_vsg_without_creating_vcpe_instance(self):
792 """
793 Algo:
794 1.Create a vSG VM in compute Node
795 2.Ensure vSG VM created properly
796 3.Do not create vCPE container inside vSG VM
797 4.From a subscriber, send ping to external valid IP
798 5.Verify that ping fails as the ping packet drops at vSG VM entry itself.
799 """
800 def test_vsg_for_remove_vcpe_instance(self):
801 """
802 Algo:
803 1.Create a vSG VM in compute node
804 2.Create a vCPE container in vSG VM
805 3.Ensure vSG VM and vCPE container created properly
806 4.From subscriber, send ping request with valid s-tag and c-tag
807 5.Verify that ping success
808 6.Verify ping success flows in OvS switch in compute node
809 7.Now remove the vCPE container in vSG VM
810 8.Ensure that the container removed properly
811 9.Repeat step 4
812 10.Verify that now, ping fails
813 """
814 def test_vsg_for_restart_vcpe_instance(self):
815 """
816 Algo:
817 1.Create a vSG VM in compute node
818 2.Create a vCPE container in vSG VM
819 3.Ensure vSG VM and vCPE container created properly
820 4.From subscriber, send ping request with valid s-tag and c-tag
821 5.Verify that ping success
822 6.Verify ping success flows in OvS switch in compute node
823 7.Now restart the vCPE container in vSG VM
824 8.Ensure that the container came up after restart
825 9.Repeat step 4
826 10.Verify that now,ping gets success and flows added in OvS
827 """
828 def test_vsg_for_restart_vsg_vm(self):
829 """
830 Algo:
831 1.Create a vSG VM in compute node
832 2.Create a vCPE container in vSG VM
833 3.Ensure vSG VM and vCPE container created properly
834 4.From subscriber, send ping request with valid s-tag and c-tag
835 5.Verify that ping success
836 6.Verify ping success flows in OvS switch in compute node
837 7.Now restart the vSG VM
838 8.Ensure that the vSG comes up properly after restart
839 9.Verify that vCPE container comes up after vSG restart
840 10.Repeat step 4
841 11.Verify that now,ping gets success and flows added in OvS
842 """
843 def test_vsg_for_pause_vcpe_instance(self):
844 """
845 Algo:
846 1.Create a vSG VM in compute node
847 2.Create a vCPE container in vSG VM
848 3.Ensure vSG VM and vCPE container created properly
849 4.From subscriber, send ping request with valid s-tag and c-tag
850 5.Verify that ping success
851 6.Verify ping success flows in OvS switch in compute node
852 7.Now pause vCPE container in vSG VM for a while
853 8.Ensure that the container state is pause
854 9.Repeat step 4
855 10.Verify that now,ping fails now and verify flows in OvS
856 11.Now resume the container
857 12.Now repeat step 4 again
858 13.Verify that now, ping gets success
859 14.Verify ping success flows in OvS
860 """
861 def test_vsg_for_extract_all_compute_stats_from_all_vcpe_containers(self):
862 """
863 Algo:
864 1.Create a vSG VM in compute node
865 2.Create 10 vCPE containers in VM
866 3.Ensure vSG VM and vCPE containers created properly
867 4.Login to all vCPE containers
868 4.Get all compute stats from all vCPE containers
869 5.Verify the stats # verification method need to add
870 """
871 def test_vsg_for_extract_dns_stats_from_all_vcpe_containers(self):
872 """
873 Algo:
874 1.Create a vSG VM in compute node
875 2.Create 10 vCPE containers in VM
876 3.Ensure vSG VM and vCPE containers created properly
877 4.From 10 subscribers, send ping to valid and invalid dns hosts
878 5.Verify dns resolves and ping success for valid dns hosts
879 6.Verify ping fails for invalid dns hosts
880 7.Verify dns host name resolve flows in OvS
881 8.Login to all 10 vCPE containers
882 9.Extract all dns stats
883 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios
884 """
885 def test_vsg_for_subscriber_access_two_vsg_services(self):
886 """
887 # Intention is to verify if subscriber can reach internet via two vSG VMs
888 Algo:
889 1.Create two vSG VMs for two services in compute node
890 2.Create one vCPE container in each VM for one subscriber
891 3.Ensure VMs and containers created properly
892 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
893 5.Verify ping gets success
894 6.Verify ping success flows in OvS
895 7.Now repeat step 4 with stag corresponds to vSG-2 VM
896 8.Verify that ping again success
897 9.Verify ping success flows in OvS
898 """
899 def test_vsg_for_subscriber_access_service2_if_service1_goes_down(self):
900 """
901 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down
902 Algo:
903 1.Create two vSG VMs for two services in compute node
904 2.Create one vCPE container in each VM for one subscriber
905 3.Ensure VMs and containers created properly
906 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
907 5.Verify ping gets success
908 6.Verify ping success flows in OvS
909 7.Down the vSG-1 VM
910 8.Now repeat step 4
911 9.Verify that ping fails as vSG-1 is down
912 10.Repeat step 4 with stag corresponding to vSG-2
913 9.Verify ping success and flows added in OvS
914 """
915 def test_vsg_for_subscriber_access_service2_if_service1_goes_restart(self):
916 """
917 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts
918 Algo:
919 1.Create two vSG VMs for two services in compute node
920 2.Create one vCPE container in each VM for one subscriber
921 3.Ensure VMs and containers created properly
922 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag
923 5.Verify ping gets success
924 6.Verify ping success flows added in OvS
925 7.Now restart vSG-1 VM
926 8.Now repeat step 4 while vSG-1 VM restarts
927 9.Verify that ping fails as vSG-1 is restarting
928 10.Repeat step 4 with stag corresponding to vSG-2 while vSG-1 VM restarts
929 11.Verify ping success and flows added in OvS
930 """
931 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_goes_down(self):
932 """
933 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down
934 Algo:
935 1.Create a vSG VM in compute node
936 2.Create two vCPE containers corresponds to two subscribers in vSG VM
937 3.Ensure VM and containers created properly
938 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
939 5.Verify ping gets success
940 6.Verify ping success flows added in OvS
941 7.Now stop vCPE-1 container
942 8.Now repeat step 4
943 9.Verify that ping fails as vCPE-1 container is down
944 10.Repeat step 4 with ctag corresponding to vCPE-2 container
945 11.Verify ping success and flows added in OvS
946 """
947 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_restart(self):
948 """
949 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts
950 Algo:
951 1.Create a vSG VM in compute node
952 2.Create two vCPE containers corresponds to two subscribers in vSG VM
953 3.Ensure VM and containers created properly
954 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
955 5.Verify ping gets success
956 6.Verify ping success flows added in OvS
957 7.Now restart vCPE-1 container
958 8.Now repeat step 4 while vCPE-1 restarts
959 9.Verify that ping fails as vCPE-1 container is restarts
960 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 restarts
961 11..Verify ping success and flows added in OvS
962 """
963 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_pause(self):
964 """
965 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 paused
966 Algo:
967 1.Create a vSG VM in compute node
968 2.Create two vCPE containers corresponds to two subscribers in vSG VM
969 3.Ensure VM and containers created properly
970 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
971 5.Verify ping gets success
972 6.Verify ping success flows added in OvS
973 7.Now pause vCPE-1 container
974 8.Now repeat step 4 while vCPE-1 in pause state
975 9.Verify that ping fails as vCPE-1 container in pause state
976 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 in pause state
977 11.Verify ping success and flows added in OvS
978 """
979 def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_removed(self):
980 """
981 # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 removed
982 Algo:
983 1.Create a vSG VM in compute node
984 2.Create two vCPE containers corresponds to two subscribers in vSG VM
985 3.Ensure VM and containers created properly
986 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag
987 5.Verify ping gets success
988 6.Verify ping success flows added in OvS
989 7.Now remove vCPE-1 container
990 8.Now repeat step 4
991 9.Verify that ping fails as vCPE-1 container removed
992 10.Repeat step 4 with ctag corresponding to vCPE-2 container
993 11.Verify ping success and flows added in OvS
994 """
995 def test_vsg_for_vcpe_instance_removed_and_added_again(self):
996 """
997 Algo:
998 1.Create a vSG VM in compute node
999 2.Create a vCPE container in vSG VM
1000 3.Ensure VM and containers created properly
1001 4.From subscriber end, send ping to public IP
1002 5.Verify ping gets success
1003 6.Verify ping success flows added in OvS
1004 7.Now remove vCPE container in vSG VM
1005 8.Now repeat step 4
1006 9.Verify that ping fails as vCPE container removed
1007 10.Create the vCPE container again for the same subscriber
1008 11.Ensure that vCPE created now
1009 12.Now repeat step 4
1010 13.Verify ping success and flows added in OvS
1011 """
1012 def test_vsg_for_vsg_vm_removed_and_added_again(self):
1013 """
1014 Algo:
1015 1.Create a vSG VM in compute node
1016 2.Create a vCPE container in vSG VM
1017 3.Ensure VM and containers created properly
1018 4.From subscriber end, send ping to public IP
1019 5.Verify ping gets success
1020 6.Verify ping success flows added in OvS
1021 7.Now remove vSG VM
1022 8.Now repeat step 4
1023 9.Verify that ping fails as vSG VM not exists
1024 10.Create the vSG VM and vCPE container in VM again
1025 11.Ensure that vSG and vCPE created
1026 12.Now repeat step 4
1027 13.Verify ping success and flows added in OvS
1028 """
1029
1030 #Test vSG - Subscriber Configuration
1031 def test_vsg_for_configuring_new_subscriber_in_vcpe(self):
1032 """
1033 Algo:
1034 1.Create a vSG VM in compute node
1035 2.Create a vCPE container in vSG VM
1036 3.Ensure VM and containers created properly
1037 4.Configure a subscriber in XOS and assign a service id
1038 5.Set the admin privileges to the subscriber
1039 6.Verify subscriber configuration is success
1040 """
1041 def test_vsg_for_adding_subscriber_devices_in_vcpe(self):
1042 """
1043 Algo:
1044 1.Create a vSG VM in compute node
1045 2.Create a vCPE container in vSG VM
1046 3.Ensure VM and containers created properly
1047 4.Configure a subscriber in XOS and assign a service id
1048 5.Verify subscriber successfully configured in vCPE
1049 6.Now add devices( Mac addresses ) under the subscriber admin group
1050 7.Verify all devices ( Macs ) added successfully
1051 """
1052 def test_vsg_for_removing_subscriber_devices_in_vcpe(self):
1053 """
1054 Algo:
1055 1.Create a vSG VM in compute node
1056 2.Create a vCPE container in vSG VM
1057 3.Ensure VM and containers created properly
1058 4.Configure a subscriber in XOS and assign a service id
1059 5.Verify subscriber successfully configured
1060 6.Now add devices( Mac addresses ) under the subscriber admin group
1061 7.Verify all devices ( Macs ) added successfully
1062 8.Now remove All the added devices in XOS
1063 9.Verify all the devices removed
1064 """
1065 def test_vsg_for_modify_subscriber_devices_in_vcpe(self):
1066 """
1067 Algo:
1068 1.Create a vSG VM in compute node
1069 2.Create a vCPE container in vSG VM
1070 3.Ensure VM and containers created properly
1071 4.Configure a user in XOS and assign a service id
1072 5.Verify subscriber successfully configured in vCPE.
1073 6.Now add devices( Mac addresses ) under the subscriber admin group
1074 7.Verify all devices ( Macs ) added successfully
1075 8.Now remove few devices in XOS
1076 9.Verify devices removed successfully
1077 10.Now add few additional devices in XOS under the same subscriber admin group
1078 11.Verify newly added devices successfully added
1079 """
1080 def test_vsg_for_vcpe_login_fails_with_incorrect_subscriber_credentials(self):
1081 """
1082 Algo:
1083 1.Create a vSG VM in compute node
1084 2.Create a vCPE container in vSG VM
1085 3.Ensure VM and containers created properly
1086 4.Configure a subscriber in XOS and assign a service id
1087 5.Verify subscriber successfully configured
1088 6.Now add devices( Mac addresses ) under the subscriber admin group
1089 7.Verify all devices ( Macs ) added successfully
1090 8.Login vCPE with credentials with which subscriber configured
1091 9.Verify subscriber successfully logged in
1092 10.Logout and login again with incorrect credentials ( either user name or password )
1093 11.Verify login attempt to vCPE fails wtih incorrect credentials
1094 """
1095 def test_vsg_for_subscriber_configuration_in_vcpe_retain_after_vcpe_restart(self):
1096 """
1097 Algo:
1098 1.Create a vSG VM in compute node
1099 2.Create a vCPE container in vSG VM
1100 3.Ensure VM and containers created properly
1101 4.Configure a subscriber in XOS and assign a service id
1102 5.Verify subscriber successfully configured
1103 6.Now add devices( Mac addresses ) under the subscriber admin group
1104 7.Verify all devices ( Macs ) added successfully
1105 8.Restart vCPE ( locate backup config path while restart )
1106 9.Verify subscriber details in vCPE after restart should be same as before the restart
1107 """
1108 def test_vsg_for_create_multiple_vcpe_instances_and_configure_subscriber_in_each_instance(self):
1109 """
1110 Algo:
1111 1.Create a vSG VM in compute node
1112 2.Create 2 vCPE containers in vSG VM
1113 3.Ensure VM and containers created properly
1114 4.Configure a subscriber in XOS for each vCPE instance and assign a service id
1115 5.Verify subscribers successfully configured
1116 6.Now login vCPE-2 with subscriber-1 credentials
1117 7.Verify login fails
1118 8.Now login vCPE-1 with subscriber-2 credentials
1119 9.Verify login fails
1120 10.Now login vCPE-1 with subscriber-1 and vCPE-2 with subscriber-2 credentials
1121 11.Verify that both the subscribers able to login to their respective vCPE containers
1122 """
1123 def test_vsg_for_same_subscriber_can_be_configured_for_multiple_services(self):
1124 """
1125 Algo:
1126 1.Create 2 vSG VMs in compute node
1127 2.Create a vCPE container in each vSG VM
1128 3.Ensure VMs and containers created properly
1129 4.Configure same subscriber in XOS for each vCPE instance and assign a service id
1130 5.Verify subscriber successfully configured
1131 6.Now login vCPE-1 with subscriber credentials
1132 7.Verify login success
1133 8.Now login vCPE-2 with the same subscriber credentials
1134 9.Verify login success
1135 """
1136
1137 #Test Example Service
1138 def test_vsg_for_subcriber_avail_example_service_running_in_apache_server(self):
1139 """
1140 Algo:
1141 1.Create a vSG VM in compute node
1142 2.Create a vCPE container in each vSG VM
1143 3.Ensure VM and container created properly
1144 4.Configure a subscriber in XOS for the vCPE instance and assign a service id
1145 5.On-board an example service into cord pod
1146 6.Create a VM in compute node and run the example service ( Apache server )
1147 7.Configure the example service with service specific and subscriber specific messages
1148 8.Verify example service on-boarded successfully
1149 9.Verify example service running in VM
1150 10.Run a curl command from subscriber to reach example service
1151 11.Verify subscriber can successfully reach example service via vSG
1152 12.Verify that service specific and subscriber specific messages
1153 """
1154 def test_vsg_for_subcriber_avail_example_service_running_in_apache_server_after_service_restart(self):
1155 """
1156 Algo:
1157 1.Create a vSG VM in compute node
1158 2.Create a vCPE container in each vSG VM
1159 3.Ensure VM and container created properly
1160 4.Configure a subscriber in XOS for the vCPE instance and assign a service id
1161 5.On-board an example service into cord pod
1162 6.Create a VM in compute node and run the example service ( Apache server )
1163 7.Configure the example service with service specific and subscriber specific messages
1164 8.Verify example service on-boarded successfully
1165 9.Verify example service running in VM
1166 10.Run a curl command from subscriber to reach example service
1167 11.Verify subscriber can successfully reach example service via vSG
1168 12.Verify that service specific and subscriber specific messages
1169 13.Restart example service running in VM
1170 14.Repeat step 10
1171 15.Verify the same results as mentioned in steps 11, 12
1172 """
1173
1174 #vCPE Firewall Functionality
1175 def test_vsg_firewall_for_creating_acl_rule_based_on_source_ip(self):
1176 """
1177 Algo:
1178 1.Create a vSG VM in compute node
1179 2.Create vCPE container in the VM
1180 3.Ensure vSG VM and vCPE container created properly
1181 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP
1182 5.Bound the acl rule to WAN interface of vCPE
1183 6.Verify configuration in vCPE is success
1184 8.Verify flows added in OvS
1185 """
1186 def test_vsg_firewall_for_creating_acl_rule_based_on_destination_ip(self):
1187 """
1188 Algo:
1189 1.Create a vSG VM in compute node
1190 2.Create vCPE container in the VM
1191 3.Ensure vSG VM and vCPE container created properly
1192 4.Configure ac acl rule in vCPE to deny IP traffic to a destination ip
1193 5.Bound the acl rule to WAN interface of vCPE
1194 6.Verify configuration in vCPE is success
1195 8.Verify flows added in OvS
1196 """
1197 def test_vsg_firewall_for_acl_deny_rule_based_on_source_ip_traffic(self):
1198 """
1199 Algo:
1200 1.Create a vSG VM in compute node
1201 2.Create vCPE container in the VM
1202 3.Ensure vSG VM and vCPE container created properly
1203 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP
1204 5.Bound the acl rule to WAN interface of vCPE
1205 6.From subscriber, send ping to the denied IP address
1206 7.Verify that ping fails as vCPE denies ping response
1207 8.Verify flows added in OvS
1208 """
1209 def test_vsg_firewall_for_acl_deny_rule_based_on_destination_ip_traffic(self):
1210 """
1211 Algo:
1212 1.Create a vSG VM in compute node
1213 2.Create vCPE container in the VM
1214 3.Ensure vSG VM and vCPE container created properly
1215 4.Configure ac acl rule in vCPE to deny IP traffic to a destination IP
1216 5.Bound the acl rule to WAN interface of vCPE
1217 6.From subscriber, send ping to the denied IP address
1218 7.Verify that ping fails as vCPE drops the ping request at WAN interface
1219 8.Verify flows added in OvS
1220 """
Chetan Gaonker52418832017-01-26 23:03:13 +00001221
1222 def test_vsg_dnsmasq(self):
1223 pass
1224
1225 def test_vsg_with_external_parental_control_family_shield_for_filter(self):
1226 pass
1227
1228 def test_vsg_with_external_parental_control_with_answerx(self):
1229 pass
1230
1231 def test_vsg_for_subscriber_upstream_bandwidth(self):
1232 pass
1233
1234 def test_vsg_for_subscriber_downstream_bandwidth(self):
1235 pass
1236
1237 def test_vsg_for_diagnostic_run_of_traceroute(self):
1238 pass
1239
1240 def test_vsg_for_diagnostic_run_of_tcpdump(self):
1241 pass
1242
1243 def test_vsg_for_iptable_rules(self):
1244 pass
1245
1246 def test_vsg_for_iptables_with_neutron(self):
1247 pass