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

Lines changed: 12 additions & 0 deletions
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

Lines changed: 35 additions & 16 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 6 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 1 addition & 0 deletions
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)
Lines changed: 45 additions & 0 deletions
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

0 commit comments

Comments
 (0)