diff --git a/neutron/tests/tempest/scenario/base.py b/neutron/tests/tempest/scenario/base.py
index cf7686f..8c45f4b 100644
--- a/neutron/tests/tempest/scenario/base.py
+++ b/neutron/tests/tempest/scenario/base.py
@@ -66,7 +66,7 @@
         return body['keypair']
 
     @classmethod
-    def create_loginable_secgroup_rule(cls, secgroup_id=None):
+    def create_secgroup_rules(cls, rule_list, secgroup_id=None):
         client = cls.manager.network_client
         if not secgroup_id:
             sgs = client.list_security_groups()['security_groups']
@@ -75,18 +75,29 @@
                     secgroup_id = sg['id']
                     break
 
-        # This rule is intended to permit inbound ssh
-        # traffic from all sources, so no group_id is provided.
-        # Setting a group_id would only permit traffic from ports
-        # belonging to the same security group.
-        ruleset = {'protocol': 'tcp',
-                   'port_range_min': 22,
-                   'port_range_max': 22,
-                   'remote_ip_prefix': '0.0.0.0/0'}
-        rules = [client.create_security_group_rule(
-                     direction='ingress', security_group_id=secgroup_id,
-                     **ruleset)['security_group_rule']]
-        return rules
+        for rule in rule_list:
+            direction = rule.pop('direction')
+            client.create_security_group_rule(
+                direction=direction,
+                security_group_id=secgroup_id,
+                **rule)
+
+    @classmethod
+    def create_loginable_secgroup_rule(cls, secgroup_id=None):
+        """This rule is intended to permit inbound ssh
+
+        Allowing ssh traffic traffic from all sources, so no group_id is
+        provided.
+        Setting a group_id would only permit traffic from ports
+        belonging to the same security group.
+        """
+
+        rule_list = [{'protocol': 'tcp',
+                      'direction': 'ingress',
+                      'port_range_min': 22,
+                      'port_range_max': 22,
+                      'remote_ip_prefix': '0.0.0.0/0'}]
+        cls.create_secgroup_rules(rule_list, secgroup_id=secgroup_id)
 
     @classmethod
     def create_router_and_interface(cls, subnet_id):
@@ -109,3 +120,24 @@
     def check_connectivity(cls, host, ssh_user, ssh_key=None):
         ssh_client = ssh.Client(host, ssh_user, pkey=ssh_key)
         ssh_client.test_connection_auth()
+
+    @classmethod
+    def setup_network_and_server(cls):
+        cls.network = cls.create_network()
+        cls.subnet = cls.create_subnet(cls.network)
+
+        cls.create_router_and_interface(cls.subnet['id'])
+        cls.keypair = cls.create_keypair()
+        cls.create_loginable_secgroup_rule()
+        cls.server = cls.create_server(
+            flavor_ref=CONF.compute.flavor_ref,
+            image_ref=CONF.compute.image_ref,
+            key_name=cls.keypair['name'],
+            networks=[{'uuid': cls.network['id']}])
+        waiters.wait_for_server_status(cls.manager.servers_client,
+                                       cls.server['server']['id'],
+                                       constants.SERVER_STATUS_ACTIVE)
+        port = cls.client.list_ports(network_id=cls.network['id'],
+                                     device_id=cls.server[
+                                          'server']['id'])['ports'][0]
+        cls.fip = cls.create_and_associate_floatingip(port['id'])
diff --git a/neutron/tests/tempest/scenario/constants.py b/neutron/tests/tempest/scenario/constants.py
index bb1cab3..258c587 100644
--- a/neutron/tests/tempest/scenario/constants.py
+++ b/neutron/tests/tempest/scenario/constants.py
@@ -14,3 +14,5 @@
 
 SERVER_STATUS_ACTIVE = 'ACTIVE'
 DEFAULT_SECURITY_GROUP = 'default'
+LIMIT_KILO_BITS_PER_SECOND = 1000
+SOCKET_CONNECT_TIMEOUT = 60
diff --git a/neutron/tests/tempest/scenario/exceptions.py b/neutron/tests/tempest/scenario/exceptions.py
new file mode 100644
index 0000000..369a85b
--- /dev/null
+++ b/neutron/tests/tempest/scenario/exceptions.py
@@ -0,0 +1,33 @@
+# Copyright 2016 Red Hat, Inc.
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+from tempest.lib import exceptions
+
+TempestException = exceptions.TempestException
+
+
+class QoSLimitReached(TempestException):
+    message = "Limit reached, limit = %(limit)d"
+
+
+class SocketConnectionRefused(TempestException):
+    message = "Unable to connect to %(host)s port %(port)d:Connection Refused"
+
+
+class ConnectionTimeoutException(TempestException):
+    message = "Timeout connecting to %(host)s port %(port)d"
+
+
+class FileCreationFailedException(TempestException):
+    message = "File %(file)s has not been created or has the wrong size"
diff --git a/neutron/tests/tempest/scenario/test_basic.py b/neutron/tests/tempest/scenario/test_basic.py
index a846591..3fd1bc6 100644
--- a/neutron/tests/tempest/scenario/test_basic.py
+++ b/neutron/tests/tempest/scenario/test_basic.py
@@ -12,12 +12,10 @@
 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 #    License for the specific language governing permissions and limitations
 #    under the License.
