You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by sh...@apache.org on 2019/02/06 14:22:59 UTC
[trafficserver] branch master updated: For tls tests look at logs
until config has been reloaded
This is an automated email from the ASF dual-hosted git repository.
shinrich 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 e378980 For tls tests look at logs until config has been reloaded
e378980 is described below
commit e3789807fcedbd83a929fbd834307be992771544
Author: Susan Hinrichs <sh...@oath.com>
AuthorDate: Tue Feb 5 17:14:47 2019 +0000
For tls tests look at logs until config has been reloaded
---
tests/gold_tests/tls/tls_client_cert.test.py | 18 +++++++++++++++++-
tests/gold_tests/tls/tls_tunnel.test.py | 20 ++++++++++++++++++--
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/tests/gold_tests/tls/tls_client_cert.test.py b/tests/gold_tests/tls/tls_client_cert.test.py
index 394b8ab..58bb03e 100644
--- a/tests/gold_tests/tls/tls_client_cert.test.py
+++ b/tests/gold_tests/tls/tls_client_cert.test.py
@@ -18,6 +18,7 @@ Test offering client cert to origin
# limitations under the License.
import os
+import subprocess
import re
Test.Summary = '''
@@ -32,6 +33,7 @@ cafile2 = "{0}/signer2.pem".format(Test.RunDirectory)
# --clientverify: "" empty string because microserver does store_true for argparse, but options is a dictionary
server = Test.MakeOriginServer("server", ssl=True, options = { "--clientCA": cafile, "--clientverify": ""}, clientcert="{0}/signed-foo.pem".format(Test.RunDirectory), clientkey="{0}/signed-foo.key".format(Test.RunDirectory))
server2 = Test.MakeOriginServer("server2", ssl=True, options = { "--clientCA": cafile2, "--clientverify": ""}, clientcert="{0}/signed2-bar.pem".format(Test.RunDirectory), clientkey="{0}/signed-bar.key".format(Test.RunDirectory))
+server3 = Test.MakeOriginServer("server3")
server.Setup.Copy("ssl/signer.pem")
server.Setup.Copy("ssl/signer2.pem")
server.Setup.Copy("ssl/signed-foo.pem")
@@ -171,6 +173,20 @@ tr2.Processes.Default.Command = 'echo Updated configs'
tr2.Processes.Default.Env = ts.Env
tr2.Processes.Default.ReturnCode = 0
+# Parking this as a ready tester on a meaningless process
+# Stall the test runs until the ssl_server_name reload has completed
+# At that point the new ssl_server_name settings are ready to go
+def ssl_server_name_reload_done(tsenv):
+ def done_reload(process, hasRunFor, **kw):
+ cmd = "grep 'ssl_server_name.yaml done reloading!' {0} | wc -l > {1}/test.out".format(ts.Disk.diags_log.Name, Test.RunDirectory)
+ retval = subprocess.run(cmd, shell=True, env=tsenv)
+ if retval.returncode == 0:
+ cmd ="if [ -f {0}/test.out -a \"`cat {0}/test.out`\" = \"2\" ] ; then true; else false; fi".format(Test.RunDirectory)
+ retval = subprocess.run(cmd, shell = True, env=tsenv)
+ return retval.returncode == 0
+
+ return done_reload
+
tr2reload = Test.AddTestRun("Reload config")
tr2reload.StillRunningAfter = ts
tr2reload.StillRunningAfter = server
@@ -184,7 +200,7 @@ tr2reload.Processes.Default.ReturnCode = 0
#Should succeed
tr3bar = Test.AddTestRun("Make request with other bar cert to first server")
# Wait for the reload to complete
-tr3bar.DelayStart = 10
+tr3bar.Processes.Default.StartBefore(server3, ready=ssl_server_name_reload_done(ts.Env))
tr3bar.StillRunningAfter = ts
tr3bar.StillRunningAfter = server
tr3bar.StillRunningAfter = server2
diff --git a/tests/gold_tests/tls/tls_tunnel.test.py b/tests/gold_tests/tls/tls_tunnel.test.py
index 007077b..5f653db 100644
--- a/tests/gold_tests/tls/tls_tunnel.test.py
+++ b/tests/gold_tests/tls/tls_tunnel.test.py
@@ -17,6 +17,7 @@
# limitations under the License.
import os
+import subprocess
Test.Summary = '''
Test tunneling based on SNI
'''
@@ -30,6 +31,7 @@ Test.SkipUnless(
ts = Test.MakeATSProcess("ts", command="traffic_manager", select_ports=False)
server_foo = Test.MakeOriginServer("server_foo", ssl=True)
server_bar = Test.MakeOriginServer("server_bar", ssl=True)
+server2 = Test.MakeOriginServer("server2")
request_foo_header = {"headers": "GET / HTTP/1.1\r\nHost: foo.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
request_bar_header = {"headers": "GET / HTTP/1.1\r\nHost: bar.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
@@ -153,11 +155,25 @@ trreload.Processes.Default.Command = 'traffic_ctl config reload'
trreload.Processes.Default.Env = ts.Env
trreload.Processes.Default.ReturnCode = 0
+# Parking this as a ready tester on a meaningless process
+# Stall the test runs until the ssl_server_name reload has completed
+# At that point the new ssl_server_name settings are ready to go
+def ssl_server_name_reload_done(tsenv):
+ def done_reload(process, hasRunFor, **kw):
+ cmd = "grep 'ssl_server_name.yaml done reloading!' {0} | wc -l > {1}/test.out".format(ts.Disk.diags_log.Name, Test.RunDirectory)
+ retval = subprocess.run(cmd, shell=True, env=tsenv)
+ if retval.returncode == 0:
+ cmd ="if [ -f {0}/test.out -a \"`cat {0}/test.out`\" = \"2\" ] ; then true; else false; fi".format(Test.RunDirectory)
+ retval = subprocess.run(cmd, shell = True, env=tsenv)
+ return retval.returncode == 0
+
+ return done_reload
+
# Should termimate on traffic_server (not tunnel)
tr = Test.AddTestRun("foo.com no Tunnel-test")
tr.StillRunningAfter = ts
-# Wait for the reload to complete
-tr.DelayStart = 5
+# Wait for the reload to complete by running the ssl_server_name_reload_done test
+tr.Processes.Default.StartBefore(server2, ready=ssl_server_name_reload_done(ts.Env))
tr.Processes.Default.Command = "curl -v --resolve 'foo.com:{0}:127.0.0.1' -k https://foo.com:{0}".format(ts.Variables.ssl_port)
tr.Processes.Default.Streams.All += Testers.ContainsExpression("Not Found on Accelerato", "Terminates on on Traffic Server")
tr.Processes.Default.Streams.All += Testers.ContainsExpression("ATS", "Terminate on Traffic Server")