fastlane-plugin-automated_test_emulator_run 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fastlane/plugin/automated_test_emulator_run/actions/automated_test_emulator_run_action.rb +168 -99
- data/lib/fastlane/plugin/automated_test_emulator_run/factory/adb_controller_factory.rb +1 -1
- data/lib/fastlane/plugin/automated_test_emulator_run/provider/avd_setup_provider.rb +5 -5
- data/lib/fastlane/plugin/automated_test_emulator_run/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eb526613eca13ae8ef9235ae150146a2016d3a0
|
4
|
+
data.tar.gz: e22231a66a5fe51dbf336a5caf80be1685727cf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a60cafaef152b7380478860eaad74c412cf2bc792d7c649c984d04c4772aa670bed0f500f7de85e86d0934802b6da2be002a1f4fc7fa50a62563594747dbd5f
|
7
|
+
data.tar.gz: eddb81d99cb8b79512d900e785adc3c6a0027dda1d88b593309879a2306aebae038afe46209ff4dcb3bff8994e416cbe338ba96498afec99004eca1169d6fb6f
|
data/lib/fastlane/plugin/automated_test_emulator_run/actions/automated_test_emulator_run_action.rb
CHANGED
@@ -16,9 +16,8 @@ module Fastlane
|
|
16
16
|
avd_controllers = []
|
17
17
|
|
18
18
|
# Create AVD_Controller class for each AVD_scheme
|
19
|
-
for i in 0
|
20
|
-
|
21
|
-
avd_controller = Factory::AvdControllerFactory.get_avd_controller(params, avd_scheme)
|
19
|
+
for i in 0...avd_schemes.length
|
20
|
+
avd_controller = Factory::AvdControllerFactory.get_avd_controller(params, avd_schemes[i])
|
22
21
|
avd_controllers << avd_controller
|
23
22
|
end
|
24
23
|
|
@@ -28,23 +27,31 @@ module Fastlane
|
|
28
27
|
|
29
28
|
# Preparation
|
30
29
|
UI.message("Configuring environment in order to launch emulators: ".yellow)
|
31
|
-
|
32
30
|
UI.message("Getting avaliable AVDs".yellow)
|
33
31
|
devices = Action.sh(adb_controller.command_get_avds)
|
34
32
|
|
35
|
-
for i in 0
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
for i in 0...avd_schemes.length
|
34
|
+
unless devices.match(avd_schemes[i].avd_name).nil?
|
35
|
+
UI.message(["AVD with name '", avd_schemes[i].avd_name, " 'currently exists."].join("").yellow)
|
36
|
+
if params[:AVD_recreate_new]
|
37
|
+
# Delete existing AVDs
|
38
|
+
UI.message("AVD_create_new parameter set to true.".yellow)
|
39
|
+
UI.message(["Deleting existing AVD with name:", avd_schemes[i].avd_name].join(" ").yellow)
|
40
|
+
Action.sh(avd_controllers[i].command_delete_avd)
|
41
|
+
|
42
|
+
# Re-create AVD
|
43
|
+
UI.message(["Re-creating new AVD."].join(" ").yellow)
|
44
|
+
Action.sh(avd_controllers[i].command_create_avd)
|
45
|
+
else
|
46
|
+
# Use existing AVD
|
47
|
+
UI.message("AVD_recreate_new parameter set to false.".yellow)
|
48
|
+
UI.message("Using existing AVD for tests.".yellow)
|
49
|
+
end
|
50
|
+
else
|
51
|
+
# Create AVD
|
52
|
+
UI.message(["AVD with name '", avd_schemes[i].avd_name, "' does not exist. Creating new AVD."].join("").yellow)
|
53
|
+
Action.sh(avd_controllers[i].command_create_avd)
|
43
54
|
end
|
44
|
-
|
45
|
-
# Re-create deleted AVDs
|
46
|
-
UI.message("Creating new AVD".yellow)
|
47
|
-
Action.sh(avd_controller.command_create_avd)
|
48
55
|
end
|
49
56
|
|
50
57
|
# Restart ADB
|
@@ -53,46 +60,43 @@ module Fastlane
|
|
53
60
|
Action.sh(adb_controller.command_start)
|
54
61
|
|
55
62
|
# Applying custom configs (it's not done directly after create because 'cat' operation seems to fail overwrite)
|
56
|
-
for i in 0
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
UI.message(["Attemting to apply custom config to ", avd_scheme.avd_name].join("").yellow)
|
61
|
-
if avd_controller.command_apply_config_avd.eql? ""
|
62
|
-
UI.message(["No config file found for AVD '", avd_scheme.avd_name, "'. AVD won't have config.ini applied."].join("").yellow)
|
63
|
+
for i in 0...avd_schemes.length
|
64
|
+
UI.message(["Attemting to apply custom config to ", avd_schemes[i].avd_name].join("").yellow)
|
65
|
+
if avd_controllers[i].command_apply_config_avd.eql? ""
|
66
|
+
UI.message(["No config file found for AVD '", avd_schemes[i].avd_name, "'. AVD won't have config.ini applied."].join("").yellow)
|
63
67
|
else
|
64
|
-
UI.message(["Config file found! Applying custom config to: ",
|
65
|
-
Action.sh(
|
68
|
+
UI.message(["Config file found! Applying custom config to: ", avd_schemes[i].avd_name].join("").yellow)
|
69
|
+
Action.sh(avd_controllers[i].command_apply_config_avd)
|
66
70
|
end
|
67
71
|
end
|
68
72
|
|
69
73
|
# Launching AVDs
|
70
|
-
UI.message("Launching all AVDs at the same time".yellow)
|
71
|
-
for i in 0
|
72
|
-
|
73
|
-
avd_controller = avd_controllers[i]
|
74
|
-
|
75
|
-
Action.sh(avd_controller.command_start_avd)
|
74
|
+
UI.message("Launching all AVDs at the same time.".yellow)
|
75
|
+
for i in 0...avd_controllers.length
|
76
|
+
Action.sh(avd_controllers[i].command_start_avd)
|
76
77
|
end
|
77
78
|
|
78
79
|
# Wait for AVDs finish booting
|
79
|
-
UI.message("Waiting for AVDs to finish booting".yellow)
|
80
|
+
UI.message("Waiting for AVDs to finish booting.".yellow)
|
80
81
|
boot_status = []
|
81
|
-
for i in 0
|
82
|
+
for i in 0...avd_schemes.length
|
82
83
|
boot_status << false
|
83
84
|
end
|
84
85
|
|
85
|
-
UI.message("
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
all_avd_launched =
|
93
|
-
|
86
|
+
UI.message("Performig wait for ADB boot".yellow)
|
87
|
+
all_avd_launched = wait_for_emulator_boot_by_adb(adb_controller, avd_schemes, "#{params[:AVD_adb_launch_timeout]}")
|
88
|
+
|
89
|
+
if all_avd_launched
|
90
|
+
UI.message("Wait for ADB boot completed with success".yellow)
|
91
|
+
UI.message("Performing wait for params: dev.bootcomplete, sys.boot_completed, init.svc.bootanim.".yellow)
|
92
|
+
for i in 0...avd_schemes.length
|
93
|
+
all_avd_launched = wait_for_emulator_boot_by_params(adb_controller, avd_controllers[i], "#{params[:AVD_param_launch_timeout]}")
|
94
|
+
unless all_avd_launched
|
95
|
+
break
|
96
|
+
end
|
94
97
|
end
|
95
|
-
|
98
|
+
else
|
99
|
+
UI.message("Wait for ADB boot failed".yellow)
|
96
100
|
end
|
97
101
|
|
98
102
|
# Deciding if AVD launch should be restarted
|
@@ -100,17 +104,12 @@ module Fastlane
|
|
100
104
|
if all_avd_launched
|
101
105
|
UI.message("AVDs Booted!".green)
|
102
106
|
else
|
103
|
-
for i in 0
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
# Kill all emulators
|
108
|
-
if !devices.match(["emulator-", avd_scheme.launch_avd_port].join("")).nil?
|
109
|
-
Action.sh(avd_controller.command_kill_device)
|
107
|
+
for i in 0...avd_schemes.length
|
108
|
+
unless devices.match(["emulator-", avd_schemes[i].launch_avd_port].join("")).nil?
|
109
|
+
Action.sh(avd_controllers[i].command_kill_device)
|
110
110
|
end
|
111
111
|
end
|
112
112
|
end
|
113
|
-
|
114
113
|
end
|
115
114
|
|
116
115
|
# Launching tests
|
@@ -122,33 +121,85 @@ module Fastlane
|
|
122
121
|
UI.message("Starting tests".green)
|
123
122
|
begin
|
124
123
|
unless shell_task.nil?
|
125
|
-
UI.message("Using shell task".green)
|
124
|
+
UI.message("Using shell task.".green)
|
126
125
|
Action.sh(shell_task)
|
127
126
|
end
|
128
127
|
|
129
128
|
unless gradle_task.nil?
|
130
|
-
UI.message("Using gradle task".green)
|
129
|
+
UI.message("Using gradle task.".green)
|
131
130
|
gradle.trigger(task: params[:gradle_task], flags: params[:gradle_flags], serial: nil)
|
132
131
|
end
|
133
132
|
ensure
|
134
133
|
# Clean up
|
135
|
-
for i in 0
|
136
|
-
avd_scheme = avd_schemes[i]
|
137
|
-
avd_controller = avd_controllers[i]
|
138
|
-
|
134
|
+
for i in 0...avd_schemes.length
|
139
135
|
# Kill all emulators
|
140
|
-
|
141
|
-
Action.sh(
|
136
|
+
unless devices.match(["emulator-", avd_schemes[i].launch_avd_port].join("")).nil?
|
137
|
+
Action.sh(avd_controllers[i].command_kill_device)
|
142
138
|
end
|
143
139
|
|
144
140
|
# Delete AVDs
|
145
|
-
|
141
|
+
if params[:AVD_clean_after]
|
142
|
+
UI.message("AVD_clean_after param set to true. Deleting AVDs.".green)
|
143
|
+
Action.sh(avd_controllers[i].command_delete_avd)
|
144
|
+
else
|
145
|
+
UI.message("AVD_clean_after param set to false. Created AVDs won't be deleted.".green)
|
146
|
+
end
|
146
147
|
end
|
147
148
|
end
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.wait_for_emulator_boot_by_adb(adb_controller, avd_schemes, timeout)
|
152
|
+
timeoutInSeconds= timeout.to_i
|
153
|
+
startTime = Time.now
|
154
|
+
|
155
|
+
launch_status_hash = Hash.new
|
156
|
+
device_visibility_hash = Hash.new
|
157
|
+
|
158
|
+
for i in 0...avd_schemes.length
|
159
|
+
device_name = ["emulator-", avd_schemes[i].launch_avd_port].join("")
|
160
|
+
launch_status_hash.store(device_name, false)
|
161
|
+
device_visibility_hash.store(device_name, false)
|
162
|
+
end
|
163
|
+
|
164
|
+
launch_status = false
|
165
|
+
loop do
|
166
|
+
currentTime = Time.now
|
167
|
+
devices = Action.sh(adb_controller.command_get_devices)
|
148
168
|
|
169
|
+
# Check if device is visible
|
170
|
+
all_devices_visible = true
|
171
|
+
device_visibility_hash.each do |name, is_visible|
|
172
|
+
unless (devices.match(name).nil? || is_visible)
|
173
|
+
device_visibility_hash[name] = true
|
174
|
+
end
|
175
|
+
all_devices_visible = false unless is_visible
|
176
|
+
end
|
177
|
+
|
178
|
+
# Check if device is booted
|
179
|
+
all_devices_booted = true
|
180
|
+
launch_status_hash.each do |name, is_booted|
|
181
|
+
unless (devices.match(name + " device").nil? || is_booted)
|
182
|
+
launch_status_hash[name] = true
|
183
|
+
end
|
184
|
+
all_devices_booted = false unless is_booted
|
185
|
+
end
|
186
|
+
|
187
|
+
if ((currentTime - startTime) >= timeoutInSeconds)
|
188
|
+
UI.message(["AVD ADB loading took more than ", timeout, ". Attempting to re-launch."].join("").red)
|
189
|
+
launch_status = false
|
190
|
+
break
|
191
|
+
end
|
192
|
+
|
193
|
+
if (all_devices_booted && all_devices_visible)
|
194
|
+
launch_status = true
|
195
|
+
break
|
196
|
+
end
|
197
|
+
sleep(10)
|
198
|
+
end
|
199
|
+
return launch_status
|
149
200
|
end
|
150
201
|
|
151
|
-
def self.
|
202
|
+
def self.wait_for_emulator_boot_by_params(adb_controller, avd_controller, timeout)
|
152
203
|
timeoutInSeconds= timeout.to_i
|
153
204
|
startTime = Time.now
|
154
205
|
|
@@ -160,7 +211,7 @@ module Fastlane
|
|
160
211
|
currentTime = Time.now
|
161
212
|
|
162
213
|
if (currentTime - startTime) >= timeoutInSeconds
|
163
|
-
UI.message("AVD loading took more than
|
214
|
+
UI.message(["AVD param loading took more than ", timeout, ". Attempting to re-launch."].join("").red)
|
164
215
|
launch_status = false
|
165
216
|
break
|
166
217
|
end
|
@@ -177,49 +228,67 @@ module Fastlane
|
|
177
228
|
[
|
178
229
|
#paths
|
179
230
|
FastlaneCore::ConfigItem.new(key: :AVD_path,
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
231
|
+
env_name: "AVD_PATH",
|
232
|
+
description: "The path to your android AVD directory (root). HOME/.android/avd by default",
|
233
|
+
is_string: true,
|
234
|
+
default_value: ENV['HOME'] + '/.android/avd',
|
235
|
+
optional: true),
|
185
236
|
FastlaneCore::ConfigItem.new(key: :AVD_setup_path,
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
237
|
+
env_name: "AVD_SETUP_PATH",
|
238
|
+
description: "Location to AVD_setup.json file which contains info about how many AVD should be launched and their configs",
|
239
|
+
is_string: true,
|
240
|
+
optional: false),
|
190
241
|
FastlaneCore::ConfigItem.new(key: :SDK_path,
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
242
|
+
env_name: "SDK_PATH",
|
243
|
+
description: "The path to your android sdk directory (root). ANDROID_HOME by default",
|
244
|
+
is_string: true,
|
245
|
+
default_value: ENV['ANDROID_HOME'],
|
246
|
+
optional: true),
|
247
|
+
|
248
|
+
|
249
|
+
#emulator re-launch config params
|
250
|
+
FastlaneCore::ConfigItem.new(key: :AVD_param_launch_timeout,
|
251
|
+
env_name: "AVD_PARAM_LAUNCH_TIMEOUT",
|
252
|
+
description: "Timeout in seconds. Even though ADB might find all devices you still might want to wait for animations to finish and system to boot. Default 60 seconds",
|
253
|
+
is_string: true,
|
254
|
+
default_value: 60,
|
255
|
+
optional: true),
|
256
|
+
FastlaneCore::ConfigItem.new(key: :AVD_adb_launch_timeout,
|
257
|
+
env_name: "AVD_ADB_LAUNCH_TIMEOUT",
|
258
|
+
description: "Timeout in seconds. Wait until ADB finds all devices specified in config and sets their value to 'device'. Default 240 seconds",
|
259
|
+
is_string: true,
|
260
|
+
default_value: 240,
|
261
|
+
optional: true),
|
262
|
+
FastlaneCore::ConfigItem.new(key: :AVD_recreate_new,
|
263
|
+
env_name: "AVD_RECREATE_NEW",
|
264
|
+
description: "Allow to decide if AVDs from AVD_setup.json (in case they already exist) should be deleted and created from scratch",
|
265
|
+
default_value: true,
|
266
|
+
optional: true),
|
267
|
+
FastlaneCore::ConfigItem.new(key: :AVD_clean_after,
|
268
|
+
env_name: "AVD_CLEAN_AFTER",
|
269
|
+
description: "Allow to decide if AVDs should be deleted from PC after test session ends",
|
270
|
+
default_value: true,
|
271
|
+
optional: true),
|
272
|
+
|
204
273
|
#launch commands
|
205
274
|
FastlaneCore::ConfigItem.new(key: :shell_task,
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
275
|
+
env_name: "SHELL_TASK",
|
276
|
+
description: "The shell command you want to execute",
|
277
|
+
is_string: true,
|
278
|
+
conflicting_options: [:gradle_task],
|
279
|
+
optional: true),
|
211
280
|
FastlaneCore::ConfigItem.new(key: :gradle_task,
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
281
|
+
env_name: "GRADLE_TASK",
|
282
|
+
description: "The gradle task you want to execute",
|
283
|
+
is_string: true,
|
284
|
+
conflicting_options: [:shell_command],
|
285
|
+
optional: true),
|
217
286
|
FastlaneCore::ConfigItem.new(key: :gradle_flags,
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
287
|
+
env_name: "GRADLE_FLAGS",
|
288
|
+
description: "All parameter flags you want to pass to the gradle command, e.g. `--exitcode --xml file.xml`",
|
289
|
+
optional: true,
|
290
|
+
conflicting_options: [:shell_command],
|
291
|
+
is_string: true),
|
223
292
|
]
|
224
293
|
end
|
225
294
|
|
@@ -18,7 +18,7 @@ module Fastlane
|
|
18
18
|
# ADB shell command parts
|
19
19
|
sh_stop_adb = "kill-server"
|
20
20
|
sh_start_adb = "start-server"
|
21
|
-
sh_devices_adb = "devices"
|
21
|
+
sh_devices_adb = "devices | grep [0-9] | tr -s \"\t\" \" | cut -d\""
|
22
22
|
sh_wait_for_device_adb = "wait-for-device"
|
23
23
|
sh_list_avd_adb = "list avd"
|
24
24
|
|
@@ -22,7 +22,7 @@ module Fastlane
|
|
22
22
|
|
23
23
|
# Create AVD_scheme objects and fill them with data
|
24
24
|
avd_scheme_list = []
|
25
|
-
for i in 0
|
25
|
+
for i in 0...avd_hash_list.length
|
26
26
|
avd_hash = avd_hash_list[i]
|
27
27
|
|
28
28
|
avd_scheme = AVD_scheme.new
|
@@ -50,7 +50,7 @@ module Fastlane
|
|
50
50
|
avaliable_ports = get_unused_even_tcp_ports(5556, 5586, avd_scheme_list)
|
51
51
|
|
52
52
|
# Fill empty AVD_schemes with open ports
|
53
|
-
for i in 0
|
53
|
+
for i in 0...avd_scheme_list.length
|
54
54
|
avd_scheme = avd_scheme_list[i]
|
55
55
|
if avd_scheme.launch_avd_port.eql? ""
|
56
56
|
avd_scheme.launch_avd_port = avaliable_ports[0]
|
@@ -74,7 +74,7 @@ module Fastlane
|
|
74
74
|
reserved_ports = []
|
75
75
|
|
76
76
|
# Gather ports requested in JSON config
|
77
|
-
for i in 0
|
77
|
+
for i in 0...avd_scheme_list.length
|
78
78
|
avd_scheme = avd_scheme_list[i]
|
79
79
|
unless avd_scheme.launch_avd_port.eql? ""
|
80
80
|
reserved_ports << avd_scheme.launch_avd_port
|
@@ -83,13 +83,13 @@ module Fastlane
|
|
83
83
|
|
84
84
|
# Find next open port which wasn't reserved in JSON config
|
85
85
|
port = min_port
|
86
|
-
for i in 0
|
86
|
+
for i in 0...avd_scheme_list.length
|
87
87
|
|
88
88
|
while port < max_port do
|
89
89
|
if !system("lsof -i:#{port}", out: '/dev/null')
|
90
90
|
|
91
91
|
is_port_reserved = false
|
92
|
-
for j in 0
|
92
|
+
for j in 0...reserved_ports.length
|
93
93
|
if reserved_ports[j].eql?(port.to_s)
|
94
94
|
is_port_reserved = true
|
95
95
|
break
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-automated_test_emulator_run
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kamil Krzyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|