-from tempest.common import waiters
 from tempest import test
 
 from neutron.tests.tempest import config
 from neutron.tests.tempest.scenario import base
-from neutron.tests.tempest.scenario import constants
 
 CONF = config.CONF
 
@@ -31,24 +29,7 @@
 
     @test.idempotent_id('de07fe0a-e955-449e-b48b-8641c14cd52e')
     def test_basic_instance(self):
-        network = self.create_network()
-        subnet = self.create_subnet(network)
-
-        self.create_router_and_interface(subnet['id'])
-        keypair = self.create_keypair()
-        self.create_loginable_secgroup_rule()
-        server = self.create_server(
-            flavor_ref=CONF.compute.flavor_ref,
-            image_ref=CONF.compute.image_ref,
-            key_name=keypair['name'],
-            networks=[{'uuid': network['id']}])
-        waiters.wait_for_server_status(self.manager.servers_client,
-                                       server['server']['id'],
-                                       constants.SERVER_STATUS_ACTIVE)
-        port = self.client.list_ports(network_id=network['id'],
-                                      device_id=server[
-                                          'server']['id'])['ports'][0]
-        fip = self.create_and_associate_floatingip(port['id'])
-        self.check_connectivity(fip['floating_ip_address'],
+        self.setup_network_and_server()
+        self.check_connectivity(self.fip['floating_ip_address'],
                                 CONF.validation.image_ssh_user,
-                                keypair['private_key'])
+                                self.keypair['private_key'])
diff --git a/neutron/tests/tempest/scenario/test_qos.py b/neutron/tests/tempest/scenario/test_qos.py
new file mode 100644
index 0000000..4a30d09
--- /dev/null
+++ b/neutron/tests/tempest/scenario/test_qos.py
@@ -0,0 +1,179 @@
+# Copyright 2016 Red Hat, Inc.
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+import errno
+import socket
+import time
+
+from oslo_log import log as logging
+from tempest.lib.common import ssh
+from tempest.lib import exceptions
+from tempest import test
+
+from neutron.common import utils
+from neutron.tests.tempest import config
+from neutron.tests.tempest.scenario import base
+from neutron.tests.tempest.scenario import constants
+from neutron.tests.tempest.scenario import exceptions as sc_exceptions
+
+CONF = config.CONF
+LOG = logging.getLogger(__name__)
+
+
+def _try_connect(host_ip, port):
+    try:
+        client_socket = socket.socket(socket.AF_INET,
+                                      socket.SOCK_STREAM)
+        client_socket.connect((host_ip, port))
+        client_socket.setblocking(0)
+        return client_socket
+    except socket.error as serr:
+        if serr.errno == errno.ECONNREFUSED:
+            raise sc_exceptions.SocketConnectionRefused(host=host_ip,
+                                                        port=port)
+        else:
+            raise
+
+
+def _connect_socket(host, port):
+    """Try to initiate a connection to a host using an ip address
+    and a port.
+
+    Trying couple of times until a timeout is reached in case the listening
+    host is not ready yet.
+    """
+
+    start = time.time()
+    while True:
+        try:
+            return _try_connect(host, port)
+        except sc_exceptions.SocketConnectionRefused:
+            if time.time() - start > constants.SOCKET_CONNECT_TIMEOUT:
+                raise sc_exceptions.ConnectionTimeoutException(host=host,
+                                                               port=port)
+
+
+class QoSTest(base.BaseTempestTestCase):
+    credentials = ['primary', 'admin']
+    force_tenant_isolation = False
+
+    BUFFER_SIZE = 1024 * 1024
+    TOLERANCE_FACTOR = 1.5
+    BS = 512
+    COUNT = BUFFER_SIZE / BS
+    FILE_SIZE = BS * COUNT
+    LIMIT_BYTES_SEC = (constants.LIMIT_KILO_BITS_PER_SECOND * 1024
+                       * TOLERANCE_FACTOR / 8.0)
+    FILE_PATH = "/tmp/img"
+
+    def _create_file_for_bw_tests(self, ssh_client):
+        cmd = ("(dd if=/dev/zero bs=%(bs)d count=%(count)d of=%(file_path)s) "
+               % {'bs': QoSTest.BS, 'count': QoSTest.COUNT,
+               'file_path': QoSTest.FILE_PATH})
+        ssh_client.exec_command(cmd)
+        cmd = "stat -c %%s %s" % QoSTest.FILE_PATH
+        filesize = ssh_client.exec_command(cmd)
+        if int(filesize.strip()) != QoSTest.FILE_SIZE:
+            raise sc_exceptions.FileCreationFailedException(
+                file=QoSTest.FILE_PATH)
+
+    def _check_bw(self, ssh_client, host, port):
+        total_bytes_read = 0
+        cycle_start_time = time.time()
+        cycle_data_read = 0
+
+        cmd = "killall -q nc"
+        try:
+            ssh_client.exec_command(cmd)
+        except exceptions.SSHExecCommandFailed:
+            pass
+        cmd = ("(nc -ll -p %(port)d < %(file_path)s > /dev/null &)" % {
+                'port': port, 'file_path': QoSTest.FILE_PATH})
+        ssh_client.exec_command(cmd)
+        client_socket = _connect_socket(host, port)
+
+        while total_bytes_read < QoSTest.FILE_SIZE:
+            try:
+                data = client_socket.recv(QoSTest.BUFFER_SIZE)
+            except socket.error as e:
+                if e.args[0] in [errno.EAGAIN, errno.EWOULDBLOCK]:
+                    continue
+                else:
+                    raise
+            total_bytes_read += len(data)
+            cycle_data_read += len(data)
+            time_elapsed = time.time() - cycle_start_time
+            should_check = (time_elapsed >= 5 or
+                            total_bytes_read == QoSTest.FILE_SIZE)
+            if should_check:
+                LOG.debug("time_elapsed =  %(time_elapsed)d,"
+                          "total_bytes_read = %(bytes_read)d,"
+                          "cycle_data_read = %(cycle_data)d",
+                          {"time_elapsed": time_elapsed,
+                           "bytes_read": total_bytes_read,
+                           "cycle_data": cycle_data_read})
+
+                if cycle_data_read / time_elapsed > QoSTest.LIMIT_BYTES_SEC:
+                    # Limit reached
+                    return False
+                else:
+                    cycle_start_time = time.time()
+                    cycle_data_read = 0
+        return True
+
+    @test.idempotent_id('1f7ed39b-428f-410a-bd2b-db9f465680df')
+    def test_qos(self):
+        """This is a basic test that check that a QoS policy with
+
+           a bandwidth limit rule is applied correctly by sending
+           a file from the instance to the test node.
+           Then calculating the bandwidth every ~1 sec by the number of bits
+           received / elapsed time.
+        """
+
+        NC_PORT = 1234
+
+        self.setup_network_and_server()
+        self.check_connectivity(self.fip['floating_ip_address'],
+                                CONF.validation.image_ssh_user,
+                                self.keypair['private_key'])
+        rulesets = [{'protocol': 'tcp',
+                     'direction': 'ingress',
+                     'port_range_min': NC_PORT,
+                     'port_range_max': NC_PORT,
+                     'remote_ip_prefix': '0.0.0.0/0'}]
+        self.create_secgroup_rules(rulesets)
+        ssh_client = ssh.Client(self.fip['floating_ip_address'],
+                                CONF.validation.image_ssh_user,
+                                pkey=self.keypair['private_key'])
+        policy = self.admin_manager.network_client.create_qos_policy(
+                                        name='test-policy',
+                                        description='test-qos-policy',
+                                        shared=True)
+        policy_id = policy['policy']['id']
+        self.admin_manager.network_client.create_bandwidth_limit_rule(
+            policy_id, max_kbps=constants.LIMIT_KILO_BITS_PER_SECOND,
+            max_burst_kbps=constants.LIMIT_KILO_BITS_PER_SECOND)
+        port = self.client.list_ports(network_id=self.network['id'],
+                                      device_id=self.server[
+                                      'server']['id'])['ports'][0]
+        self.admin_manager.network_client.update_port(port['id'],
+                                                      qos_policy_id=policy_id)
+        self._create_file_for_bw_tests(ssh_client)
+        utils.wait_until_true(lambda: self._check_bw(
+            ssh_client,
+            self.fip['floating_ip_address'],
+            port=NC_PORT),
+            timeout=120,
+            sleep=1)
