Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 1 | #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 | # |
| 15 | import unittest |
| 16 | from nose.tools import * |
| 17 | from scapy.all import * |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 18 | from CordTestUtils import * |
A.R Karthick | be7768c | 2017-03-17 11:39:41 -0700 | [diff] [blame] | 19 | from OnosCtrl import OnosCtrl |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 20 | from OltConfig import OltConfig |
| 21 | from socket import socket |
| 22 | from OnosFlowCtrl import OnosFlowCtrl |
| 23 | from nose.twistedtools import reactor, deferred |
| 24 | from twisted.internet import defer |
| 25 | from onosclidriver import OnosCliDriver |
| 26 | from CordContainer import Container, Onos, Quagga |
| 27 | from CordTestServer import cord_test_onos_restart, cord_test_onos_shutdown |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 28 | from SSHTestAgent import SSHTestAgent |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 29 | from portmaps import g_subscriber_port_map |
| 30 | from scapy.all import * |
| 31 | import time, monotonic |
| 32 | from OnosLog import OnosLog |
| 33 | from CordLogger import CordLogger |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 34 | import os |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 35 | import shutil |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 36 | import json |
| 37 | import random |
| 38 | import collections |
| 39 | import paramiko |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 40 | import re |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 41 | from paramiko import SSHClient |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 42 | from neutronclient.v2_0 import client as neutron_client |
| 43 | from novaclient import client as nova_client |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 44 | log.setLevel('INFO') |
| 45 | |
| 46 | class vsg_exchange(CordLogger): |
| 47 | ONOS_INSTANCES = 3 |
| 48 | V_INF1 = 'veth0' |
| 49 | device_id = 'of:' + get_mac() |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 50 | TEST_IP = '8.8.8.8' |
| 51 | HOST = "10.1.0.1" |
| 52 | USER = "vagrant" |
| 53 | PASS = "vagrant" |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 54 | head_node = os.environ['HEAD_NODE'] |
| 55 | HEAD_NODE = head_node + '.cord.lab' if len(head_node.split('.')) == 1 else head_node |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 56 | 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 Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 59 | |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 60 | @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 Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 66 | 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 Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 81 | try: |
| 82 | shutil.copy('/etc/resolv.conf', '/etc/resolv.conf.orig') |
| 83 | except: |
| 84 | pass |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 85 | |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 86 | @classmethod |
| 87 | def tearDownClass(cls): |
| 88 | try: |
| 89 | shutil.copy('/etc/resolv.conf.orig', '/etc/resolv.conf') |
| 90 | except: |
| 91 | pass |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 92 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 93 | 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 Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 118 | def log_set(self, level = None, app = 'org.onosproject'): |
| 119 | CordLogger.logSet(level = level, app = app, controllers = self.controllers, forced = True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 120 | |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 121 | def get_nova_credentials_v2(self): |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 122 | credential = {} |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 123 | 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 Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 127 | return credential |
| 128 | |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 129 | 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 Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 133 | |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 134 | 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 Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 139 | return filter(lambda vsg: vsg.status == 'ACTIVE', vsgs) |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 140 | return vsgs |
| 141 | |
| 142 | def get_vsg_ip(self, vm_name): |
| 143 | vsgs = self.get_vsgs() |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 144 | vms = filter(lambda vsg: vsg.name == vm_name, vsgs) |
| 145 | if vms: |
| 146 | vm = vms[0] |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 147 | if vm.networks.has_key('management'): |
| 148 | ips = vm.networks['management'] |
| 149 | if len(ips) > 0: |
| 150 | return ips[0] |
| 151 | return None |
| 152 | |
| 153 | def get_compute_node(self, vsg): |
| 154 | return vsg._info['OS-EXT-SRV-ATTR:hypervisor_hostname'] |
| 155 | |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 156 | def run_cmd_compute(self, compute, cmd, timeout = 5): |
| 157 | ssh_agent = SSHTestAgent(compute) |
| 158 | st, output = ssh_agent.run_cmd(cmd, timeout = timeout) |
| 159 | if st == True and output: |
| 160 | output = output.strip() |
| 161 | else: |
| 162 | output = None |
| 163 | |
| 164 | return st, output |
| 165 | |
| 166 | def run_cmd_vsg(self, compute, vsg_ip, cmd, timeout = 5, mgmt = 'eth0'): |
| 167 | last_gw = self.open_compute(mgmt) |
| 168 | ssh_agent = SSHTestAgent(compute) |
| 169 | ssh_cmd = 'ssh {} {}'.format(vsg_ip, cmd) |
| 170 | st, output = ssh_agent.run_cmd(ssh_cmd, timeout = timeout) |
| 171 | if st == True and output: |
| 172 | output = output.strip() |
| 173 | else: |
| 174 | output = None |
| 175 | self.close_compute(last_gw, mgmt) |
| 176 | return st, output |
| 177 | |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 178 | #ping the vsg through the compute node. |
| 179 | #the ssh key is already used by SSHTestAgent in cord-tester |
| 180 | def get_vsg_health(self, vsg): |
| 181 | compute_node = self.get_compute_node(vsg) |
| 182 | vsg_ip = self.get_vsg_ip(vsg.name) |
| 183 | if vsg_ip is None: |
| 184 | return False |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 185 | cmd = 'ping -c 1 {}'.format(vsg_ip) |
| 186 | st, _ = self.run_cmd_compute(compute_node, cmd) |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 187 | return st |
| 188 | |
| 189 | #returns 0 if all active vsgs are reachable through the compute node |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 190 | def health_check(self): |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 191 | vsgs = self.get_vsgs() |
| 192 | vsg_status = [] |
| 193 | for vsg in vsgs: |
| 194 | vsg_status.append(self.get_vsg_health(vsg)) |
| 195 | unreachable = filter(lambda st: st == False, vsg_status) |
| 196 | return len(unreachable) == 0 |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 197 | |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 198 | #find the vsg hosting the vcpe service |
| 199 | def get_vcpe_vsg(self, vcpe): |
| 200 | if vcpe in self.vcpe_map: |
| 201 | return self.vcpe_map[vcpe]['vsg'] |
| 202 | vsgs = self.get_vsgs() |
| 203 | for vsg in vsgs: |
| 204 | vsg_ip = self.get_vsg_ip(vsg.name) |
| 205 | compute_node = self.get_compute_node(vsg) |
| 206 | cmd = 'sudo docker exec {} ls 2>/dev/null'.format(vcpe) |
| 207 | st, _ = self.run_cmd_vsg(compute_node, vsg_ip, cmd, timeout = 30) |
| 208 | if st == True: |
| 209 | return vsg |
| 210 | return None |
| 211 | |
| 212 | def save_vcpe_config(self, vsg, vcpe): |
| 213 | if vcpe not in self.vcpe_map: |
| 214 | cmd_gw = "sudo docker exec %s ip route show | grep default | head -1 | awk '{print $3}'" %(vcpe) |
| 215 | vsg_ip = self.get_vsg_ip(vsg.name) |
| 216 | if vsg_ip is None: |
| 217 | return False |
| 218 | compute_node = self.get_compute_node(vsg) |
| 219 | st, output = self.run_cmd_vsg(compute_node, vsg_ip, cmd_gw, timeout = 30) |
| 220 | if st == False or not output: |
| 221 | return False |
| 222 | gw = output |
| 223 | cmd_wan = "sudo docker exec %s ip addr show eth0 |grep inet |head -1 | tr -s ' ' | awk '{print $2}' | awk '{print $1}'" %(vcpe) |
| 224 | cmd_lan = "sudo docker exec %s ip addr show eth1 |grep inet |head -1 | tr -s ' ' | awk '{print $2}' | awk '{print $1}'" %(vcpe) |
| 225 | st, output = self.run_cmd_vsg(compute_node, vsg_ip, cmd_wan, timeout = 30) |
| 226 | ip_wan = '0.0.0.0/24' |
| 227 | ip_lan = '0.0.0.0/24' |
| 228 | if st and output: |
| 229 | if self.ip_addr_pattern.match(output): |
| 230 | ip_wan = output |
| 231 | |
| 232 | st, output = self.run_cmd_vsg(compute_node, vsg_ip, cmd_lan, timeout = 30) |
| 233 | if st and output: |
| 234 | if self.ip_addr_pattern.match(output): |
| 235 | ip_lan = output |
| 236 | |
| 237 | self.vcpe_map[vcpe] = { 'vsg': vsg, 'vsg_ip': vsg_ip, 'gw': gw, 'wan': ip_wan, 'lan': ip_lan } |
| 238 | |
| 239 | return True |
| 240 | |
| 241 | def restore_vcpe_config(self, vcpe, gw = True, wan = False, lan = False): |
| 242 | if vcpe in self.vcpe_map: |
| 243 | vsg = self.vcpe_map[vcpe]['vsg'] |
| 244 | vsg_ip = self.vcpe_map[vcpe]['vsg_ip'] |
| 245 | compute_node = self.get_compute_node(vsg) |
| 246 | cmds = [] |
| 247 | if gw is True: |
| 248 | #restore default gw |
| 249 | gw = self.vcpe_map[vcpe]['gw'] |
| 250 | cmds.append('sudo docker exec {} ip link set eth0 up'.format(vcpe)) |
| 251 | cmds.append('sudo docker exec {} route add default gw {} dev eth0'.format(vcpe, gw)) |
| 252 | if wan is True: |
| 253 | ip_wan = self.vcpe_map[vcpe]['wan'] |
| 254 | cmds.append('sudo docker exec {} ip addr set {} dev eth0'.format(vcpe, ip_wan)) |
| 255 | if lan is True: |
| 256 | ip_lan = self.vcpe_map[vcpe]['lan'] |
| 257 | cmds.append('sudo docker exec {} ip addr set {} dev eth1'.format(vcpe, ip_lan)) |
| 258 | ret_status = True |
| 259 | for cmd in cmds: |
| 260 | st, _ = self.run_cmd_vsg(compute_node, vsg_ip, cmd, timeout = 30) |
| 261 | if st == False: |
| 262 | ret_status = False |
| 263 | return ret_status |
| 264 | return False |
| 265 | |
| 266 | def get_vcpe_gw(self, vcpe): |
| 267 | if vcpe in self.vcpe_map: |
| 268 | return self.vcpe_map[vcpe]['gw'] |
| 269 | return None |
| 270 | |
| 271 | def get_vcpe_wan(self, vcpe): |
| 272 | if vcpe in self.vcpe_map: |
| 273 | return self.vcpe_map[vcpe]['wan'] |
| 274 | return None |
| 275 | |
| 276 | def get_vcpe_lan(self, vcpe): |
| 277 | if vcpe in self.vcpe_map: |
| 278 | return self.vcpe_map[vcpe]['lan'] |
| 279 | return None |
| 280 | |
| 281 | def vcpe_wan_up(self, vcpe, vsg = None): |
| 282 | if vsg is None: |
| 283 | vsg = self.get_vcpe_vsg(vcpe) |
| 284 | if vsg is None: |
| 285 | return False |
| 286 | return self.restore_vcpe_config(vcpe) |
| 287 | |
| 288 | def vcpe_lan_up(self, vcpe, vsg = None): |
| 289 | if vsg is None: |
| 290 | vsg = self.get_vcpe_vsg(vcpe) |
| 291 | if vsg is None: |
| 292 | return False |
| 293 | if vcpe in self.vcpe_map: |
| 294 | vsg_ip = self.vcpe_map[vcpe]['vsg_ip'] |
| 295 | else: |
| 296 | vsg_ip = self.get_vsg_ip(vsg.name) |
| 297 | 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 |
| 310 | vsg_ip = self.get_vsg_ip(vsg.name) |
| 311 | 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 Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 325 | #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 Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 332 | |
| 333 | def test_vsg_vm(self): |
| 334 | status = self.health_check() |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 335 | assert_equal( status, True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 336 | |
| 337 | def test_vsg_for_default_route_to_vsg_vm(self): |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 338 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 339 | cmd = "sudo lxc exec testclient -- route | grep default" |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 340 | status, output = ssh_agent.run_cmd(cmd) |
| 341 | assert_equal(status, True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 342 | |
| 343 | def test_vsg_vm_for_vcpe(self): |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 344 | 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 Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 348 | |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 349 | #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 Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 353 | def test_vsg_for_external_connectivity(self): |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 354 | ssh_agent = SSHTestAgent(host = self.HEAD_NODE, user = self.USER, password = self.PASS) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 355 | cmd = "lxc exec testclient -- ping -c 3 8.8.8.8" |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 356 | status, output = ssh_agent.run_cmd(cmd) |
| 357 | assert_equal( status, True) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 358 | |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 359 | 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 Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 371 | def test_vsg_vm_for_login_to_vsg(self): |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 372 | 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 Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 393 | #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 Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 421 | 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 Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 440 | getstatusoutput('pkill -9 dhclient') |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 441 | st, output = getstatusoutput('dhclient -q {}'.format(vcpe)) |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 442 | getstatusoutput('pkill -9 dhclient') |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 443 | 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 Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 461 | |
A.R Karthick | 9ccd0d0 | 2017-03-16 17:11:08 -0700 | [diff] [blame] | 462 | #these need to first get dhcp through dhclient on vcpe interfaces (using OltConfig get_vcpes()) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 463 | def test_vsg_external_connectivity_with_sending_icmp_echo_requests(self): |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 464 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 465 | mgmt = 'eth0' |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 466 | host = '8.8.8.8' |
| 467 | self.success = False |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 468 | assert_not_equal(vcpe, None) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 469 | 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 Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 476 | |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 477 | 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 Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 499 | assert_not_equal(self.vcpe_dhcp_stag, None) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 500 | 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 Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 505 | lfilter = lambda p: IP in p and p[ICMP].type == 0, |
| 506 | prn = recv_cb, iface = self.vcpe_dhcp_stag) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 507 | 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 Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 512 | send(pkt, count=3, iface = self.vcpe_dhcp_stag) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 513 | 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 Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 518 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 519 | mgmt = 'eth0' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 520 | assert_not_equal(vcpe, None) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 521 | 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 Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 528 | |
| 529 | def test_vsg_external_connectivity_pinging_to_non_existing_website(self): |
| 530 | host = 'www.goglee.com' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 531 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 532 | mgmt = 'eth0' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 533 | assert_not_equal(vcpe, None) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 534 | 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 Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 541 | |
| 542 | def test_vsg_external_connectivity_ping_to_google_with_ttl_1(self): |
| 543 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 544 | vcpe = self.vcpe_dhcp |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 545 | mgmt = 'eth0' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 546 | assert_not_equal(vcpe, None) |
A.R Karthick | 33cfdbe | 2017-03-17 18:03:48 -0700 | [diff] [blame] | 547 | 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 Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 554 | |
| 555 | def test_vsg_for_external_connectivity_with_wan_interface_down_and_making_up_in_vcpe_container(self): |
| 556 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 557 | 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)) |
| 584 | if st != 0: |
| 585 | self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 586 | assert_equal(st, 0) |
Anil Kumar Sanka | 87115b0 | 2017-03-14 17:46:47 +0000 | [diff] [blame] | 587 | |
| 588 | def test_vsg_for_external_connectivity_with_lan_interface_down_and_up_in_vcpe_container(self): |
| 589 | host = '8.8.8.8' |
A R Karthick | 03f40aa | 2017-03-20 19:33:55 -0700 | [diff] [blame^] | 590 | mgmt = 'eth0' |
| 591 | vcpe = self.vcpe_container |
| 592 | assert_not_equal(vcpe, None) |
| 593 | assert_not_equal(self.vcpe_dhcp, None) |
| 594 | #first get dhcp on the vcpe interface |
| 595 | vcpe_ip = self.vcpe_get_dhcp(self.vcpe_dhcp, mgmt = mgmt) |
| 596 | assert_not_equal(vcpe_ip, None) |
| 597 | log.info('Got DHCP IP %s for %s' %(vcpe_ip, self.vcpe_dhcp)) |
| 598 | log.info('Sending ICMP pings to host %s' %(host)) |
| 599 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 600 | if st != 0: |
| 601 | self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 602 | assert_equal(st, 0) |
| 603 | #bring down the lan interface and check again |
| 604 | st = self.vcpe_lan_down(vcpe) |
| 605 | if st is False: |
| 606 | self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 607 | assert_equal(st, True) |
| 608 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 609 | if st == 0: |
| 610 | self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 611 | assert_not_equal(st, 0) |
| 612 | st = self.vcpe_lan_up(vcpe) |
| 613 | if st is False: |
| 614 | self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 615 | assert_equal(st, True) |
| 616 | st, _ = getstatusoutput('ping -c 1 {}'.format(host)) |
| 617 | if st != 0: |
| 618 | self.restore_interface_config(mgmt, vcpe = self.vcpe_dhcp) |
| 619 | assert_equal(st, 0) |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 620 | |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 621 | def test_vsg_for_ping_from_vsg_to_external_network(self): |
| 622 | """ |
| 623 | Algo: |
| 624 | 1.Create a vSG VM in compute node |
| 625 | 2.Ensure VM created properly |
| 626 | 3.Verify login to VM success |
| 627 | 4.Do ping to external network from vSG VM |
| 628 | 5.Verify that ping gets success |
| 629 | 6.Verify ping success flows added in OvS |
| 630 | """ |
| 631 | def test_vsg_for_ping_from_vcpe_to_external_network(self): |
| 632 | """ |
| 633 | Algo: |
| 634 | 1.Create a vSG VM in compute node |
| 635 | 2.Create a vCPE container inside VM |
| 636 | 3.Verify both VM and Container created properly |
| 637 | 4.Verify login to vCPE container success |
| 638 | 5.Do ping to external network from vCPE container |
| 639 | 6.Verify that ping gets success |
| 640 | 7.Verify ping success flows added in OvS |
| 641 | """ |
| 642 | |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 643 | def test_vsg_for_dns_service(self): |
Anil Kumar Sanka | 1213d4c | 2017-02-23 22:50:48 +0000 | [diff] [blame] | 644 | """ |
| 645 | Algo: |
| 646 | 1. Create a test client in Prod VM |
| 647 | 2. Create a vCPE container in vSG VM inside compute Node |
| 648 | 3. Ensure vSG VM and vCPE container created properly |
| 649 | 4. Enable dns service in vCPE ( if not by default ) |
| 650 | 5. Send ping request from test client to valid domain address say, 'www.google'com |
| 651 | 6. Verify that dns should resolve ping should success |
| 652 | 7. Now send ping request to invalid domain address say 'www.invalidaddress'.com' |
| 653 | 8. Verify that dns resolve should fail and hence ping |
| 654 | """ |
| 655 | def test_vsg_for_10_subscribers_for_same_service(self): |
| 656 | """ |
| 657 | Algo: |
| 658 | 1.Create a vSG VM in compute node |
| 659 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 660 | 3.Ensure vSG VM and vCPE container created properly |
| 661 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP |
| 662 | 5.Verify that ping success for all 10 subscribers |
| 663 | """ |
| 664 | def test_vsg_for_10_subscribers_for_same_service_ping_invalid_ip(self): |
| 665 | """ |
| 666 | Algo: |
| 667 | 1.Create a vSG VM in compute Node |
| 668 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 669 | 3.Ensure vSG VM and vCPE container created properly |
| 670 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP |
| 671 | 5.Verify that ping fails for all 10 subscribers |
| 672 | """ |
| 673 | def test_vsg_for_10_subscribers_for_same_service_ping_valid_and_invalid_ip(self): |
| 674 | """ |
| 675 | Algo: |
| 676 | 1.Create a vSG VM in VM |
| 677 | 2.Create 10 vCPE containers for 10 subscribers, in vSG VM |
| 678 | 3.Ensure vSG VM and vCPE container created properly |
| 679 | 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP |
| 680 | 5.Verify that ping success for all 5 subscribers |
| 681 | 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP |
| 682 | 7.Verify that ping fails for all 5 subscribers |
| 683 | """ |
| 684 | def test_vsg_for_100_subscribers_for_same_service(self): |
| 685 | """ |
| 686 | Algo: |
| 687 | 1.Create a vSG VM in compute node |
| 688 | 2.Create 100 vCPE containers for 100 subscribers, in vSG VM |
| 689 | 3.Ensure vSG VM and vCPE container created properly |
| 690 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to valid external public IP |
| 691 | 5.Verify that ping success for all 100 subscribers |
| 692 | """ |
| 693 | def test_vsg_for_100_subscribers_for_same_service_ping_invalid_ip(self): |
| 694 | """ |
| 695 | Algo: |
| 696 | 1.Create a vSG VM in compute Node |
| 697 | 2.Create 10 vCPE containers for 100 subscribers, in vSG VM |
| 698 | 3.Ensure vSG VM and vCPE container created properly |
| 699 | 4.From each of the subscriber, with same s-tag and different c-tag, send a ping to invalid IP |
| 700 | 5.Verify that ping fails for all 100 subscribers |
| 701 | """ |
| 702 | def test_vsg_for_100_subscribers_for_same_service_ping_valid_and_invalid_ip(self): |
| 703 | """ |
| 704 | Algo: |
| 705 | 1.Create a vSG VM in VM |
| 706 | 2.Create 10 vCPE containers for 100 subscribers, in vSG VM |
| 707 | 3.Ensure vSG VM and vCPE container created properly |
| 708 | 4.From first 5 subscribers, with same s-tag and different c-tag, send a ping to valid IP |
| 709 | 5.Verify that ping success for all 5 subscribers |
| 710 | 6.From next 5 subscribers, with same s-tag and different c-tag, send a ping to invalid IP |
| 711 | 7.Verify that ping fails for all 5 subscribers |
| 712 | """ |
| 713 | def test_vsg_for_packet_received_with_invalid_ip_fields(self): |
| 714 | """ |
| 715 | Algo: |
| 716 | 1.Create a vSG VM in compute node |
| 717 | 2.Create a vCPE container in vSG VM |
| 718 | 3.Ensure vSG VM and vCPE container created properly |
| 719 | 4.From subscriber, send a ping packet with invalid ip fields |
| 720 | 5.Verify that vSG drops the packet |
| 721 | 6.Verify ping fails |
| 722 | """ |
| 723 | def test_vsg_for_packet_received_with_invalid_mac_fields(self): |
| 724 | """ |
| 725 | Algo: |
| 726 | 1.Create a vSG VM in compute node |
| 727 | 2.Create a vCPE container in vSG VM |
| 728 | 3.Ensure vSG VM and vCPE container created properly |
| 729 | 4.From subscriber, send a ping packet with invalid mac fields |
| 730 | 5.Verify that vSG drops the packet |
| 731 | 6.Verify ping fails |
| 732 | """ |
| 733 | def test_vsg_for_vlan_id_mismatch_in_stag(self): |
| 734 | """ |
| 735 | Algo: |
| 736 | 1.Create a vSG VM in compute Node |
| 737 | 2.Create a vCPE container in vSG VM |
| 738 | 3.Ensure vSG VM and vCPE container created properly |
| 739 | 4.Send a ping request to external valid IP from subscriber, with incorrect vlan id in s-tag and valid c-tag |
| 740 | 5.Verify that ping fails as the packet drops at VM entry |
| 741 | 6.Repeat step 4 with correct s-tag |
| 742 | 7.Verify that ping success |
| 743 | """ |
| 744 | def test_vsg_for_vlan_id_mismatch_in_ctag(self): |
| 745 | """ |
| 746 | Algo: |
| 747 | 1.Create a vSG VM in compute node |
| 748 | 2.Create a vCPE container in vSG VM |
| 749 | 3.Ensure vSG VM and vCPE container created properly |
| 750 | 4.Send a ping request to external valid IP from subscriber, with valid s-tag and incorrect vlan id in c-tag |
| 751 | 5.Verify that ping fails as the packet drops at vCPE container entry |
| 752 | 6.Repeat step 4 with valid s-tag and c-tag |
| 753 | 7.Verify that ping success |
| 754 | """ |
| 755 | def test_vsg_for_matching_and_mismatching_vlan_id_in_stag(self): |
| 756 | """ |
| 757 | Algo: |
| 758 | 1.Create two vSG VMs in compute node |
| 759 | 2.Create a vCPE container in each vSG VM |
| 760 | 3.Ensure vSG VM and vCPE container created properly |
| 761 | 4.From subscriber one, send ping request with valid s and c tags |
| 762 | 5.From subscriber two, send ping request with vlan id mismatch in s-tag and valid c tags |
| 763 | 6.Verify that ping success for only subscriber one and fails for two. |
| 764 | """ |
| 765 | def test_vsg_for_matching_and_mismatching_vlan_id_in_ctag(self): |
| 766 | """ |
| 767 | Algo: |
| 768 | 1.Create a vSG VM in compute node |
| 769 | 2.Create two vCPE containers in vSG VM |
| 770 | 3.Ensure vSG VM and vCPE container created properly |
| 771 | 4.From subscriber one, send ping request with valid s and c tags |
| 772 | 5.From subscriber two, send ping request with valid s-tag and vlan id mismatch in c-tag |
| 773 | 6.Verify that ping success for only subscriber one and fails for two |
| 774 | """ |
| 775 | def test_vsg_for_out_of_range_vlanid_in_ctag(self): |
| 776 | """ |
| 777 | Algo: |
| 778 | 1.Create a vSG VM in compute node |
| 779 | 2.Create a vCPE container in vSG VM |
| 780 | 3.Ensure vSG VM and vCPE container created properly |
| 781 | 4.From subscriber, send ping request with valid stag and vlan id in c-tag is an out of range value ( like 0,4097 ) |
| 782 | 4.Verify that ping fails as the ping packets drops at vCPE container entry |
| 783 | """ |
| 784 | def test_vsg_for_out_of_range_vlanid_in_stag(self): |
| 785 | """ |
| 786 | Algo: |
| 787 | 1.Create a vSG VM in compute node |
| 788 | 2.Create a vCPE container in vSG VM |
| 789 | 3.Ensure vSG VM and vCPE container created properly |
| 790 | 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 |
| 791 | 4.Verify that ping fails as the ping packets drops at vSG VM entry |
| 792 | """ |
| 793 | def test_vsg_without_creating_vcpe_instance(self): |
| 794 | """ |
| 795 | Algo: |
| 796 | 1.Create a vSG VM in compute Node |
| 797 | 2.Ensure vSG VM created properly |
| 798 | 3.Do not create vCPE container inside vSG VM |
| 799 | 4.From a subscriber, send ping to external valid IP |
| 800 | 5.Verify that ping fails as the ping packet drops at vSG VM entry itself. |
| 801 | """ |
| 802 | def test_vsg_for_remove_vcpe_instance(self): |
| 803 | """ |
| 804 | Algo: |
| 805 | 1.Create a vSG VM in compute node |
| 806 | 2.Create a vCPE container in vSG VM |
| 807 | 3.Ensure vSG VM and vCPE container created properly |
| 808 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 809 | 5.Verify that ping success |
| 810 | 6.Verify ping success flows in OvS switch in compute node |
| 811 | 7.Now remove the vCPE container in vSG VM |
| 812 | 8.Ensure that the container removed properly |
| 813 | 9.Repeat step 4 |
| 814 | 10.Verify that now, ping fails |
| 815 | """ |
| 816 | def test_vsg_for_restart_vcpe_instance(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 vSG VM and vCPE container created properly |
| 822 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 823 | 5.Verify that ping success |
| 824 | 6.Verify ping success flows in OvS switch in compute node |
| 825 | 7.Now restart the vCPE container in vSG VM |
| 826 | 8.Ensure that the container came up after restart |
| 827 | 9.Repeat step 4 |
| 828 | 10.Verify that now,ping gets success and flows added in OvS |
| 829 | """ |
| 830 | def test_vsg_for_restart_vsg_vm(self): |
| 831 | """ |
| 832 | Algo: |
| 833 | 1.Create a vSG VM in compute node |
| 834 | 2.Create a vCPE container in vSG VM |
| 835 | 3.Ensure vSG VM and vCPE container created properly |
| 836 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 837 | 5.Verify that ping success |
| 838 | 6.Verify ping success flows in OvS switch in compute node |
| 839 | 7.Now restart the vSG VM |
| 840 | 8.Ensure that the vSG comes up properly after restart |
| 841 | 9.Verify that vCPE container comes up after vSG restart |
| 842 | 10.Repeat step 4 |
| 843 | 11.Verify that now,ping gets success and flows added in OvS |
| 844 | """ |
| 845 | def test_vsg_for_pause_vcpe_instance(self): |
| 846 | """ |
| 847 | Algo: |
| 848 | 1.Create a vSG VM in compute node |
| 849 | 2.Create a vCPE container in vSG VM |
| 850 | 3.Ensure vSG VM and vCPE container created properly |
| 851 | 4.From subscriber, send ping request with valid s-tag and c-tag |
| 852 | 5.Verify that ping success |
| 853 | 6.Verify ping success flows in OvS switch in compute node |
| 854 | 7.Now pause vCPE container in vSG VM for a while |
| 855 | 8.Ensure that the container state is pause |
| 856 | 9.Repeat step 4 |
| 857 | 10.Verify that now,ping fails now and verify flows in OvS |
| 858 | 11.Now resume the container |
| 859 | 12.Now repeat step 4 again |
| 860 | 13.Verify that now, ping gets success |
| 861 | 14.Verify ping success flows in OvS |
| 862 | """ |
| 863 | def test_vsg_for_extract_all_compute_stats_from_all_vcpe_containers(self): |
| 864 | """ |
| 865 | Algo: |
| 866 | 1.Create a vSG VM in compute node |
| 867 | 2.Create 10 vCPE containers in VM |
| 868 | 3.Ensure vSG VM and vCPE containers created properly |
| 869 | 4.Login to all vCPE containers |
| 870 | 4.Get all compute stats from all vCPE containers |
| 871 | 5.Verify the stats # verification method need to add |
| 872 | """ |
| 873 | def test_vsg_for_extract_dns_stats_from_all_vcpe_containers(self): |
| 874 | """ |
| 875 | Algo: |
| 876 | 1.Create a vSG VM in compute node |
| 877 | 2.Create 10 vCPE containers in VM |
| 878 | 3.Ensure vSG VM and vCPE containers created properly |
| 879 | 4.From 10 subscribers, send ping to valid and invalid dns hosts |
| 880 | 5.Verify dns resolves and ping success for valid dns hosts |
| 881 | 6.Verify ping fails for invalid dns hosts |
| 882 | 7.Verify dns host name resolve flows in OvS |
| 883 | 8.Login to all 10 vCPE containers |
| 884 | 9.Extract all dns stats |
| 885 | 10.Verify dns stats for queries sent, queries received for dns host resolve success and failed scenarios |
| 886 | """ |
| 887 | def test_vsg_for_subscriber_access_two_vsg_services(self): |
| 888 | """ |
| 889 | # Intention is to verify if subscriber can reach internet via two vSG VMs |
| 890 | Algo: |
| 891 | 1.Create two vSG VMs for two services in compute node |
| 892 | 2.Create one vCPE container in each VM for one subscriber |
| 893 | 3.Ensure VMs and containers created properly |
| 894 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 895 | 5.Verify ping gets success |
| 896 | 6.Verify ping success flows in OvS |
| 897 | 7.Now repeat step 4 with stag corresponds to vSG-2 VM |
| 898 | 8.Verify that ping again success |
| 899 | 9.Verify ping success flows in OvS |
| 900 | """ |
| 901 | def test_vsg_for_subscriber_access_service2_if_service1_goes_down(self): |
| 902 | """ |
| 903 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down |
| 904 | Algo: |
| 905 | 1.Create two vSG VMs for two services in compute node |
| 906 | 2.Create one vCPE container in each VM for one subscriber |
| 907 | 3.Ensure VMs and containers created properly |
| 908 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 909 | 5.Verify ping gets success |
| 910 | 6.Verify ping success flows in OvS |
| 911 | 7.Down the vSG-1 VM |
| 912 | 8.Now repeat step 4 |
| 913 | 9.Verify that ping fails as vSG-1 is down |
| 914 | 10.Repeat step 4 with stag corresponding to vSG-2 |
| 915 | 9.Verify ping success and flows added in OvS |
| 916 | """ |
| 917 | def test_vsg_for_subscriber_access_service2_if_service1_goes_restart(self): |
| 918 | """ |
| 919 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts |
| 920 | Algo: |
| 921 | 1.Create two vSG VMs for two services in compute node |
| 922 | 2.Create one vCPE container in each VM for one subscriber |
| 923 | 3.Ensure VMs and containers created properly |
| 924 | 4.From subscriber end, send ping to public IP with stag corresponds to vSG-1 VM and ctag |
| 925 | 5.Verify ping gets success |
| 926 | 6.Verify ping success flows added in OvS |
| 927 | 7.Now restart vSG-1 VM |
| 928 | 8.Now repeat step 4 while vSG-1 VM restarts |
| 929 | 9.Verify that ping fails as vSG-1 is restarting |
| 930 | 10.Repeat step 4 with stag corresponding to vSG-2 while vSG-1 VM restarts |
| 931 | 11.Verify ping success and flows added in OvS |
| 932 | """ |
| 933 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_goes_down(self): |
| 934 | """ |
| 935 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 goes down |
| 936 | Algo: |
| 937 | 1.Create a vSG VM in compute node |
| 938 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 939 | 3.Ensure VM and containers created properly |
| 940 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 941 | 5.Verify ping gets success |
| 942 | 6.Verify ping success flows added in OvS |
| 943 | 7.Now stop vCPE-1 container |
| 944 | 8.Now repeat step 4 |
| 945 | 9.Verify that ping fails as vCPE-1 container is down |
| 946 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container |
| 947 | 11.Verify ping success and flows added in OvS |
| 948 | """ |
| 949 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_restart(self): |
| 950 | """ |
| 951 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 restarts |
| 952 | Algo: |
| 953 | 1.Create a vSG VM in compute node |
| 954 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 955 | 3.Ensure VM and containers created properly |
| 956 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 957 | 5.Verify ping gets success |
| 958 | 6.Verify ping success flows added in OvS |
| 959 | 7.Now restart vCPE-1 container |
| 960 | 8.Now repeat step 4 while vCPE-1 restarts |
| 961 | 9.Verify that ping fails as vCPE-1 container is restarts |
| 962 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 restarts |
| 963 | 11..Verify ping success and flows added in OvS |
| 964 | """ |
| 965 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_pause(self): |
| 966 | """ |
| 967 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 paused |
| 968 | Algo: |
| 969 | 1.Create a vSG VM in compute node |
| 970 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 971 | 3.Ensure VM and containers created properly |
| 972 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 973 | 5.Verify ping gets success |
| 974 | 6.Verify ping success flows added in OvS |
| 975 | 7.Now pause vCPE-1 container |
| 976 | 8.Now repeat step 4 while vCPE-1 in pause state |
| 977 | 9.Verify that ping fails as vCPE-1 container in pause state |
| 978 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container while vCPE-1 in pause state |
| 979 | 11.Verify ping success and flows added in OvS |
| 980 | """ |
| 981 | def test_vsg_for_multiple_vcpes_in_vsg_vm_with_one_vcpe_removed(self): |
| 982 | """ |
| 983 | # Intention is to verify if subscriber can reach internet via vSG2 if vSG1 removed |
| 984 | Algo: |
| 985 | 1.Create a vSG VM in compute node |
| 986 | 2.Create two vCPE containers corresponds to two subscribers in vSG VM |
| 987 | 3.Ensure VM and containers created properly |
| 988 | 4.From subscriber-1 end, send ping to public IP with ctag corresponds to vCPE-1 and stag |
| 989 | 5.Verify ping gets success |
| 990 | 6.Verify ping success flows added in OvS |
| 991 | 7.Now remove vCPE-1 container |
| 992 | 8.Now repeat step 4 |
| 993 | 9.Verify that ping fails as vCPE-1 container removed |
| 994 | 10.Repeat step 4 with ctag corresponding to vCPE-2 container |
| 995 | 11.Verify ping success and flows added in OvS |
| 996 | """ |
| 997 | def test_vsg_for_vcpe_instance_removed_and_added_again(self): |
| 998 | """ |
| 999 | Algo: |
| 1000 | 1.Create a vSG VM in compute node |
| 1001 | 2.Create a vCPE container in vSG VM |
| 1002 | 3.Ensure VM and containers created properly |
| 1003 | 4.From subscriber end, send ping to public IP |
| 1004 | 5.Verify ping gets success |
| 1005 | 6.Verify ping success flows added in OvS |
| 1006 | 7.Now remove vCPE container in vSG VM |
| 1007 | 8.Now repeat step 4 |
| 1008 | 9.Verify that ping fails as vCPE container removed |
| 1009 | 10.Create the vCPE container again for the same subscriber |
| 1010 | 11.Ensure that vCPE created now |
| 1011 | 12.Now repeat step 4 |
| 1012 | 13.Verify ping success and flows added in OvS |
| 1013 | """ |
| 1014 | def test_vsg_for_vsg_vm_removed_and_added_again(self): |
| 1015 | """ |
| 1016 | Algo: |
| 1017 | 1.Create a vSG VM in compute node |
| 1018 | 2.Create a vCPE container in vSG VM |
| 1019 | 3.Ensure VM and containers created properly |
| 1020 | 4.From subscriber end, send ping to public IP |
| 1021 | 5.Verify ping gets success |
| 1022 | 6.Verify ping success flows added in OvS |
| 1023 | 7.Now remove vSG VM |
| 1024 | 8.Now repeat step 4 |
| 1025 | 9.Verify that ping fails as vSG VM not exists |
| 1026 | 10.Create the vSG VM and vCPE container in VM again |
| 1027 | 11.Ensure that vSG and vCPE created |
| 1028 | 12.Now repeat step 4 |
| 1029 | 13.Verify ping success and flows added in OvS |
| 1030 | """ |
| 1031 | |
| 1032 | #Test vSG - Subscriber Configuration |
| 1033 | def test_vsg_for_configuring_new_subscriber_in_vcpe(self): |
| 1034 | """ |
| 1035 | Algo: |
| 1036 | 1.Create a vSG VM in compute node |
| 1037 | 2.Create a vCPE container in vSG VM |
| 1038 | 3.Ensure VM and containers created properly |
| 1039 | 4.Configure a subscriber in XOS and assign a service id |
| 1040 | 5.Set the admin privileges to the subscriber |
| 1041 | 6.Verify subscriber configuration is success |
| 1042 | """ |
| 1043 | def test_vsg_for_adding_subscriber_devices_in_vcpe(self): |
| 1044 | """ |
| 1045 | Algo: |
| 1046 | 1.Create a vSG VM in compute node |
| 1047 | 2.Create a vCPE container in vSG VM |
| 1048 | 3.Ensure VM and containers created properly |
| 1049 | 4.Configure a subscriber in XOS and assign a service id |
| 1050 | 5.Verify subscriber successfully configured in vCPE |
| 1051 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1052 | 7.Verify all devices ( Macs ) added successfully |
| 1053 | """ |
| 1054 | def test_vsg_for_removing_subscriber_devices_in_vcpe(self): |
| 1055 | """ |
| 1056 | Algo: |
| 1057 | 1.Create a vSG VM in compute node |
| 1058 | 2.Create a vCPE container in vSG VM |
| 1059 | 3.Ensure VM and containers created properly |
| 1060 | 4.Configure a subscriber in XOS and assign a service id |
| 1061 | 5.Verify subscriber successfully configured |
| 1062 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1063 | 7.Verify all devices ( Macs ) added successfully |
| 1064 | 8.Now remove All the added devices in XOS |
| 1065 | 9.Verify all the devices removed |
| 1066 | """ |
| 1067 | def test_vsg_for_modify_subscriber_devices_in_vcpe(self): |
| 1068 | """ |
| 1069 | Algo: |
| 1070 | 1.Create a vSG VM in compute node |
| 1071 | 2.Create a vCPE container in vSG VM |
| 1072 | 3.Ensure VM and containers created properly |
| 1073 | 4.Configure a user in XOS and assign a service id |
| 1074 | 5.Verify subscriber successfully configured in vCPE. |
| 1075 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1076 | 7.Verify all devices ( Macs ) added successfully |
| 1077 | 8.Now remove few devices in XOS |
| 1078 | 9.Verify devices removed successfully |
| 1079 | 10.Now add few additional devices in XOS under the same subscriber admin group |
| 1080 | 11.Verify newly added devices successfully added |
| 1081 | """ |
| 1082 | def test_vsg_for_vcpe_login_fails_with_incorrect_subscriber_credentials(self): |
| 1083 | """ |
| 1084 | Algo: |
| 1085 | 1.Create a vSG VM in compute node |
| 1086 | 2.Create a vCPE container in vSG VM |
| 1087 | 3.Ensure VM and containers created properly |
| 1088 | 4.Configure a subscriber in XOS and assign a service id |
| 1089 | 5.Verify subscriber successfully configured |
| 1090 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1091 | 7.Verify all devices ( Macs ) added successfully |
| 1092 | 8.Login vCPE with credentials with which subscriber configured |
| 1093 | 9.Verify subscriber successfully logged in |
| 1094 | 10.Logout and login again with incorrect credentials ( either user name or password ) |
| 1095 | 11.Verify login attempt to vCPE fails wtih incorrect credentials |
| 1096 | """ |
| 1097 | def test_vsg_for_subscriber_configuration_in_vcpe_retain_after_vcpe_restart(self): |
| 1098 | """ |
| 1099 | Algo: |
| 1100 | 1.Create a vSG VM in compute node |
| 1101 | 2.Create a vCPE container in vSG VM |
| 1102 | 3.Ensure VM and containers created properly |
| 1103 | 4.Configure a subscriber in XOS and assign a service id |
| 1104 | 5.Verify subscriber successfully configured |
| 1105 | 6.Now add devices( Mac addresses ) under the subscriber admin group |
| 1106 | 7.Verify all devices ( Macs ) added successfully |
| 1107 | 8.Restart vCPE ( locate backup config path while restart ) |
| 1108 | 9.Verify subscriber details in vCPE after restart should be same as before the restart |
| 1109 | """ |
| 1110 | def test_vsg_for_create_multiple_vcpe_instances_and_configure_subscriber_in_each_instance(self): |
| 1111 | """ |
| 1112 | Algo: |
| 1113 | 1.Create a vSG VM in compute node |
| 1114 | 2.Create 2 vCPE containers in vSG VM |
| 1115 | 3.Ensure VM and containers created properly |
| 1116 | 4.Configure a subscriber in XOS for each vCPE instance and assign a service id |
| 1117 | 5.Verify subscribers successfully configured |
| 1118 | 6.Now login vCPE-2 with subscriber-1 credentials |
| 1119 | 7.Verify login fails |
| 1120 | 8.Now login vCPE-1 with subscriber-2 credentials |
| 1121 | 9.Verify login fails |
| 1122 | 10.Now login vCPE-1 with subscriber-1 and vCPE-2 with subscriber-2 credentials |
| 1123 | 11.Verify that both the subscribers able to login to their respective vCPE containers |
| 1124 | """ |
| 1125 | def test_vsg_for_same_subscriber_can_be_configured_for_multiple_services(self): |
| 1126 | """ |
| 1127 | Algo: |
| 1128 | 1.Create 2 vSG VMs in compute node |
| 1129 | 2.Create a vCPE container in each vSG VM |
| 1130 | 3.Ensure VMs and containers created properly |
| 1131 | 4.Configure same subscriber in XOS for each vCPE instance and assign a service id |
| 1132 | 5.Verify subscriber successfully configured |
| 1133 | 6.Now login vCPE-1 with subscriber credentials |
| 1134 | 7.Verify login success |
| 1135 | 8.Now login vCPE-2 with the same subscriber credentials |
| 1136 | 9.Verify login success |
| 1137 | """ |
| 1138 | |
| 1139 | #Test Example Service |
| 1140 | def test_vsg_for_subcriber_avail_example_service_running_in_apache_server(self): |
| 1141 | """ |
| 1142 | Algo: |
| 1143 | 1.Create a vSG VM in compute node |
| 1144 | 2.Create a vCPE container in each vSG VM |
| 1145 | 3.Ensure VM and container created properly |
| 1146 | 4.Configure a subscriber in XOS for the vCPE instance and assign a service id |
| 1147 | 5.On-board an example service into cord pod |
| 1148 | 6.Create a VM in compute node and run the example service ( Apache server ) |
| 1149 | 7.Configure the example service with service specific and subscriber specific messages |
| 1150 | 8.Verify example service on-boarded successfully |
| 1151 | 9.Verify example service running in VM |
| 1152 | 10.Run a curl command from subscriber to reach example service |
| 1153 | 11.Verify subscriber can successfully reach example service via vSG |
| 1154 | 12.Verify that service specific and subscriber specific messages |
| 1155 | """ |
| 1156 | def test_vsg_for_subcriber_avail_example_service_running_in_apache_server_after_service_restart(self): |
| 1157 | """ |
| 1158 | Algo: |
| 1159 | 1.Create a vSG VM in compute node |
| 1160 | 2.Create a vCPE container in each vSG VM |
| 1161 | 3.Ensure VM and container created properly |
| 1162 | 4.Configure a subscriber in XOS for the vCPE instance and assign a service id |
| 1163 | 5.On-board an example service into cord pod |
| 1164 | 6.Create a VM in compute node and run the example service ( Apache server ) |
| 1165 | 7.Configure the example service with service specific and subscriber specific messages |
| 1166 | 8.Verify example service on-boarded successfully |
| 1167 | 9.Verify example service running in VM |
| 1168 | 10.Run a curl command from subscriber to reach example service |
| 1169 | 11.Verify subscriber can successfully reach example service via vSG |
| 1170 | 12.Verify that service specific and subscriber specific messages |
| 1171 | 13.Restart example service running in VM |
| 1172 | 14.Repeat step 10 |
| 1173 | 15.Verify the same results as mentioned in steps 11, 12 |
| 1174 | """ |
| 1175 | |
| 1176 | #vCPE Firewall Functionality |
| 1177 | def test_vsg_firewall_for_creating_acl_rule_based_on_source_ip(self): |
| 1178 | """ |
| 1179 | Algo: |
| 1180 | 1.Create a vSG VM in compute node |
| 1181 | 2.Create vCPE container in the VM |
| 1182 | 3.Ensure vSG VM and vCPE container created properly |
| 1183 | 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP |
| 1184 | 5.Bound the acl rule to WAN interface of vCPE |
| 1185 | 6.Verify configuration in vCPE is success |
| 1186 | 8.Verify flows added in OvS |
| 1187 | """ |
| 1188 | def test_vsg_firewall_for_creating_acl_rule_based_on_destination_ip(self): |
| 1189 | """ |
| 1190 | Algo: |
| 1191 | 1.Create a vSG VM in compute node |
| 1192 | 2.Create vCPE container in the VM |
| 1193 | 3.Ensure vSG VM and vCPE container created properly |
| 1194 | 4.Configure ac acl rule in vCPE to deny IP traffic to a destination ip |
| 1195 | 5.Bound the acl rule to WAN interface of vCPE |
| 1196 | 6.Verify configuration in vCPE is success |
| 1197 | 8.Verify flows added in OvS |
| 1198 | """ |
| 1199 | def test_vsg_firewall_for_acl_deny_rule_based_on_source_ip_traffic(self): |
| 1200 | """ |
| 1201 | Algo: |
| 1202 | 1.Create a vSG VM in compute node |
| 1203 | 2.Create vCPE container in the VM |
| 1204 | 3.Ensure vSG VM and vCPE container created properly |
| 1205 | 4.Configure ac acl rule in vCPE to deny IP traffic from a source IP |
| 1206 | 5.Bound the acl rule to WAN interface of vCPE |
| 1207 | 6.From subscriber, send ping to the denied IP address |
| 1208 | 7.Verify that ping fails as vCPE denies ping response |
| 1209 | 8.Verify flows added in OvS |
| 1210 | """ |
| 1211 | def test_vsg_firewall_for_acl_deny_rule_based_on_destination_ip_traffic(self): |
| 1212 | """ |
| 1213 | Algo: |
| 1214 | 1.Create a vSG VM in compute node |
| 1215 | 2.Create vCPE container in the VM |
| 1216 | 3.Ensure vSG VM and vCPE container created properly |
| 1217 | 4.Configure ac acl rule in vCPE to deny IP traffic to a destination IP |
| 1218 | 5.Bound the acl rule to WAN interface of vCPE |
| 1219 | 6.From subscriber, send ping to the denied IP address |
| 1220 | 7.Verify that ping fails as vCPE drops the ping request at WAN interface |
| 1221 | 8.Verify flows added in OvS |
| 1222 | """ |
Chetan Gaonker | 5241883 | 2017-01-26 23:03:13 +0000 | [diff] [blame] | 1223 | |
| 1224 | def test_vsg_dnsmasq(self): |
| 1225 | pass |
| 1226 | |
| 1227 | def test_vsg_with_external_parental_control_family_shield_for_filter(self): |
| 1228 | pass |
| 1229 | |
| 1230 | def test_vsg_with_external_parental_control_with_answerx(self): |
| 1231 | pass |
| 1232 | |
| 1233 | def test_vsg_for_subscriber_upstream_bandwidth(self): |
| 1234 | pass |
| 1235 | |
| 1236 | def test_vsg_for_subscriber_downstream_bandwidth(self): |
| 1237 | pass |
| 1238 | |
| 1239 | def test_vsg_for_diagnostic_run_of_traceroute(self): |
| 1240 | pass |
| 1241 | |
| 1242 | def test_vsg_for_diagnostic_run_of_tcpdump(self): |
| 1243 | pass |
| 1244 | |
| 1245 | def test_vsg_for_iptable_rules(self): |
| 1246 | pass |
| 1247 | |
| 1248 | def test_vsg_for_iptables_with_neutron(self): |
| 1249 | pass |