You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2022/02/14 13:55:59 UTC

svn commit: r1898069 - in /httpd/httpd/branches/2.4.x: ./ test/modules/http2/test_500_proxy.py test/pyhttpd/nghttp.py

Author: icing
Date: Mon Feb 14 13:55:59 2022
New Revision: 1898069

URL: http://svn.apache.org/viewvc?rev=1898069&view=rev
Log:
Merge r1898068 from trunk:

 *) test: capture and parse output from nghttp more reliably.
    add repeat param to certain proxy tests.


Modified:
    httpd/httpd/branches/2.4.x/   (props changed)
    httpd/httpd/branches/2.4.x/test/modules/http2/test_500_proxy.py
    httpd/httpd/branches/2.4.x/test/pyhttpd/nghttp.py

Propchange: httpd/httpd/branches/2.4.x/
------------------------------------------------------------------------------
  Merged /httpd/httpd/trunk:r1898068

Modified: httpd/httpd/branches/2.4.x/test/modules/http2/test_500_proxy.py
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/test/modules/http2/test_500_proxy.py?rev=1898069&r1=1898068&r2=1898069&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/test/modules/http2/test_500_proxy.py (original)
+++ httpd/httpd/branches/2.4.x/test/modules/http2/test_500_proxy.py Mon Feb 14 13:55:59 2022
@@ -10,12 +10,11 @@ class TestProxy:
 
     @pytest.fixture(autouse=True, scope='class')
     def _class_scope(self, env):
-        TestProxy._local_dir = os.path.dirname(inspect.getfile(TestProxy))
         H2Conf(env).add_vhost_cgi(proxy_self=True).install()
         assert env.apache_restart() == 0
 
     def local_src(self, fname):
-        return os.path.join(TestProxy._local_dir, fname)
+        return os.path.join(os.path.dirname(inspect.getfile(TestProxy)), fname)
 
     def setup_method(self, method):
         print("setup_method: %s" % method.__name__)
@@ -28,10 +27,10 @@ class TestProxy:
         r = env.curl_get(url, 5)
         assert r.response["status"] == 200
         assert "HTTP/1.1" == r.response["json"]["protocol"]
-        assert "" == r.response["json"]["https"]
-        assert "" == r.response["json"]["ssl_protocol"]
-        assert "" == r.response["json"]["h2"]
-        assert "" == r.response["json"]["h2push"]
+        assert r.response["json"]["https"] == ""
+        assert r.response["json"]["ssl_protocol"] == ""
+        assert r.response["json"]["h2"] == ""
+        assert r.response["json"]["h2push"] == ""
 
     # upload and GET again using curl, compare to original content
     def curl_upload_and_verify(self, env, fname, options=None):
@@ -47,9 +46,9 @@ class TestProxy:
         assert r2.response["status"] == 200
         with open(self.local_src(fpath), mode='rb') as file:
             src = file.read()
-        assert src == r2.response["body"]
+        assert r2.response["body"] == src
 
-    def test_h2_500_10(self, env):
+    def test_h2_500_10(self, env, repeat):
         self.curl_upload_and_verify(env, "data-1k", ["--http2"])
         self.curl_upload_and_verify(env, "data-10k", ["--http2"])
         self.curl_upload_and_verify(env, "data-100k", ["--http2"])
@@ -64,15 +63,20 @@ class TestProxy:
         assert 200 <= r.response["status"] < 300
         with open(self.local_src(fpath), mode='rb') as file:
             src = file.read()
-        assert src == r.response["body"]
+        if r.response["body"] != src:
+            with open(os.path.join(env.gen_dir, "nghttp.out"), 'w') as fd:
+                fd.write(r.outraw)
+                fd.write("\nstderr:\n")
+                fd.write(r.stderr)
+            assert r.response["body"] == src
 
