From ee6fbbae05aa127568eef0692290d40a2259a491 Mon Sep 17 00:00:00 2001 From: Handa Wang <7058128+superwhd@users.noreply.github.com> Date: Thu, 31 Oct 2024 23:14:43 +0800 Subject: [PATCH] [tests] fix `test_upstream_dns.py` (#10883) There's a CI failure that the BR sends the query to 8.8.8.8 as the upstream DNS server and responded to the DNS client. This is undesired behavior. We want the BR to query our test DNS server instead. The issue happened because 8.8.8.8 is already an entry in `/etc/resolv.conf`. To avoid querying it, we should fully overwrite the `/etc/resolv.conf` to ensure the BR queries the test DNS server. There's another issue that `bind9` service was also running on the BR node which taken over all incoming DNS queries. `bind9` should only run on the upstream DNS server node. I'll try fix this in a more generic way later. --- .../thread-cert/border_router/internet/test_upstream_dns.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/scripts/thread-cert/border_router/internet/test_upstream_dns.py b/tests/scripts/thread-cert/border_router/internet/test_upstream_dns.py index acd52560920..238f32b12e2 100755 --- a/tests/scripts/thread-cert/border_router/internet/test_upstream_dns.py +++ b/tests/scripts/thread-cert/border_router/internet/test_upstream_dns.py @@ -91,8 +91,11 @@ def test(self): self._start_dns_server(dns_server) dns_server_addr = dns_server.get_ether_addrs(ipv4=True, ipv6=False)[0] + # Disable the bind9 service on the BR otherwise bind9 may respond to Thread devices' DNS queries + br.bash('service bind9 stop') + # Update BR's /etc/resolv.conf and force BR to reload it - br.bash(shlex.join(['echo', 'nameserver ' + dns_server_addr]) + ' >> /etc/resolv.conf') + br.bash(shlex.join(['echo', 'nameserver ' + dns_server_addr]) + ' > /etc/resolv.conf') br.stop_otbr_service() br.start_otbr_service()