Merge "Add a tempest scenario for floating-ip"
diff --git a/neutron/tests/tempest/api/test_floating_ips.py b/neutron/tests/tempest/api/test_floating_ips.py
index 6e722db..6523f3c 100644
--- a/neutron/tests/tempest/api/test_floating_ips.py
+++ b/neutron/tests/tempest/api/test_floating_ips.py
@@ -51,6 +51,7 @@
             port_id=self.ports[0]['id'],
             description='d1'
         )['floatingip']
+        self.floating_ips.append(body)
         self.assertEqual(self.ports[0]['id'], body['port_id'])
         body = self.client.update_floatingip(body['id'])['floatingip']
         self.assertFalse(body['port_id'])
@@ -64,6 +65,7 @@
             port_id=self.ports[0]['id'],
             description='d1'
         )['floatingip']
+        self.floating_ips.append(body)
         self.assertEqual('d1', body['description'])
         body = self.client.show_floatingip(body['id'])['floatingip']
         self.assertEqual('d1', body['description'])
@@ -86,6 +88,7 @@
             port_id=port_id,
             description='d1'
         )['floatingip']
+        self.floating_ips.append(body)
         self.assertEqual('d1', body['description'])
         body = self.client.show_floatingip(body['id'])['floatingip']
         self.assertEqual(port_id, body['port_id'])
diff --git a/neutron/tests/tempest/api/test_revisions.py b/neutron/tests/tempest/api/test_revisions.py
index e0419d9..1da4493 100644
--- a/neutron/tests/tempest/api/test_revisions.py
+++ b/neutron/tests/tempest/api/test_revisions.py
@@ -255,6 +255,7 @@
             port_id=port['id'],
             description='d1'
         )['floatingip']
+        self.floating_ips.append(body)
         self.assertIn('revision_number', body)
         b2 = self.client.update_floatingip(body['id'], description='d2')
         self.assertGreater(b2['floatingip']['revision_number'],
diff --git a/neutron/tests/tempest/scenario/test_qos.py b/neutron/tests/tempest/scenario/test_qos.py
index b558438..8b8e90a 100644
--- a/neutron/tests/tempest/scenario/test_qos.py
+++ b/neutron/tests/tempest/scenario/test_qos.py
@@ -38,7 +38,6 @@
         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:
@@ -97,10 +96,6 @@
                 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)
@@ -109,36 +104,26 @@
         cmd = ("(nc -ll -p %(port)d < %(file_path)s > /dev/null &)" % {
                 'port': port, 'file_path': QoSTest.FILE_PATH})
         ssh_client.exec_command(cmd)
+
+        start_time = time.time()
         client_socket = _connect_socket(host, port)
+        total_bytes_read = 0
 
         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
+            data = client_socket.recv(QoSTest.BUFFER_SIZE)
             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
+        time_elapsed = time.time() - start_time
+        bytes_per_second = total_bytes_read / time_elapsed
+
+        LOG.debug("time_elapsed = %(time_elapsed)d, "
+                  "total_bytes_read = %(total_bytes_read)d, "
+                  "bytes_per_second = %(bytes_per_second)d",
+                  {'time_elapsed': time_elapsed,
+                   'total_bytes_read': total_bytes_read,
+                   'bytes_per_second': bytes_per_second})
+
+        return bytes_per_second <= QoSTest.LIMIT_BYTES_SEC
 
     @test.idempotent_id('1f7ed39b-428f-410a-bd2b-db9f465680df')
     def test_qos(self):
diff --git a/neutron/tests/tempest/scenario/test_trunk.py b/neutron/tests/tempest/scenario/test_trunk.py
index 13fec2d..195882d 100644
--- a/neutron/tests/tempest/scenario/test_trunk.py
+++ b/neutron/tests/tempest/scenario/test_trunk.py
@@ -13,7 +13,6 @@
 #    under the License.
 
 import netaddr
-from oslo_log import log as logging
 from tempest.common.utils.linux import remote_client
 from tempest.common import waiters
 from tempest.lib.common.utils import data_utils
@@ -25,7 +24,6 @@
 from neutron.tests.tempest.scenario import constants
 
 CONF = config.CONF
-LOG = logging.getLogger(__name__)
 
 CONFIGURE_VLAN_INTERFACE_COMMANDS = (
     'IFACE=$(ip l | grep "^[0-9]*: e" | cut -d \: -f 2) && '