-    def test_h2_500_20(self, env):
+    def test_h2_500_20(self, env, repeat):
         self.nghttp_post_and_verify(env, "data-1k", [])
         self.nghttp_post_and_verify(env, "data-10k", [])
         self.nghttp_post_and_verify(env, "data-100k", [])
         self.nghttp_post_and_verify(env, "data-1m", [])
 
-    def test_h2_500_21(self, env):
+    def test_h2_500_21(self, env, repeat):
         self.nghttp_post_and_verify(env, "data-1k", ["--no-content-length"])
         self.nghttp_post_and_verify(env, "data-10k", ["--no-content-length"])
         self.nghttp_post_and_verify(env, "data-100k", ["--no-content-length"])

Modified: httpd/httpd/branches/2.4.x/test/pyhttpd/nghttp.py
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/test/pyhttpd/nghttp.py?rev=1898069&r1=1898068&r2=1898069&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/test/pyhttpd/nghttp.py (original)
+++ httpd/httpd/branches/2.4.x/test/pyhttpd/nghttp.py Mon Feb 14 13:55:59 2022
@@ -84,11 +84,12 @@ class Nghttp:
             if len(l) == 0:
                 body += '\n'
                 continue
-            m = re.match(r'\[.*] recv \(stream_id=(\d+)\) (\S+): (\S*)', l)
+            m = re.match(r'(.*)\[.*] recv \(stream_id=(\d+)\) (\S+): (\S*)', l)
             if m:
-                s = self.get_stream(streams, m.group(1))
-                hname = m.group(2)
-                hval = m.group(3)
+                body += m.group(1)
+                s = self.get_stream(streams, m.group(2))
+                hname = m.group(3)
+                hval = m.group(4)
                 print("stream %d header %s: %s" % (s["id"], hname, hval))
                 header = s["header"]
                 if hname in header: 
@@ -98,9 +99,10 @@ class Nghttp:
                 body = ''
                 continue
 
-            m = re.match(r'\[.*] recv HEADERS frame <.* stream_id=(\d+)>', l)
+            m = re.match(r'(.*)\[.*] recv HEADERS frame <.* stream_id=(\d+)>', l)
             if m:
-                s = self.get_stream(streams, m.group(1))
+                body += m.group(1)
+                s = self.get_stream(streams, m.group(2))
                 if s:
                     print("stream %d: recv %d header" % (s["id"], len(s["header"]))) 
                     response = s["response"]
@@ -123,8 +125,8 @@ class Nghttp:
             
             m = re.match(r'(.*)\[.*] recv DATA frame <length=(\d+), .*stream_id=(\d+)>', l)
             if m:
-                s = self.get_stream(streams, m.group(3))
                 body += m.group(1)
+                s = self.get_stream(streams, m.group(3))
                 blen = int(m.group(2))
                 if s:
                     print("stream %d: %d DATA bytes added" % (s["id"], blen))
@@ -140,9 +142,10 @@ class Nghttp:
                 skip_indents = True
                 continue
                 
-            m = re.match(r'\[.*] recv PUSH_PROMISE frame <.* stream_id=(\d+)>', l)
+            m = re.match(r'(.*)\[.*] recv PUSH_PROMISE frame <.* stream_id=(\d+)>', l)
             if m:
-                s = self.get_stream(streams, m.group(1))
+                body += m.group(1)
+                s = self.get_stream(streams, m.group(2))
                 if s:
                     # headers we have are request headers for the PUSHed stream
                     # these have been received on the originating stream, the promised
@@ -283,7 +286,7 @@ Content-Transfer-Encoding: binary
     def _run(self, args) -> ExecResult:
         print(("execute: %s" % " ".join(args)))
         start = datetime.now()
-        p = subprocess.run(args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+        p = subprocess.run(args, capture_output=True, text=False)
         return ExecResult(args=args, exit_code=p.returncode,
                           stdout=p.stdout, stderr=p.stderr,
                           duration=datetime.now() - start)