apophis 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/apophis/appium_runner.rb +52 -50
- data/lib/apophis/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: 50f56e95831b8061ce7ae629bc4af6ce64202fd9
|
4
|
+
data.tar.gz: 73ccf637b6adb5ea926e3f7663f5e010935d4caf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 464d5cb83823c08880ac0e66570e4c4ec55d0a303426f060cf55500a6895aae5bc94c41bef55e838bfd23b239a9b0308d9da8744d01a3059faa5a0e1e6027c1a
|
7
|
+
data.tar.gz: c787e49d56d4fe0c89cce2215deca4c0c7b017b325c8bc40b3179a6fdc482723b7339793e673ea4a543c5da9a44c15beb8954b5f070d19e49e343f0ebe7b33e1
|
@@ -1,71 +1,73 @@
|
|
1
1
|
require 'open-uri'
|
2
2
|
|
3
|
-
|
3
|
+
module Apophis
|
4
|
+
class AppiumRunner
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def doctor!
|
7
|
+
errors = []
|
8
|
+
errors << "No valid appium install, or not available to this environment." unless system('appium -v > /dev/null')
|
9
|
+
errors << "No valid unix tooling: lsof" unless system('lsof -v > /dev/null 2>&1')
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
raise errors.join("\n") unless errors.empty?
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
def any?
|
15
|
+
appiums.size > 0
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
def available?(port)
|
19
|
+
return false unless port
|
20
|
+
!!find(port)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
def kill_and_wait(port, timeout=10)
|
24
|
+
DottyTimeout.timeout(timeout) do
|
25
|
+
kill(port)
|
26
|
+
!available?(port)
|
27
|
+
end
|
26
28
|
end
|
27
|
-
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
def kill(port)
|
31
|
+
app = find(port)
|
32
|
+
return unless app
|
33
|
+
Process.kill('KILL', app[:pid])
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def find(port)
|
37
|
+
appiums.find{|app| app[:url] =~ /:#{port}/}
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
40
|
+
def launch_and_wait(port=nil, timeout=20)
|
41
|
+
port = port || find_available_port(4500)
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
#we'll use the env variable later to locate this process (`ps -p <PID> -wwwE`)
|
44
|
+
Process.spawn("APOPHIS_TAG=#{port} appium -p #{port} -bp #{port+1} > /dev/null 2>&1")
|
45
|
+
DottyTimeout.timeout(timeout){ available?(port) }
|
45
46
|
|
46
|
-
|
47
|
-
|
47
|
+
{ port: port }
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
def probe(candidate)
|
51
|
+
begin
|
52
|
+
Timeout.timeout(0.5) do
|
53
|
+
res = JSON.parse(open("#{ candidate }/status").read)
|
54
|
+
!!res["value"]
|
55
|
+
end
|
56
|
+
rescue Exception => _
|
57
|
+
false
|
54
58
|
end
|
55
|
-
rescue Exception => _
|
56
|
-
false
|
57
59
|
end
|
58
|
-
end
|
59
60
|
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
def find_available_port(above)
|
62
|
+
Selenium::WebDriver::PortProber.above(above)
|
63
|
+
end
|
63
64
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
def appiums
|
66
|
+
`lsof -P -n -i -sTCP:LISTEN`.lines.map(&:chomp) \
|
67
|
+
.map{|ln| ln =~ /\D+\s(\d+)\s.*TCP\s+(.*):(\d+)\s+\(LISTEN\)/; { pid: $1.to_i, url: "http://#{$2}:#{$3}/wd/hub".sub('*', 'localhost')} }
|
68
|
+
.select{|app| app[:pid] > 0}
|
69
|
+
.select{|app| probe(app[:url])}
|
70
|
+
end
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
data/lib/apophis/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apophis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dotan Nahum
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appium_lib
|