Skip to content

Commit 8c1155c

Browse files
committed
Other files sync
1 parent 8519621 commit 8c1155c

File tree

32 files changed

+1100
-99
lines changed

32 files changed

+1100
-99
lines changed

docker-compose-test.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,26 @@ services:
55
image: mongo:6.0.10
66
hostname: mongo1
77
container_name: mongo1
8-
entrypoint: ["mongod", "--replSet", "myReplicaSet", "--bind_ip", "localhost,mongo1"]
8+
entrypoint:
9+
["mongod", "--replSet", "myReplicaSet", "--bind_ip", "localhost,mongo1"]
910
networks:
1011
default:
1112
ipv4_address: 172.88.0.2
1213
mongo2:
1314
image: mongo:6.0.10
1415
hostname: mongo2
1516
container_name: mongo2
16-
entrypoint: ["mongod", "--replSet", "myReplicaSet", "--bind_ip", "localhost,mongo2"]
17+
entrypoint:
18+
["mongod", "--replSet", "myReplicaSet", "--bind_ip", "localhost,mongo2"]
1719
networks:
1820
default:
1921
ipv4_address: 172.88.0.3
2022
mongo3:
2123
image: mongo:6.0.10
2224
hostname: mongo3
2325
container_name: mongo3
24-
entrypoint: ["mongod", "--replSet", "myReplicaSet", "--bind_ip", "localhost,mongo3"]
26+
entrypoint:
27+
["mongod", "--replSet", "myReplicaSet", "--bind_ip", "localhost,mongo3"]
2528
networks:
2629
default:
2730
ipv4_address: 172.88.0.4
@@ -34,7 +37,7 @@ services:
3437
volumes:
3538
- ./scripts/mongo_setup.sh:/scripts/mongo_setup.sh
3639
restart: "no"
37-
entrypoint: [ "bash", "/scripts/mongo_setup.sh"]
40+
entrypoint: ["bash", "/scripts/mongo_setup.sh"]
3841
adb:
3942
container_name: adb
4043
image: devicefarmer/adb:latest

lib/cli/device/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ export const builder = function(yargs) {
179179
, demand: true
180180
, default: '127.0.0.1'
181181
})
182+
.option('url-without-adb-port', {
183+
describe: 'If there isnt adbPort in DB use baseUrl.'
184+
, type: 'boolean'
185+
, default: true
186+
})
182187
}
183188
export const handler = function(argv) {
184189
return device({
@@ -214,5 +219,6 @@ export const handler = function(argv) {
214219
, needScrcpy: argv.needScrcpy
215220
, deviceName: argv.deviceName
216221
, host: argv.host
217-
})
222+
, urlWithoutAdbPort: argv.urlWithoutAdbPort
223+
})
218224
}

lib/cli/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import * as authSaml2 from './auth-saml2/index.js'
1717
import * as groupsEngine from './groups-engine/index.js'
1818
import * as device from './device/index.js'
1919
import * as iosDevice from './ios-device/index.js'
20+
import * as vncDevice from './vnc-device/index.js'
2021
import * as doctor from './doctor/index.js'
2122
import * as generateFakeDevice from './generate-fake-device/index.js'
2223
import * as generateFakeUser from './generate-fake-user/index.js'
@@ -49,6 +50,7 @@ yargs(hideBin(process.argv)).usage('Usage: $0 <command> [options]')
4950
.command(groupsEngine)
5051
.command(device)
5152
.command(iosDevice)
53+
.command(vncDevice)
5254
.command(doctor)
5355
.command(generateFakeDevice)
5456
.command(generateFakeUser)

