You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by pa...@apache.org on 2017/05/08 16:01:52 UTC

[trafficserver] branch master updated: h2 test with chunked download

This is an automated email from the ASF dual-hosted git repository.

paziz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  75ff305   h2 test with chunked download
75ff305 is described below

commit 75ff3055d60bf6c7f2ede6cfd8bf3b98229b2e5c
Author: Persia Aziz <pe...@yahoo-inc.com>
AuthorDate: Fri May 5 16:55:31 2017 -0500

    h2 test with chunked download
---
 tests/gold_tests/h2/gold/chunked.gold |  6 ++++
 tests/gold_tests/h2/h2chunked.py      | 68 +++++++++++++++++++++++++++++++++++
 tests/gold_tests/h2/http2.test.py     | 21 +++++++++--
 tests/tools/microServer/uWServer.py   |  7 ++--
 4 files changed, 97 insertions(+), 5 deletions(-)

diff --git a/tests/gold_tests/h2/gold/chunked.gold b/tests/gold_tests/h2/gold/chunked.gold
new file mode 100644
index 0000000..836d51a
--- /dev/null
+++ b/tests/gold_tests/h2/gold/chunked.gold
@@ -0,0 +1,6 @@
+HTTP/2 200
+date: {}
+server: ATS/{}
+``
+microserverapachetrafficserver
+``
diff --git a/tests/gold_tests/h2/h2chunked.py b/tests/gold_tests/h2/h2chunked.py
new file mode 100644
index 0000000..6aeac03
--- /dev/null
+++ b/tests/gold_tests/h2/h2chunked.py
@@ -0,0 +1,68 @@
+'''
+'''
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing, software
+#  distributed under the License is distributed on an "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#  See the License for the specific language governing permissions and
+#  limitations under the License.
+
+import json
+from hyper import HTTPConnection
+import hyper
+import argparse
+
+def getResponseString(response):
+    typestr = str(type(response))
+    if typestr.find('HTTP20') != -1:
+        string = "HTTP/2 {0}\r\n".format(response.status)
+    else:
+        string = "HTTP {0}\r\n".format(response.status)
+    string+='date: '+response.headers.get('date')[0].decode('utf-8')+"\r\n"
+    string+='server: '+response.headers.get('Server')[0].decode('utf-8')+"\r\n"
+    return string
+
+def makerequest(port,_url):
+    hyper.tls._context = hyper.tls.init_context()
+    hyper.tls._context.check_hostname = False
+    hyper.tls._context.verify_mode = hyper.compat.ssl.CERT_NONE
+
+    conn = HTTPConnection('localhost:{0}'.format(port), secure=True)
+
+    sites={'/'}
+    responses = []
+    request_ids = []
+    for site in sites:
+            request_id = conn.request('GET',url=_url)
+            request_ids.append(request_id)
+
+    # get responses
+    for req_id in request_ids:
+        response = conn.get_response(req_id)
+        body = response.read()
+        print(getResponseString(response))
+        print(body.decode('utf-8'))
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument("--port","-p",
+                        type=int,                        
+                        help="Port to use")
+    parser.add_argument("--url","-u",
+                    type=str,                        
+                    help="url")
+    args=parser.parse_args()
+    makerequest(args.port,args.url)
+
+if __name__ == '__main__':
+    main()
+    
diff --git a/tests/gold_tests/h2/http2.test.py b/tests/gold_tests/h2/http2.test.py
index 2d81c1b..d3f6f4d 100644
--- a/tests/gold_tests/h2/http2.test.py
+++ b/tests/gold_tests/h2/http2.test.py
@@ -29,10 +29,17 @@ Test.ContinueOnFail=True
 ts=Test.MakeATSProcess("ts",select_ports=False)
 server=Test.MakeOriginServer("server")
 
+
+requestLocation = "test2"
+reHost = "www.example.com"
+
 testName = ""
 request_header={"headers": "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
 #desired response form the origin server
 response_header={"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
+request_header2={"headers": "GET /{0} HTTP/1.1\r\nHost: {1}\r\n\r\n".format(requestLocation,reHost), "timestamp": "1469733493.993", "body": ""}
+#desired response form the origin server
+response_header2={"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nTransfer-Encoding: chunked\r\nConnection: close\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
 server.addResponse("sessionlog.json", request_header, response_header)
 
 # Add info for the large H2 download test
@@ -40,7 +47,7 @@ server.addResponse("sessionlog.json",
     {"headers": "GET /bigfile HTTP/1.1\r\nHost: www.example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""},
     {"headers": "HTTP/1.1 200 OK\r\nServer: microserver\r\nConnection: close\r\nCache-Control: max-age=3600\r\nContent-Length: 191414\r\n\r\n", "timestamp": "1469733493.993", "body": "" })
 
-
+server.addResponse("sessionlog.json",request_header2,response_header2)
 #add ssl materials like key, certificates for the server
 ts.addSSLfile("ssl/server.pem")
 ts.addSSLfile("ssl/server.key")
@@ -49,12 +56,13 @@ ts.Variables.ssl_port = 4443
 ts.Disk.remap_config.AddLine(
     'map / http://127.0.0.1:{0}'.format(server.Variables.Port)
 )
+
 ts.Disk.ssl_multicert_config.AddLine(
     'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key'
 )
 ts.Disk.records_config.update({
-        'proxy.config.diags.debug.enabled': 0,
-        'proxy.config.diags.debug.tags': 'http',
+        'proxy.config.diags.debug.enabled': 1,
+        'proxy.config.diags.debug.tags': 'http|remap',
         'proxy.config.ssl.server.cert.path': '{0}'.format(ts.Variables.SSLDir), 
         'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir),
         'proxy.config.ssl.number.threads': 0,
@@ -64,6 +72,7 @@ ts.Disk.records_config.update({
     })
 ts.Setup.CopyAs('h2client.py',Test.RunDirectory)
 ts.Setup.CopyAs('h2bigclient.py',Test.RunDirectory)
+ts.Setup.CopyAs('h2chunked.py',Test.RunDirectory)
 
 # Test Case 1:  basic H2 interaction
 tr=Test.AddTestRun()
@@ -82,3 +91,9 @@ tr.Processes.Default.ReturnCode=0
 tr.Processes.Default.Streams.stdout="gold/bigfile.gold"
 tr.StillRunningAfter=server
 
+# Test Case 3: Chunked content
+tr=Test.AddTestRun()
+tr.Processes.Default.Command='python3 h2chunked.py -p {0}  -u /{1}'.format(ts.Variables.ssl_port,requestLocation)
+tr.Processes.Default.ReturnCode=0
+tr.Processes.Default.Streams.stdout="gold/chunked.gold"
+tr.StillRunningAfter=server
diff --git a/tests/tools/microServer/uWServer.py b/tests/tools/microServer/uWServer.py
index 84ed27a..67f35a2 100644
--- a/tests/tools/microServer/uWServer.py
+++ b/tests/tools/microServer/uWServer.py
@@ -191,8 +191,11 @@ class MyHandler(BaseHTTPRequestHandler):
         return int(header.split(' ')[1])
 
     def generator(self):
-        yield 'microserver'
-        yield 'yahoo'
+        yield 'micro'
+        yield 'server'
+        yield 'apache'
+        yield 'traffic'
+        yield 'server'
     def send_response(self, code, message=None):
         ''' Override `send_response()`'s tacking on of server and date header lines. '''
         #self.log_request(code)

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].