Browse Source

Merge "Fix fullstack test_dscp_marking_packets test"

Zuul 1 month ago
parent
commit
0f89f3e6dd
1 changed files with 14 additions and 2 deletions
  1. 14
    2
      neutron/tests/common/agents/l2_extensions.py

+ 14
- 2
neutron/tests/common/agents/l2_extensions.py View File

@@ -15,12 +15,14 @@
15 15
 
16 16
 import re
17 17
 import signal
18
+import time
18 19
 
19 20
 from oslo_log import log as logging
20 21
 
21 22
 from neutron.agent.common import async_process
22 23
 from neutron.agent.linux import iptables_manager
23 24
 from neutron.common import utils as common_utils
25
+from neutron.tests.common import net_helpers
24 26
 
25 27
 LOG = logging.getLogger(__name__)
26 28
 
@@ -108,19 +110,29 @@ def wait_for_dscp_marked_packet(sender_vm, receiver_vm, dscp_mark):
108 110
         cmd += ["and", "(ip[1] & 0xfc == %s)" % (dscp_mark << 2)]
109 111
     tcpdump_async = async_process.AsyncProcess(cmd, run_as_root=True,
110 112
                                                namespace=receiver_vm.namespace)
111
-    tcpdump_async.start()
112
-    sender_vm.block_until_ping(receiver_vm.ip)
113
+    tcpdump_async.start(block=True)
114
+
115
+    with net_helpers.async_ping(sender_vm.namespace, [receiver_vm.ip]) as done:
116
+        while not done():
117
+            time.sleep(0.25)
118
+
113 119
     try:
114 120
         tcpdump_async.stop(kill_signal=signal.SIGINT)
115 121
     except async_process.AsyncProcessException:
116 122
         # If it was already stopped than we don't care about it
117 123
         pass
118 124
 
125
+    tcpdump_stderr_lines = []
119 126
     pattern = r"(?P<packets_count>^\d+) packets received by filter"
120 127
     for line in tcpdump_async.iter_stderr():
121 128
         m = re.match(pattern, line)
122 129
         if m and int(m.group("packets_count")) != 0:
123 130
             return
131
+        tcpdump_stderr_lines.append(line)
132
+
133
+    tcpdump_stdout_lines = [line for line in tcpdump_async.iter_stdout()]
134
+    LOG.debug("Captured output lines from tcpdump. Stdout: %s; Stderr: %s",
135
+              tcpdump_stdout_lines, tcpdump_stderr_lines)
124 136
 
125 137
     raise TcpdumpException(
126 138
         "No packets marked with DSCP = %(dscp_mark)s received from %(src)s "

Loading…
Cancel
Save