This is an automated email from the ASF dual-hosted git repository. cmcfarlen pushed a commit to branch 10.2.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit d5f6f952e2d94d4e8691238ef37e8f9d1b7fca17 Author: Masaori Koshiba <[email protected]> AuthorDate: Tue Feb 24 08:03:52 2026 +0900 Check state of HostDBInfo (#12880) * Check state of HostDBInfo * Adjust AuTest * Cleanup: use select function for consistency (cherry picked from commit bc464c534dbda6abcdacacb024e809abd4603ebb) --- src/iocore/hostdb/HostDB.cc | 4 +++- tests/gold_tests/dns/dns_host_down.test.py | 14 +------------- tests/gold_tests/dns/replay/server_down.replay.yaml | 5 ++++- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/iocore/hostdb/HostDB.cc b/src/iocore/hostdb/HostDB.cc index f30246b8c7..12a8532be6 100644 --- a/src/iocore/hostdb/HostDB.cc +++ b/src/iocore/hostdb/HostDB.cc @@ -1324,7 +1324,9 @@ HostDBRecord::select_best_http(ts_time now, ts_seconds fail_window, sockaddr con } } } else { - best_alive = &info[0]; + if (info[0].select(now, fail_window)) { + best_alive = &info[0]; + } } return best_alive; diff --git a/tests/gold_tests/dns/dns_host_down.test.py b/tests/gold_tests/dns/dns_host_down.test.py index 74930c7544..3d05805769 100644 --- a/tests/gold_tests/dns/dns_host_down.test.py +++ b/tests/gold_tests/dns/dns_host_down.test.py @@ -55,24 +55,13 @@ class DownCachedOriginServerTest: 'proxy.config.hostdb.host_file.path': os.path.join(Test.TestDirectory, "hosts_file"), }) - # Even when the origin server is down, SM will return a hit-fresh domain from HostDB. - # After request has failed, SM should mark the IP as down def _test_host_mark_down(self): tr = Test.AddTestRun() tr.Processes.Default.StartBefore(self._server) tr.Processes.Default.StartBefore(self._ts) - tr.AddVerifierClientProcess( - "client-1", DownCachedOriginServerTest.replay_file, http_ports=[self._ts.Variables.port], other_args='--keys 1') - - # After host has been marked down from previous test, HostDB should not return - # the host as available and DNS lookup should fail. - def _test_host_unreachable(self): - tr = Test.AddTestRun() - - tr.AddVerifierClientProcess( - "client-2", DownCachedOriginServerTest.replay_file, http_ports=[self._ts.Variables.port], other_args='--keys 2') + tr.AddVerifierClientProcess("client-1", DownCachedOriginServerTest.replay_file, http_ports=[self._ts.Variables.port]) # Verify error log marking host down exists def _test_error_log(self): @@ -86,7 +75,6 @@ class DownCachedOriginServerTest: def run(self): self._test_host_mark_down() - self._test_host_unreachable() self._test_error_log() diff --git a/tests/gold_tests/dns/replay/server_down.replay.yaml b/tests/gold_tests/dns/replay/server_down.replay.yaml index d5b33bc784..52fbead289 100644 --- a/tests/gold_tests/dns/replay/server_down.replay.yaml +++ b/tests/gold_tests/dns/replay/server_down.replay.yaml @@ -36,6 +36,7 @@ sessions: status: 200 # Returns 502 since server connection is unreachable + # This transaction should mark the IP as down proxy-response: status: 502 @@ -55,5 +56,7 @@ sessions: server-response: status: 200 + # After host has been marked down from previous test, HostDB should not return + # the host as available and HostDB lookup should fail. proxy-response: - status: 502 + status: 500
