Repository navigation
fix(e2e): connect the mobile suite to realtime and give dev-server round trips the server budget #8937
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
fix(e2e): connect the mobile suite to realtime and give dev-server round trips the server budget #8937
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,8 @@ server_pid='' | |
| app_tag='' | ||
| server_log='' | ||
| status_log='' | ||
| realtime_pid='' | ||
| realtime_tag='' | ||
|
|
||
| finish() { | ||
| local status=$? | ||
|
|
@@ -39,6 +41,10 @@ finish() { | |
| tail -n 200 "$server_log" | ||
| fi | ||
| fi | ||
| if [ -n "$realtime_pid" ]; then | ||
| bash "$GITHUB_WORKSPACE/.github/scripts/stop-session.sh" "$realtime_pid" "$realtime_tag" || status=1 | ||
| wait "$realtime_pid" 2>/dev/null || true | ||
| fi | ||
| exit "$status" | ||
| } | ||
| trap finish EXIT | ||
|
|
@@ -58,20 +64,38 @@ start_app() { | |
| E2E_APP="$app_tag" setsid node ../../node_modules/next/dist/bin/next dev --hostname 127.0.0.1 \ | ||
| --port "$port" > "$server_log" 2>&1 & | ||
| server_pid=$! | ||
| wait_ready "$server_pid" "$NEXT_PUBLIC_APP_URL/api/health" "$label app" | ||
| } | ||
|
|
||
| # start_realtime <name> <port>: the Socket.IO server the app's browser clients connect to, so pages | ||
| # render connected rather than under a "Reconnecting..." notification. Start after start_app, which | ||
| # exports the app URL the server allows as an origin; NEXT_PUBLIC_SOCKET_URL must already be set | ||
| # when the app starts. | ||
| start_realtime() { | ||
| local name=$1 port=$2 | ||
| realtime_tag="$name-realtime-$GITHUB_RUN_ID-$GITHUB_RUN_ATTEMPT-$$" | ||
| (cd ../realtime && PORT="$port" E2E_APP="$realtime_tag" exec setsid bun run start \ | ||
| > "$report_dir/$name-realtime.log" 2>&1) & | ||
| realtime_pid=$! | ||
| wait_ready "$realtime_pid" "http://127.0.0.1:$port/health" "$name realtime server" | ||
| } | ||
|
|
||
| # wait_ready <pid> <health-url> <label> | ||
| wait_ready() { | ||
| local pid=$1 url=$2 label=$3 | ||
| local started=$SECONDS | ||
| until curl --fail --silent --max-time 10 "$NEXT_PUBLIC_APP_URL/api/health" > /dev/null; do | ||
| if ! kill -0 "$server_pid" 2>/dev/null; then | ||
| echo "::error::Local $label app exited during startup." | ||
| until curl --fail --silent --max-time 10 "$url" > /dev/null; do | ||
| if ! kill -0 "$pid" 2>/dev/null; then | ||
| echo "::error::Local $label exited during startup." | ||
| exit 1 | ||
| fi | ||
| if [ $((SECONDS - started)) -ge "$ready_timeout_seconds" ]; then | ||
| echo "::error::Local $label app did not become ready within $ready_timeout_seconds seconds." | ||
| echo "::error::Local $label did not become ready within $ready_timeout_seconds seconds." | ||
| exit 1 | ||
| fi | ||
| sleep 2 | ||
| done | ||
| echo "Local $label app ready after $((SECONDS - started))s" | ||
| echo "Local $label ready after $((SECONDS - started))s" | ||
| } | ||
|
|
||
| case "$group" in | ||
|
|
@@ -159,8 +183,13 @@ case "$group" in | |
| export NEXT_PUBLIC_FORCE_HOSTED=false | ||
| export INTERNAL_API_SECRET=mobile-http-ci-local-secret-at-least-32-characters | ||
| export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--max-old-space-size=12288" | ||
| bunx --no-install playwright install --with-deps chromium webkit | ||
| export NEXT_PUBLIC_SOCKET_URL=http://127.0.0.1:3025 SOCKET_SERVER_URL=http://127.0.0.1:3025 | ||
| # The browsers install while the app boots. | ||
| bunx --no-install playwright install --with-deps chromium webkit & | ||
| browsers_pid=$! | ||
|
Comment on lines
+188
to
+189
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The browser installer now runs in the background, but |
||
| start_app mobile 3024 'mobile browser' record-http-status | ||
| start_realtime mobile 3025 | ||
| wait "$browsers_pid" | ||
| MOBILE_E2E_BASE_URL="$NEXT_PUBLIC_APP_URL" \ | ||
| MOBILE_E2E_DATABASE_URL="$DATABASE_URL" \ | ||
| MOBILE_E2E_AUTH_SECRET="$BETTER_AUTH_SECRET" \ | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.