@@ -8,9 +8,10 @@ RETRY_DELAY=10
88
99# Timeout for the Maestro driver (instrumentation) to come up. Maestro's default is 15s;
1010# CI emulators/simulators are slower, but 5 min (300000) was the per-attempt multiplier that
11- # amplified broken-build runs to ~25 min. 2 min is generous for the driver to start while
12- # keeping the worst-case failure time bounded.
13- MAESTRO_DRIVER_STARTUP_TIMEOUT=120000
11+ # amplified broken-build runs to ~25 min. 3 min balances driver startup on loaded CI runners
12+ # (macos-26 with 4 parallel shards) while still failing fast on genuinely broken builds.
13+ # Override via env var if needed: export MAESTRO_DRIVER_STARTUP_TIMEOUT=240000
14+ MAESTRO_DRIVER_STARTUP_TIMEOUT=" ${MAESTRO_DRIVER_STARTUP_TIMEOUT:- 180000} "
1415
1516# --- Per-flow video recording (BrowserStack-style debugging) ----------------------------
1617# We record a screen video around every flow, then KEEP it only if the flow FAILS and DELETE
@@ -78,9 +79,24 @@ stop_recording() {
7879 REC_FILE=" "
7980}
8081
82+ # Function to clean up stale XCTest processes (iOS only)
83+ cleanup_xctest_processes () {
84+ if [ " $PLATFORM " != " ios" ]; then
85+ return 0
86+ fi
87+ echo " 🧹 Cleaning up stale XCTest processes..."
88+ # Kill any leftover XCTest runner processes that might be blocking driver initialization
89+ pkill -9 -f " XCTRunner" 2> /dev/null || true
90+ pkill -9 -f " xctest" 2> /dev/null || true
91+ pkill -9 -f " maestro.*driver" 2> /dev/null || true
92+ sleep 2
93+ }
94+
8195# Function to restart the iOS simulator
8296restart_simulator () {
8397 echo " 🔄 Restarting iOS Simulator..."
98+ # Clean up XCTest processes first
99+ cleanup_xctest_processes
84100 # Shut down whatever is booted; the device is auto-selected in prepare_ios.sh,
85101 # so we don't depend on a hardcoded device name here.
86102 xcrun simctl shutdown all || true
@@ -135,6 +151,28 @@ ensure_emulator_ready() {
135151 done
136152}
137153
154+ # Function to verify Mendix runtime is responding (Android only - uses adb reverse)
155+ verify_runtime_ready () {
156+ if [ " $PLATFORM " != " android" ]; then
157+ return 0 # iOS doesn't need this check - runtime is on localhost
158+ fi
159+ local max_attempts=5 # Reduced from 10 since we're checking from host side
160+ local attempt=1
161+ echo " Verifying Mendix runtime connectivity..."
162+ while [ " $attempt " -le " $max_attempts " ]; do
163+ # Check from host side (runner) - if host can reach it, the adb reverse tunnel will work
164+ if curl -fsS -o /dev/null --max-time 2 " http://localhost:8080/" 2> /dev/null; then
165+ echo " ✅ Runtime is reachable (attempt $attempt )"
166+ return 0
167+ fi
168+ echo " Runtime not ready yet (attempt $attempt /$max_attempts ), waiting..."
169+ sleep 2
170+ attempt=$(( attempt + 1 ))
171+ done
172+ echo " ⚠️ Runtime verification timed out - proceeding anyway (app will handle connection errors)"
173+ return 0 # Don't fail hard - let the app/smoke check handle it
174+ }
175+
138176# Function to run tests
139177run_tests () {
140178 local test_files=(" $@ " )
@@ -177,6 +215,7 @@ smoke_check() {
177215 if [ " $PLATFORM " == " android" ]; then
178216 ensure_emulator_ready
179217 set_status_bar
218+ verify_runtime_ready # Ensure runtime is reachable before launching app
180219 fi
181220 start_recording " smoke-attempt-$attempt "
182221 if $HOME /.local/bin/maestro/bin/maestro test --env APP_ID=$APP_ID --env PLATFORM=$PLATFORM --env MAESTRO_DRIVER_STARTUP_TIMEOUT=$MAESTRO_DRIVER_STARTUP_TIMEOUT " $script_dir /Smoke.yaml" ; then
0 commit comments