Copilot commented on code in PR #13385:
URL: https://github.com/apache/trafficserver/pull/13385#discussion_r3596630534
##########
tests/gold_tests/pluginTest/packet_mark/packet_mark.test.py:
##########
@@ -44,60 +46,130 @@ def _can_set_so_mark() -> bool:
Test.SkipUnless(
Condition.IsPlatform("linux"),
- Condition(_can_set_so_mark, "Setting SO_MARK requires Linux with
CAP_NET_ADMIN or CAP_NET_RAW", True),
+ # pass_value defaults to True: run only when the probe reports SO_MARK is
settable.
+ Condition(_can_set_so_mark, "Setting SO_MARK requires Linux with
CAP_NET_ADMIN or CAP_NET_RAW"),
)
+# SOCK_OPT_PACKET_MARK (0x10) | SOCK_OPT_NO_DELAY (0x1). The mark is only
pushed
+# to the socket when the PACKET_MARK bit is set in the sock option flag.
+SOCK_OPT_FLAG_PACKET_MARK = 0x11
-class ClientPacketMarkTest:
- """Drive TSHttpTxnClientPacketMarkSet through a test plugin and assert on
the
- firewall mark read back off the client socket.
- The starting mark is seeded per process via
- proxy.config.net.sock_packet_mark_in, applied at accept time.
+class PacketMarkTest:
+ """Drive a TSHttpTxn*PacketMarkSet API through a test plugin and assert on
the
+ firewall mark read back off the relevant socket.
+
+ This base holds the shared skeleton -- process setup, the common records,
the
+ curl-and-assert case runner. Each subclass supplies its plugin and echo
+ header and extends _configure() (via super()) with the side-specific mark
and
+ flag records.
"""
# Value the plugin sets; the mark is expected to become exactly this.
SET_MARK = 0x0000000A
+ # Seeded starting mark, distinct from SET_MARK so a no-op would be visible.
+ SEED_MARK = 0x0000FF00
+
+ # Bumped per instance so each side gets uniquely-numbered processes.
+ _counter = 0
def __init__(self):
+ self._num = PacketMarkTest._counter
+ PacketMarkTest._counter += 1
self._server = self._make_server()
- self._ts = self._make_ats("ts", seed_mark=0x0000FF00)
+ self._ts = self._make_ats()
+ self._configure(self._ts)
+ self._started = False
- def _make_server(self) -> 'Process':
- server = Test.MakeOriginServer("server")
+ def _make_server(self):
+ server = Test.MakeOriginServer(f"server{self._num}")
request_header = {"headers": "GET / HTTP/1.1\r\nHost:
example.com\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
response_header = {"headers": "HTTP/1.1 200 OK\r\nConnection:
close\r\n\r\n", "timestamp": "1469733493.993", "body": ""}
server.addResponse("sessionlog.json", request_header, response_header)
return server
Review Comment:
ServerPacketMarkTest issues two curl requests against the same origin
server, but _make_server() only registers a single transaction in
sessionlog.json. The microserver consumes transactions sequentially, so the
second request can run out of scripted responses and fail/flake. Add at least
one extra addResponse() (or otherwise ensure one response per request).
--
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]