Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support resolve upstream host in stream subsystem #8500

Merged
merged 2 commits into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"