Skip to content

Run autests with curl UDS default #12168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@
"ENABLE_EXAMPLE": "ON"
}
},
{
"name": "autest-uds",
"inherits": ["default"],
"binaryDir": "${sourceDir}/build-autest",
"cacheVariables": {
"ENABLE_AUTEST": "ON",
"ENABLE_AUTEST_UDS": "ON",
"CMAKE_INSTALL_PREFIX": "/tmp/ts-autest",
"BUILD_EXPERIMENTAL_PLUGINS": "ON",
"ENABLE_EXAMPLE": "ON"
}
},
{
"name": "dev",
"displayName": "development",
Expand Down
51 changes: 35 additions & 16 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,53 @@ function(ADD_AUTEST_PLUGIN _NAME)
endfunction()

add_subdirectory(tools/plugins)
add_subdirectory(gold_tests/chunked_encoding)
add_subdirectory(gold_tests/continuations/plugins)
add_subdirectory(gold_tests/jsonrpc/plugins)
add_subdirectory(gold_tests/pluginTest/polite_hook_wait)
add_subdirectory(gold_tests/pluginTest/tsapi)
add_subdirectory(gold_tests/pluginTest/TSVConnFd)
add_subdirectory(gold_tests/timeout)
add_subdirectory(gold_tests/tls)

set(RUNPIPENV PIPENV_VENV_IN_PROJECT=True ${PipEnv})

configure_file(Pipfile Pipfile COPYONLY)
configure_file(autest.sh.in autest.sh)

set(CMAKE_GOLD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/gold_tests_filtered")
set(CURL_UDS_FLAG "")
if(ENABLE_AUTEST_UDS)
set(CURL_UDS_FLAG "--curl-uds")
# Copy everything except dirs: h2, tls
# Other specific tests will be skipped
file(
COPY ${CMAKE_CURRENT_SOURCE_DIR}/gold_tests/
DESTINATION ${CMAKE_GOLD_DIR}
FILES_MATCHING
PATTERN "*"
PATTERN "h2" EXCLUDE
PATTERN "tls*" EXCLUDE
PATTERN "tls/ssl/**"
)
else()
# Copy everything except autest_uds tests that are only for curl uds option
file(
COPY ${CMAKE_CURRENT_SOURCE_DIR}/gold_tests/
DESTINATION ${CMAKE_GOLD_DIR}
FILES_MATCHING
PATTERN "*"
)
add_subdirectory(gold_tests_filtered/tls)
endif()

add_subdirectory(gold_tests_filtered/chunked_encoding)
add_subdirectory(gold_tests_filtered/continuations/plugins)
add_subdirectory(gold_tests_filtered/jsonrpc/plugins)
add_subdirectory(gold_tests_filtered/pluginTest/polite_hook_wait)
add_subdirectory(gold_tests_filtered/pluginTest/tsapi)
add_subdirectory(gold_tests_filtered/pluginTest/TSVConnFd)
add_subdirectory(gold_tests_filtered/timeout)

configure_file(Pipfile Pipfile COPYONLY)
configure_file(autest.sh.in autest.sh)

add_custom_target(
autest
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install
COMMAND ${RUNPIPENV} install
COMMAND
${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/gold_tests/remap:$ENV{PYTHONPATH} ${RUNPIPENV} run
env autest --directory ${CMAKE_CURRENT_SOURCE_DIR}/gold_tests --ats-bin=${CMAKE_INSTALL_PREFIX}/bin
--proxy-verifier-bin ${PROXY_VERIFIER_PATH} --build-root ${CMAKE_BINARY_DIR} --sandbox ${AUTEST_SANDBOX}
${CURL_UDS_FLAG} ${AUTEST_OPTIONS}
${CMAKE_COMMAND} -E env PYTHONPATH=${CMAKE_GOLD_DIR}/remap:$ENV{PYTHONPATH} ${RUNPIPENV} run env autest --directory
${CMAKE_GOLD_DIR} --ats-bin=${CMAKE_INSTALL_PREFIX}/bin --proxy-verifier-bin ${PROXY_VERIFIER_PATH} --build-root
${CMAKE_BINARY_DIR} --sandbox ${AUTEST_SANDBOX} ${CURL_UDS_FLAG} ${AUTEST_OPTIONS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
USES_TERMINAL
)
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ ts=Test.MakeATSProcess("ts")
#first test is a miss for default
tr=Test.AddTestRun()
# get port for command from Variables
tr.MakeCurlCommand('"http://127.0.0.1:{0}" --verbose'.format(ts.Variables.port))
tr.MakeCurlCommand('"http://127.0.0.1:{0}" --verbose'.format(ts.Variables.port), uds_path=ts.Variables.uds_path)

```

Expand Down
2 changes: 1 addition & 1 deletion tests/autest.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/gold_tests/remap:$PYTHONPATH

${RUNPIPENV} run env autest \
--sandbox ${AUTEST_SANDBOX} \
--directory ${CMAKE_CURRENT_SOURCE_DIR}/gold_tests \
--directory ${CMAKE_GOLD_DIR} \
--ats-bin=${CMAKE_INSTALL_PREFIX}/bin \
--proxy-verifier-bin ${PROXY_VERIFIER_PATH} \
--build-root ${CMAKE_BINARY_DIR} \
Expand Down
5 changes: 5 additions & 0 deletions tests/gold_tests/autest-site/conditions.test.ext
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ def PluginExists(self, pluginname):
return self.Condition(lambda: os.path.isfile(path), path + " not found.")


def CurlUsingUnixDomainSocket(self):
return self.Condition(lambda: self.Variables.get("CurlUds", False), "Curl using UDS. Not relevant for test")


ExtendCondition(HasOpenSSLVersion)
ExtendCondition(HasProxyVerifierVersion)
ExtendCondition(IsBoringSSL)
Expand All @@ -119,3 +123,4 @@ ExtendCondition(HasCurlVersion)
ExtendCondition(HasCurlFeature)
ExtendCondition(HasCurlOption)
ExtendCondition(PluginExists)
ExtendCondition(CurlUsingUnixDomainSocket)
14 changes: 6 additions & 8 deletions tests/gold_tests/autest-site/curl.test.ext
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ Tools to help with TestRun commands
#


def spawn_curl_commands(self, cmdstr, count, retcode=0, use_default=True):
def spawn_curl_commands(self, cmdstr, count, retcode=0, use_default=True, uds_path=""):
ret = []

if self.Variables.get("CurlUds", False):
cmdstr = 'curl --unix-socket /tmp/socket ' + cmdstr
cmdstr = f'curl --unix-socket {uds_path} ' + cmdstr
else:
cmdstr = 'curl ' + cmdstr
if use_default:
Expand All @@ -48,24 +48,22 @@ def spawn_curl_commands(self, cmdstr, count, retcode=0, use_default=True):
return ret


def curl_command(self, cmd, p=None):
def curl_command(self, cmd, uds_path="", p=None):
if p == None:
p = self.Processes.Default
if self.Variables.get("CurlUds", False):
uds_path = os.path.join(p.RunDirectory, 'uds.socket')
p.Command = f'curl --unix-socket {uds_path} ' + cmd
else:
p.Command = 'curl ' + cmd
return p


def curl_multiple_commands(self, cmd):
def curl_multiple_commands(self, cmd, uds_path=""):
p = self.Processes.Default
if self.Variables.get("CurlUds", False):
uds_path = os.path.join(p.RunDirectory, 'uds.socket')
p.Command = cmd.format(curl=f'curl --unix-socket {uds_path}')
p.Command = cmd.format(curl=f'curl --unix-socket {uds_path}', curl_base='curl')
else:
p.Command = cmd.format(curl='curl')
p.Command = cmd.format(curl='curl', curl_base='curl')
return p


Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/autest-site/setup.cli.ext
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Variables.VerifierBinPath = ENV['VERIFIER_BIN']
Variables.BuildRoot = ENV['BUILD_ROOT']
Variables.RepoDir = repo_root
Variables.AtsTestPluginsDir = os.path.join(Variables.BuildRoot, 'tests', 'tools', 'plugins', '.libs')
Variables.AtsBuildGoldTestsDir = os.path.join(Variables.BuildRoot, 'tests', 'gold_tests')
Variables.AtsBuildGoldTestsDir = os.path.join(Variables.BuildRoot, 'tests', 'gold_tests_filtered')
Variables.CurlUds = Arguments.curl_uds

# modify delay times as we always have to kill Trafficserver
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/autest-site/trafficserver.test.ext
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def MakeATSProcess(
p.Variables.ssl_portv6 = 4444

# unix domain socket path
uds_path = os.path.join(obj.RunDirectory, 'uds.socket')
uds_path = os.path.join(runtime_dir, 'uds.socket')
p.Variables.uds_path = uds_path

get_port(p, "manager_port")
Expand Down
2 changes: 1 addition & 1 deletion tests/gold_tests/basic/basic.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
t.StillRunningAfter = Test.Processes.ts

p = t.Processes.Default
t.MakeCurlCommand("http://127.0.0.1:{0}".format(ts.Variables.port))
t.MakeCurlCommand("http://127.0.0.1:{0}".format(ts.Variables.port), uds_path=ts.Variables.uds_path)
p.ReturnCode = 0
p.StartBefore(Test.Processes.ts)
5 changes: 3 additions & 2 deletions tests/gold_tests/basic/config.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@
# 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.
import os

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

ts = Test.MakeATSProcess("ts", select_ports=False)
ts.Variables.port = 8090
ts.Disk.records_config.update({
'proxy.config.http.server_ports': str(ts.Variables.port),
'proxy.config.http.server_ports': str(ts.Variables.port) + f" {ts.Variables.uds_path}",
})
ts.Ready = When.PortOpen(ts.Variables.port)
t = Test.AddTestRun("Test traffic server started properly")
t.Processes.Default.StartBefore(ts)
t.MakeCurlCommand("127.0.0.1:{port}".format(port=ts.Variables.port))
t.MakeCurlCommand("127.0.0.1:{port}".format(port=ts.Variables.port), uds_path=ts.Variables.uds_path)
t.ReturnCode = 0
t.StillRunningAfter = ts
9 changes: 5 additions & 4 deletions tests/gold_tests/basic/copy_config.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@
# 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.
import os

Test.Summary = "Test start up of Traffic server with configuration modification of starting port of different servers at the same time"

# set up some ATS processes
ts1 = Test.MakeATSProcess("ts1", select_ports=False)
ts1.Variables.port = 8090
ts1.Disk.records_config.update({
'proxy.config.http.server_ports': str(ts1.Variables.port),
'proxy.config.http.server_ports': str(ts1.Variables.port) + f" {ts1.Variables.uds_path}",
})
ts1.Ready = When.PortOpen(ts1.Variables.port)

ts2 = Test.MakeATSProcess("ts2", select_ports=False)
ts2 = Test.MakeATSProcess("ts2", select_ports=False, enable_uds=False)
ts2.Variables.port = 8091
ts2.Disk.records_config.update({
'proxy.config.http.server_ports': str(ts2.Variables.port),
Expand All @@ -37,14 +38,14 @@
t = Test.AddTestRun("Talk to ts1")
t.Processes.Default.StartBefore(ts1)
t.Processes.Default.StartBefore(ts2)
t.MakeCurlCommand("127.0.0.1:{port}".format(port=ts1.Variables.port))
t.MakeCurlCommand("127.0.0.1:{port}".format(port=ts1.Variables.port), uds_path=ts1.Variables.uds_path)
t.ReturnCode = 0
t.StillRunningAfter = ts1
t.StillRunningAfter += ts2

# setup a testrun
t = Test.AddTestRun("Talk to ts2")
t.MakeCurlCommand("127.0.0.1:{port}".format(port=ts2.Variables.port))
t.MakeCurlCommandMulti("{{curl_base}} 127.0.0.1:{port}".format(port=ts2.Variables.port))
t.ReturnCode = 0
t.StillRunningAfter = ts1
t.StillRunningAfter += ts2
4 changes: 2 additions & 2 deletions tests/gold_tests/basic/copy_config2.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
t.StillRunningAfter = ts1
t.StillRunningAfter += ts2
p = t.Processes.Default
t.MakeCurlCommand("127.0.0.1:{0}".format(ts1.Variables.port))
t.MakeCurlCommand("127.0.0.1:{0}".format(ts1.Variables.port), uds_path=ts1.Variables.uds_path)
p.ReturnCode = 0
p.StartBefore(Test.Processes.ts1)
p.StartBefore(Test.Processes.ts2)
Expand All @@ -39,5 +39,5 @@
t.StillRunningAfter = ts1
t.StillRunningAfter += ts2
p = t.Processes.Default
t.MakeCurlCommand("127.0.0.1:{0}".format(ts2.Variables.port))
t.MakeCurlCommand("127.0.0.1:{0}".format(ts2.Variables.port), uds_path=ts2.Variables.uds_path)
p.ReturnCode = 0
47 changes: 27 additions & 20 deletions tests/gold_tests/bigobj/bigobj.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,40 +63,46 @@ def create_pushfile():
return True


ipv4flag = ""
if not Condition.CurlUsingUnixDomainSocket():
ipv4flag = "--ipv4"

tr = Test.AddTestRun("PUSH an object to the cache")
# Delay on readiness of TS IPv4 ssl port
tr.Processes.Default.StartBefore(ts, ready=lambda: create_pushfile())
# Put object with URL http://localhost/bigobj in cache using PUSH request.
tr.MakeCurlCommand(
"-v -H 'Content-Type: application/octet-stream' --data-binary @{}/objfile -X PUSH http://localhost:{}/bigobj -H 'Content-Length:{}'"
.format(Test.RunDirectory, ts.Variables.port,
len(header) + obj_bytes))
len(header) + obj_bytes),
uds_path=ts.Variables.uds_path)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/1.1 201 Created", "The PUSH request should have succeeded")

tr = Test.AddTestRun("GET bigobj: cleartext, HTTP/1.1, IPv4")
tr.MakeCurlCommand(f'--verbose --ipv4 --http1.1 http://localhost:{ts.Variables.port}/bigobj')
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/1.1 200 OK", "Should fetch pushed object")
tr.Processes.Default.Streams.All = Testers.ContainsExpression("Content-length: 102400", "Content size should be accurate")

tr = Test.AddTestRun("GET bigobj: TLS, HTTP/1.1, IPv4")
tr.MakeCurlCommand(f'--verbose --ipv4 --http1.1 --insecure https://localhost:{ts.Variables.ssl_port}/bigobj')
tr.MakeCurlCommand(f'--verbose {ipv4flag} --http1.1 http://localhost:{ts.Variables.port}/bigobj', uds_path=ts.Variables.uds_path)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/1.1 200 OK", "Should fetch pushed object")
tr.Processes.Default.Streams.All = Testers.ContainsExpression("Content-length: 102400", "Content size should be accurate")

tr = Test.AddTestRun("GET bigobj: TLS, HTTP/2, IPv4")
tr.MakeCurlCommand(f'--verbose --ipv4 --http2 --insecure https://localhost:{ts.Variables.ssl_port}/bigobj')
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/2 200", "Should fetch pushed object")
tr.Processes.Default.Streams.All = Testers.ContainsExpression("content-length: 102400", "Content size should be accurate")

tr = Test.AddTestRun("GET bigobj: TLS, HTTP/2, IPv6")
tr.MakeCurlCommand(f'--verbose --ipv6 --http2 --insecure https://localhost:{ts.Variables.ssl_portv6}/bigobj')
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/2 200", "Should fetch pushed object")
tr.Processes.Default.Streams.All = Testers.ContainsExpression("content-length: 102400", "Content size should be accurate")
if not Condition.CurlUsingUnixDomainSocket():
tr = Test.AddTestRun("GET bigobj: TLS, HTTP/1.1, IPv4")
tr.MakeCurlCommand(f'--verbose --ipv4 --http1.1 --insecure https://localhost:{ts.Variables.ssl_port}/bigobj')
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/1.1 200 OK", "Should fetch pushed object")
tr.Processes.Default.Streams.All = Testers.ContainsExpression("Content-length: 102400", "Content size should be accurate")

tr = Test.AddTestRun("GET bigobj: TLS, HTTP/2, IPv4")
tr.MakeCurlCommand(f'--verbose --ipv4 --http2 --insecure https://localhost:{ts.Variables.ssl_port}/bigobj')
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/2 200", "Should fetch pushed object")
tr.Processes.Default.Streams.All = Testers.ContainsExpression("content-length: 102400", "Content size should be accurate")

tr = Test.AddTestRun("GET bigobj: TLS, HTTP/2, IPv6")
tr.MakeCurlCommand(f'--verbose --ipv6 --http2 --insecure https://localhost:{ts.Variables.ssl_portv6}/bigobj')
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression("HTTP/2 200", "Should fetch pushed object")
tr.Processes.Default.Streams.All = Testers.ContainsExpression("content-length: 102400", "Content size should be accurate")

# Verify that PUSH requests are rejected when push_method_enabled is 0 (the
# default configuration).
Expand Down Expand Up @@ -124,7 +130,8 @@ def create_pushfile():
tr.MakeCurlCommand(
"-v -H 'Content-Type: application/octet-stream' --data-binary @{}/objfile -X PUSH http://localhost:{}/bigobj -H 'Content-Length:{}'"
.format(Test.RunDirectory, ts.Variables.port,
len(header) + obj_bytes))
len(header) + obj_bytes),
uds_path=ts.Variables.uds_path)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.All = Testers.ContainsExpression(
"403 Access Denied", "The PUSH request should have received a 403 response.")
19 changes: 12 additions & 7 deletions tests/gold_tests/cache/background_fill.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def __setupTS(self, ts_names=['default']):

self.ts[name].Disk.records_config.update(
{
"proxy.config.http.server_ports": f"{self.ts[name].Variables.port} {self.ts[name].Variables.ssl_port}:ssl",
"proxy.config.http.server_ports":
f"{self.ts[name].Variables.port} {self.ts[name].Variables.ssl_port}:ssl {self.ts[name].Variables.uds_path}",
"proxy.config.http.background_fill_active_timeout": "0",
"proxy.config.http.background_fill_completed_threshold": "0.0",
"proxy.config.http.cache.required_headers": 0, # Force cache
Expand Down Expand Up @@ -112,7 +113,8 @@ def __testCase0(self):
timeout 2 {{curl}} --http1.1 -vs http://127.0.0.1:{self.ts['for_httpbin'].Variables.port}/drip?duration=4;
sleep 4;
{{curl}} --http1.1 -vs http://127.0.0.1:{self.ts['for_httpbin'].Variables.port}/drip?duration=4
""")
""",
uds_path=self.ts['for_httpbin'].Variables.uds_path)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stderr = Testers.Any(
"gold/background_fill_0_stderr_H.gold", "gold/background_fill_0_stderr_W.gold")
Expand All @@ -130,7 +132,8 @@ def __testCase1(self):
timeout 3 {{curl}} --http1.1 -vsk https://127.0.0.1:{self.ts['for_httpbin'].Variables.ssl_port}/drip?duration=4;
sleep 5;
{{curl}} --http1.1 -vsk https://127.0.0.1:{self.ts['for_httpbin'].Variables.ssl_port}/drip?duration=4
""")
""",
uds_path=self.ts['for_httpbin'].Variables.uds_path)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stderr = Testers.Any(
"gold/background_fill_1_stderr_H.gold", "gold/background_fill_1_stderr_W.gold")
Expand All @@ -148,7 +151,8 @@ def __testCase2(self):
timeout 3 {{curl}} --http2 -vsk https://127.0.0.1:{self.ts['for_httpbin'].Variables.ssl_port}/drip?duration=4;
sleep 5;
{{curl}} --http2 -vsk https://127.0.0.1:{self.ts['for_httpbin'].Variables.ssl_port}/drip?duration=4
""")
""",
uds_path=self.ts['for_httpbin'].Variables.uds_path)
tr.Processes.Default.ReturnCode = 0
tr.Processes.Default.Streams.stderr = Testers.Any(
"gold/background_fill_2_stderr_H.gold", "gold/background_fill_2_stderr_W.gold")
Expand All @@ -172,9 +176,10 @@ def __testCase3(self):

def run(self):
self.__testCase0()
self.__testCase1()
self.__testCase2()
self.__testCase3()
if not Condition.CurlUsingUnixDomainSocket():
self.__testCase1()
self.__testCase2()
self.__testCase3()


BackgroundFillTest().run()
Loading