lib/cli/ios-device/run-wda.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
# Example to run WDA with pymobiledevice3
3+
4+
echo "This script is a mere example. Please do not run it without modifications"
5+
read -p "Press enter to continue"
6+
7+
set -o pipefail
8+
9+
cd "$(git rev-parse --show-toplevel)" || exit
10+
11+
12+
if [ -n "$1" ]; then
13+
deviceId=$1
14+
else
15+
deviceId=$(idb list-targets | grep "device" | awk -F '|' '{ gsub(/ /, "", $0); print $2 }' | head -1)
16+
fi
17+
18+
trap exit EXIT
19+
20+
deviceName=$(idb list-targets | grep "$deviceId" | awk -F '|' '{ gsub(/ $/, "", $0); print $1 }' | head -1)
21+
echo "Using device $deviceId ($deviceName)" >&2
22+
pushd WebDriverAgent || exit
23+
xcodebuild \
24+
-project WebDriverAgent.xcodeproj \
25+
-scheme WebDriverAgentRunner \
26+
-destination "id=$deviceId" \
27+
build
28+
29+
xcodebuild \
30+
-project WebDriverAgent.xcodeproj \
31+
-scheme WebDriverAgentRunner \
32+
-destination "id=$deviceId" \
33+
test &
34+
wdapid=$!
35+
36+
source /path/to/pymobiledevice3/venv
37+
pymobiledevice3 usbmux forward 9100 9100 &
38+
mjpegpid=$!
39+
pymobiledevice3 usbmux forward 8100 8100 &
40+
wdaproxypic=$!
41+
42+
function exit() {
43+
kill $wdapid
44+
kill $mjpegpid
45+
kill $wdaproxypic
46+
wait
47+
}
48+
49+
read -p "Press enter to continue"
50+
51+
MONGODB_PORT_27017_TCP=mongodburl stf ios-device \
52+
--serial "$deviceId" \
53+
--device-name "$deviceName" \
54+
--host localhost \
55+
--screen-port 18000 \
56+
--mjpeg-port 9100 \
57+
--provider providerName \
58+
--public-ip localhost \
59+
--screen-ws-url-pattern "wss://accessibleurlforfrontend/ios-device/18000/" \
60+
--storage-url http://storageurl/ \
61+
--connect-sub "tcp://ip:22003" \
62+
--connect-push "tcp://ip:22005" \
63+
--connect-app-dealer tcp://ip:22001 \
64+
--connect-dev-dealer tcp://ip:22004 \
65+
--wda-host 127.0.0.1 \
66+
--wda-port 8100
67+

lib/cli/ios-device/start-ios.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
stf ios-device \
3+
--serial ios-device \
4+
--device-name "ios device" \
5+
--host localhost \
6+
--screen-port 7409 \
7+
--mjpeg-port 9100 \
8+
--provider local-provider \
9+
--public-ip localhost \
10+
--screen-ws-url-pattern "ws://localhost:7409" \
11+
--storage-url http://localhost:7100/ \
12+
--connect-sub tcp://127.0.0.1:7114 \
13+
--connect-push tcp://127.0.0.1:7116 \
14+
--connect-app-dealer tcp://127.0.0.1:7112 \
15+
--connect-dev-dealer tcp://127.0.0.1:7115 \
16+
--wda-host 127.0.0.1 \
17+
--wda-port 8100

