trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dra...@apache.org
Subject [trafficserver] branch master updated: Remove use of netstat in tests
Date Fri, 05 Jan 2018 15:38:01 GMT
This is an automated email from the ASF dual-hosted git repository.

dragon 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 87a873c  Remove use of netstat in tests
87a873c is described below

commit 87a873cbd820634a75c4a6ccece1753d35660bde
Author: Jason Kenny <dragon512@live.com>
AuthorDate: Thu Jan 4 17:18:18 2018 -0600

    Remove use of netstat in tests
    
    update autest to 1.4.2 as this has fix for portopen to be like netstat, but portable
    Add to traffic_layout the reporting of brotli as a feature
    update tests to test for brotli
    change test to use dynamic ports
---
 cmd/traffic_layout/info.cc                         |  5 +++++
 tests/gold_tests/autest-site/init.cli.ext          |  2 +-
 tests/gold_tests/headers/forwarded.test.py         | 15 +++------------
 tests/gold_tests/headers/normalize_ae.test.py      | 22 ++++++----------------
 tests/gold_tests/headers/via.test.py               | 14 +++-----------
 tests/gold_tests/logging/ccid_ctid.test.py         | 13 ++-----------
 tests/gold_tests/pluginTest/gzip/gzip.test.py      | 18 +++++++++---------
 .../gold_tests/pluginTest/url_sig/url_sig.test.py  | 14 ++++----------
 8 files changed, 33 insertions(+), 70 deletions(-)

diff --git a/cmd/traffic_layout/info.cc b/cmd/traffic_layout/info.cc
index 7f45541..eeca485 100644
--- a/cmd/traffic_layout/info.cc
+++ b/cmd/traffic_layout/info.cc
@@ -68,6 +68,11 @@ produce_features(bool json)
 #else
   print_feature("TS_HAS_LZMA", 0, json);
 #endif
+#ifdef HAVE_BROTLI_ENCODE_H
+  print_feature("TS_HAS_BROTLI", 1, json);
+#else
+  print_feature("TS_HAS_BROTLI", 0, json);
+#endif
   print_feature("TS_HAS_JEMALLOC", TS_HAS_JEMALLOC, json);
   print_feature("TS_HAS_TCMALLOC", TS_HAS_TCMALLOC, json);
   print_feature("TS_HAS_IN6_IS_ADDR_UNSPECIFIED", TS_HAS_IN6_IS_ADDR_UNSPECIFIED, json);
diff --git a/tests/gold_tests/autest-site/init.cli.ext b/tests/gold_tests/autest-site/init.cli.ext
index 633171c..903f12f 100644
--- a/tests/gold_tests/autest-site/init.cli.ext
+++ b/tests/gold_tests/autest-site/init.cli.ext
@@ -23,7 +23,7 @@ if sys.version_info < (3, 5, 0):
     host.WriteError(
         "You need python 3.5 or later to run these tests\n", show_stack=False)
 
-autest_version ="1.4.1"
+autest_version ="1.4.2"
 if AuTestVersion() < autest_version:
     host.WriteError(
         "Tests need AuTest version {ver} or better\n Please update AuTest:\n  pip install
--upgrade autest\n".format(ver=autest_version), show_stack=False)
diff --git a/tests/gold_tests/headers/forwarded.test.py b/tests/gold_tests/headers/forwarded.test.py
index e03f190..e5854f2 100644
--- a/tests/gold_tests/headers/forwarded.test.py
+++ b/tests/gold_tests/headers/forwarded.test.py
@@ -28,7 +28,6 @@ Test.SkipUnless(
     Condition.HasATSFeature('TS_USE_TLS_ALPN'),
     Condition.HasCurlFeature('http2'),
     Condition.HasCurlFeature('IPv6'),
-    Condition.HasProgram("netstat", "netstat need to be installed on system for this test
to work")
 )
 Test.ContinueOnFail = True
 
@@ -157,20 +156,12 @@ ts.Disk.remap_config.AddLine(
     ' @plugin=conf_remap.so @pparam=proxy.config.http.insert_forwarded=connection=full'
 )
 
-# Ask the OS if the port is ready for connect()
-#
-
-
-def CheckPort(Port):
-    return lambda: 0 == subprocess.call('netstat --listen --tcp -n | grep -q :{}'.format(Port),
shell=True)
-
-
 # Basic HTTP 1.1 -- No Forwarded by default
 tr = Test.AddTestRun()
 # Wait for the micro server
-tr.Processes.Default.StartBefore(server, ready=CheckPort(server.Variables.Port))
+tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port))
 # Delay on readiness of our ssl ports
