Skip to content

Commit

Permalink
Fix nested interval when updating devices from node. (#902)
Browse files Browse the repository at this point in the history
* Remove nested setInterval. My previous PR has nested setInterval calls to update node devices.
* Aligning the values (5 minutes) for interval check on: node-availabilities (remove stale devices), update-device (sending node devices to hub), and release-blocked-devices.
* Ignore session filter and use udid instead when checking/releasing blocked devices. It will solely depends onlastCmdExecutedAt.
* Catch error when sending device updates to hub. The callers have never aware of the potential failure.
* Add test for releasing blocked device based onlastCmdExecutedAt
* Renames some methods to reduce ambiguity. E.g.: checkNodeServerAvailability to setupCronCheckNodesAvailability
  • Loading branch information
afathonih authored Dec 7, 2023
1 parent f56fc36 commit 183871d
Show file tree
Hide file tree
Showing 44 changed files with 49,126 additions and 20,097 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
'prettier/prettier': ['error', { singleQuote: true }],
quotes: ['error', 'single'],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
},
settings: {
'import/resolver': {
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ lib/
local_appium_home/
.nyc_output/
site
appium-e2e-test
temp-appium
.env
64 changes: 42 additions & 22 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ jobs:
- script: |
$ANDROID_HOME/platform-tools/adb devices
echo '---'
nohup $ANDROID_HOME/emulator/emulator -avd test_android_emulator -no-snapshot > /dev/null 2>&1 & $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
nohup $ANDROID_HOME/emulator/emulator -avd test_android_emulator -no-snapshot > /dev/null 2>&1 & $ANDROID_HOME/platform-tools/adb wait-for-any-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
echo '---'
echo '---'
nohup $ANDROID_HOME/emulator/emulator -avd test_android_emulator1 -no-snapshot > /dev/null 2>&1 & $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
nohup $ANDROID_HOME/emulator/emulator -avd test_android_emulator1 -no-snapshot > /dev/null 2>&1 & $ANDROID_HOME/platform-tools/adb wait-for-any-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
echo '---'
$ANDROID_HOME/platform-tools/adb devices
displayName: "start Android emulator"
Expand All @@ -68,12 +68,41 @@ jobs:

- script: |
npm ci
export APPIUM_HOME=/tmp/device-farm
./node_modules/.bin/appium plugin install --source=local .
nohup ./node_modules/.bin/appium server -ka 800 --use-plugins=device-farm -pa /wd/hub --config=./server-config.json &
npm run test-e2e
displayName: 'E2E Test'
- job: E2EHubAndNodeTest
pool:
vmImage: 'macOS-latest'

steps:
- task: [email protected]
inputs:
versionSpec: '16.x'

- bash: |
echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-27;google_apis;x86'
displayName: "install Android image"
- script: |
$ANDROID_HOME/emulator/emulator -list-avds
echo '---'
echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n test_android_emulator -k 'system-images;android-27;google_apis;x86' --force
echo '---'
$ANDROID_HOME/emulator/emulator -list-avds
displayName: "create AVD"
- script: |
$ANDROID_HOME/platform-tools/adb devices
echo '---'
nohup $ANDROID_HOME/emulator/emulator -avd test_android_emulator -no-snapshot > /dev/null 2>&1 & $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done; input keyevent 82'
echo '---'
$ANDROID_HOME/platform-tools/adb devices
displayName: "start Android emulator"
- script: |
npm ci
npm run test-e2e-hubnode
displayName: 'E2E Hub and Node Test'
- job: E2EPluginBrowserStackTest
pool:
vmImage: 'macOS-latest'
Expand All @@ -85,9 +114,7 @@ jobs:

- script: |
npm ci
export APPIUM_HOME=/tmp/device-farm
./node_modules/.bin/appium plugin install --source=local .
nohup ./node_modules/.bin/appium server -ka 800 --use-plugins=device-farm -pa /wd/hub --config=./serverConfig/bs-config.json &
npm run test-e2e-browserstack
displayName: 'E2E Test'
Expand All @@ -102,10 +129,8 @@ jobs:

- script: |
npm ci
export APPIUM_HOME=/tmp/device-farm
./node_modules/.bin/appium plugin install --source=local .
nohup ./node_modules/.bin/appium server -ka 800 --use-plugins=device-farm -pa /wd/hub --config=./serverConfig/pcloudy-config.json &
npm run test-e2e-pCloudy
npm run test-e2e-pcloudy
displayName: 'E2E Test'
- job: BrowserStack_mac
Expand All @@ -119,11 +144,10 @@ jobs:

- script: |
npm ci
export APPIUM_HOME=/tmp/device-farm
export CLOUD_USERNAME=$BS_USERNAME
export CLOUD_KEY=$BS_PASSWORD
./node_modules/.bin/appium plugin install --source=local .
nohup ./node_modules/.bin/appium server -ka 800 --use-plugins=device-farm -pa /wd/hub --config=./serverConfig/bs-config.json &
npm run test-parallel-bs
displayName: 'E2E Test'
Expand All @@ -138,11 +162,9 @@ jobs:

- script: |
npm ci
export APPIUM_HOME=/tmp/device-farm
export CLOUD_USERNAME=$BS_USERNAME
export CLOUD_KEY=$BS_PASSWORD
./node_modules/.bin/appium plugin install --source=local .
nohup ./node_modules/.bin/appium server -ka 800 --use-plugins=device-farm -pa /wd/hub --config=./serverConfig/bs-config.json &
npm run test-parallel-ios-bs
displayName: 'E2E Test BS Linux'
Expand Down Expand Up @@ -174,10 +196,8 @@ jobs:

- script: |
npm ci
export APPIUM_HOME=/tmp/device-farm
export CLOUD_USERNAME=$LT_USERNAME
export CLOUD_KEY=$LT_PASSWORD
./node_modules/.bin/appium plugin install --source=local .
nohup ./node_modules/.bin/appium server -ka 800 --use-plugins=device-farm -pa /wd/hub --config=./serverConfig/lt-config.json &
npm run test-parallel-lt
displayName: 'E2E Test'
displayName: 'E2E Test'
8 changes: 7 additions & 1 deletion docs/server-args.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ These arguments are set when you launch the Appium server with device-farm plugi
| `--plugin-device-farm-derived-data-path` | No | DriveDataPath of WDA to speed iOS test run. | None | `{'simulator': 'PathtoDrivedDataPath', 'device': 'PathtoDrivedDataPath'}` |
| `--plugin-device-farm-adb-remote` | No | ADB Remote host and port as array | None | `["remoteMachine1IP:adbPort", "remoteMachine2IP:adbPort"]` |
| `--plugin-device-farm-proxy-ip` | No | For remote execution if the node machine is behing proxy | None | `http://remoteMachineProxyIP:proxyPort`, For example: 'https://10.x.x.x:3333' |
| `--plugin-device-farm-emulators` | No | The name of Android emulator to run the test on. The names of currently installed emulators could be listed using avdmanager list avd command. If the emulator with the given name is not running then it is going to be launched on automated session startup. | None | [{"avdName": "device1, launchTimeout: 200000 }] [Refer to Emulator (Android Virtual Device)]() |
| `--plugin-device-farm-emulators` | No | The name of Android emulator to run the test on. The names of currently installed emulators could be listed using avdmanager list avd command. If the emulator with the given name is not running then it is going to be launched on automated session startup. | None | `[{"avdName": "device1, launchTimeout: 200000 }]` [Refer to Emulator (Android Virtual Device)]() |
| `--plugin-device-availability-timeout-ms` | No | Hub only. How long to wait for free device before giving up (in milliseconds) | `300000` | e.g.: `300000` ms (5 minutes) |
| `--plugin-device-availability-query-interval-ms` | No | Hub only. How often to check for free device (in milliseconds) | `10000` | e.g.: `10000` ms|
| `--plugin-send-node-devices-to-hub-interval-ms` | No | Node only. How often to send list of local device to hub (in milliseconds). This event is an addition to real-time event when device get plugged or unplugged (in milliseconds)| `10000` | e.g.: `10000` ms |
| `--plugin-check-stale-devices-interval-ms` | No | Hub only. How often to check device staleness (in milliseconds). Node(s) may go down without notice. | `10000` | e.g.: `10000` ms |
| `--plugin-check-blocked-devices-interval-ms` | No | Hub only. How often to check device block status (in milliseconds). Sessions may be terminated without notice. | `10000` | e.g.: `10000` ms|
| `--plugin-new-command-timeout-sec` | No | Hub only. When last received command is older than this value (in seconds), device is considered no longer in session and will be unblocked. | `60` | e.g.: `60` seconds |

### Emulator (Android Virtual Device)

Expand Down
Loading

0 comments on commit 183871d

Please sign in to comment.