]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix PYTHONHASHSEED bugs in test_security_groups_rpc
authorCedric Brandily <zzelle@gmail.com>
Thu, 28 May 2015 07:07:23 +0000 (09:07 +0200)
committerCedric Brandily <zzelle@gmail.com>
Thu, 28 May 2015 07:44:54 +0000 (09:44 +0200)
This fixes the test_security_group_member/rule_updated unit tests[1]
that breaks with a randomized PYTHONHASHSEED (see the bug report).

The test assumed that several dictionaries had elements in a
particular order. Found with PYTHONHASHSEED=2.

The fix refactors the test case by injecting values using the same
ordering[2].

[1] neutron.tests.unit.agent.test_securitygroups_rpc.\
   TestSecurityGroupAgentWithOVSIptables

[2] https://github.com/openstack/neutron/blob/\
   e8364a72e62d83e5a76bec1d7aa76ecfe2ed53ac/\
   neutron/tests/unit/agent/test_securitygroups_rpc.py#L1630-L1635

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: I5077764045a34d1be0e85bb4b80f3655e87692cc

neutron/tests/unit/agent/test_securitygroups_rpc.py

index 5fd97ba144802a7e4179d6cf48e7852cb2147c8a..726ed3eab55fe9412d6a7cedf1f81a6096edf66c 100644 (file)
@@ -1670,10 +1670,12 @@ IPTABLES_RAW_DEVICE_2 = """# Generated by iptables_manager
 :%(bn)s-PREROUTING - [0:0]
 [0:0] -A PREROUTING -j %(bn)s-PREROUTING
 [0:0] -A OUTPUT -j %(bn)s-OUTPUT
-[0:0] -A %(bn)s-PREROUTING -m physdev --physdev-in qvbtap_port1 -j CT --zone 1
-[0:0] -A %(bn)s-PREROUTING -m physdev --physdev-in tap_port1 -j CT --zone 1
-[0:0] -A %(bn)s-PREROUTING -m physdev --physdev-in qvbtap_port2 -j CT --zone 1
-[0:0] -A %(bn)s-PREROUTING -m physdev --physdev-in tap_port2 -j CT --zone 1
+[0:0] -A %(bn)s-PREROUTING -m physdev --physdev-in qvbtap_%(port1)s \
+-j CT --zone 1
+[0:0] -A %(bn)s-PREROUTING -m physdev --physdev-in tap_%(port1)s -j CT --zone 1
+[0:0] -A %(bn)s-PREROUTING -m physdev --physdev-in qvbtap_%(port2)s \
+-j CT --zone 1
+[0:0] -A %(bn)s-PREROUTING -m physdev --physdev-in tap_%(port2)s -j CT --zone 1
 COMMIT
 # Completed by iptables_manager
 """ % IPTABLES_ARG