bneradt commented on code in PR #12122:
URL: https://github.com/apache/trafficserver/pull/12122#discussion_r2019169437
##########
tests/README.md:
##########
@@ -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.Processes.Default.Command='curl "http://127.0.0.1:{0}"
--verbose'.format(ts.Variables.port)
+tr.MakeCurlCommand='"http://127.0.0.1:{0}" --verbose'.format(ts.Variables.port)
Review Comment:
Function call rather than assignment.
##########
tests/gold_tests/autest-site/cli_tools.test.ext:
##########
@@ -45,4 +45,46 @@ def spawn_commands(self, cmdstr, count, retcode=0,
use_default=True):
return ret
+def spawn_curl_commands(self, cmdstr, count, retcode=0, use_default=True):
+ ret = []
+
+ if self.Variables.get("CurlUds", False):
+ cmdstr = 'curl --unix-socket /tmp/socket ' + cmdstr
+ else:
+ cmdstr = 'curl ' + cmdstr
+ if use_default:
+ count = int(count) - 1
+ for cnt in range(0, count):
+
ret.append(self.Processes.Process(name="cmdline-{num}".format(num=cnt),
cmdstr=cmdstr, returncode=retcode))
+ if use_default:
+ self.Processes.Default.Command = cmdstr
+ self.Processes.Default.ReturnCode = retcode
+ self.Processes.Default.StartBefore(*ret)
+ return ret
+
+
+def curl_command(self, cmd, p=None):
+ if p == None:
+ p = self.Processes.Default
+ if self.Variables.get("CurlUds", False):
+ p.Command = 'curl --unix-socket /tmp/socket ' + cmd
+ else:
+ p.Command = 'curl ' + cmd
+ return p
+
+
+def curl_multiple_commands(self, cmd):
+ p = self.Processes.Default
+ if self.Variables.get("CurlUds", False):
+ p.Command = cmd.format(curl='curl --unix-socket /tmp/socket')
+ else:
+ p.Command = cmd.format(curl='curl')
+ return p
+
+
ExtendTestRun(spawn_commands, name="SpawnCommands")
+ExtendTestRun(spawn_curl_commands, name="SpawnCurlCommands")
+ExtendTestRun(curl_command, name="MakeCurlCommand")
+ExtendTest(curl_command, name="MakeCurlCommand")
+ExtendTestRun(curl_multiple_commands, name="MakeCurlCommandMulti")
+ExtendTest(curl_multiple_commands, name="MakeCurlCommandMulti")
Review Comment:
For consistency with like extensions in the project, let's put this in a
separate `curl.test.ext` file.
##########
tests/gold_tests/autest-site/trafficserver.test.ext:
##########
@@ -403,6 +404,7 @@ def MakeATSProcess(
p.Ready = When.FileContains(p.Disk.diags_log.AbsPath, "NOTE: Traffic
Server is fully initialized")
if select_ports:
+ uds_path = "/tmp/socket"
Review Comment:
`/tmp/socket` might be generic enough to accidentally clash with another
socket. Let's put this in the sandbox.
My initial thought was to put the socket in the ts.Variables namespace and
have the MakeCurlCommand reference that, but then we need to pass ts to each of
those MakeCurlCommand calls which is kind of clunky. Let's instead put this in
the `RunDirectory` which all the processes should be able to access:
So here in this trafficserver Process logic:
```python3
uds_path = os.path.join(obj.RunDirectory, 'uds.socket')
p.Variables.uds_path = uds_path
```
Then the MakeCurlCommand logic can do the same type of thing:
```python3
uds_path = os.path.join(p.RunDirectory, 'uds.socket')
f'curl --unix-socket {uds_path} ' + cmd
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]