From 093acb28ff787c7cd46074196d3c4df2f38fa133 Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Tue, 25 Aug 2026 21:40:00 +0000 Subject: [PATCH 1/2] Give the Android emulator fixed DNS servers The Android test jobs intermittently fail with java.net.UnknownHostException: Unable to resolve host "javasdkgate-dps.azure-devices-provisioning.net": No address associated with hostname thrown from the first HTTPS call the test makes. It is not deterministic: in the same emulator run, some tests resolve that hostname successfully while others fail on it, and the number of affected tests varies from run to run. The emulator was started without -dns-server, so the guest resolves through the emulator's DNS proxy, which forwards to whatever resolvers the host agent has. Pointing the guest at fixed public resolvers takes the host's resolver configuration out of the picture. Also logs a single name resolution check after boot, so that a later DNS failure can be told apart from an emulator that never had working name resolution. That check only logs and cannot fail the task. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- vsts/StartEmulator.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/vsts/StartEmulator.sh b/vsts/StartEmulator.sh index 3e71305093..d32989e2e6 100644 --- a/vsts/StartEmulator.sh +++ b/vsts/StartEmulator.sh @@ -22,8 +22,20 @@ echo "List AVDs:" $EMU -list-avds # Start emulator in background and with no UI (-no-window), as we're only running database tests. -nohup $EMU -avd ${NAME_EMU} -no-window -no-snapshot -no-audio -no-boot-anim > /dev/null 2>&1 & +# +# -dns-server is set explicitly because the emulator otherwise resolves through its own DNS proxy, which forwards to +# whatever resolvers the host agent happens to have. On the hosted agents that has proven unreliable: lookups of the +# test hub and provisioning service hostnames intermittently come back as +# java.net.UnknownHostException: Unable to resolve host "...": No address associated with hostname +# for some tests while other tests in the same run resolve the same hostname successfully. Pointing the guest at fixed +# public resolvers takes the host's resolver configuration out of the picture. +nohup $EMU -avd ${NAME_EMU} -no-window -no-snapshot -no-audio -no-boot-anim -dns-server 8.8.8.8,8.8.4.4 > /dev/null 2>&1 & $ADB wait-for-device $ADB shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done; input keyevent 82' -$ADB devices \ No newline at end of file +$ADB devices + +# Logged so that a DNS failure later in the run can be told apart from an emulator that never had working name +# resolution to begin with. Does not fail the task; the tests report their own failures. +echo "Checking name resolution from inside the emulator:" +$ADB shell ping -c 1 -W 5 azure-devices-provisioning.net || echo "WARNING: emulator could not resolve azure-devices-provisioning.net" \ No newline at end of file From 6dfc1a33783834655c8b5a6ce9e1b6694f29a2da Mon Sep 17 00:00:00 2001 From: Copilot <223556219+Copilot@users.noreply.github.com> Date: Tue, 25 Aug 2026 21:50:41 +0000 Subject: [PATCH 2/2] Judge the post-boot check on resolution only, not on ping's exit status ping also fails when ICMP is not allowed out, which is common and harmless on these agents, so its exit status cannot stand in for a DNS verdict. Inspect the output for the resolution failure signatures instead, and say explicitly when a ping failure was reachability rather than name resolution. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- vsts/StartEmulator.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/vsts/StartEmulator.sh b/vsts/StartEmulator.sh index d32989e2e6..5bf14d0fca 100644 --- a/vsts/StartEmulator.sh +++ b/vsts/StartEmulator.sh @@ -37,5 +37,19 @@ $ADB devices # Logged so that a DNS failure later in the run can be told apart from an emulator that never had working name # resolution to begin with. Does not fail the task; the tests report their own failures. +# +# ping's exit status is not used to judge DNS, because it also fails when ICMP is simply not allowed out, which is +# common and harmless here. Only the resolution step is inspected: ping prints the resolved address when the lookup +# succeeded, and reports an unknown host or bad address when it did not. echo "Checking name resolution from inside the emulator:" -$ADB shell ping -c 1 -W 5 azure-devices-provisioning.net || echo "WARNING: emulator could not resolve azure-devices-provisioning.net" \ No newline at end of file +resolutionOutput=$($ADB shell ping -c 1 -W 5 azure-devices-provisioning.net 2>&1) +echo "${resolutionOutput}" + +case "${resolutionOutput}" in + *"unknown host"*|*"bad address"*|*"Name or service not known"*|*"Temporary failure in name resolution"*) + echo "WARNING: emulator could not resolve azure-devices-provisioning.net. Name resolution is broken in the guest." + ;; + *) + echo "Name resolution succeeded. Any ping failure above is ICMP reachability, not DNS." + ;; +esac \ No newline at end of file