Skip to content

Commit

Permalink
feat: support resolve upstream host in stream subsystem (apache#8500)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzssangglass authored Dec 13, 2022
1 parent c5fc10d commit ad58195
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rockspec/apisix-master-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ description = {

dependencies = {
"lua-resty-ctxdump = 0.1-0",
"lua-resty-dns-client = 6.0.2",
"api7-lua-resty-dns-client = 7.0.1",
"lua-resty-template = 2.0",
"lua-resty-etcd = 1.10.1",
"api7-lua-resty-http = 0.2.0",
Expand Down
47 changes: 47 additions & 0 deletions t/cli/test_dns.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,50 @@ if grep "fe80::21c:42ff:fe00:18%eth0" conf/nginx.conf > /dev/null; then
fi

echo "passed: check dns resolver"

# dns resolver in stream subsystem
rm logs/error.log || true

echo "
apisix:
enable_admin: true
stream_proxy:
tcp:
- addr: 9100
dns_resolver:
- 127.0.0.1:1053
nginx_config:
error_log_level: info
" > conf/config.yaml

make run
sleep 0.5

curl -v -k -i -m 20 -o /dev/null -s -X PUT http://127.0.0.1:9180/apisix/admin/stream_routes/1 \
-H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" \
-d '{
"upstream": {
"type": "roundrobin",
"nodes": [{
"host": "sd.test.local",
"port": 1995,
"weight": 1
}]
}
}'

curl http://127.0.0.1:9100 || true
make stop
sleep 0.1 # wait for logs output

if grep -E 'dns client error: 101 empty record received while prereading client data' logs/error.log; then
echo "failed: resolve upstream host in stream subsystem should works fine"
exit 1
fi

if ! grep -E 'dns resolver domain: sd.test.local to 127.0.0.(1|2) while prereading client data' logs/error.log; then
echo "failed: resolve upstream host in preread phase should works fine"
exit 1
fi

echo "success: resolve upstream host in stream subsystem works fine"

0 comments on commit ad58195

Please sign in to comment.