]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Remove useless code in L3 HA unit tests
authorAssaf Muller <amuller@redhat.com>
Mon, 12 Oct 2015 17:33:02 +0000 (13:33 -0400)
committerCedric Brandily <zzelle@gmail.com>
Wed, 14 Oct 2015 08:49:52 +0000 (08:49 +0000)
I added a helper function to make the server consider an agent
as down, might as well use it!

Change-Id: If1110de7f46ecb3dc2e72b3c62d7faeb0e71c586

neutron/tests/unit/db/test_l3_hamode_db.py

index 69a6826dfe86a2298be89256a843abb7887fd362..36712d9a454d8c4508a66d990153622bd84f468c 100644 (file)
 # License for the specific language governing permissions and limitations
 # under the License.
 
-import datetime
 import mock
 from oslo_config import cfg
-from oslo_utils import timeutils
 from oslo_utils import uuidutils
 
 from neutron.api.rpc.handlers import l3_rpc
@@ -62,13 +60,6 @@ class L3HATestFramework(testlib_api.SqlTestCase):
         self.agent2 = helpers.register_l3_agent(
             'host_2', constants.L3_AGENT_MODE_DVR_SNAT)
 
-    def _bring_down_agent(self, agent_id):
-        update = {
-            'agent': {
-                'heartbeat_timestamp':
-                timeutils.utcnow() - datetime.timedelta(hours=1)}}
-        self.plugin.update_agent(self.admin_ctx, agent_id, update)
-
     def _create_router(self, ha=True, tenant_id='tenant1', distributed=None,
                        ctx=None):
         if ctx is None:
@@ -497,8 +488,7 @@ class L3HATestCase(L3HATestFramework):
 
     def test_get_number_of_agents_for_scheduling_not_enough_agents(self):
         cfg.CONF.set_override('min_l3_agents_per_router', 3)
-        agent_to_bring_down = helpers.register_l3_agent(host='l3host_3')
-        self._bring_down_agent(agent_to_bring_down['id'])
+        helpers.kill_agent(helpers.register_l3_agent(host='l3host_3')['id'])
         self.assertRaises(l3_ext_ha_mode.HANotEnoughAvailableAgents,
                           self.plugin.get_number_of_agents_for_scheduling,
                           self.admin_ctx)