Skip to content

Commit fdbe471

Browse files
Riccardo Cipolleschifacebook-github-bot
authored andcommitted
fix: Make WebSocketTests work in CI (#33721)
Summary: This PR reestablish the WebSocketTest in CI which is making the `test_ios_unit` fail. **Note:** the test_ios_unit is actually running integration tests... ## Changelog [iOS] [Changed] - Fix the test_ios_unit test Pull Request resolved: #33721 Test Plan: The CI of this PR is green. 😬 Reviewed By: cortinico Differential Revision: D36002823 Pulled By: cipolleschi fbshipit-source-id: 20eeb08bfd02658ad6579085241f81654f74c1af
1 parent eb2a83b commit fdbe471

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ jobs:
432432
# -------------------------
433433
# JOBS: iOS Unit Tests
434434
# -------------------------
435-
test_ios_unit:
435+
test_ios:
436436
executor: reactnativeios
437437
parameters:
438438
use_frameworks:
@@ -1237,16 +1237,16 @@ workflows:
12371237
- build_npm_package
12381238
- test_ios_rntester
12391239
- build_ios
1240-
- test_ios_unit:
1240+
- test_ios:
12411241
run_unit_tests: true
12421242
requires:
12431243
- build_ios
12441244
# DISABLED: USE_FRAMEWORKS=1 not supported by Flipper
12451245
# - build_ios:
12461246
# name: build_ios_frameworks
12471247
# use_frameworks: true
1248-
# - test_ios_unit:
1249-
# name: test_ios_unit_frameworks
1248+
# - test_ios:
1249+
# name: test_ios_frameworks
12501250
# use_frameworks: true
12511251
# run_unit_tests: true
12521252
# requires:
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
#!/bin/bash
2-
32
# Copyright (c) Meta Platforms, Inc. and affiliates.
43
#
54
# This source code is licensed under the MIT license found in the
65
# LICENSE file in the root directory of this source tree.
76

8-
# Set terminal title
9-
echo -en "\033]0;Web Socket Test Server\a"
10-
clear
11-
127
THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
13-
pushd "$THIS_DIR"
8+
pushd "$THIS_DIR" || exit
149
./websocket_integration_test_server.js
15-
popd
10+
popd || exit
1611

17-
echo "Process terminated. Press <enter> to close the window"
18-
read
12+
echo "Process terminated."

scripts/objc-test.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,24 @@ waitForPackager() {
5555
echo "Packager is ready!"
5656
}
5757

58+
waitForWebSocketServer() {
59+
local -i max_attempts=60
60+
local -i attempt_num=1
61+
62+
until curl -s http://localhost:5555 | grep "Upgrade Required" -q; do
63+
if (( attempt_num == max_attempts )); then
64+
echo "WebSocket Server did not respond in time. No more attempts left."
65+
exit 1
66+
else
67+
(( attempt_num++ ))
68+
echo "WebSocket Server did not respond. Retrying for attempt number $attempt_num..."
69+
sleep 1
70+
fi
71+
done
72+
73+
echo "WebSocket Server is ready!"
74+
}
75+
5876
runTests() {
5977
# shellcheck disable=SC1091
6078
source "./scripts/.tests.env"
@@ -102,11 +120,13 @@ main() {
102120
# Otherwise, just build RNTester and exit
103121
if [ "$1" = "test" ]; then
104122

105-
# Start the packager
106-
yarn start --max-workers=1 || echo "Can't start packager automatically" &
107123
# Start the WebSocket test server
108-
open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically"
124+
echo "Launch WebSocket Server"
125+
sh "./IntegrationTests/launchWebSocketServer.sh" &
126+
waitForWebSocketServer
109127

128+
# Start the packager
129+
yarn start --max-workers=1 || echo "Can't start packager automatically" &
110130
waitForPackager
111131
preloadBundles
112132

0 commit comments

Comments
 (0)