nonnative 1.42.0 → 1.47.0
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/.rubocop.yml +1 -1
- data/CHANGELOG.md +44 -0
- data/Gemfile.lock +10 -10
- data/README.md +69 -20
- data/lib/nonnative.rb +7 -4
- data/lib/nonnative/before.rb +0 -2
- data/lib/nonnative/configuration.rb +77 -71
- data/lib/nonnative/configuration_process.rb +1 -1
- data/lib/nonnative/configuration_runner.rb +1 -1
- data/lib/nonnative/configuration_server.rb +1 -1
- data/lib/nonnative/cucumber.rb +31 -0
- data/lib/nonnative/not_found_error.rb +6 -0
- data/lib/nonnative/pool.rb +10 -6
- data/lib/nonnative/process.rb +11 -2
- data/lib/nonnative/runner.rb +1 -2
- data/lib/nonnative/server.rb +7 -1
- data/lib/nonnative/version.rb +1 -1
- data/nonnative.gemspec +2 -2
- metadata +7 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fadc106377cb9006d00a0a15af09b93e9f63d360737e676595581e0d108a0dbe
|
|
4
|
+
data.tar.gz: 071bc7fc5293f47d425da66c1c98368492c9d62b068645e8d651ebd10562a80b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 32166837748726de12fdcdd5a25202ef2df5f6c6919459a0bbe53f02cb62e96a1469ea9c208734cbb64edbdcb71c653f8d4ebef94a272b47c54a8c1a58a86b50
|
|
7
|
+
data.tar.gz: a2fd4abffbf60b676d793cd42641bf94511dfddb215f5a0988c1c337f96a411b53e89a125d78f879e1ac2594836b75aef725e099eab7ebdf2f4d5337a1165cf4
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.47.0](https://github.com/alexfalkowski/nonnative/compare/v1.46.0...v1.47.0) (2021-05-14)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* allow to pass env variables to processes ([#88](https://github.com/alexfalkowski/nonnative/issues/88)) ([4401a77](https://github.com/alexfalkowski/nonnative/commit/4401a776ccc50dbefa45b06de01945abf4724864))
|
|
11
|
+
|
|
12
|
+
## [1.46.0](https://github.com/alexfalkowski/nonnative/compare/v1.45.0...v1.46.0) (2021-05-10)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add loading config through configure ([#87](https://github.com/alexfalkowski/nonnative/issues/87)) ([a95e8b6](https://github.com/alexfalkowski/nonnative/commit/a95e8b6817380afd732d0aefb170726f905548cb))
|
|
18
|
+
|
|
19
|
+
## [1.45.0](https://github.com/alexfalkowski/nonnative/compare/v1.44.1...v1.45.0) (2021-05-10)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* add loading go command through config ([#86](https://github.com/alexfalkowski/nonnative/issues/86)) ([2f500d3](https://github.com/alexfalkowski/nonnative/commit/2f500d34ef6eb536b223651f84213f4f3d10c496))
|
|
25
|
+
|
|
26
|
+
### [1.44.1](https://github.com/alexfalkowski/nonnative/compare/v1.44.0...v1.44.1) (2021-05-06)
|
|
27
|
+
|
|
28
|
+
## [1.44.0](https://github.com/alexfalkowski/nonnative/compare/v1.43.0...v1.44.0) (2021-05-01)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* move to reusable steps ([#84](https://github.com/alexfalkowski/nonnative/issues/84)) ([37b6175](https://github.com/alexfalkowski/nonnative/commit/37b6175e920dfb70f3d6f13226240dd045c2db3d))
|
|
34
|
+
|
|
35
|
+
## [1.43.0](https://github.com/alexfalkowski/nonnative/compare/v1.42.2...v1.43.0) (2021-04-30)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
### Features
|
|
39
|
+
|
|
40
|
+
* release version 1.43.0 ([#83](https://github.com/alexfalkowski/nonnative/issues/83)) ([b51526d](https://github.com/alexfalkowski/nonnative/commit/b51526d99d24522a26f534d28769cc8cdee4af04))
|
|
41
|
+
|
|
42
|
+
### [1.42.2](https://github.com/alexfalkowski/nonnative/compare/v1.42.1...v1.42.2) (2021-04-30)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
|
|
47
|
+
* make sure we parse services config ([#82](https://github.com/alexfalkowski/nonnative/issues/82)) ([2a52af7](https://github.com/alexfalkowski/nonnative/commit/2a52af74b75443674a2235c424d69f15516ab60f))
|
|
48
|
+
|
|
5
49
|
### [1.42.1](https://github.com/alexfalkowski/nonnative/compare/v1.42.0...v1.42.1) (2021-04-30)
|
|
6
50
|
|
|
7
51
|
## [1.42.0](https://github.com/alexfalkowski/nonnative/compare/v1.41.0...v1.42.0) (2021-04-30)
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
nonnative (1.
|
|
4
|
+
nonnative (1.47.0)
|
|
5
5
|
concurrent-ruby (~> 1.0, >= 1.0.5)
|
|
6
6
|
cucumber (>= 6, < 7)
|
|
7
7
|
grpc (>= 1, < 2)
|
|
@@ -15,7 +15,7 @@ PATH
|
|
|
15
15
|
GEM
|
|
16
16
|
remote: https://rubygems.org/
|
|
17
17
|
specs:
|
|
18
|
-
activesupport (6.1.3.
|
|
18
|
+
activesupport (6.1.3.2)
|
|
19
19
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
20
20
|
i18n (>= 1.6, < 2)
|
|
21
21
|
minitest (>= 5.1)
|
|
@@ -73,7 +73,7 @@ GEM
|
|
|
73
73
|
unf (>= 0.0.5, < 1.0.0)
|
|
74
74
|
e2mmap (0.1.0)
|
|
75
75
|
ffi (1.15.0)
|
|
76
|
-
google-protobuf (3.
|
|
76
|
+
google-protobuf (3.17.0)
|
|
77
77
|
googleapis-common-protos-types (1.0.6)
|
|
78
78
|
google-protobuf (~> 3.14)
|
|
79
79
|
grpc (1.37.1)
|
|
@@ -106,14 +106,14 @@ GEM
|
|
|
106
106
|
mini_portile2 (~> 2.5.0)
|
|
107
107
|
racc (~> 1.4)
|
|
108
108
|
parallel (1.20.1)
|
|
109
|
-
parser (3.0.1.
|
|
109
|
+
parser (3.0.1.1)
|
|
110
110
|
ast (~> 2.4.1)
|
|
111
111
|
protobuf-cucumber (3.10.8)
|
|
112
112
|
activesupport (>= 3.2)
|
|
113
113
|
middleware
|
|
114
114
|
thor
|
|
115
115
|
thread_safe
|
|
116
|
-
puma (5.
|
|
116
|
+
puma (5.3.1)
|
|
117
117
|
nio4r (~> 2.0)
|
|
118
118
|
racc (1.5.2)
|
|
119
119
|
rack (2.2.3)
|
|
@@ -147,17 +147,17 @@ GEM
|
|
|
147
147
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
148
148
|
rspec-support (~> 3.10.0)
|
|
149
149
|
rspec-support (3.10.2)
|
|
150
|
-
rubocop (1.
|
|
150
|
+
rubocop (1.14.0)
|
|
151
151
|
parallel (~> 1.10)
|
|
152
152
|
parser (>= 3.0.0.0)
|
|
153
153
|
rainbow (>= 2.2.2, < 4.0)
|
|
154
154
|
regexp_parser (>= 1.8, < 3.0)
|
|
155
155
|
rexml
|
|
156
|
-
rubocop-ast (>= 1.
|
|
156
|
+
rubocop-ast (>= 1.5.0, < 2.0)
|
|
157
157
|
ruby-progressbar (~> 1.7)
|
|
158
158
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
159
|
-
rubocop-ast (1.
|
|
160
|
-
parser (>=
|
|
159
|
+
rubocop-ast (1.5.0)
|
|
160
|
+
parser (>= 3.0.1.1)
|
|
161
161
|
ruby-progressbar (1.11.0)
|
|
162
162
|
ruby2_keywords (0.0.4)
|
|
163
163
|
simplecov (0.16.1)
|
|
@@ -210,7 +210,7 @@ DEPENDENCIES
|
|
|
210
210
|
bundler (~> 2.1, >= 2.1.4)
|
|
211
211
|
coveralls (~> 0.8.23)
|
|
212
212
|
nonnative!
|
|
213
|
-
rubocop (~> 1.
|
|
213
|
+
rubocop (~> 1.14)
|
|
214
214
|
solargraph (~> 0.40.4)
|
|
215
215
|
|
|
216
216
|
BUNDLED WITH
|
data/README.md
CHANGED
|
@@ -69,7 +69,10 @@ Nonnative.configure do |config|
|
|
|
69
69
|
p.timeout = config.strategy.timeout
|
|
70
70
|
p.port = 12_321
|
|
71
71
|
p.log = 'features/logs/12_321.log'
|
|
72
|
-
p.signal = 'INT' # Possible values are described in Signal.list.keys
|
|
72
|
+
p.signal = 'INT' # Possible values are described in Signal.list.keys.
|
|
73
|
+
p.environment = { # Pass environment variables to process.
|
|
74
|
+
'TEST' => 'true'
|
|
75
|
+
}
|
|
73
76
|
end
|
|
74
77
|
|
|
75
78
|
config.process do |p|
|
|
@@ -94,7 +97,9 @@ processes:
|
|
|
94
97
|
timeout: 5
|
|
95
98
|
port: 12321
|
|
96
99
|
log: features/logs/12_321.log
|
|
97
|
-
signal: INT # Possible values are described in Signal.list.keys
|
|
100
|
+
signal: INT # Possible values are described in Signal.list.keys.
|
|
101
|
+
environment: # Pass environment variables to process.
|
|
102
|
+
TEST: true
|
|
98
103
|
-
|
|
99
104
|
name: start_2
|
|
100
105
|
command: features/support/bin/start 12_322
|
|
@@ -108,7 +113,9 @@ Then load the file with
|
|
|
108
113
|
```ruby
|
|
109
114
|
require 'nonnative'
|
|
110
115
|
|
|
111
|
-
Nonnative.
|
|
116
|
+
Nonnative.configure do |config|
|
|
117
|
+
config.load_file('configuration.yml')
|
|
118
|
+
end
|
|
112
119
|
```
|
|
113
120
|
|
|
114
121
|
### Servers
|
|
@@ -172,13 +179,13 @@ strategy: startup
|
|
|
172
179
|
servers:
|
|
173
180
|
-
|
|
174
181
|
name: server_1
|
|
175
|
-
|
|
182
|
+
class: Nonnative::EchoServer
|
|
176
183
|
timeout: 1
|
|
177
184
|
port: 12323
|
|
178
185
|
log: features/logs/server_1.log
|
|
179
186
|
-
|
|
180
187
|
name: server_2
|
|
181
|
-
|
|
188
|
+
class: Nonnative::EchoServer
|
|
182
189
|
timeout: 1
|
|
183
190
|
port: 12324
|
|
184
191
|
log: features/logs/server_2.log
|
|
@@ -189,7 +196,9 @@ Then load the file with:
|
|
|
189
196
|
```ruby
|
|
190
197
|
require 'nonnative'
|
|
191
198
|
|
|
192
|
-
Nonnative.
|
|
199
|
+
Nonnative.configure do |config|
|
|
200
|
+
config.load_file('configuration.yml')
|
|
201
|
+
end
|
|
193
202
|
```
|
|
194
203
|
|
|
195
204
|
#### HTTP
|
|
@@ -244,7 +253,7 @@ strategy: startup
|
|
|
244
253
|
servers:
|
|
245
254
|
-
|
|
246
255
|
name: http_server_1
|
|
247
|
-
|
|
256
|
+
class: Nonnative::Features::HTTPServer
|
|
248
257
|
timeout: 1
|
|
249
258
|
port: 4567
|
|
250
259
|
log: features/logs/http_server_1.log
|
|
@@ -255,7 +264,9 @@ Then load the file with:
|
|
|
255
264
|
```ruby
|
|
256
265
|
require 'nonnative'
|
|
257
266
|
|
|
258
|
-
Nonnative.
|
|
267
|
+
Nonnative.configure do |config|
|
|
268
|
+
config.load_file('configuration.yml')
|
|
269
|
+
end
|
|
259
270
|
```
|
|
260
271
|
|
|
261
272
|
#### gRPC
|
|
@@ -306,7 +317,7 @@ strategy: startup
|
|
|
306
317
|
servers:
|
|
307
318
|
-
|
|
308
319
|
name: grpc_server_1
|
|
309
|
-
|
|
320
|
+
class: Nonnative::Features::GRPCServer
|
|
310
321
|
timeout: 1
|
|
311
322
|
port: 9002
|
|
312
323
|
log: features/logs/grpc_server_1.log
|
|
@@ -317,7 +328,9 @@ Then load the file with:
|
|
|
317
328
|
```ruby
|
|
318
329
|
require 'nonnative'
|
|
319
330
|
|
|
320
|
-
Nonnative.
|
|
331
|
+
Nonnative.configure do |config|
|
|
332
|
+
config.load_file('configuration.yml')
|
|
333
|
+
end
|
|
321
334
|
```
|
|
322
335
|
|
|
323
336
|
### Services
|
|
@@ -363,7 +376,9 @@ Then load the file with
|
|
|
363
376
|
```ruby
|
|
364
377
|
require 'nonnative'
|
|
365
378
|
|
|
366
|
-
Nonnative.
|
|
379
|
+
Nonnative.configure do |config|
|
|
380
|
+
config.load_file('configuration.yml')
|
|
381
|
+
end
|
|
367
382
|
```
|
|
368
383
|
|
|
369
384
|
#### Proxies
|
|
@@ -505,6 +520,13 @@ server.proxy.close_all # To use close_all.
|
|
|
505
520
|
server.proxy.reset # To reset it back to a good state.
|
|
506
521
|
```
|
|
507
522
|
|
|
523
|
+
With cucumber:
|
|
524
|
+
|
|
525
|
+
```cucumber
|
|
526
|
+
Given I set the proxy for process 'process_1' to 'close_all'
|
|
527
|
+
Then And I should reset the proxy for process 'process_1'
|
|
528
|
+
```
|
|
529
|
+
|
|
508
530
|
###### Servers
|
|
509
531
|
|
|
510
532
|
Setup it up programmatically:
|
|
@@ -517,6 +539,13 @@ server.proxy.close_all # To use close_all.
|
|
|
517
539
|
server.proxy.reset # To reset it back to a good state.
|
|
518
540
|
```
|
|
519
541
|
|
|
542
|
+
With cucumber:
|
|
543
|
+
|
|
544
|
+
```cucumber
|
|
545
|
+
Given I set the proxy for server 'server_1' to 'close_all'
|
|
546
|
+
Then And I should reset the proxy for server 'server_1'
|
|
547
|
+
```
|
|
548
|
+
|
|
520
549
|
###### Services
|
|
521
550
|
|
|
522
551
|
Setup it up programmatically:
|
|
@@ -529,6 +558,13 @@ service.proxy.close_all # To use close_all.
|
|
|
529
558
|
service.proxy.reset # To reset it back to a good state.
|
|
530
559
|
```
|
|
531
560
|
|
|
561
|
+
With cucumber:
|
|
562
|
+
|
|
563
|
+
```cucumber
|
|
564
|
+
Given I set the proxy for service 'service_1' to 'close_all'
|
|
565
|
+
Then And I should reset the proxy for service 'service_1'
|
|
566
|
+
```
|
|
567
|
+
|
|
532
568
|
### Go
|
|
533
569
|
|
|
534
570
|
As we love using go as a language for services we have added support to start binaries with defined parameters. This expects that you build your services in the format of `command sub_command --params`
|
|
@@ -540,16 +576,10 @@ To get this to work you will need to create a `main_test.go` file with these con
|
|
|
540
576
|
|
|
541
577
|
package main
|
|
542
578
|
|
|
543
|
-
import
|
|
544
|
-
"testing"
|
|
545
|
-
|
|
546
|
-
"github.com/your_location/cmd"
|
|
547
|
-
)
|
|
579
|
+
import "testing"
|
|
548
580
|
|
|
549
581
|
func TestFeatures(t *testing.T) {
|
|
550
|
-
|
|
551
|
-
t.Fatal(err.Error())
|
|
552
|
-
}
|
|
582
|
+
main()
|
|
553
583
|
}
|
|
554
584
|
```
|
|
555
585
|
|
|
@@ -559,8 +589,27 @@ Then to compile this binary you will need to do the following:
|
|
|
559
589
|
go test -mod vendor -c -tags features -covermode=count -o your_binary -coverpkg=./... github.com/your_location
|
|
560
590
|
```
|
|
561
591
|
|
|
562
|
-
|
|
592
|
+
Setup it up programmatically:
|
|
563
593
|
|
|
564
594
|
```ruby
|
|
565
595
|
Nonnative.go_executable('reports', 'your_binary', 'sub_command', '--config config.yaml')
|
|
566
596
|
```
|
|
597
|
+
|
|
598
|
+
Setup it up through configuration:
|
|
599
|
+
|
|
600
|
+
```yaml
|
|
601
|
+
version: 1.0
|
|
602
|
+
strategy: startup
|
|
603
|
+
processes:
|
|
604
|
+
-
|
|
605
|
+
name: go
|
|
606
|
+
go:
|
|
607
|
+
output: reports
|
|
608
|
+
executable: your_binary
|
|
609
|
+
command: sub_command
|
|
610
|
+
parameters:
|
|
611
|
+
- --config config.yaml
|
|
612
|
+
timeout: 5
|
|
613
|
+
port: 8000
|
|
614
|
+
log: features/logs/go.log
|
|
615
|
+
```
|
data/lib/nonnative.rb
CHANGED
|
@@ -11,11 +11,13 @@ require 'rest-client'
|
|
|
11
11
|
require 'puma'
|
|
12
12
|
require 'puma/server'
|
|
13
13
|
require 'concurrent'
|
|
14
|
+
require 'cucumber'
|
|
14
15
|
|
|
15
16
|
require 'nonnative/version'
|
|
16
17
|
require 'nonnative/error'
|
|
17
18
|
require 'nonnative/start_error'
|
|
18
19
|
require 'nonnative/stop_error'
|
|
20
|
+
require 'nonnative/not_found_error'
|
|
19
21
|
require 'nonnative/timeout'
|
|
20
22
|
require 'nonnative/port'
|
|
21
23
|
require 'nonnative/configuration'
|
|
@@ -44,17 +46,18 @@ require 'nonnative/invalid_data_socket_pair'
|
|
|
44
46
|
require 'nonnative/socket_pair_factory'
|
|
45
47
|
require 'nonnative/strategy'
|
|
46
48
|
require 'nonnative/go_command'
|
|
49
|
+
require 'nonnative/cucumber'
|
|
47
50
|
|
|
48
51
|
module Nonnative
|
|
49
52
|
class << self
|
|
50
53
|
attr_reader :pool
|
|
51
54
|
|
|
52
|
-
def
|
|
53
|
-
|
|
55
|
+
def log_lines(path, predicate)
|
|
56
|
+
File.readlines(path).select { |l| predicate.call(l) }
|
|
54
57
|
end
|
|
55
58
|
|
|
56
|
-
def
|
|
57
|
-
|
|
59
|
+
def go_executable(output, exec, cmd, *params)
|
|
60
|
+
Nonnative::GoCommand.new(exec, output).executable(cmd, params)
|
|
58
61
|
end
|
|
59
62
|
|
|
60
63
|
def configuration
|
data/lib/nonnative/before.rb
CHANGED
|
@@ -2,77 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
module Nonnative
|
|
4
4
|
class Configuration
|
|
5
|
-
class << self
|
|
6
|
-
def load_file(path)
|
|
7
|
-
file = YAML.load_file(path)
|
|
8
|
-
|
|
9
|
-
new.tap do |c|
|
|
10
|
-
c.strategy = file['strategy']
|
|
11
|
-
|
|
12
|
-
processes(file, c)
|
|
13
|
-
servers(file, c)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
private
|
|
18
|
-
|
|
19
|
-
def processes(file, config)
|
|
20
|
-
processes = file['processes'] || []
|
|
21
|
-
processes.each do |fd|
|
|
22
|
-
config.process do |d|
|
|
23
|
-
d.name = fd['name']
|
|
24
|
-
d.command = fd['command']
|
|
25
|
-
d.timeout = fd['timeout']
|
|
26
|
-
d.port = fd['port']
|
|
27
|
-
d.log = fd['log']
|
|
28
|
-
d.signal = fd['signal']
|
|
29
|
-
|
|
30
|
-
proxy d, fd['proxy']
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def servers(file, config)
|
|
36
|
-
servers = file['servers'] || []
|
|
37
|
-
servers.each do |fd|
|
|
38
|
-
config.server do |s|
|
|
39
|
-
s.name = fd['name']
|
|
40
|
-
s.klass = Object.const_get(fd['klass'])
|
|
41
|
-
s.timeout = fd['timeout']
|
|
42
|
-
s.port = fd['port']
|
|
43
|
-
s.log = fd['log']
|
|
44
|
-
|
|
45
|
-
proxy s, fd['proxy']
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def services(file, config)
|
|
51
|
-
services = file['services'] || []
|
|
52
|
-
services.each do |fd|
|
|
53
|
-
config.service do |s|
|
|
54
|
-
s.name = fd['name']
|
|
55
|
-
s.timeout = fd['timeout']
|
|
56
|
-
s.port = fd['port']
|
|
57
|
-
s.log = fd['log']
|
|
58
|
-
|
|
59
|
-
proxy s, fd['proxy']
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def proxy(server, proxy)
|
|
65
|
-
return unless proxy
|
|
66
|
-
|
|
67
|
-
server.proxy = {
|
|
68
|
-
type: proxy['type'],
|
|
69
|
-
port: proxy['port'],
|
|
70
|
-
log: proxy['log'],
|
|
71
|
-
options: proxy['options']
|
|
72
|
-
}
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
|
-
|
|
76
5
|
def initialize
|
|
77
6
|
@strategy = Strategy.new
|
|
78
7
|
@processes = []
|
|
@@ -83,6 +12,16 @@ module Nonnative
|
|
|
83
12
|
attr_accessor :processes, :servers, :services
|
|
84
13
|
attr_reader :strategy
|
|
85
14
|
|
|
15
|
+
def load_file(path)
|
|
16
|
+
file = YAML.load_file(path)
|
|
17
|
+
|
|
18
|
+
self.strategy = file['strategy']
|
|
19
|
+
|
|
20
|
+
add_processes(file)
|
|
21
|
+
add_servers(file)
|
|
22
|
+
add_services(file)
|
|
23
|
+
end
|
|
24
|
+
|
|
86
25
|
def strategy=(value)
|
|
87
26
|
@strategy = Strategy.new(value)
|
|
88
27
|
end
|
|
@@ -107,5 +46,72 @@ module Nonnative
|
|
|
107
46
|
|
|
108
47
|
services << service
|
|
109
48
|
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
def add_processes(file)
|
|
53
|
+
processes = file['processes'] || []
|
|
54
|
+
processes.each do |fd|
|
|
55
|
+
process do |d|
|
|
56
|
+
d.name = fd['name']
|
|
57
|
+
d.command = command(fd)
|
|
58
|
+
d.timeout = fd['timeout']
|
|
59
|
+
d.port = fd['port']
|
|
60
|
+
d.log = fd['log']
|
|
61
|
+
d.signal = fd['signal']
|
|
62
|
+
d.environment = fd['environment']
|
|
63
|
+
|
|
64
|
+
proxy d, fd['proxy']
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def command(process)
|
|
70
|
+
go = process['go']
|
|
71
|
+
if go
|
|
72
|
+
params = go['parameters'] || []
|
|
73
|
+
Nonnative.go_executable(go['output'], go['executable'], go['command'], *params)
|
|
74
|
+
else
|
|
75
|
+
process['command']
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def add_servers(file)
|
|
80
|
+
servers = file['servers'] || []
|
|
81
|
+
servers.each do |fd|
|
|
82
|
+
server do |s|
|
|
83
|
+
s.name = fd['name']
|
|
84
|
+
s.klass = Object.const_get(fd['class'])
|
|
85
|
+
s.timeout = fd['timeout']
|
|
86
|
+
s.port = fd['port']
|
|
87
|
+
s.log = fd['log']
|
|
88
|
+
|
|
89
|
+
proxy s, fd['proxy']
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def add_services(file)
|
|
95
|
+
services = file['services'] || []
|
|
96
|
+
services.each do |fd|
|
|
97
|
+
service do |s|
|
|
98
|
+
s.name = fd['name']
|
|
99
|
+
s.port = fd['port']
|
|
100
|
+
|
|
101
|
+
proxy s, fd['proxy']
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def proxy(runner, proxy)
|
|
107
|
+
return unless proxy
|
|
108
|
+
|
|
109
|
+
runner.proxy = {
|
|
110
|
+
type: proxy['type'],
|
|
111
|
+
port: proxy['port'],
|
|
112
|
+
log: proxy['log'],
|
|
113
|
+
options: proxy['options']
|
|
114
|
+
}
|
|
115
|
+
end
|
|
110
116
|
end
|
|
111
117
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
Given('I set the proxy for process {string} to {string}') do |name, operation|
|
|
4
|
+
server = Nonnative.pool.process_by_name(name)
|
|
5
|
+
server.proxy.send(operation)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
Given('I set the proxy for server {string} to {string}') do |name, operation|
|
|
9
|
+
server = Nonnative.pool.server_by_name(name)
|
|
10
|
+
server.proxy.send(operation)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Given('I set the proxy for service {string} to {string}') do |name, operation|
|
|
14
|
+
service = Nonnative.pool.service_by_name(name)
|
|
15
|
+
service.proxy.send(operation)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
Then('I should reset the proxy for process {string}') do |name|
|
|
19
|
+
server = Nonnative.pool.process_by_name(name)
|
|
20
|
+
server.proxy.reset
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Then('I should reset the proxy for server {string}') do |name|
|
|
24
|
+
server = Nonnative.pool.server_by_name(name)
|
|
25
|
+
server.proxy.reset
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
Then('I should reset the proxy for service {string}') do |name|
|
|
29
|
+
service = Nonnative.pool.service_by_name(name)
|
|
30
|
+
service.proxy.reset
|
|
31
|
+
end
|
data/lib/nonnative/pool.rb
CHANGED
|
@@ -17,24 +17,28 @@ module Nonnative
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def process_by_name(name)
|
|
20
|
-
|
|
21
|
-
processes[index].first
|
|
20
|
+
processes[runner_index(configuration.processes, name)].first
|
|
22
21
|
end
|
|
23
22
|
|
|
24
23
|
def server_by_name(name)
|
|
25
|
-
|
|
26
|
-
servers[index].first
|
|
24
|
+
servers[runner_index(configuration.servers, name)].first
|
|
27
25
|
end
|
|
28
26
|
|
|
29
27
|
def service_by_name(name)
|
|
30
|
-
|
|
31
|
-
services[index]
|
|
28
|
+
services[runner_index(configuration.services, name)]
|
|
32
29
|
end
|
|
33
30
|
|
|
34
31
|
private
|
|
35
32
|
|
|
36
33
|
attr_reader :configuration
|
|
37
34
|
|
|
35
|
+
def runner_index(runners, name)
|
|
36
|
+
index = runners.find_index { |s| s.name == name }
|
|
37
|
+
raise NotFoundError, "Could not find runner with name '#{name}'" if index.nil?
|
|
38
|
+
|
|
39
|
+
index
|
|
40
|
+
end
|
|
41
|
+
|
|
38
42
|
def processes
|
|
39
43
|
@processes ||= configuration.processes.map do |p|
|
|
40
44
|
[Nonnative::Process.new(p), Nonnative::Port.new(p)]
|
data/lib/nonnative/process.rb
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module Nonnative
|
|
4
4
|
class Process < Runner
|
|
5
|
+
def initialize(service)
|
|
6
|
+
super service
|
|
7
|
+
|
|
8
|
+
@timeout = Nonnative::Timeout.new(service.timeout)
|
|
9
|
+
end
|
|
10
|
+
|
|
5
11
|
def start
|
|
6
12
|
unless process_exists?
|
|
7
13
|
proxy.start
|
|
@@ -32,7 +38,7 @@ module Nonnative
|
|
|
32
38
|
|
|
33
39
|
private
|
|
34
40
|
|
|
35
|
-
attr_reader :pid
|
|
41
|
+
attr_reader :pid, :timeout
|
|
36
42
|
|
|
37
43
|
def process_kill
|
|
38
44
|
signal = Signal.list[service.signal || 'INT'] || Signal.list['INT']
|
|
@@ -40,7 +46,10 @@ module Nonnative
|
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
def process_spawn
|
|
43
|
-
|
|
49
|
+
environment = service.environment || {}
|
|
50
|
+
environment = environment.transform_keys(&:to_s).transform_values(&:to_s)
|
|
51
|
+
|
|
52
|
+
spawn(environment, service.command, %i[out err] => [service.log, 'a'])
|
|
44
53
|
end
|
|
45
54
|
|
|
46
55
|
def process_exists?
|
data/lib/nonnative/runner.rb
CHANGED
|
@@ -6,7 +6,6 @@ module Nonnative
|
|
|
6
6
|
|
|
7
7
|
def initialize(service)
|
|
8
8
|
@service = service
|
|
9
|
-
@timeout = Nonnative::Timeout.new(service.timeout)
|
|
10
9
|
@proxy = Nonnative::ProxyFactory.create(service)
|
|
11
10
|
end
|
|
12
11
|
|
|
@@ -16,7 +15,7 @@ module Nonnative
|
|
|
16
15
|
|
|
17
16
|
protected
|
|
18
17
|
|
|
19
|
-
attr_reader :service
|
|
18
|
+
attr_reader :service
|
|
20
19
|
|
|
21
20
|
def wait_start
|
|
22
21
|
sleep 0.1
|
data/lib/nonnative/server.rb
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
module Nonnative
|
|
4
4
|
class Server < Runner
|
|
5
|
+
def initialize(service)
|
|
6
|
+
super service
|
|
7
|
+
|
|
8
|
+
@timeout = Nonnative::Timeout.new(service.timeout)
|
|
9
|
+
end
|
|
10
|
+
|
|
5
11
|
def start
|
|
6
12
|
unless thread
|
|
7
13
|
proxy.start
|
|
@@ -28,6 +34,6 @@ module Nonnative
|
|
|
28
34
|
|
|
29
35
|
private
|
|
30
36
|
|
|
31
|
-
attr_reader :thread
|
|
37
|
+
attr_reader :thread, :timeout
|
|
32
38
|
end
|
|
33
39
|
end
|
data/lib/nonnative/version.rb
CHANGED
data/nonnative.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ require 'nonnative/version'
|
|
|
8
8
|
Gem::Specification.new do |spec|
|
|
9
9
|
spec.name = 'nonnative'
|
|
10
10
|
spec.version = Nonnative::VERSION
|
|
11
|
-
spec.authors = ['
|
|
11
|
+
spec.authors = ['Alejandro Falkowski']
|
|
12
12
|
spec.email = ['alexrfalkowski@gmail.com']
|
|
13
13
|
|
|
14
14
|
spec.summary = 'Allows you to keep using the power of ruby to test other systems'
|
|
@@ -35,6 +35,6 @@ Gem::Specification.new do |spec|
|
|
|
35
35
|
|
|
36
36
|
spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
|
|
37
37
|
spec.add_development_dependency 'coveralls', '~> 0.8.23'
|
|
38
|
-
spec.add_development_dependency 'rubocop', '~> 1.
|
|
38
|
+
spec.add_development_dependency 'rubocop', '~> 1.14'
|
|
39
39
|
spec.add_development_dependency 'solargraph', '~> 0.40.4'
|
|
40
40
|
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.47.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
-
|
|
7
|
+
- Alejandro Falkowski
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -212,14 +212,14 @@ dependencies:
|
|
|
212
212
|
requirements:
|
|
213
213
|
- - "~>"
|
|
214
214
|
- !ruby/object:Gem::Version
|
|
215
|
-
version: '1.
|
|
215
|
+
version: '1.14'
|
|
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: '1.
|
|
222
|
+
version: '1.14'
|
|
223
223
|
- !ruby/object:Gem::Dependency
|
|
224
224
|
name: solargraph
|
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -265,6 +265,7 @@ files:
|
|
|
265
265
|
- lib/nonnative/configuration_runner.rb
|
|
266
266
|
- lib/nonnative/configuration_server.rb
|
|
267
267
|
- lib/nonnative/configuration_service.rb
|
|
268
|
+
- lib/nonnative/cucumber.rb
|
|
268
269
|
- lib/nonnative/delay_socket_pair.rb
|
|
269
270
|
- lib/nonnative/error.rb
|
|
270
271
|
- lib/nonnative/fault_injection_proxy.rb
|
|
@@ -275,6 +276,7 @@ files:
|
|
|
275
276
|
- lib/nonnative/invalid_data_socket_pair.rb
|
|
276
277
|
- lib/nonnative/manual.rb
|
|
277
278
|
- lib/nonnative/no_proxy.rb
|
|
279
|
+
- lib/nonnative/not_found_error.rb
|
|
278
280
|
- lib/nonnative/observability.rb
|
|
279
281
|
- lib/nonnative/pool.rb
|
|
280
282
|
- lib/nonnative/port.rb
|