lib/cli/local/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ export const builder = function(yargs) {
301301
.option('websocket-url', {
302302
describe: 'Publicly accessible URL to the websocket unit.'
303303
, type: 'string'
304+
})
305+
.option('url-without-adb-port', {
306+
describe: 'If there isnt adbPort in DB use baseUrl.'
307+
, type: 'boolean'
308+
, default: true
304309
})
305310
.epilog('Each option can be be overwritten with an environment variable ' +
306311
'by converting the option to uppercase, replacing dashes with ' +
@@ -360,7 +365,8 @@ export const handler = function(argv) {
360365
, '--mute-master', argv.muteMaster
361366
, '--need-scrcpy', argv.needScrcpy
362367
, '--screen-ws-url-pattern', argv.screenWsUrlPattern
363-
]
368+
, '--url-without-adb-port', argv.urlWithoutAdbPort
369+
]
364370
.concat(argv.allowRemote ? ['--allow-remote'] : [])
365371
.concat(argv.lockRotation ? ['--lock-rotation'] : [])
366372
.concat(!argv.cleanup ? ['--no-cleanup'] : [])

lib/cli/provider/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ export const builder = function(yargs) {
194194
, demand: true
195195
, default: '127.0.0.1'
196196
})
197+
.option('url-without-adb-port', {
198+
describe: 'If there isnt adbPort in DB use baseUrl.'
199+
, type: 'boolean'
200+
, default: true
201+
})
197202
.epilog('Each option can be be overwritten with an environment variable ' +
198203
'by converting the option to uppercase, replacing dashes with ' +
199204
'underscores and prefixing it with `STF_PROVIDER_` (e.g. ' +
@@ -242,7 +247,8 @@ export const handler = function(argv) {
242247
, '--mute-master', argv.muteMaster
243248
, '--need-scrcpy', argv.needScrcpy
244249
, '--host', argv.host
245-
]
250+
, '--url-without-adb-port', argv.urlWithoutAdbPort
251+
]
246252
.concat(argv.connectSub.reduce(function(all, val) {
247253
return all.concat(['--connect-sub', val])
248254
}, []))

lib/cli/vnc-device/example

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
stf vnc-device \
2+
--serial vnc-device \
3+
--device-name "Generic VNC" \
4+
--host localhost \
5+
--screen-port 7409 \
6+
--vnc-port 5900 \
7+
--provider local-provider \
8+
--public-ip localhost \
9+
--screen-ws-url-pattern "ws://localhost:7409" \
10+
--storage-url http://localhost:7100/ \
11+
--connect-sub tcp://127.0.0.1:7114 \
12+
--connect-push tcp://127.0.0.1:7116 \
13+
--connect-app-dealer tcp://127.0.0.1:7112 \
14+
--connect-dev-dealer tcp://127.0.0.1:7115 \

