Skip to content

Commit 2b98f7e

Browse files
committed
ci: add dnsmasq in ci to avoid flaky test
Signed-off-by: Y.Horie <u5.horie@gmail.com>
1 parent 7873a51 commit 2b98f7e

1 file changed

Lines changed: 25 additions & 4 deletions

File tree

.github/workflows/build_and_test.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,28 @@ jobs:
184184
sudo ip route add prohibit 0.0.0.1/32
185185
sudo sysctl -w kernel.pid_max=10000
186186
187+
- name: Start local DNS cache (dnsmasq)
188+
run: |
189+
sudo apt-get install -y --no-install-recommends dnsmasq
190+
# Stop any pre-installed dnsmasq instance from the package's default unit.
191+
sudo systemctl stop dnsmasq 2>/dev/null || true
192+
# --no-resolv: ignore /etc/resolv.conf (which on ubuntu-latest points at
193+
# systemd-resolved on 127.0.0.53 and would loop back to ourselves on
194+
# port 53 if we ever bound there).
195+
# Bind to 5353 to avoid colliding with systemd-resolved.
196+
sudo dnsmasq --port=5353 \
197+
--listen-address=127.0.0.1 \
198+
--bind-interfaces \
199+
--no-resolv --no-hosts \
200+
--server=8.8.4.4 --server=8.8.8.8 --server=1.1.1.1 \
201+
--cache-size=1000 \
202+
--pid-file=/tmp/dnsmasq.pid
203+
# Warm the cache for all external hostnames the test suite resolves.
204+
for h in openresty.org www.openresty.org agentzh.org sregex.org \
205+
www.google.com google-public-dns-a.google.com; do
206+
dig +short +tries=3 +time=2 @127.0.0.1 -p 5353 "$h" || true
207+
done
208+
187209
- name: Build LuaJIT
188210
run: |
189211
cd luajit2
@@ -254,9 +276,8 @@ jobs:
254276
export LD_PRELOAD=$PWD/mockeagain/mockeagain.so
255277
export TEST_NGINX_HTTP3_CRT=$PWD/t/cert/http3/http3.crt
256278
export TEST_NGINX_HTTP3_KEY=$PWD/t/cert/http3/http3.key
257-
export TEST_NGINX_RESOLVER=8.8.4.4
258-
dig +short myip.opendns.com @resolver1.opendns.com || exit 0
259-
dig +short @$TEST_NGINX_RESOLVER openresty.org || exit 0
260-
dig +short @$TEST_NGINX_RESOLVER agentzh.org || exit 0
279+
export TEST_NGINX_OPENRESTY_ORG_IP=$(dig +short @127.0.0.1 -p 5353 openresty.org | head -n1)
280+
dig +short @127.0.0.1 -p 5353 openresty.org || true
281+
dig +short @127.0.0.1 -p 5353 agentzh.org || true
261282
python3 ./util/nc_server.py &
262283
/usr/bin/env perl $(command -v prove) -I. -Itest-nginx/inc -Itest-nginx/lib -r t/

0 commit comments

Comments
 (0)