Skip to content

Commit 05f50f4

Browse files
author
Serris Lew
committed
Run autests with curl UDS default
1 parent 35735bd commit 05f50f4

File tree

120 files changed

+4479
-87
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+4479
-87
lines changed

CMakePresets.json

+12
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@
6161
"ENABLE_EXAMPLE": "ON"
6262
}
6363
},
64+
{
65+
"name": "autest-uds",
66+
"inherits": ["default"],
67+
"binaryDir": "${sourceDir}/build-autest",
68+
"cacheVariables": {
69+
"ENABLE_AUTEST": "ON",
70+
"ENABLE_AUTEST_UDS": "ON",
71+
"CMAKE_INSTALL_PREFIX": "/tmp/ts-autest",
72+
"BUILD_EXPERIMENTAL_PLUGINS": "ON",
73+
"ENABLE_EXAMPLE": "ON"
74+
}
75+
},
6476
{
6577
"name": "dev",
6678
"displayName": "development",

tests/CMakeLists.txt

+35-16
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,53 @@ function(ADD_AUTEST_PLUGIN _NAME)
3636
endfunction()
3737

3838
add_subdirectory(tools/plugins)
39-
add_subdirectory(gold_tests/chunked_encoding)
40-
add_subdirectory(gold_tests/continuations/plugins)
41-
add_subdirectory(gold_tests/jsonrpc/plugins)
42-
add_subdirectory(gold_tests/pluginTest/polite_hook_wait)
43-
add_subdirectory(gold_tests/pluginTest/tsapi)
44-
add_subdirectory(gold_tests/pluginTest/TSVConnFd)
45-
add_subdirectory(gold_tests/timeout)
46-
add_subdirectory(gold_tests/tls)
47-
4839
set(RUNPIPENV PIPENV_VENV_IN_PROJECT=True ${PipEnv})
4940

50-
configure_file(Pipfile Pipfile COPYONLY)
51-
configure_file(autest.sh.in autest.sh)
52-
41+
set(CMAKE_GOLD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gold_tests_filtered")
5342
set(CURL_UDS_FLAG "")
5443
if(ENABLE_AUTEST_UDS)
5544
set(CURL_UDS_FLAG "--curl-uds")
45+
# Copy everything except dirs: h2, tls
46+
# Other specific tests will be skipped
47+
file(
48+
COPY ${CMAKE_CURRENT_SOURCE_DIR}/gold_tests/
49+
DESTINATION ${CMAKE_GOLD_DIR}
50+
FILES_MATCHING
51+
PATTERN "*"
52+
PATTERN "h2" EXCLUDE
53+
PATTERN "tls*" EXCLUDE
54+
)
55+
else()
56+
# Copy everything except autest_uds tests that are only for curl uds option
57+
file(
58+
COPY ${CMAKE_CURRENT_SOURCE_DIR}/gold_tests/
59+
DESTINATION ${CMAKE_GOLD_DIR}
60+
FILES_MATCHING
61+
PATTERN "*"
62+
PATTERN "*_uds.test.py" EXCLUDE
63+
)
64+
add_subdirectory(gold_tests_filtered/tls)
5665
endif()
5766

67+
add_subdirectory(gold_tests_filtered/chunked_encoding)
68+
add_subdirectory(gold_tests_filtered/continuations/plugins)
69+
add_subdirectory(gold_tests_filtered/jsonrpc/plugins)
70+
add_subdirectory(gold_tests_filtered/pluginTest/polite_hook_wait)
71+
add_subdirectory(gold_tests_filtered/pluginTest/tsapi)
72+
add_subdirectory(gold_tests_filtered/pluginTest/TSVConnFd)
73+
add_subdirectory(gold_tests_filtered/timeout)
74+
75+
configure_file(Pipfile Pipfile COPYONLY)
76+
configure_file(autest.sh.in autest.sh)
77+
5878
add_custom_target(
5979
autest
6080
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install
6181
COMMAND ${RUNPIPENV} install
6282
COMMAND
63-
${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/gold_tests/remap:$ENV{PYTHONPATH} ${RUNPIPENV} run
64-
env autest --directory ${CMAKE_CURRENT_SOURCE_DIR}/gold_tests --ats-bin=${CMAKE_INSTALL_PREFIX}/bin
65-
--proxy-verifier-bin ${PROXY_VERIFIER_PATH} --build-root ${CMAKE_BINARY_DIR} --sandbox ${AUTEST_SANDBOX}
66-
${CURL_UDS_FLAG} ${AUTEST_OPTIONS}
83+
${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_GOLD_DIR}/remap:$ENV{PYTHONPATH} ${RUNPIPENV} run env autest --directory
84+
${CMAKE_GOLD_DIR} --ats-bin=${CMAKE_INSTALL_PREFIX}/bin --proxy-verifier-bin ${PROXY_VERIFIER_PATH} --build-root
85+
${CMAKE_BINARY_DIR} --sandbox ${AUTEST_SANDBOX} ${CURL_UDS_FLAG} ${AUTEST_OPTIONS}
6786
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
6887
USES_TERMINAL
6988
)

tests/autest.sh.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/gold_tests/remap:$PYTHONPATH
99

1010
${RUNPIPENV} run env autest \
1111
--sandbox ${AUTEST_SANDBOX} \
12-
--directory ${CMAKE_CURRENT_SOURCE_DIR}/gold_tests \
12+
--directory ${CMAKE_GOLD_DIR} \
1313
--ats-bin=${CMAKE_INSTALL_PREFIX}/bin \
1414
--proxy-verifier-bin ${PROXY_VERIFIER_PATH} \
1515
--build-root ${CMAKE_BINARY_DIR} \

tests/gold_tests/autest-site/conditions.test.ext

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ def PluginExists(self, pluginname):
110110
return self.Condition(lambda: os.path.isfile(path), path + " not found.")
111111

112112

113+
def CurlUds(self):
114+
return self.Condition(lambda: self.Variables.get("CurlUds", False), "Curl using UDS. Not relevant for test")
115+
116+
113117
ExtendCondition(HasOpenSSLVersion)
114118
ExtendCondition(HasProxyVerifierVersion)
115119
ExtendCondition(IsBoringSSL)
@@ -119,3 +123,4 @@ ExtendCondition(HasCurlVersion)
119123
ExtendCondition(HasCurlFeature)
120124
ExtendCondition(HasCurlOption)
121125
ExtendCondition(PluginExists)
126+
ExtendCondition(CurlUds)

tests/gold_tests/autest-site/curl.test.ext

+6-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ def spawn_curl_commands(self, cmdstr, count, retcode=0, use_default=True):
3434
ret = []
3535

3636
if self.Variables.get("CurlUds", False):
37-
cmdstr = 'curl --unix-socket /tmp/socket ' + cmdstr
37+
uds_path = os.path.join(self.Processes.Default.RunDirectory, 'uds.socket')
38+
cmdstr = f'curl --unix-socket {uds_path} ' + cmdstr
3839
else:
3940
cmdstr = 'curl ' + cmdstr
4041
if use_default:
@@ -48,11 +49,12 @@ def spawn_curl_commands(self, cmdstr, count, retcode=0, use_default=True):
4849
return ret
4950

5051

51-
def curl_command(self, cmd, p=None):
52+
def curl_command(self, cmd, uds_suffix="", p=None):
5253
if p == None:
5354
p = self.Processes.Default
5455
if self.Variables.get("CurlUds", False):
5556
uds_path = os.path.join(p.RunDirectory, 'uds.socket')
57+
uds_path += uds_suffix
5658
p.Command = f'curl --unix-socket {uds_path} ' + cmd
5759
else:
5860
p.Command = 'curl ' + cmd
@@ -63,9 +65,9 @@ def curl_multiple_commands(self, cmd):
6365
p = self.Processes.Default
6466
if self.Variables.get("CurlUds", False):
6567
uds_path = os.path.join(p.RunDirectory, 'uds.socket')
66-
p.Command = cmd.format(curl=f'curl --unix-socket {uds_path}')
68+
p.Command = cmd.format(curl=f'curl --unix-socket {uds_path}', curl_base='curl')
6769
else:
68-
p.Command = cmd.format(curl='curl')
70+
p.Command = cmd.format(curl='curl', curl_base='curl')
6971
return p
7072

7173

tests/gold_tests/autest-site/setup.cli.ext

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Variables.VerifierBinPath = ENV['VERIFIER_BIN']
116116
Variables.BuildRoot = ENV['BUILD_ROOT']
117117
Variables.RepoDir = repo_root
118118
Variables.AtsTestPluginsDir = os.path.join(Variables.BuildRoot, 'tests', 'tools', 'plugins', '.libs')
119-
Variables.AtsBuildGoldTestsDir = os.path.join(Variables.BuildRoot, 'tests', 'gold_tests')
119+
Variables.AtsBuildGoldTestsDir = os.path.join(Variables.BuildRoot, 'tests', 'gold_tests_filtered')
120120
Variables.CurlUds = Arguments.curl_uds
121121

122122
# modify delay times as we always have to kill Trafficserver

tests/gold_tests/autest-site/trafficserver.test.ext

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def MakeATSProcess(
5353
enable_cache=True,
5454
enable_quic=False,
5555
enable_uds=True,
56+
uds_path_suffix='',
5657
block_for_debug=False,
5758
log_data=default_log_data,
5859
use_traffic_out=True,
@@ -369,6 +370,7 @@ def MakeATSProcess(
369370

370371
# unix domain socket path
371372
uds_path = os.path.join(obj.RunDirectory, 'uds.socket')
373+
uds_path += uds_path_suffix # to allow multiple sockets in one test file
372374
p.Variables.uds_path = uds_path
373375

374376
get_port(p, "manager_port")

tests/gold_tests/basic/config.test.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@
1515
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1616
# See the License for the specific language governing permissions and
1717
# limitations under the License.
18+
import os
1819

1920
Test.Summary = "Test start up of Traffic server with configuration modification of starting port"
2021

2122
ts = Test.MakeATSProcess("ts", select_ports=False)
2223
ts.Variables.port = 8090
24+
uds_path = os.path.join(Test.RunDirectory, 'uds.socket')
2325
ts.Disk.records_config.update({
24-
'proxy.config.http.server_ports': str(ts.Variables.port),
26+
'proxy.config.http.server_ports': str(ts.Variables.port) + f" {uds_path}",
2527
})
2628
ts.Ready = When.PortOpen(ts.Variables.port)
2729
t = Test.AddTestRun("Test traffic server started properly")

tests/gold_tests/basic/copy_config.test.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# limitations under the License.
1818

1919
Test.Summary = "Test start up of Traffic server with configuration modification of starting port of different servers at the same time"
20+
Test.SkipIf(Condition.CurlUds())
2021

2122
# set up some ATS processes
2223
ts1 = Test.MakeATSProcess("ts1", select_ports=False)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
'''
2+
'''
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
import os
19+
20+
Test.Summary = "Test start up of Traffic server with configuration modification of starting port of different servers at the same time"
21+
22+
# set up some ATS processes
23+
ts1 = Test.MakeATSProcess("ts1", select_ports=False)
24+
ts1.Variables.port = 8090
25+
uds_path = os.path.join(Test.RunDirectory, 'uds.socket')
26+
ts1.Disk.records_config.update({
27+
'proxy.config.http.server_ports': str(ts1.Variables.port) + f" {uds_path}",
28+
})
29+
ts1.Ready = When.PortOpen(ts1.Variables.port)
30+
31+
ts2 = Test.MakeATSProcess("ts2", select_ports=False)
32+
ts2.Variables.port = 8091
33+
ts2.Disk.records_config.update({
34+
'proxy.config.http.server_ports': str(ts2.Variables.port),
35+
})
36+
ts2.Ready = When.PortOpen(ts2.Variables.port)
37+
38+
# setup a testrun
39+
t = Test.AddTestRun("Talk to ts1")
40+
t.Processes.Default.StartBefore(ts1)
41+
t.Processes.Default.StartBefore(ts2)
42+
t.MakeCurlCommand("127.0.0.1:{port}".format(port=ts1.Variables.port))
43+
t.ReturnCode = 0
44+
t.StillRunningAfter = ts1
45+
t.StillRunningAfter += ts2

tests/gold_tests/bigobj/bigobj.test.py

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Test.Summary = '''
2020
Test PUSHing an object into the cache and the GETting it with a few variations on the client connection protocol.
2121
'''
22+
Test.SkipIf(Condition.CurlUds())
2223

2324
# NOTE: You can also use this to test client-side communication when GET-ing very large (multi-GB) objects
2425
# by increasing the value of the obj_kilobytes variable below. (But do not increase it on any shared branch
+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import os
18+
19+
Test.Summary = '''
20+
Test PUSHing an object into the cache and the GETting it with a few variations on the client connection protocol.
21+
'''
22+
23+
# NOTE: You can also use this to test client-side communication when GET-ing very large (multi-GB) objects
24+
# by increasing the value of the obj_kilobytes variable below. (But do not increase it on any shared branch
25+
# that we do CI runs on.)
26+
27+
Test.SkipUnless(Condition.HasCurlFeature('http2'))
28+
29+
ts = Test.MakeATSProcess("ts1", enable_tls=True)
30+
ts.addDefaultSSLFiles()
31+
32+
ts.Disk.records_config.update(
33+
{
34+
'proxy.config.diags.debug.enabled': 1,
35+
'proxy.config.diags.debug.tags': 'http|dns|cache',
36+
'proxy.config.http.cache.required_headers': 0, # No required headers for caching
37+
'proxy.config.http.push_method_enabled': 1,
38+
'proxy.config.proxy_name': 'Poxy_Proxy', # This will be the server name.
39+
'proxy.config.ssl.server.cert.path': ts.Variables.SSLDir,
40+
'proxy.config.ssl.server.private_key.path': ts.Variables.SSLDir,
41+
'proxy.config.url_remap.remap_required': 0
42+
})
43+
44+
ts.Disk.ssl_multicert_config.AddLine('dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key')
45+
46+
ts.Disk.remap_config.AddLine(f'map https://localhost:{ts.Variables.ssl_port} http://localhost:{ts.Variables.port}')
47+
ts.Disk.remap_config.AddLine(f'map https://localhost:{ts.Variables.ssl_portv6} http://localhost:{ts.Variables.port}')
48+
49+
# Size of object to get. (NOTE: If you increase this significantly you may also have to increase cache
50+
# capacity in tests/gold_tests/autest-size/min_cfg/storage.config. Also, for very large objects, if
51+
# proxy.config.diags.debug.enabled is 1, the PUSH request will timeout and fail.)
52+
#
53+
obj_kilobytes = 10 * 1024
54+
obj_bytes = obj_kilobytes * 10
55+
header = "HTTP/1.1 200 OK\r\nContent-length: {}\r\n\r\n".format(obj_bytes)
56+
57+
58+
def create_pushfile():
59+
f = open(Test.RunDirectory + "/objfile", "w")
60+
f.write(header)
61+
f.write("x" * obj_bytes)
62+
f.close()
63+
return True
64+
65+
66+
tr = Test.AddTestRun("PUSH an object to the cache")
67+
# Delay on readiness of TS IPv4 ssl port
68+
tr.Processes.Default.StartBefore(ts, ready=lambda: create_pushfile())
69+
# Put object with URL http://localhost/bigobj in cache using PUSH request.
70+
tr.MakeCurlCommand(
71+
"-v -H 'Content-Type: application/octet-stream' --data-binary @{}/objfile -X PUSH http://localhost:{}/bigobj -H 'Content-Length:{}'"
72+
.format(Test.RunDirectory, ts.Variables.port,
73+
len(header) + obj_bytes))
74+
tr.Processes.Default.ReturnCode = 0
75+
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/1.1 201 Created", "The PUSH request should have succeeded")
76+
77+
tr = Test.AddTestRun("GET bigobj: cleartext, HTTP/1.1, IPv4")
78+
tr.MakeCurlCommand(f'--verbose --http1.1 http://localhost:{ts.Variables.port}/bigobj')
79+
tr.Processes.Default.ReturnCode = 0
80+
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/1.1 200 OK", "Should fetch pushed object")
81+
tr.Processes.Default.Streams.All = Testers.ContainsExpression("Content-length: 102400", "Content size should be accurate")
82+
83+
# Verify that PUSH requests are rejected when push_method_enabled is 0 (the
84+
# default configuration).
85+
ts = Test.MakeATSProcess("ts2", enable_tls=True)
86+
ts.addDefaultSSLFiles()
87+
88+
ts.Disk.records_config.update(
89+
{
90+
'proxy.config.diags.debug.enabled': 1,
91+
'proxy.config.diags.debug.tags': 'http|dns|cache',
92+
'proxy.config.http.cache.required_headers': 0, # No required headers for caching
93+
'proxy.config.proxy_name': 'Poxy_Proxy', # This will be the server name.
94+
'proxy.config.ssl.server.cert.path': ts.Variables.SSLDir,
95+
'proxy.config.ssl.server.private_key.path': ts.Variables.SSLDir,
96+
'proxy.config.url_remap.remap_required': 0
97+
})
98+
99+
ts.Disk.ssl_multicert_config.AddLine('dest_ip=* ssl_cert_name=server.pem ssl_key_name=server.key')
100+
101+
ts.Disk.remap_config.AddLine(f'map https://localhost:{ts.Variables.ssl_port} http://localhost:{ts.Variables.port}')
102+
ts.Disk.remap_config.AddLine(f'map https://localhost:{ts.Variables.ssl_portv6} http://localhost:{ts.Variables.port}')
103+
104+
tr = Test.AddTestRun("PUSH request is rejected when push_method_enabled is 0")
105+
tr.Processes.Default.StartBefore(ts)
106+
tr.MakeCurlCommand(
107+
"-v -H 'Content-Type: application/octet-stream' --data-binary @{}/objfile -X PUSH http://localhost:{}/bigobj -H 'Content-Length:{}'"
108+
.format(Test.RunDirectory, ts.Variables.port,
109+
len(header) + obj_bytes))
110+
tr.Processes.Default.ReturnCode = 0
111+
tr.Processes.Default.Streams.All = Testers.ContainsExpression(
112+
"403 Access Denied", "The PUSH request should have received a 403 response.")

tests/gold_tests/cache/background_fill.test.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
Test.Summary = 'Exercise Background Fill'
2222
Test.SkipUnless(Condition.HasCurlFeature('http2'), Condition.HasProxyVerifierVersion('2.8.0'))
23+
Test.SkipIf(Condition.CurlUds())
2324
Test.ContinueOnFail = True
2425

2526

0 commit comments

Comments
 (0)