lib/cli/vnc-device/index.js

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
import vncDevice from '../../units/vnc-device/index.js'
2+
export const command = 'vnc-device'
3+
4+
export const describe = 'Start an vnc device provider.'
5+
6+
7+
export function builder(yargs) {
8+
return yargs
9+
.strict()
10+
.option('connect-push', {
11+
alias: 'p'
12+
, describe: 'ZeroMQ PULL endpoint to connect to.'
13+
, array: true
14+
, demand: true
15+
})
16+
.option('connect-sub', {
17+
alias: 's'
18+
, describe: 'ZeroMQ PUB endpoint to connect to.'
19+
, array: true
20+
, demand: true
21+
})
22+
.option('connect-url-pattern', {
23+
describe: 'The URL pattern to use for `adb connect`.'
24+
, type: 'string'
25+
, default: '${publicIp}:${publicPort}'
26+
})
27+
.option('group-timeout', {
28+
alias: 't'
29+
, describe: 'Timeout in seconds for automatic release of inactive devices.'
30+
, type: 'number'
31+
, default: 900
32+
})
33+
.option('heartbeat-interval', {
34+
describe: 'Send interval in milliseconds for heartbeat messages.'
35+
, type: 'number'
36+
, default: 10000
37+
})
38+
.option('lock-rotation', {
39+
describe: 'Whether to lock rotation when devices are being used. ' +
40+
'Otherwise changing device orientation may not always work due to ' +
41+
'sensitive sensors quickly or immediately reverting it back to the ' +
42+
'physical orientation.'
43+
, type: 'boolean'
44+
})
45+
.option('provider', {
46+
alias: 'n'
47+
, describe: 'Name of the provider.'
48+
, type: 'string'
49+
, demand: true
50+
})
51+
.option('public-ip', {
52+
describe: 'The IP or hostname to use in URLs.'
53+
, type: 'string'
54+
, demand: true
55+
})
56+
.option('screen-jpeg-quality', {
57+
describe: 'The JPG quality to use for the screen.'
58+
, type: 'number'
59+
, default: process.env.SCREEN_JPEG_QUALITY || 80
60+
})
61+
.option('screen-ping-interval', {
62+
describe: 'The interval at which to send ping messages to keep the ' +
63+
'screen WebSocket alive.'
64+
, type: 'number'
65+
, default: 30000
66+
})
67+
.option('screen-port', {
68+
describe: 'Port allocated to the screen WebSocket.'
69+
, type: 'number'
70+
, demand: true
71+
})
72+
.option('screen-ws-url-pattern', {
73+
describe: 'The URL pattern to use for the screen WebSocket.'
74+
, type: 'string'
75+
, default: 'ws://${publicIp}:${publicPort}'
76+
})
77+
.option('serial', {
78+
describe: 'The USB serial number of the device.'
79+
, type: 'string'
80+
, demand: true
81+
})
82+
.option('storage-url', {
83+
alias: 'r'
84+
, describe: 'The URL to the storage unit.'
85+
, type: 'string'
86+
, demand: true
87+
})
88+
.option('connect-app-dealer', {
89+
describe: 'App-side ZeroMQ DEALER endpoint to connect to.'
90+
, array: true
91+
, demand: true
92+
})
93+
.option('connect-dev-dealer', {
94+
describe: 'Device-side ZeroMQ DEALER endpoint to connect to.'
95+
, array: true
96+
, demand: true
97+
})
98+
.option('vnc-port', {
99+
describe: 'The port where vnc is started.'
100+
, type: 'number'
101+
, default: 9001
102+
, demand: true
103+
})
104+
.option('device-url', {
105+
describe: 'url for device'
106+
, type: 'string'
107+
, default: '127.0.0.1'
108+
, demand: true
109+
})
110+
.option('device-name', {
111+
describe: 'Device name'
112+
, type: 'string'
113+
, default: 'Generic VNC Device'
114+
})
115+
.option('device-os', {
116+
describe: 'Device os'
117+
, type: 'string'
118+
, default: 'VNC Device'
119+
})
120+
.option('device-password', {
121+
describe: 'device password'
122+
, type: 'string'
123+
, default: 'Password'
124+
})
125+
.option('device-type', {
126+
describe: 'device type'
127+
, type: 'string'
128+
, default: 'VNC'
129+
})
130+
.option('host', {
131+
describe: 'Provider hostname.'
132+
, type: 'string'
133+
, demand: true
134+
, default: '127.0.0.1'
135+
})
136+
}
137+
138+
export function handler(argv) {
139+
return vncDevice({
140+
serial: argv.serial
141+
, provider: argv.provider
142+
, publicIp: argv.publicIp
143+
, endpoints: {
144+
sub: argv.connectSub
145+
, push: argv.connectPush
146+
, appDealer: argv.connectAppDealer
147+
, devDealer: argv.connectDevDealer
148+
}
149+
, groupTimeout: argv.groupTimeout * 1000 // change to ms
150+
, storageUrl: argv.storageUrl
151+
, screenJpegQuality: argv.screenJpegQuality
152+
, screenPingInterval: argv.screenPingInterval
153+
, screenPort: argv.screenPort
154+
, screenWsUrlPattern: argv.screenWsUrlPattern
155+
, connectUrlPattern: argv.connectUrlPattern
156+
, mjpegPort: argv.vncPort
157+
, deviceUrl: argv.deviceUrl
158+
, deviceOs: argv.deviceOs
159+
, devicePassword: argv.devicePassword
160+
, deviceType: argv.deviceType
161+
, heartbeatInterval: argv.heartbeatInterval
162+
, lockRotation: argv.lockRotation
163+
, cleanup: argv.cleanup
164+
, screenReset: argv.screenReset
165+
, deviceName: argv.deviceName
166+
, host: argv.host
167+
})
168+
}
169+
export default {
170+
command
171+
, describe
172+
, builder
173+
, handler
174+
}

0 commit comments

Comments
 (0)