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