From d23f9e49f4efb49330c9894d8c69a2cce0228337 Mon Sep 17 00:00:00 2001 From: Masaori Koshiba Date: Tue, 13 Oct 2020 13:15:15 +0900 Subject: [PATCH] Add AuTest for HTTP/2 Graceful Shutdown --- tests/gold_tests/h2/gold/nghttp_1_stdout.gold | 12 ++++++ .../gold_tests/h2/gold/nghttp_ts_stderr.gold | 5 +++ tests/gold_tests/h2/nghttp.test.py | 37 +++++++++++++++---- .../h2/rules/graceful_shutdown.conf | 19 ++++++++++ 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 tests/gold_tests/h2/gold/nghttp_1_stdout.gold create mode 100644 tests/gold_tests/h2/gold/nghttp_ts_stderr.gold create mode 100644 tests/gold_tests/h2/rules/graceful_shutdown.conf diff --git a/tests/gold_tests/h2/gold/nghttp_1_stdout.gold b/tests/gold_tests/h2/gold/nghttp_1_stdout.gold new file mode 100644 index 00000000000..fb9b831b18f --- /dev/null +++ b/tests/gold_tests/h2/gold/nghttp_1_stdout.gold @@ -0,0 +1,12 @@ +`` +[``] recv HEADERS frame +`` +[``] recv GOAWAY frame + (last_stream_id=2147483647, error_code=NO_ERROR(0x00), opaque_data(0)=[]) +`` +[``] recv GOAWAY frame + (last_stream_id=1, error_code=NO_ERROR(0x00), opaque_data(0)=[]) +`` +[``] recv DATA frame + ; END_STREAM +`` diff --git a/tests/gold_tests/h2/gold/nghttp_ts_stderr.gold b/tests/gold_tests/h2/gold/nghttp_ts_stderr.gold new file mode 100644 index 00000000000..913d1c84696 --- /dev/null +++ b/tests/gold_tests/h2/gold/nghttp_ts_stderr.gold @@ -0,0 +1,5 @@ +`` +``session free +`` +``session free +`` diff --git a/tests/gold_tests/h2/nghttp.test.py b/tests/gold_tests/h2/nghttp.test.py index 7399a21e341..0bb5e5c3ae6 100644 --- a/tests/gold_tests/h2/nghttp.test.py +++ b/tests/gold_tests/h2/nghttp.test.py @@ -30,6 +30,7 @@ # Setup Origin Server # ---- microserver = Test.MakeOriginServer("microserver") +httpbin = Test.MakeHttpBinServer("httpbin") # 128KB post_body = "0123456789abcdef" * 8192 @@ -49,15 +50,20 @@ # ---- # Setup ATS # ---- -ts = Test.MakeATSProcess("ts", select_ports=True, enable_tls=True, enable_cache=False) +ts = Test.MakeATSProcess("ts", select_ports=True, + enable_tls=True, enable_cache=False) # add ssl materials like key, certificates for the server ts.addSSLfile("ssl/server.pem") ts.addSSLfile("ssl/server.key") -ts.Disk.remap_config.AddLine( - 'map /post http://127.0.0.1:{0}/post'.format(microserver.Variables.Port) -) +ts.Setup.CopyAs('rules/graceful_shutdown.conf', Test.RunDirectory) + +ts.Disk.remap_config.AddLines([ + 'map /post http://127.0.0.1:{0}/post'.format(microserver.Variables.Port), + 'map /httpbin/ http://127.0.0.1:{0}/ @plugin=header_rewrite.so @pparam={1}/graceful_shutdown.conf'.format( + httpbin.Variables.Port, Test.RunDirectory) +]) ts.Disk.ssl_multicert_config.AddLine( 'dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key' @@ -65,18 +71,18 @@ ts.Disk.records_config.update({ 'proxy.config.diags.debug.enabled': 1, - 'proxy.config.diags.debug.tags': 'http', + 'proxy.config.diags.debug.tags': 'http2_cs', '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.http2.active_timeout_in': 3, + 'proxy.config.ssl.server.private_key.path': '{0}'.format(ts.Variables.SSLDir) }) # ---- # Test Cases # ---- -# Test Case 0: Trailer +# Test Case 0: Trailer tr = Test.AddTestRun() +tr.TimeOut = 10 tr.Processes.Default.Command = "nghttp -v --no-dep 'https://127.0.0.1:{0}/post' --trailer 'foo: bar' -d 'post_body'".format( ts.Variables.ssl_port) tr.Processes.Default.ReturnCode = 0 @@ -84,3 +90,18 @@ tr.Processes.Default.StartBefore(Test.Processes.ts) tr.Processes.Default.Streams.stdout = "gold/nghttp_0_stdout.gold" tr.StillRunningAfter = microserver +tr.StillRunningAfter = ts + +# Test Case 1: Graceful Shutdown +# - This test takes 3 seconds to make sure receiving 2 GOAWAY frames +# - TODO: add a test case of a client keeps the connection open ( -e.g. keep sending PING frame) +tr = Test.AddTestRun() +tr.TimeOut = 10 +tr.Processes.Default.Command = f"nghttp -vn --no-dep 'https://127.0.0.1:{ts.Variables.ssl_port}/httpbin/drip?duration=3'" +tr.Processes.Default.ReturnCode = 0 +tr.Processes.Default.StartBefore(httpbin, ready=When.PortOpen(httpbin.Variables.Port)) +tr.Processes.Default.Streams.stdout = "gold/nghttp_1_stdout.gold" +tr.StillRunningAfter = httpbin +tr.StillRunningAfter = ts + +ts.Streams.stderr = "gold/nghttp_ts_stderr.gold" diff --git a/tests/gold_tests/h2/rules/graceful_shutdown.conf b/tests/gold_tests/h2/rules/graceful_shutdown.conf new file mode 100644 index 00000000000..278dc04d9db --- /dev/null +++ b/tests/gold_tests/h2/rules/graceful_shutdown.conf @@ -0,0 +1,19 @@ +# +# 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. + +cond %{SEND_RESPONSE_HDR_HOOK} + set-header Connection "close"