This fixes the test_periodoc_resync_helper unit test that breaks with
a randomized PYTHONHASHSEED (see the bug report).
The test assumed that the dhcp.needs_resync_reasons dictionary from
neutron.agent.dhcp.agent had elements in a particular order. Found with
PYTHONHASHSEED=2.
The fix refactors the test case to force a sorted dhcp.needs_resync_reasons
dictionary.
Partial-bug: #
1348818
Note: There are several other unrelated unit tests that also break with
a randomized PYTHONHASHSEED, but they are not addressed here. They will
be addressed in separate patches.
Change-Id: Ia7fc2c3e605d92d8497d44e28054bdda613cebf2
# License for the specific language governing permissions and limitations
# under the License.
+import collections
import copy
import sys
import uuid
def test_periodoc_resync_helper(self):
with mock.patch.object(dhcp_agent.eventlet, 'sleep') as sleep:
dhcp = dhcp_agent.DhcpAgent(HOSTNAME)
- dhcp.needs_resync_reasons = {'a': 'reason1', 'b': 'reason2'}
+ dhcp.needs_resync_reasons = collections.OrderedDict(
+ (('a', 'reason1'), ('b', 'reason2')))
with mock.patch.object(dhcp, 'sync_state') as sync_state:
sync_state.side_effect = RuntimeError
with testtools.ExpectedException(RuntimeError):