fastlane-plugin-automated_test_emulator_run_mik 1.6.14 → 1.6.15.pre.1
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_mik/actions/automated_test_emulator_run_action.rb +35 -14
- data/lib/fastlane/plugin/automated_test_emulator_run_mik/factory/avd_controller_factory.rb +7 -4
- data/lib/fastlane/plugin/automated_test_emulator_run_mik/provider/avd_setup_provider.rb +1 -69
- data/lib/fastlane/plugin/automated_test_emulator_run_mik/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e9cccc5342dd54f5f33b38a34e940407f4c6643
|
4
|
+
data.tar.gz: c2fa469dea9201edcdbcfd5ae8b5293d9a78401d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98d35b11901102cb2d38f003bebbcd7cbfcc91de2d242a14ed8ce1f511fac0934cc941ac2399e0ef882c270540d6213b5d780316874196291798d839c7da3394
|
7
|
+
data.tar.gz: d9edd0cb14b47dc96e9aa58fa4caecb4ac57cf4d58bf378d03fd7e231c25e5807720624d1a3c6cdbfe486cc81e297881e7d8810ea1121920c7858072c400ee96
|
@@ -17,7 +17,10 @@ module Fastlane
|
|
17
17
|
|
18
18
|
# Create AVD_Controller class for each AVD_scheme
|
19
19
|
for i in 0...avd_schemes.length
|
20
|
-
|
20
|
+
port, f_port = generate_free_port()
|
21
|
+
UI.verbose(["Found port:", port].join(" "))
|
22
|
+
|
23
|
+
avd_controller = Factory::AvdControllerFactory.get_avd_controller(params, avd_schemes[i], port, f_port)
|
21
24
|
avd_controllers << avd_controller
|
22
25
|
|
23
26
|
if params[:verbose]
|
@@ -106,7 +109,7 @@ module Fastlane
|
|
106
109
|
# Wait for AVDs finish booting
|
107
110
|
UI.message("Waiting for AVDs to finish booting.".yellow)
|
108
111
|
UI.message("Performing wait for ADB boot".yellow)
|
109
|
-
adb_launch_complete = wait_for_emulator_boot_by_adb(adb_controller,
|
112
|
+
adb_launch_complete = wait_for_emulator_boot_by_adb(adb_controller, avd_controllers, "#{params[:AVD_adb_launch_timeout]}")
|
110
113
|
|
111
114
|
# Wait for AVD params finish booting
|
112
115
|
if adb_launch_complete
|
@@ -154,8 +157,8 @@ module Fastlane
|
|
154
157
|
if all_avd_launched
|
155
158
|
UI.message("AVDs Booted!".green)
|
156
159
|
if params[:logcat]
|
157
|
-
for i in 0...
|
158
|
-
device = ["emulator-",
|
160
|
+
for i in 0...avd_controllers.length
|
161
|
+
device = ["emulator-", avd_controllers[i].port].join('')
|
159
162
|
cmd = [adb_controller.adb_path, '-s', device, 'logcat -c'].join(' ')
|
160
163
|
Action.sh(cmd) unless devices.match(device).nil?
|
161
164
|
end
|
@@ -171,7 +174,7 @@ module Fastlane
|
|
171
174
|
end
|
172
175
|
|
173
176
|
# Killing devices
|
174
|
-
unless devices.match(["emulator-",
|
177
|
+
unless devices.match(["emulator-", avd_controllers[i].port].join("")).nil?
|
175
178
|
Action.sh(avd_controllers[i].command_kill_device)
|
176
179
|
Process.kill("INT", pids[i])
|
177
180
|
Process.wait(pids[i])
|
@@ -193,7 +196,7 @@ module Fastlane
|
|
193
196
|
|
194
197
|
unless gradle_task.nil?
|
195
198
|
gradle = Helper::GradleHelper.new(gradle_path: Dir["./gradlew"].last)
|
196
|
-
serial =
|
199
|
+
serial = avd_controllers.map { |x| "emulator-" + x.port.to_s }.join(",")
|
197
200
|
|
198
201
|
UI.message("Using gradle task.".green)
|
199
202
|
gradle.trigger(task: params[:gradle_task], flags: params[:gradle_flags], serial: serial)
|
@@ -202,7 +205,7 @@ module Fastlane
|
|
202
205
|
# Clean up
|
203
206
|
for i in 0...avd_schemes.length
|
204
207
|
# Kill all emulators
|
205
|
-
device = ["emulator-",
|
208
|
+
device = ["emulator-", avd_controllers[i].port].join("")
|
206
209
|
unless devices.match(device).nil?
|
207
210
|
if params[:logcat]
|
208
211
|
file = [device, '.log'].join('')
|
@@ -237,7 +240,25 @@ module Fastlane
|
|
237
240
|
end
|
238
241
|
end
|
239
242
|
|
240
|
-
def self.
|
243
|
+
def self.generate_free_port()
|
244
|
+
FileUtils.mkdir_p '/tmp/automated_test_emulator_run'
|
245
|
+
for p in (6000..7000).step(2)
|
246
|
+
f = File.open("/tmp/automated_test_emulator_run/#{p}", File::RDWR | File::CREAT)
|
247
|
+
if f.flock(File::LOCK_EX | File::LOCK_NB)
|
248
|
+
return p, f
|
249
|
+
end
|
250
|
+
|
251
|
+
f.close()
|
252
|
+
end
|
253
|
+
|
254
|
+
raise("Error finding free port")
|
255
|
+
end
|
256
|
+
|
257
|
+
def clean_up_port(port, p_file)
|
258
|
+
p_file.flock(File::LOCK_UN)
|
259
|
+
end
|
260
|
+
|
261
|
+
def self.wait_for_emulator_boot_by_adb(adb_controller, avd_controllers, timeout)
|
241
262
|
timeoutInSeconds= timeout.to_i
|
242
263
|
interval = 1000 * 10
|
243
264
|
startTime = Time.now
|
@@ -245,8 +266,8 @@ module Fastlane
|
|
245
266
|
launch_status_hash = Hash.new
|
246
267
|
device_visibility_hash = Hash.new
|
247
268
|
|
248
|
-
for i in 0...
|
249
|
-
device_name = ["emulator-",
|
269
|
+
for i in 0...avd_controllers.length
|
270
|
+
device_name = ["emulator-", avd_controllers[i].port].join("")
|
250
271
|
launch_status_hash.store(device_name, false)
|
251
272
|
device_visibility_hash.store(device_name, false)
|
252
273
|
end
|
@@ -350,7 +371,7 @@ module Fastlane
|
|
350
371
|
device_boot_statuses.store(avd_schema.avd_name, avd_booted)
|
351
372
|
|
352
373
|
# Plotting current wait results
|
353
|
-
device_log = "Device 'emulator-" +
|
374
|
+
device_log = "Device 'emulator-" + avd_controllers[i].port.to_s + "' launch status:"
|
354
375
|
UI.message(device_log.magenta)
|
355
376
|
avd_param_boot_hash.each do |name, is_booted|
|
356
377
|
device_log = "'" + name + "' - '" + avd_param_status_hash[name].strip + "' (launched: " + is_booted.to_s + ")"
|
@@ -421,19 +442,19 @@ module Fastlane
|
|
421
442
|
FastlaneCore::ConfigItem.new(key: :AVD_recreate_new,
|
422
443
|
env_name: "AVD_RECREATE_NEW",
|
423
444
|
description: "Allow to decide if AVDs from AVD_setup.json (in case they already exist) should be deleted and created from scratch",
|
424
|
-
default_value:
|
445
|
+
default_value: false,
|
425
446
|
is_string: false,
|
426
447
|
optional: true),
|
427
448
|
FastlaneCore::ConfigItem.new(key: :AVD_clean_after,
|
428
449
|
env_name: "AVD_CLEAN_AFTER",
|
429
450
|
description: "Allow to decide if AVDs should be deleted from PC after test session ends",
|
430
|
-
default_value:
|
451
|
+
default_value: false,
|
431
452
|
is_string: false,
|
432
453
|
optional: true),
|
433
454
|
FastlaneCore::ConfigItem.new(key: :ADB_restart,
|
434
455
|
env_name: "ADB_RESTART",
|
435
456
|
description: "Allows to switch adb restarting on/off",
|
436
|
-
default_value:
|
457
|
+
default_value: false,
|
437
458
|
is_string: false,
|
438
459
|
optional: true),
|
439
460
|
FastlaneCore::ConfigItem.new(key: :AVD_wait_for_bootcomplete,
|
@@ -5,7 +5,7 @@ module Fastlane
|
|
5
5
|
|
6
6
|
class AVD_Controller
|
7
7
|
attr_accessor :command_install_package, :command_create_avd, :command_start_avd, :command_delete_avd, :command_apply_config_avd, :command_get_property, :command_kill_device,
|
8
|
-
:output_file
|
8
|
+
:output_file, :p_file, :port
|
9
9
|
|
10
10
|
def self.create_output_file(params)
|
11
11
|
output_file = Tempfile.new('emulator_output', '#{params[:AVD_path]}')
|
@@ -14,7 +14,7 @@ module Fastlane
|
|
14
14
|
|
15
15
|
class AvdControllerFactory
|
16
16
|
|
17
|
-
def self.get_avd_controller(params, avd_scheme)
|
17
|
+
def self.get_avd_controller(params, avd_scheme, port, p_file)
|
18
18
|
UI.message(["Preparing parameters and commands for emulator:", avd_scheme.avd_name].join(" ").yellow)
|
19
19
|
|
20
20
|
# Get paths
|
@@ -55,7 +55,7 @@ module Fastlane
|
|
55
55
|
sh_launch_emulator_binary = [path_sdk, "/emulator/", avd_scheme.launch_avd_launch_binary_name].join("")
|
56
56
|
sh_launch_avd_name = ["-avd ", avd_scheme.avd_name].join("")
|
57
57
|
sh_launch_avd_additional_options = avd_scheme.launch_avd_additional_options
|
58
|
-
sh_launch_avd_port = ["-port",
|
58
|
+
sh_launch_avd_port = ["-port", port].join(" ")
|
59
59
|
|
60
60
|
if avd_scheme.launch_avd_snapshot_filepath.eql? ""
|
61
61
|
sh_launch_avd_snapshot = ""
|
@@ -68,12 +68,14 @@ module Fastlane
|
|
68
68
|
|
69
69
|
# ADB related shell command parts
|
70
70
|
sh_specific_device = "-s"
|
71
|
-
sh_device_name_adb = ["emulator-",
|
71
|
+
sh_device_name_adb = ["emulator-", port].join("")
|
72
72
|
sh_get_property = "shell getprop"
|
73
73
|
sh_kill_device = "emu kill"
|
74
74
|
|
75
75
|
# Assemble AVD controller
|
76
76
|
avd_controller = AVD_Controller.new
|
77
|
+
avd_controller.p_file=p_file
|
78
|
+
avd_controller.port=port
|
77
79
|
avd_controller.command_create_avd = [
|
78
80
|
sh_create_answer_no,
|
79
81
|
path_avdmanager_binary,
|
@@ -90,6 +92,7 @@ module Fastlane
|
|
90
92
|
|
91
93
|
avd_controller.command_start_avd = [
|
92
94
|
sh_launch_emulator_binary,
|
95
|
+
"-read-only",
|
93
96
|
sh_launch_avd_port,
|
94
97
|
sh_launch_avd_name,
|
95
98
|
sh_launch_avd_snapshot,
|
@@ -3,7 +3,7 @@ module Fastlane
|
|
3
3
|
|
4
4
|
class AVD_scheme
|
5
5
|
attr_accessor :avd_name, :create_avd_package, :create_avd_device, :create_avd_tag, :create_avd_abi, :create_avd_hardware_config_filepath, :create_avd_additional_options,
|
6
|
-
:
|
6
|
+
:launch_avd_launch_binary_name, :launch_avd_additional_options, :launch_avd_snapshot_filepath
|
7
7
|
end
|
8
8
|
|
9
9
|
class AvdSchemeProvider
|
@@ -34,7 +34,6 @@ module Fastlane
|
|
34
34
|
avd_scheme.create_avd_abi = avd_hash['create_avd_abi']
|
35
35
|
avd_scheme.create_avd_hardware_config_filepath = avd_hash['create_avd_hardware_config_filepath']
|
36
36
|
|
37
|
-
avd_scheme.launch_avd_port = avd_hash['launch_avd_port']
|
38
37
|
avd_scheme.launch_avd_launch_binary_name = avd_hash['launch_avd_launch_binary_name']
|
39
38
|
avd_scheme.launch_avd_additional_options = avd_hash['launch_avd_additional_options']
|
40
39
|
avd_scheme.launch_avd_snapshot_filepath = avd_hash['launch_avd_snapshot_filepath']
|
@@ -48,74 +47,10 @@ module Fastlane
|
|
48
47
|
|
49
48
|
avd_scheme_list << avd_scheme
|
50
49
|
end
|
51
|
-
|
52
|
-
# Prepare list of open ports for AVD_schemes without ports set in JSON
|
53
|
-
avaliable_ports = get_unused_even_tcp_ports(5556, 5586, avd_scheme_list)
|
54
|
-
|
55
|
-
# Fill empty AVD_schemes with open ports
|
56
|
-
for i in 0...avd_scheme_list.length
|
57
|
-
avd_scheme = avd_scheme_list[i]
|
58
|
-
if avd_scheme.launch_avd_port.eql? ""
|
59
|
-
avd_scheme.launch_avd_port = avaliable_ports[0]
|
60
|
-
avaliable_ports.delete(avaliable_ports[0])
|
61
|
-
end
|
62
|
-
end
|
63
50
|
|
64
51
|
return avd_scheme_list
|
65
52
|
end
|
66
53
|
|
67
|
-
def self.get_unused_even_tcp_ports(min_port, max_port, avd_scheme_list)
|
68
|
-
if min_port % 2 != 0
|
69
|
-
min_port += 1
|
70
|
-
end
|
71
|
-
|
72
|
-
if max_port % 2 != 0
|
73
|
-
max_port += 1
|
74
|
-
end
|
75
|
-
|
76
|
-
avaliable_ports = []
|
77
|
-
reserved_ports = []
|
78
|
-
|
79
|
-
# Gather ports requested in JSON config
|
80
|
-
for i in 0...avd_scheme_list.length
|
81
|
-
avd_scheme = avd_scheme_list[i]
|
82
|
-
unless avd_scheme.launch_avd_port.eql? ""
|
83
|
-
reserved_ports << avd_scheme.launch_avd_port
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
# Find next open port which wasn't reserved in JSON config
|
88
|
-
port = min_port
|
89
|
-
for i in 0...avd_scheme_list.length
|
90
|
-
|
91
|
-
while port < max_port do
|
92
|
-
if !system("lsof -i:#{port}", out: '/dev/null')
|
93
|
-
|
94
|
-
is_port_reserved = false
|
95
|
-
for j in 0...reserved_ports.length
|
96
|
-
if reserved_ports[j].eql?(port.to_s)
|
97
|
-
is_port_reserved = true
|
98
|
-
break
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
if is_port_reserved
|
103
|
-
port = port + 2
|
104
|
-
break
|
105
|
-
end
|
106
|
-
|
107
|
-
avaliable_ports << port
|
108
|
-
port = port + 2
|
109
|
-
break
|
110
|
-
else
|
111
|
-
port = port + 2
|
112
|
-
end
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
return avaliable_ports
|
117
|
-
end
|
118
|
-
|
119
54
|
def self.read_avd_setup(params)
|
120
55
|
if File.exists?(File.expand_path("#{params[:AVD_setup_path]}"))
|
121
56
|
file = File.open(File.expand_path("#{params[:AVD_setup_path]}"), "rb")
|
@@ -154,9 +89,6 @@ module Fastlane
|
|
154
89
|
if avd_scheme.launch_avd_launch_binary_name.nil?
|
155
90
|
errors.push("launch_avd_launch_binary_name not found")
|
156
91
|
end
|
157
|
-
if avd_scheme.launch_avd_port.nil?
|
158
|
-
errors.push("launch_avd_port not found")
|
159
|
-
end
|
160
92
|
if avd_scheme.launch_avd_additional_options.nil?
|
161
93
|
errors.push("launch_avd_additional_options not found")
|
162
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-automated_test_emulator_run_mik
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.15.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kamil Krzyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -123,9 +123,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
123
|
version: '0'
|
124
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
125
|
requirements:
|
126
|
-
- - "
|
126
|
+
- - ">"
|
127
127
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
128
|
+
version: 1.3.1
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
131
|
rubygems_version: 2.5.2.3
|