Skip to content

Commit f0deccb

Browse files
committed
Further fix
1 parent 73e108f commit f0deccb

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

integration-tests/run_tests_ci.sh

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -755,14 +755,15 @@ if [ -n "$CI" ]; then
755755
sleep 2
756756

757757
# Check current route table and add default route if missing
758+
# NOTE: Android emulator uses 10.0.2.1 as gateway (not 10.0.2.2)
758759
print_info "Checking and fixing routing table..."
759760
if ! adb shell "ip route show" 2>/dev/null | grep -q "default"; then
760-
print_info "No default route found, adding..."
761-
adb shell "ip route add default via 10.0.2.2 dev eth0" 2>/dev/null || true
761+
print_info "No default route found, adding via 10.0.2.1 (emulator gateway)..."
762+
adb shell "ip route add default via 10.0.2.1 dev eth0" 2>/dev/null || true
762763
else
763-
print_info "Default route exists, replacing to use eth0..."
764+
print_info "Default route exists, replacing to use eth0 via 10.0.2.1..."
764765
adb shell "ip route del default" 2>/dev/null || true
765-
adb shell "ip route add default via 10.0.2.2 dev eth0" 2>/dev/null || true
766+
adb shell "ip route add default via 10.0.2.1 dev eth0" 2>/dev/null || true
766767
fi
767768
sleep 2
768769

@@ -776,11 +777,30 @@ if [ -n "$CI" ]; then
776777
adb shell "ip addr show eth0" 2>/dev/null || true
777778
adb shell "ip route show" 2>/dev/null || true
778779

779-
# Verify connectivity to gateway
780-
if adb shell "ping -c 1 -W 2 10.0.2.2" &>/dev/null; then
781-
print_success "Gateway (10.0.2.2) is reachable"
780+
# Verify connectivity to gateway (10.0.2.1 is the emulator's router)
781+
if adb shell "ping -c 1 -W 2 10.0.2.1" &>/dev/null; then
782+
print_success "Gateway (10.0.2.1) is reachable"
783+
784+
# Add default route now that gateway is confirmed reachable
785+
print_info "Adding default route to routing table..."
786+
adb shell "ip route add default via 10.0.2.1 dev eth0 2>&1" || true
787+
sleep 1
788+
789+
# Verify route was added
790+
if adb shell "ip route show" | grep -q "default"; then
791+
print_success "Default route added successfully"
792+
else
793+
print_warning "Failed to add default route"
794+
fi
782795
else
783-
print_warning "Cannot reach gateway - network may not work"
796+
print_warning "Cannot reach gateway (10.0.2.1) - trying fallback 10.0.2.2..."
797+
# Try 10.0.2.2 as fallback (host loopback)
798+
if adb shell "ping -c 1 -W 2 10.0.2.2" &>/dev/null; then
799+
print_success "Host loopback (10.0.2.2) is reachable, using as gateway"
800+
adb shell "ip route add default via 10.0.2.2 dev eth0 2>&1" || true
801+
else
802+
print_warning "Cannot reach any gateway - network may not work"
803+
fi
784804
fi
785805

786806
# Manually set DNS servers if not set
@@ -805,14 +825,23 @@ if [ -n "$CI" ]; then
805825

806826
if [ "$network_ok" = false ]; then
807827
print_warning "Network connectivity check failed after 15 attempts"
808-
print_warning "Attempting network service restart..."
809-
adb shell "svc wifi enable" 2>/dev/null || true
828+
print_warning "Attempting advanced network fixes (keep wlan0 disabled)..."
829+
830+
# Don't re-enable wifi - it conflicts with eth0 routing
831+
# adb shell "svc wifi enable" 2>/dev/null || true
810832
adb shell "svc data enable" 2>/dev/null || true
833+
834+
# Re-verify default route exists
835+
if ! adb shell "ip route show" | grep -q "default"; then
836+
print_warning "Default route missing, re-adding via 10.0.2.1..."
837+
adb shell "ip route add default via 10.0.2.1 dev eth0" 2>/dev/null || true
838+
fi
839+
811840
sleep 5
812841

813842
# One final retry
814843
if adb shell "ping -c 1 -W 3 8.8.8.8" &>/dev/null; then
815-
print_success "Network OK after service restart"
844+
print_success "Network OK after fixes"
816845
network_ok=true
817846
else
818847
print_warning "Network connectivity check failed - continuing anyway"

0 commit comments

Comments
 (0)