You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ma...@apache.org on 2018/01/30 00:25:06 UTC

[trafficserver] branch master updated: Add an example of testing http2 with httpbin

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

masaori 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 168729a  Add an example of testing http2 with httpbin
168729a is described below

commit 168729a99edbf57bd9570060531e2d637cd71030
Author: Masaori Koshiba <ma...@apache.org>
AuthorDate: Mon Dec 4 10:52:05 2017 +0900

    Add an example of testing http2 with httpbin
---
 tests/gold_tests/autest-site/httpbin.test.ext  | 11 +++-
 tests/gold_tests/h2/gold/httpbin_0_stderr.gold | 15 +++++
 tests/gold_tests/h2/gold/httpbin_0_stdout.gold | 10 ++++
 tests/gold_tests/h2/httpbin.test.py            | 80 ++++++++++++++++++++++++++
 4 files changed, 113 insertions(+), 3 deletions(-)

diff --git a/tests/gold_tests/autest-site/httpbin.test.ext b/tests/gold_tests/autest-site/httpbin.test.ext
index 6e2dd86..144eeb3 100644
--- a/tests/gold_tests/autest-site/httpbin.test.ext
+++ b/tests/gold_tests/autest-site/httpbin.test.ext
@@ -19,10 +19,10 @@
 from ports import get_port
 
 
-def MakeHttpBinServer(obj, name, port=False, ip=False, delay=False, public_ip=False, ssl=False, options={}):
-    data_dir = os.path.join(obj.RunDirectory, name)
+def MakeHttpBinServer(self, name, port=False, ip=False, delay=False, public_ip=False, ssl=False, options={}):
+    data_dir = os.path.join(self.RunDirectory, name)
     # create Process
-    p = obj.Processes.Process(name)
+    p = self.Processes.Process(name)
     if (port == False):
         port = get_port(p, "Port")
     if (ip == False):
@@ -30,6 +30,10 @@ def MakeHttpBinServer(obj, name, port=False, ip=False, delay=False, public_ip=Fa
     if (delay == False):
         delay = 0
 
+    self._RootRunable.SkipUnless(
+        Condition.HasProgram("gunicorn", "gunicorn needs be installed with httpbin package for this extension to run")
+    )
+
     command = "gunicorn -b {0}:{1} httpbin:app".format(ip, port)
     for flag, value in options.items():
         command += " {} {}".format(flag, value)
@@ -45,3 +49,4 @@ def MakeHttpBinServer(obj, name, port=False, ip=False, delay=False, public_ip=Fa
 
 
 ExtendTest(MakeHttpBinServer, name="MakeHttpBinServer")
+ExtendTestRun(MakeHttpBinServer, name="MakeHttpBinServer")
diff --git a/tests/gold_tests/h2/gold/httpbin_0_stderr.gold b/tests/gold_tests/h2/gold/httpbin_0_stderr.gold
new file mode 100644
index 0000000..3ed2777
--- /dev/null
+++ b/tests/gold_tests/h2/gold/httpbin_0_stderr.gold
@@ -0,0 +1,15 @@
+``
+> GET /get HTTP/2
+> Host: ``
+> User-Agent: curl/``
+> Accept: */*
+``
+< HTTP/2 200 ``
+< server: ATS/``
+< date: ``
+< content-type: application/json
+``
+< content-length: ``
+< age: ``
+< via: ``ApacheTrafficServer/``
+``
diff --git a/tests/gold_tests/h2/gold/httpbin_0_stdout.gold b/tests/gold_tests/h2/gold/httpbin_0_stdout.gold
new file mode 100644
index 0000000..c46139d
--- /dev/null
+++ b/tests/gold_tests/h2/gold/httpbin_0_stdout.gold
@@ -0,0 +1,10 @@
+{
+  "args": {}, ``
+  "headers": {
+    "Accept": "*/*", ``
+    "Host": ``
+    "User-Agent": "curl/``
+  }, ``
+  "origin": ``
+  "url": "http://``/get"
+}
diff --git a/tests/gold_tests/h2/httpbin.test.py b/tests/gold_tests/h2/httpbin.test.py
new file mode 100644
index 0000000..2e32269
--- /dev/null
+++ b/tests/gold_tests/h2/httpbin.test.py
@@ -0,0 +1,80 @@
+'''
+'''
+#  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 os
+
+# ----
+# Setup Test
+# ----
+Test.Summary = '''
+Test HTTP/2 with httpbin origin server
+'''
+# Require HTTP/2 enabled Curl
+Test.SkipUnless(
+    Condition.HasProgram("curl", "Curl need to be installed on system for this test to work"),
+    Condition.HasCurlFeature('http2')
+)
+Test.ContinueOnFail = True
+
+# ----
+# Setup httpbin Origin Server
+# ----
+httpbin = Test.MakeHttpBinServer("httpbin")
+
+# ----
+# Setup ATS
+# ----
+ts = Test.MakeATSProcess("ts", select_ports=False)
+
+# add ssl materials like key, certificates for the server
+ts.addSSLfile("ssl/server.pem")
+ts.addSSLfile("ssl/server.key")
+ts.Variables.ssl_port = 4443
+ts.Disk.remap_config.AddLine(
+    'map / http://127.0.0.1:{0}'.format(httpbin.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.http.server_ports': '{0} {1}:ssl'.format(ts.Variables.port, ts.Variables.ssl_port),
+    'proxy.config.http.insert_request_via_str': 1,
+    'proxy.config.http.insert_response_via_str': 1,
+    'proxy.config.http.cache.http': 0,
+    '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.client.verify.server':  0,
+    'proxy.config.ssl.server.cipher_suite': 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA:RC4-MD5:AES128-SHA:AES256-SHA:DES-CBC3-SHA!SRP:!DSS:!PSK:!aNULL:!eNULL:!SSLv2',
+    'proxy.config.diags.debug.enabled': 1,
+    'proxy.config.diags.debug.tags': 'http2',
+
+})
+
+# ----
+# Test Cases
+# ----
+
+# Test Case 0: /get
+test_run = Test.AddTestRun()
+test_run.Processes.Default.Command = 'curl -vs -k --http2 https://127.0.0.1:{0}/get'.format(ts.Variables.ssl_port)
+test_run.Processes.Default.ReturnCode = 0
+test_run.Processes.Default.StartBefore(httpbin)
+test_run.Processes.Default.StartBefore(Test.Processes.ts, ready=When.PortOpen(ts.Variables.ssl_port))
+test_run.Processes.Default.Streams.stdout = "gold/httpbin_0_stdout.gold"
+test_run.Processes.Default.Streams.stderr = "gold/httpbin_0_stderr.gold"
+test_run.StillRunningAfter = httpbin

-- 
To stop receiving notification emails like this one, please contact
masaori@apache.org.