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 53d5da0 Update testing extensions
53d5da0 is described below
commit 53d5da0b0a78c3911543bdd88b6e8e610e407316
Author: Unknown <[email protected]>
AuthorDate: Fri Jun 2 17:33:19 2017 -0500
Update testing extensions
add version check for which version of Autest is used
some fixes for the via test
add feature test for ats
Update documentation
add HasAtsFeature API
update via compact
add HasCurlFeature API
---
tests/getting_started.md | 56 ++++++++++++++++++++++
tests/gold_tests/autest-site/conditions.test.ext | 52 ++++++++++++++++++++
tests/gold_tests/autest-site/copy_config.test.ext | 58 +++++++++++++----------
tests/gold_tests/autest-site/init.cli.ext | 20 ++++++--
tests/gold_tests/autest-site/setup.cli.ext | 7 ++-
tests/gold_tests/headers/via-compact.test.py | 25 ++--------
tests/gold_tests/headers/via.test.py | 27 ++---------
7 files changed, 170 insertions(+), 75 deletions(-)
diff --git a/tests/getting_started.md b/tests/getting_started.md
index f73bb60..0994da3 100644
--- a/tests/getting_started.md
+++ b/tests/getting_started.md
@@ -193,3 +193,59 @@ ts.Disk.remap_config.AddLine(
'map http://www.example.com
http://127.0.0.1:{0}'.format(server.Variables.Port)
)
```
+## Condition Testing
+### Condition.HasATSFeature(feature)
+ * feature - The feature to test for
+
+ This function test for Traffic server for possible feature it has been
compiled with. Current Features you can test for are:
+ * TS_HAS_LIBZ
+ * TS_HAS_LZMA
+ * TS_HAS_JEMALLOC
+ * TS_HAS_TCMALLOC
+ * TS_HAS_IN6_IS_ADDR_UNSPECIFIED
+ * TS_HAS_BACKTRACE
+ * TS_HAS_PROFILER
+ * TS_USE_FAST_SDK
+ * TS_USE_DIAGS
+ * TS_USE_EPOLL
+ * TS_USE_KQUEUE
+ * TS_USE_PORT
+ * TS_USE_POSIX_CAP
+ * TS_USE_TPROXY
+ * TS_HAS_SO_MARK
+ * TS_HAS_IP_TOS
+ * TS_USE_HWLOC
+ * TS_USE_TLS_NPN
+ * TS_USE_TLS_ALPN
+ * TS_USE_TLS_SNI
+ * TS_USE_CERT_CB
+ * TS_USE_SET_RBIO
+ * TS_USE_TLS_ECKEY
+ * TS_USE_LINUX_NATIVE_AIO
+ * TS_HAS_SO_PEERCRED
+ * TS_USE_REMOTE_UNWINDING
+ * TS_HAS_128BIT_CAS
+ * TS_HAS_TESTS
+ * TS_HAS_WCCP
+ * SPLIT_DNS
+
+### Example
+```python
+#create the origin server process
+Test.SkipUnless(
+ Condition.HasATSFeature('TS_USE_TLS_ALPN'),
+)
+```
+
+### Condition.HasCurlFeature(feature)
+ * feature - The feature to test for
+
+ This function test for Curl for possible feature it has been compiled with.
Consult Curl documenation for feature set.
+
+### Example
+```python
+#create the origin server process
+Test.SkipUnless(
+ Condition.HasCurlFeature('http2'),
+)
+```
diff --git a/tests/gold_tests/autest-site/conditions.test.ext
b/tests/gold_tests/autest-site/conditions.test.ext
new file mode 100644
index 0000000..ff12378
--- /dev/null
+++ b/tests/gold_tests/autest-site/conditions.test.ext
@@ -0,0 +1,52 @@
+'''
+'''
+# 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.
+def HasCurlFeature(self, feature):
+
+ def default(output):
+ FEATURE_TAG = 'Features:'
+ tag = feature.lower()
+ for line in output.splitlines():
+ # look for line with starting with the Features
+ if line.startswith(FEATURE_TAG):
+ # get a features and lower case then for safety
+ line = line[len(FEATURE_TAG):].lower()
+ tokens = line.split()
+ for t in tokens:
+ if t == tag:
+ return True
+ return False
+
+ return self.CheckOutput(
+ ['curl', '--version'],
+ default,
+ "Curl needs to support feature: {feature}".format(feature=feature)
+ )
+
+
+def HasATSFeature(self, feature):
+
+ val = self.Variables.get(feature, None)
+
+ return self.Condition(
+ lambda: val == True,
+ "ATS feature not enabled: {feature}".format(feature=feature)
+ )
+
+
+ExtendCondition(HasATSFeature)
+ExtendCondition(HasCurlFeature)
diff --git a/tests/gold_tests/autest-site/copy_config.test.ext
b/tests/gold_tests/autest-site/copy_config.test.ext
index 2053989..d13e2fb 100644
--- a/tests/gold_tests/autest-site/copy_config.test.ext
+++ b/tests/gold_tests/autest-site/copy_config.test.ext
@@ -17,33 +17,39 @@
# limitations under the License.
import os
-from future.utils import native_str
+from future.utils import native_str
+
class CopyATSConfig(SetupItem):
- def __init__(self, file, targetname=None, process=None):
- super(CopyATSConfig, self).__init__(
- itemname="CopyATSConfig"
- )
- self.file=file
- # some protection
- if process is None and not isinstance(targetname,native_str):
- self.process=targetname
- else:
- self.process=process
- self.targetname=targetname
-
- def setup(self):
-
- process = self.process if self.process else self
- try:
- ts_dir=process.Env['TS_ROOT']
- except:
- if self.process:
- raise SetupError('TS_ROOT is not defined.
Cannot copy ats config file without location to copy to.')
- else:
- raise SetupError('TS_ROOT is not defined.
Cannot copy ats config file without location to copy to. Please pass in an ATS
process object')
- config_dir =
os.path.join(ts_dir,process.ComposeVariables().SYSCONFDIR.replace(process.ComposeVariables().PREFIX+"/",""))
- host.WriteVerbose("CopyATSConfig", "Copying {0} to
{1}".format(self.file, config_dir))
- self.CopyAs(self.file,config_dir,self.targetname)
+ def __init__(self, file, targetname=None, process=None):
+ super(CopyATSConfig, self).__init__(
+ itemname="CopyATSConfig"
+ )
+ self.file = file
+ # some protection
+ if process is None and not isinstance(targetname, native_str):
+ self.process = targetname
+ else:
+ self.process = process
+ self.targetname = targetname
+
+ def setup(self):
+
+ process = self.process if self.process else self
+ try:
+ ts_dir = process.Env['TS_ROOT']
+ except:
+ if self.process:
+ raise SetupError(
+ 'TS_ROOT is not defined. Cannot copy ats config file
without location to copy to.')
+ else:
+ raise SetupError(
+ 'TS_ROOT is not defined. Cannot copy ats config file
without location to copy to. Please pass in an ATS process object')
+ config_dir = os.path.join(ts_dir, process.ComposeVariables(
+ ).SYSCONFDIR.replace(process.ComposeVariables().PREFIX + "/", ""))
+ host.WriteVerbose(
+ "CopyATSConfig", "Copying {0} to {1}".format(self.file,
config_dir))
+ self.CopyAs(self.file, config_dir, self.targetname)
+
AddSetupItem(CopyATSConfig, "CopyConfig", ns="ts")
diff --git a/tests/gold_tests/autest-site/init.cli.ext
b/tests/gold_tests/autest-site/init.cli.ext
index cc3a1a6..3774705 100644
--- a/tests/gold_tests/autest-site/init.cli.ext
+++ b/tests/gold_tests/autest-site/init.cli.ext
@@ -19,9 +19,21 @@
import os
import sys
-if sys.version_info<(3,5,0):
- host.WriteError("You need python 3.5 or later to run these
tests\n",show_stack=False)
+if sys.version_info < (3, 5, 0):
+ host.WriteError(
+ "You need python 3.5 or later to run these tests\n", show_stack=False)
+
+try:
+ AuTestVersion()
+except:
+ host.WriteError(
+ "Tests need AuTest version 1.3.4 or better\n Please update AuTest:\n
pip install --upgrade autest\n", show_stack=False)
+
+if AuTestVersion() < "1.3.4":
+ host.WriteError(
+ "Tests need AuTest version 1.3.4 or better\n Please update AuTest:\n
pip install --upgrade autest\n", show_stack=False)
+
Settings.path_argument(["--ats-bin"],
- required=True,
- help="A user provided directory to ATS bin")
\ No newline at end of file
+ required=True,
+ help="A user provided directory to ATS bin")
diff --git a/tests/gold_tests/autest-site/setup.cli.ext
b/tests/gold_tests/autest-site/setup.cli.ext
index 6f38a87..c5a2284 100644
--- a/tests/gold_tests/autest-site/setup.cli.ext
+++ b/tests/gold_tests/autest-site/setup.cli.ext
@@ -22,8 +22,6 @@ import pprint
if Arguments.ats_bin is not None:
# Add environment variables
ENV['ATS_BIN'] = Arguments.ats_bin
- #if Arguments.ats_bin not in ENV['PATH']:
- #ENV['PATH'] = Arguments.ats_bin + ':' + ENV['PATH']
if ENV['ATS_BIN'] is not None:
# Add variables for Tests
@@ -41,6 +39,11 @@ if ENV['ATS_BIN'] is not None:
out[k]=v[:-1] if v.endswith('/') else v
Variables.update(out)
host.WriteVerbose(['ats'],"Traffic server layout
Data:\n",pprint.pformat(out))
+ # if the above worked this should as well
+ out = subprocess.check_output([traffic_layout, "-f", "--json"])
+ out = json.loads(out.decode("utf-8"))
+ Variables.update(out)
+ host.WriteVerbose(['ats'],"Traffic server feature
data:\n",pprint.pformat(out))
Variables.AtsTestToolsDir = os.path.join(AutestSitePath,'../../tools')
diff --git a/tests/gold_tests/headers/via-compact.test.py
b/tests/gold_tests/headers/via-compact.test.py
index c448789..e1f134e 100644
--- a/tests/gold_tests/headers/via-compact.test.py
+++ b/tests/gold_tests/headers/via-compact.test.py
@@ -25,28 +25,11 @@ Test.Summary = '''
Check VIA header for protocol stack data.
'''
-# Check if the local curl has a specific feature.
-# This should be made generally available.
-def RequireCurlFeature(tag):
- FEATURE_TAG = 'Features:'
- tag = tag.lower()
- try:
- text = subprocess.check_output(['curl', '--version'], universal_newlines =
True)
- for line in text.splitlines():
- if (line.startswith(FEATURE_TAG)):
- line = line[len(FEATURE_TAG):].lower()
- tokens = line.split()
- for t in tokens:
- if t == tag:
- return True
- except subprocess.CalledProcessError:
- pass # no curl at all, it clearly doesn't have the required feature.
- return False
-
Test.SkipUnless(
- Condition.Condition(lambda : RequireCurlFeature('http2'), "Via test
requires a curl that supports HTTP/2"),
- Condition.Condition(lambda : RequireCurlFeature('IPv6'), "Via test
requires a curl that supports IPv6")
- )
+ Condition.HasATSFeature('TS_USE_TLS_ALPN'),
+ Condition.HasCurlFeature('http2'),
+ Condition.HasCurlFeature('IPv6')
+)
Test.ContinueOnFail=True
# Define default ATS
diff --git a/tests/gold_tests/headers/via.test.py
b/tests/gold_tests/headers/via.test.py
index 00eef1f..f2b75e6 100644
--- a/tests/gold_tests/headers/via.test.py
+++ b/tests/gold_tests/headers/via.test.py
@@ -25,28 +25,11 @@ Test.Summary = '''
Check VIA header for protocol stack data.
'''
-# Check if the local curl has a specific feature.
-# This should be made generally available.
-def RequireCurlFeature(tag):
- FEATURE_TAG = 'Features:'
- tag = tag.lower()
- try:
- text = subprocess.check_output(['curl', '--version'], universal_newlines =
True)
- for line in text.splitlines():
- if (line.startswith(FEATURE_TAG)):
- line = line[len(FEATURE_TAG):].lower()
- tokens = line.split()
- for t in tokens:
- if t == tag:
- return True
- except subprocess.CalledProcessError:
- pass # no curl at all, it clearly doesn't have the required feature.
- return False
-
Test.SkipUnless(
- Condition.Condition(lambda : RequireCurlFeature('http2'), "Via test
requires a curl that supports HTTP/2"),
- Condition.Condition(lambda : RequireCurlFeature('IPv6'), "Via test
requires a curl that supports IPv6")
- )
+ Condition.HasATSFeature('TS_USE_TLS_ALPN'),
+ Condition.HasCurlFeature('http2'),
+ Condition.HasCurlFeature('IPv6')
+)
Test.ContinueOnFail=True
# Define default ATS
@@ -142,4 +125,4 @@ tr.Processes.Default.Command='curl --verbose --ipv6
--http1.1 --insecure --heade
tr.Processes.Default.ReturnCode=0
tr.StillRunningAfter=server
-tr.StillRunningAfter=ts
+tr.StillRunningAfter=ts
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].