-tr.Processes.Default.StartBefore(Test.Processes.ts, ready=CheckPort(ts.Variables.ssl_port))
+tr.Processes.Default.StartBefore(Test.Processes.ts, ready=When.PortOpen(ts.Variables.ssl_port))
 #
 tr.Processes.Default.Command = (
     'curl --verbose --ipv4 --http1.1 --proxy localhost:{} http://www.no-oride.com'.format(ts.Variables.port)
@@ -225,7 +216,7 @@ ts2.Disk.remap_config.AddLine(
 # Forwarded header with UUID of 2nd ATS.
 tr = Test.AddTestRun()
 # Delay on readiness of our ssl ports
-tr.Processes.Default.StartBefore(Test.Processes.ts2, ready=CheckPort(ts2.Variables.ssl_port))
+tr.Processes.Default.StartBefore(Test.Processes.ts2, ready=When.PortOpen(ts2.Variables.ssl_port))
 #
 tr.Processes.Default.Command = (
     'curl --verbose --ipv4 --http1.1 --proxy localhost:{} http://www.no-oride.com'.format(ts2.Variables.port)
diff --git a/tests/gold_tests/headers/normalize_ae.test.py b/tests/gold_tests/headers/normalize_ae.test.py
index 64c689c..f5f3e85 100644
--- a/tests/gold_tests/headers/normalize_ae.test.py
+++ b/tests/gold_tests/headers/normalize_ae.test.py
@@ -25,9 +25,8 @@ Test normalizations of the Accept-Encoding header field.
 '''
 
 Test.SkipUnless(
-    Condition.HasProgram(
-        "curl", "Curl need to be installed on system for this test to work"),
-    Condition.HasProgram("netstat", "netstat need to be installed on system for this test
to work")
+    Condition.HasProgram("curl", "Curl need to be installed on system for this test to work"),
+    Condition.HasATSFeature('TS_HAS_BROTLI')
 )
 
 Test.ContinueOnFail = True
@@ -47,7 +46,7 @@ request_header = {"headers": "GET / HTTP/1.1\r\nHost: www.ae-2.com\r\n\r\n",
"ti
 server.addResponse("sessionlog.json", request_header, response_header)
 
 # Define first ATS
-ts = Test.MakeATSProcess("ts", select_ports=False)
+ts = Test.MakeATSProcess("ts")
 
 
 def baselineTsSetup(ts):
@@ -82,13 +81,6 @@ baselineTsSetup(ts)
 normalize_ae_log_id = Test.Disk.File("normalize_ae.log")
 normalize_ae_log_id.Content = "normalize_ae.gold"
 
-# ask the os if the port is ready for connect()
-#
-
-
-def CheckPort(port):
-    return lambda: 0 == subprocess.call('netstat --listen --tcp -n | grep -q :{}'.format(port),
shell=True)
-
 # Try various Accept-Encoding header fields for a particular traffic server and host.
 
 
@@ -98,12 +90,12 @@ def allAEHdrs(shouldWaitForUServer, shouldWaitForTs, ts, host):
 
     if shouldWaitForUServer:
         # wait for the micro server
-        tr.Processes.Default.StartBefore(server, ready=CheckPort(server.Variables.Port))
+        tr.Processes.Default.StartBefore(server)
 
     if shouldWaitForTs:
         # wait for the micro server
         # delay on readiness of port
-        tr.Processes.Default.StartBefore(ts, ready=CheckPort(ts.Variables.port))
+        tr.Processes.Default.StartBefore(ts)
 
     baseCurl = 'curl --verbose --ipv4 --http1.1 --proxy localhost:{} '.format(ts.Variables.port)
 
@@ -146,9 +138,7 @@ def perTsTest(shouldWaitForUServer, ts):
 perTsTest(True, ts)
 
 # Define second ATS
-ts2 = Test.MakeATSProcess("ts2", select_ports=False)
-
-ts2.Variables.port += 1
+ts2 = Test.MakeATSProcess("ts2")
 
 baselineTsSetup(ts2)
 
diff --git a/tests/gold_tests/headers/via.test.py b/tests/gold_tests/headers/via.test.py
index 76bd547..9746cde 100644
--- a/tests/gold_tests/headers/via.test.py
+++ b/tests/gold_tests/headers/via.test.py
@@ -28,8 +28,7 @@ Check VIA header for protocol stack data.
 Test.SkipUnless(
     Condition.HasATSFeature('TS_USE_TLS_ALPN'),
     Condition.HasCurlFeature('http2'),
-    Condition.HasCurlFeature('IPv6'),
-    Condition.HasProgram("netstat", "netstat need to be installed on system for this test
to work")
+    Condition.HasCurlFeature('IPv6')
 )
 Test.ContinueOnFail = True
 
@@ -72,19 +71,12 @@ ts.Disk.ssl_multicert_config.AddLine(
 via_log_id = Test.Disk.File("via.log")
 via_log_id.Content = "via.gold"
 
-# Ask the OS if the port is ready for connect()
-
-
-def CheckPort(Port):
-    return lambda: 0 == subprocess.call('netstat --listen --tcp -n | grep -q :{}'.format(Port),
shell=True)
-
-
 # Basic HTTP 1.1
 tr = Test.AddTestRun()
 # Wait for the micro server
-tr.Processes.Default.StartBefore(server, ready=CheckPort(server.Variables.Port))
+tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port))
 # Delay on readiness of our ssl ports
-tr.Processes.Default.StartBefore(Test.Processes.ts, ready=CheckPort(ts.Variables.ssl_port))
+tr.Processes.Default.StartBefore(Test.Processes.ts, ready=When.PortOpen(ts.Variables.ssl_port))
 
 tr.Processes.Default.Command = 'curl --verbose --ipv4 --http1.1 --proxy localhost:{} http://www.example.com'.format(
     ts.Variables.port)
diff --git a/tests/gold_tests/logging/ccid_ctid.test.py b/tests/gold_tests/logging/ccid_ctid.test.py
index 5236313..b990891 100644
--- a/tests/gold_tests/logging/ccid_ctid.test.py
+++ b/tests/gold_tests/logging/ccid_ctid.test.py
@@ -28,8 +28,7 @@ Test.SkipUnless(
         "curl", "Curl need to be installed on system for this test to work"),
     # Condition.IsPlatform("linux"), Don't see the need for this.
     Condition.HasATSFeature('TS_USE_TLS_ALPN'),
-    Condition.HasCurlFeature('http2'),
-    Condition.HasProgram("netstat", "netstat need to be installed on system for this test
to work")
+    Condition.HasCurlFeature('http2')
 )
 
 # Define default ATS.  "select_ports=False" needed because SSL port used.
@@ -70,17 +69,9 @@ log.ascii {
 }'''.split("\n")
 )
 
-# Ask the OS if the port is ready for connect()
-#
-
-
-def CheckPort(Port):
-    return lambda: 0 == subprocess.call('netstat --listen --tcp -n | grep -q :{}'.format(Port),
shell=True)
-
-
 tr = Test.AddTestRun()
 # Delay on readiness of ssl port
-tr.Processes.Default.StartBefore(Test.Processes.ts, ready=CheckPort(ts.Variables.ssl_port))
+tr.Processes.Default.StartBefore(Test.Processes.ts, ready=When.PortOpen(ts.Variables.ssl_port))
 #
 tr.Processes.Default.Command = 'curl "http://127.0.0.1:{0}" --verbose'.format(
     ts.Variables.port)
diff --git a/tests/gold_tests/pluginTest/gzip/gzip.test.py b/tests/gold_tests/pluginTest/gzip/gzip.test.py
index f6aa067..6523db7 100644
--- a/tests/gold_tests/pluginTest/gzip/gzip.test.py
+++ b/tests/gold_tests/pluginTest/gzip/gzip.test.py
@@ -26,9 +26,12 @@ Test gzip plugin
 
 # Skip if plugins not present.
 #
-Test.SkipUnless(Condition.PluginExists('gzip.so'))
-Test.SkipUnless(Condition.PluginExists('conf_remap.so'))
-Test.SkipUnless(Condition.HasProgram("netstat", "netstat need to be installed on system for
this test to work"))
+Test.SkipUnless(
+    Condition.PluginExists('gzip.so'),
+    Condition.PluginExists('conf_remap.so'),
+    Condition.HasATSFeature('TS_HAS_BROTLI')
+)
+
 
 server = Test.MakeOriginServer("server", options={'--load': '{}/gzip_observer.py'.format(Test.TestDirectory)})
 
@@ -50,10 +53,6 @@ for i in range(3):
     }
     server.addResponse("sessionfile.log", request_header, response_header)
 
-# Ask the OS if the port is ready for connect()
-#
-def CheckPort(Port):
-    return lambda: 0 == subprocess.call('netstat --listen --tcp -n | grep -q :{}'.format(Port),
shell=True)
 
 def oneTs(name, AeHdr1='gzip, deflate, sdch, br'):
     global waitForServer
@@ -95,10 +94,10 @@ def oneTs(name, AeHdr1='gzip, deflate, sdch, br'):
 
         tr = Test.AddTestRun()
         if (waitForTs):
-            tr.Processes.Default.StartBefore(ts, ready=CheckPort(ts.Variables.port))
+            tr.Processes.Default.StartBefore(ts, ready=When.PortOpen(ts.Variables.port))
         waitForTs = False
         if (waitForServer):
-            tr.Processes.Default.StartBefore(server, ready=CheckPort(server.Variables.Port))
+            tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port))
         waitForServer = False
         tr.Processes.Default.ReturnCode = 0
         tr.Processes.Default.Command = curl(i, AeHdr1)
@@ -115,6 +114,7 @@ def oneTs(name, AeHdr1='gzip, deflate, sdch, br'):
         tr.Processes.Default.ReturnCode = 0
         tr.Processes.Default.Command = curl(i, "deflate")
 
+
 waitForServer = True
 
 oneTs("ts")
diff --git a/tests/gold_tests/pluginTest/url_sig/url_sig.test.py b/tests/gold_tests/pluginTest/url_sig/url_sig.test.py
index c1a3720..26d92d3 100644
--- a/tests/gold_tests/pluginTest/url_sig/url_sig.test.py
+++ b/tests/gold_tests/pluginTest/url_sig/url_sig.test.py
@@ -24,7 +24,6 @@ Test url_sig plugin
 
 Test.SkipUnless(
     Condition.HasATSFeature('TS_USE_TLS_ALPN'),
-    Condition.HasProgram("netstat", "netstat needs to be installed on system for this test
to work")
 )
 
 # Skip if plugins not present.
@@ -57,8 +56,8 @@ ts.Variables.ssl_port = 4443
 ts.Disk.records_config.update({
     # 'proxy.config.diags.debug.enabled': 1,
     # 'proxy.config.diags.debug.tags': 'http|url_sig',
-    'proxy.config.http.cache.http': 0, # Make sure each request is forwarded to the origin
server.
-    'proxy.config.proxy_name': 'Poxy_Proxy', # This will be the server name.
+    'proxy.config.http.cache.http': 0,  # Make sure each request is forwarded to the origin
server.
+    'proxy.config.proxy_name': 'Poxy_Proxy',  # This will be the server name.
     '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.http.server_ports': (
@@ -98,11 +97,6 @@ ts.Disk.remap_config.AddLine(
     ' @plugin=url_sig.so @pparam={}/url_sig.config @pparam=PristineUrl'.format(Test.TestDirectory)
 )
 
-# Ask the OS if the port is ready for connect()
-#
-def CheckPort(Port):
-    return lambda: 0 == subprocess.call('netstat --listen --tcp -n | grep -q :{}'.format(Port),
shell=True)
-
 # Validation failure tests.
 
 LogTee = " 2>&1 | tee -a {}/url_sig_long.log".format(Test.RunDirectory)
@@ -110,8 +104,8 @@ LogTee = " 2>&1 | tee -a {}/url_sig_long.log".format(Test.RunDirectory)
 # Bad client / MD5 / P=101 / URL pristine / URL altered.
 #
 tr = Test.AddTestRun()
-tr.Processes.Default.StartBefore(ts, ready=CheckPort(ts.Variables.ssl_port))
-tr.Processes.Default.StartBefore(server, ready=CheckPort(server.Variables.Port))
+tr.Processes.Default.StartBefore(ts, ready=When.PortOpen(ts.Variables.ssl_port))
+tr.Processes.Default.StartBefore(server, ready=When.PortOpen(server.Variables.Port))
 tr.Processes.Default.ReturnCode = 0
 tr.Processes.Default.Command = (
     "curl --verbose --proxy http://127.0.0.1:{} 'http://seven.eight.nine/".format(ts.Variables.port)
+

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

Mime
View raw message