nonnative 1.9.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/Gemfile.lock +18 -19
- data/lib/nonnative.rb +11 -2
- data/lib/nonnative/application.rb +10 -0
- data/lib/nonnative/command.rb +38 -13
- data/lib/nonnative/grpc_server.rb +10 -4
- data/lib/nonnative/http_client.rb +14 -0
- data/lib/nonnative/http_server.rb +19 -9
- data/lib/nonnative/pool.rb +1 -1
- data/lib/nonnative/server.rb +19 -12
- data/lib/nonnative/service.rb +15 -0
- data/lib/nonnative/startup.rb +2 -2
- data/lib/nonnative/version.rb +1 -1
- data/nonnative.gemspec +1 -1
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3d063b72e79c07612ef45de94f2b318c59d600be60823a3b72b97e14b819863
|
4
|
+
data.tar.gz: e49d9d93bd0657896c7fb1abba459ca59c6c8fc3e59b409fe9c231b20f77cf34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d12d87e1f2681fc8e9fef1eecb5b55d81eb773b1845ffb22ab094c17cd9d73bced1874ee277e11c024ca82d66d9f7c4c9d49f6f3827052f06d0ce3bdc86f1f5
|
7
|
+
data.tar.gz: 6436da5c0393b9842881722a50f23e80f3264c0a36006e9aeb8402b26910645e875313b430da8df9bd2ba02b5ff08bce576cc74f590a8b5707f6454a27ca83b4
|
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
nonnative (1.
|
4
|
+
nonnative (1.14.0)
|
5
5
|
cucumber (~> 3.1, >= 3.1.2)
|
6
6
|
grpc (~> 1.28)
|
7
7
|
puma (~> 4.3, >= 4.3.3)
|
@@ -16,9 +16,9 @@ GEM
|
|
16
16
|
amatch (0.4.0)
|
17
17
|
mize
|
18
18
|
tins (~> 1.0)
|
19
|
-
ast (2.4.
|
19
|
+
ast (2.4.1)
|
20
20
|
backport (1.1.2)
|
21
|
-
backports (3.17.
|
21
|
+
backports (3.17.2)
|
22
22
|
benchmark (0.1.0)
|
23
23
|
benchmark-malloc (0.2.0)
|
24
24
|
benchmark-perf (0.6.0)
|
@@ -31,7 +31,7 @@ GEM
|
|
31
31
|
pastel (~> 0.7)
|
32
32
|
tty-pie (~> 0.3)
|
33
33
|
concurrent-ruby (1.1.6)
|
34
|
-
cucumber (3.
|
34
|
+
cucumber (3.2.0)
|
35
35
|
builder (>= 2.1.2)
|
36
36
|
cucumber-core (~> 3.2.0)
|
37
37
|
cucumber-expressions (~> 6.0.1)
|
@@ -54,7 +54,7 @@ GEM
|
|
54
54
|
e2mmap (0.1.0)
|
55
55
|
equatable (0.6.1)
|
56
56
|
gherkin (5.1.0)
|
57
|
-
google-protobuf (3.
|
57
|
+
google-protobuf (3.12.2)
|
58
58
|
googleapis-common-protos-types (1.0.5)
|
59
59
|
google-protobuf (~> 3.11)
|
60
60
|
grpc (1.28.0)
|
@@ -64,14 +64,14 @@ GEM
|
|
64
64
|
http-accept (1.7.0)
|
65
65
|
http-cookie (1.0.3)
|
66
66
|
domain_name (~> 0.5)
|
67
|
-
i18n (1.8.
|
67
|
+
i18n (1.8.3)
|
68
68
|
concurrent-ruby (~> 1.0)
|
69
69
|
jaro_winkler (1.5.4)
|
70
70
|
json (2.3.0)
|
71
71
|
maruku (0.7.3)
|
72
72
|
mime-types (3.3.1)
|
73
73
|
mime-types-data (~> 3.2015)
|
74
|
-
mime-types-data (3.2020.
|
74
|
+
mime-types-data (3.2020.0512)
|
75
75
|
mini_portile2 (2.4.0)
|
76
76
|
mize (0.4.0)
|
77
77
|
protocol (~> 2.0)
|
@@ -83,17 +83,17 @@ GEM
|
|
83
83
|
nio4r (2.5.2)
|
84
84
|
nokogiri (1.10.9)
|
85
85
|
mini_portile2 (~> 2.4.0)
|
86
|
-
parallel (1.19.
|
87
|
-
parser (2.7.1.
|
86
|
+
parallel (1.19.2)
|
87
|
+
parser (2.7.1.3)
|
88
88
|
ast (~> 2.4.0)
|
89
89
|
pastel (0.7.4)
|
90
90
|
equatable (~> 0.6)
|
91
91
|
tty-color (~> 0.5)
|
92
92
|
protocol (2.0.0)
|
93
93
|
ruby_parser (~> 3.0)
|
94
|
-
puma (4.3.
|
94
|
+
puma (4.3.5)
|
95
95
|
nio4r (~> 2.0)
|
96
|
-
rack (2.2.
|
96
|
+
rack (2.2.3)
|
97
97
|
rack-protection (2.0.8.1)
|
98
98
|
rack
|
99
99
|
rainbow (3.0.0)
|
@@ -103,7 +103,7 @@ GEM
|
|
103
103
|
http-cookie (>= 1.0.2, < 2.0)
|
104
104
|
mime-types (>= 1.16, < 4.0)
|
105
105
|
netrc (~> 0.8)
|
106
|
-
reverse_markdown (
|
106
|
+
reverse_markdown (2.0.0)
|
107
107
|
nokogiri
|
108
108
|
rexml (3.2.4)
|
109
109
|
rspec (3.9.0)
|
@@ -124,8 +124,7 @@ GEM
|
|
124
124
|
diff-lcs (>= 1.2.0, < 2.0)
|
125
125
|
rspec-support (~> 3.9.0)
|
126
126
|
rspec-support (3.9.3)
|
127
|
-
rubocop (0.
|
128
|
-
jaro_winkler (~> 1.5.1)
|
127
|
+
rubocop (0.83.0)
|
129
128
|
parallel (~> 1.10)
|
130
129
|
parser (>= 2.7.0.1)
|
131
130
|
rainbow (>= 2.2.2, < 4.0)
|
@@ -136,7 +135,7 @@ GEM
|
|
136
135
|
ruby2_keywords (0.0.2)
|
137
136
|
ruby_parser (3.14.2)
|
138
137
|
sexp_processor (~> 4.9)
|
139
|
-
sexp_processor (4.
|
138
|
+
sexp_processor (4.15.0)
|
140
139
|
simplecov (0.17.1)
|
141
140
|
docile (~> 1.1)
|
142
141
|
json (>= 1.8, < 3)
|
@@ -147,7 +146,7 @@ GEM
|
|
147
146
|
rack (~> 2.0)
|
148
147
|
rack-protection (= 2.0.8.1)
|
149
148
|
tilt (~> 2.0)
|
150
|
-
solargraph (0.39.
|
149
|
+
solargraph (0.39.8)
|
151
150
|
backport (~> 1.1)
|
152
151
|
benchmark
|
153
152
|
bundler (>= 1.17.2)
|
@@ -156,7 +155,7 @@ GEM
|
|
156
155
|
maruku (~> 0.7, >= 0.7.3)
|
157
156
|
nokogiri (~> 1.9, >= 1.9.1)
|
158
157
|
parser (~> 2.3)
|
159
|
-
reverse_markdown (
|
158
|
+
reverse_markdown (>= 1.0.5, < 3)
|
160
159
|
rubocop (~> 0.52)
|
161
160
|
thor (~> 1.0)
|
162
161
|
tilt (~> 2.0)
|
@@ -164,7 +163,7 @@ GEM
|
|
164
163
|
sync (0.5.0)
|
165
164
|
thor (1.0.1)
|
166
165
|
tilt (2.0.10)
|
167
|
-
tins (1.
|
166
|
+
tins (1.25.0)
|
168
167
|
sync
|
169
168
|
tty-color (0.5.1)
|
170
169
|
tty-cursor (0.7.1)
|
@@ -186,7 +185,7 @@ DEPENDENCIES
|
|
186
185
|
grpc-tools (~> 1.28)
|
187
186
|
nonnative!
|
188
187
|
rake (~> 13.0, >= 13.0.1)
|
189
|
-
rubocop (~> 0.
|
188
|
+
rubocop (~> 0.83.0)
|
190
189
|
simplecov (~> 0.17.1)
|
191
190
|
solargraph (~> 0.39.7)
|
192
191
|
|
data/lib/nonnative.rb
CHANGED
@@ -18,10 +18,12 @@ require 'nonnative/port'
|
|
18
18
|
require 'nonnative/configuration'
|
19
19
|
require 'nonnative/configuration_process'
|
20
20
|
require 'nonnative/configuration_server'
|
21
|
+
require 'nonnative/service'
|
21
22
|
require 'nonnative/command'
|
22
23
|
require 'nonnative/pool'
|
23
24
|
require 'nonnative/server'
|
24
25
|
require 'nonnative/http_client'
|
26
|
+
require 'nonnative/application'
|
25
27
|
require 'nonnative/http_server'
|
26
28
|
require 'nonnative/grpc_server'
|
27
29
|
require 'nonnative/grpc_server'
|
@@ -45,18 +47,25 @@ module Nonnative
|
|
45
47
|
|
46
48
|
def start
|
47
49
|
@pool ||= Nonnative::Pool.new(configuration)
|
50
|
+
errors = []
|
48
51
|
|
49
52
|
@pool.start do |name, id, result|
|
50
|
-
|
53
|
+
errors << "Started #{name} with id #{id}, though did respond in time" unless result
|
51
54
|
end
|
55
|
+
|
56
|
+
raise Nonnative::StartError, errors.join("\n") unless errors.empty?
|
52
57
|
end
|
53
58
|
|
54
59
|
def stop
|
55
60
|
return if @pool.nil?
|
56
61
|
|
62
|
+
errors = []
|
63
|
+
|
57
64
|
@pool.stop do |name, id, result|
|
58
|
-
|
65
|
+
errors << "Stopped #{name} with id #{id}, though did respond in time" unless result
|
59
66
|
end
|
67
|
+
|
68
|
+
raise Nonnative::StopError, errors.join("\n") unless errors.empty?
|
60
69
|
end
|
61
70
|
|
62
71
|
def clear
|
data/lib/nonnative/command.rb
CHANGED
@@ -1,36 +1,61 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nonnative
|
4
|
-
class Command
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
4
|
+
class Command < Nonnative::Service
|
5
|
+
def initialize(service)
|
6
|
+
@service = service
|
7
|
+
@timeout = Nonnative::Timeout.new(service.timeout)
|
8
8
|
end
|
9
9
|
|
10
10
|
def name
|
11
|
-
|
11
|
+
service.command
|
12
12
|
end
|
13
13
|
|
14
14
|
def start
|
15
|
-
unless
|
16
|
-
@pid =
|
17
|
-
|
15
|
+
unless command_exists?
|
16
|
+
@pid = command_spawn
|
17
|
+
wait_start
|
18
18
|
end
|
19
19
|
|
20
20
|
pid
|
21
21
|
end
|
22
22
|
|
23
23
|
def stop
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
if command_exists?
|
25
|
+
command_kill
|
26
|
+
wait_stop
|
27
|
+
end
|
28
28
|
|
29
29
|
pid
|
30
30
|
end
|
31
31
|
|
32
|
+
protected
|
33
|
+
|
34
|
+
def wait_stop
|
35
|
+
timeout.perform do
|
36
|
+
Process.waitpid2(pid)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
32
40
|
private
|
33
41
|
|
34
|
-
attr_reader :
|
42
|
+
attr_reader :service, :timeout, :pid
|
43
|
+
|
44
|
+
def command_kill
|
45
|
+
Process.kill('SIGINT', pid)
|
46
|
+
end
|
47
|
+
|
48
|
+
def command_spawn
|
49
|
+
spawn(service.command, %i[out err] => [service.file, 'a'])
|
50
|
+
end
|
51
|
+
|
52
|
+
def command_exists?
|
53
|
+
return false if pid.nil?
|
54
|
+
|
55
|
+
Process.kill(0, pid)
|
56
|
+
true
|
57
|
+
rescue Errno::ESRCH
|
58
|
+
false
|
59
|
+
end
|
35
60
|
end
|
36
61
|
end
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
module Nonnative
|
4
4
|
class GRPCServer < Nonnative::Server
|
5
|
-
def initialize(
|
5
|
+
def initialize(service)
|
6
6
|
@server = GRPC::RpcServer.new
|
7
7
|
|
8
|
-
server.add_http2_port("0.0.0.0:#{port}", :this_port_is_insecure)
|
8
|
+
server.add_http2_port("0.0.0.0:#{service.port}", :this_port_is_insecure)
|
9
9
|
configure server
|
10
10
|
|
11
|
-
super
|
11
|
+
super service
|
12
12
|
end
|
13
13
|
|
14
14
|
def configure(grpc)
|
@@ -16,13 +16,19 @@ module Nonnative
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def perform_start
|
19
|
-
server.
|
19
|
+
server.run
|
20
20
|
end
|
21
21
|
|
22
22
|
def perform_stop
|
23
23
|
server.stop
|
24
24
|
end
|
25
25
|
|
26
|
+
protected
|
27
|
+
|
28
|
+
def wait_start
|
29
|
+
server.wait_till_running(service.timeout)
|
30
|
+
end
|
31
|
+
|
26
32
|
private
|
27
33
|
|
28
34
|
attr_reader :server
|
@@ -22,6 +22,20 @@ module Nonnative
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def delete(pathname, headers = {})
|
26
|
+
with_exception do
|
27
|
+
uri = URI.join(host, pathname)
|
28
|
+
RestClient.delete(uri.to_s, headers)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def put(pathname, payload, headers = {})
|
33
|
+
with_exception do
|
34
|
+
uri = URI.join(host, pathname)
|
35
|
+
RestClient.put(uri.to_s, payload.to_json, headers)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
25
39
|
private
|
26
40
|
|
27
41
|
attr_reader :host
|
@@ -2,11 +2,14 @@
|
|
2
2
|
|
3
3
|
module Nonnative
|
4
4
|
class HTTPServer < Nonnative::Server
|
5
|
-
def initialize(
|
6
|
-
|
5
|
+
def initialize(service)
|
6
|
+
@timeout = Nonnative::Timeout.new(service.timeout)
|
7
|
+
@queue = Queue.new
|
8
|
+
|
9
|
+
Application.set :port, service.port
|
7
10
|
configure Application
|
8
11
|
|
9
|
-
super
|
12
|
+
super service
|
10
13
|
end
|
11
14
|
|
12
15
|
def configure(http)
|
@@ -14,18 +17,25 @@ module Nonnative
|
|
14
17
|
end
|
15
18
|
|
16
19
|
def perform_start
|
17
|
-
Application.start!
|
20
|
+
Application.start! do |server|
|
21
|
+
queue << server
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
25
|
def perform_stop
|
21
26
|
Application.stop!
|
22
27
|
end
|
23
28
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
protected
|
30
|
+
|
31
|
+
def wait_start
|
32
|
+
timeout.perform do
|
33
|
+
queue.pop
|
34
|
+
end
|
29
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :timeout, :queue
|
30
40
|
end
|
31
41
|
end
|
data/lib/nonnative/pool.rb
CHANGED
data/lib/nonnative/server.rb
CHANGED
@@ -1,14 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nonnative
|
4
|
-
class Server <
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
|
8
|
-
|
9
|
-
super do
|
10
|
-
perform_start
|
11
|
-
end
|
4
|
+
class Server < Nonnative::Service
|
5
|
+
def initialize(service)
|
6
|
+
@service = service
|
7
|
+
@id = SecureRandom.hex(5)
|
12
8
|
end
|
13
9
|
|
14
10
|
def name
|
@@ -16,14 +12,25 @@ module Nonnative
|
|
16
12
|
end
|
17
13
|
|
18
14
|
def start
|
19
|
-
|
15
|
+
unless thread
|
16
|
+
@thread = Thread.new { perform_start }
|
17
|
+
wait_start
|
18
|
+
end
|
19
|
+
|
20
|
+
id
|
20
21
|
end
|
21
22
|
|
22
23
|
def stop
|
23
|
-
|
24
|
-
|
24
|
+
if thread
|
25
|
+
perform_stop
|
26
|
+
thread.terminate
|
27
|
+
@thread = nil
|
28
|
+
wait_stop
|
29
|
+
end
|
30
|
+
|
31
|
+
id
|
25
32
|
end
|
26
33
|
|
27
|
-
attr_reader :
|
34
|
+
attr_reader :service, :id, :thread
|
28
35
|
end
|
29
36
|
end
|
data/lib/nonnative/startup.rb
CHANGED
data/lib/nonnative/version.rb
CHANGED
data/nonnative.gemspec
CHANGED
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency 'chutney', '~> 2.0', '>= 2.0.3.1'
|
37
37
|
spec.add_development_dependency 'grpc-tools', '~> 1.28'
|
38
38
|
spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.1'
|
39
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
39
|
+
spec.add_development_dependency 'rubocop', '~> 0.83.0'
|
40
40
|
spec.add_development_dependency 'simplecov', '~> 0.17.1'
|
41
41
|
spec.add_development_dependency 'solargraph', '~> 0.39.7'
|
42
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nonnative
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Falkowski
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -212,14 +212,14 @@ dependencies:
|
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: 0.
|
215
|
+
version: 0.83.0
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: 0.
|
222
|
+
version: 0.83.0
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: simplecov
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -270,6 +270,7 @@ files:
|
|
270
270
|
- bin/console
|
271
271
|
- bin/setup
|
272
272
|
- lib/nonnative.rb
|
273
|
+
- lib/nonnative/application.rb
|
273
274
|
- lib/nonnative/before.rb
|
274
275
|
- lib/nonnative/command.rb
|
275
276
|
- lib/nonnative/configuration.rb
|
@@ -284,6 +285,7 @@ files:
|
|
284
285
|
- lib/nonnative/pool.rb
|
285
286
|
- lib/nonnative/port.rb
|
286
287
|
- lib/nonnative/server.rb
|
288
|
+
- lib/nonnative/service.rb
|
287
289
|
- lib/nonnative/start_error.rb
|
288
290
|
- lib/nonnative/startup.rb
|
289
291
|
- lib/nonnative/stop_error.rb
|
@@ -295,7 +297,7 @@ homepage: https://github.com/alexfalkowski/nonnative
|
|
295
297
|
licenses:
|
296
298
|
- Unlicense
|
297
299
|
metadata: {}
|
298
|
-
post_install_message:
|
300
|
+
post_install_message:
|
299
301
|
rdoc_options: []
|
300
302
|
require_paths:
|
301
303
|
- lib
|
@@ -311,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
311
313
|
version: '0'
|
312
314
|
requirements: []
|
313
315
|
rubygems_version: 3.0.3
|
314
|
-
signing_key:
|
316
|
+
signing_key:
|
315
317
|
specification_version: 4
|
316
318
|
summary: Allows you to keep using the power of ruby to test other systems
|
317
319
|
test_files: []
|