Skip to content

Commit a28ec9e

Browse files
committed
[Fullstack] Double check that agent is dead when it should be dead
In some fullstack tests it is expected that agent is DOWN in the Neutron DB. It could happen sometimes that in almost the same time test's client was doing GET /v2.0/agents/{agent_id} call and got result with "alive=False" and in other thread rpc worker was processing heartbeat from the agent so it was revived just after API request was finished. That was causing test failures in some cases. This patch adds second API call to get agent again after 2 seconds if it was already marked as DEAD, just to make sure that it is really dead ;) Closes-Bug: #2045757 Change-Id: I1c20c90b8abd760f3a53b24024f19ef2bd189b5a (cherry picked from commit 58dcd30)
1 parent 5fd71ac commit a28ec9e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

neutron/tests/fullstack/base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import itertools
1717
import os
1818
import random
19+
import time
1920

2021
import netaddr
2122
from neutron_lib.tests import tools
@@ -96,6 +97,17 @@ def _agent_up():
9697
def _wait_until_agent_down(self, agent_id):
9798
def _agent_down():
9899
agent = self.client.show_agent(agent_id)['agent']
100+
if not agent.get('alive'):
101+
# NOTE(slaweq): to avoid race between heartbeat written in the
102+
# database and response to this API call, lets make sure that
103+
# agent is really dead. See bug
104+
# https://bugs.launchpad.net/neutron/+bug/2045757
105+
# for details.
106+
# 2 seconds delay should be more than enough to make sure that
107+
# all pending heartbeats are already written in the Neutron
108+
# database
109+
time.sleep(2)
110+
agent = self.client.show_agent(agent_id)['agent']
99111
return not agent.get('alive')
100112

101113
common_utils.wait_until_true(_agent_down)

0 commit comments

Comments
 (0)