Skip to content

Commit bc464c5

Browse files
authored
Check state of HostDBInfo (#12880)
* Check state of HostDBInfo * Adjust AuTest * Cleanup: use select function for consistency
1 parent df83065 commit bc464c5

3 files changed

Lines changed: 8 additions & 15 deletions

File tree

src/iocore/hostdb/HostDB.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,9 @@ HostDBRecord::select_best_http(ts_time now, ts_seconds fail_window, sockaddr con
13241324
}
13251325
}
13261326
} else {
1327-
best_alive = &info[0];
1327+
if (info[0].select(now, fail_window)) {
1328+
best_alive = &info[0];
1329+
}
13281330
}
13291331

13301332
return best_alive;

tests/gold_tests/dns/dns_host_down.test.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,13 @@ def _configure_trafficserver(self):
5555
'proxy.config.hostdb.host_file.path': os.path.join(Test.TestDirectory, "hosts_file"),
5656
})
5757

58-
# Even when the origin server is down, SM will return a hit-fresh domain from HostDB.
59-
# After request has failed, SM should mark the IP as down
6058
def _test_host_mark_down(self):
6159
tr = Test.AddTestRun()
6260

6361
tr.Processes.Default.StartBefore(self._server)
6462
tr.Processes.Default.StartBefore(self._ts)
6563

66-
tr.AddVerifierClientProcess(
67-
"client-1", DownCachedOriginServerTest.replay_file, http_ports=[self._ts.Variables.port], other_args='--keys 1')
68-
69-
# After host has been marked down from previous test, HostDB should not return
70-
# the host as available and DNS lookup should fail.
71-
def _test_host_unreachable(self):
72-
tr = Test.AddTestRun()
73-
74-
tr.AddVerifierClientProcess(
75-
"client-2", DownCachedOriginServerTest.replay_file, http_ports=[self._ts.Variables.port], other_args='--keys 2')
64+
tr.AddVerifierClientProcess("client-1", DownCachedOriginServerTest.replay_file, http_ports=[self._ts.Variables.port])
7665

7766
# Verify error log marking host down exists
7867
def _test_error_log(self):
@@ -86,7 +75,6 @@ def _test_error_log(self):
8675

8776
def run(self):
8877
self._test_host_mark_down()
89-
self._test_host_unreachable()
9078
self._test_error_log()
9179

9280

tests/gold_tests/dns/replay/server_down.replay.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ sessions:
3636
status: 200
3737

3838
# Returns 502 since server connection is unreachable
39+
# This transaction should mark the IP as down
3940
proxy-response:
4041
status: 502
4142

@@ -55,5 +56,7 @@ sessions:
5556
server-response:
5657
status: 200
5758

59+
# After host has been marked down from previous test, HostDB should not return
60+
# the host as available and HostDB lookup should fail.
5861
proxy-response:
59-
status: 502
62+
status: 500

0 commit comments

Comments
 (0)