Skip to content

Commit

Permalink
fix: Make WebSocketTests work in CI (#33721)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Riccardo Cipolleschi authored and facebook-github-bot committed Apr 28, 2022
1 parent eb2a83b commit fdbe471
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ jobs:
# -------------------------
# JOBS: iOS Unit Tests
# -------------------------
test_ios_unit:
test_ios:
executor: reactnativeios
parameters:
use_frameworks:
Expand Down Expand Up @@ -1237,16 +1237,16 @@ workflows:
- build_npm_package
- test_ios_rntester
- build_ios
- test_ios_unit:
- test_ios:
run_unit_tests: true
requires:
- build_ios
# DISABLED: USE_FRAMEWORKS=1 not supported by Flipper
# - build_ios:
# name: build_ios_frameworks
# use_frameworks: true
# - test_ios_unit:
# name: test_ios_unit_frameworks
# - test_ios:
# name: test_ios_frameworks
# use_frameworks: true
# run_unit_tests: true
# requires:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
#!/bin/bash

# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# Set terminal title
echo -en "\033]0;Web Socket Test Server\a"
clear

THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd)
pushd "$THIS_DIR"
pushd "$THIS_DIR" || exit
./websocket_integration_test_server.js
popd
popd || exit

echo "Process terminated. Press <enter> to close the window"
read
echo "Process terminated."
26 changes: 23 additions & 3 deletions scripts/objc-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,24 @@ waitForPackager() {
echo "Packager is ready!"
}

waitForWebSocketServer() {
local -i max_attempts=60
local -i attempt_num=1

until curl -s http://localhost:5555 | grep "Upgrade Required" -q; do
if (( attempt_num == max_attempts )); then
echo "WebSocket Server did not respond in time. No more attempts left."
exit 1
else
(( attempt_num++ ))
echo "WebSocket Server did not respond. Retrying for attempt number $attempt_num..."
sleep 1
fi
done

echo "WebSocket Server is ready!"
}

runTests() {
# shellcheck disable=SC1091
source "./scripts/.tests.env"
Expand Down Expand Up @@ -102,11 +120,13 @@ main() {
# Otherwise, just build RNTester and exit
if [ "$1" = "test" ]; then

# Start the packager
yarn start --max-workers=1 || echo "Can't start packager automatically" &
# Start the WebSocket test server
open "./IntegrationTests/launchWebSocketServer.command" || echo "Can't start web socket server automatically"
echo "Launch WebSocket Server"
sh "./IntegrationTests/launchWebSocketServer.sh" &
waitForWebSocketServer

# Start the packager
yarn start --max-workers=1 || echo "Can't start packager automatically" &
waitForPackager
preloadBundles

Expand Down

0 comments on commit fdbe471

Please sign in to comment.