nonnative 1.43.0 → 1.48.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62f3c862b3f62e6cbb6ada5723b5d533db060ef8c801a60b1fccbbc50d3dd99c
4
- data.tar.gz: 22d05748db137d668e7366bed697abdffe6fddb97a0a5c445a6dc32568013c14
3
+ metadata.gz: c21eda5e483c7b969628385d03d390639e0f847b1b898165db0461c8aec5d63a
4
+ data.tar.gz: 310638037f07b46d849908c1d19bd03c044fd3ece4a581c0e26f9f741c3716c8
5
5
  SHA512:
6
- metadata.gz: da5be400a905ea0f6eeb6d62609664046e246ed95ea0f32661f03d1fe242d1cdefe3d2d787c8f92c770cc991237a39aa132bdedcdc241f29db5119ed9feebc29
7
- data.tar.gz: f37ddb08dc0f67363f0bb5bca5f2611999d9dd2ebe22e26d3b8bcbe0f7bbb6a0564c3010a3e5eeca98c404712cfb8364f945194c579235d5158b7a660908aab9
6
+ metadata.gz: 958a8d1db1341adf820c69df50bef022d34ec374eb2a37e5d11a768d0a0913f7366e59cb91236bf17c7979b3184090092c347e852f311e31d9677da7689c1535
7
+ data.tar.gz: feef6f7f49f4a6dc5f14ac387b983b16e6be42bedbaedd8c024967e82c294d13f18c932eebd7a126c4891bf3a4263e3bbf968b0e89a135818ffe3bd1bc12651d
data/.circleci/config.yml CHANGED
@@ -3,7 +3,7 @@ version: 2.1
3
3
  jobs:
4
4
  build:
5
5
  docker:
6
- - image: alexfalkowski/ruby:2.7
6
+ - image: alexfalkowski/ruby:3.0
7
7
  steps:
8
8
  - checkout
9
9
  - restore_cache:
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.7
2
+ TargetRubyVersion: 3.0
3
3
  DisplayCopNames: true
4
4
  NewCops: enable
5
5
 
@@ -13,7 +13,7 @@ Metrics/BlockLength:
13
13
  Max: 80
14
14
 
15
15
  Metrics/AbcSize:
16
- Max: 20
16
+ Max: 22
17
17
 
18
18
  Style/Documentation:
19
19
  Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.7.2
1
+ ruby-3.0.0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,43 @@
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.48.0](https://github.com/alexfalkowski/nonnative/compare/v1.47.0...v1.48.0) (2021-05-15)
6
+
7
+
8
+ ### Features
9
+
10
+ * **deps:** update to ruby version 3.0.0 ([#89](https://github.com/alexfalkowski/nonnative/issues/89)) ([e2b37bf](https://github.com/alexfalkowski/nonnative/commit/e2b37bfc6e6dd922258cc1d1bc5b6abc4d78fd02))
11
+
12
+ ## [1.47.0](https://github.com/alexfalkowski/nonnative/compare/v1.46.0...v1.47.0) (2021-05-14)
13
+
14
+
15
+ ### Features
16
+
17
+ * allow to pass env variables to processes ([#88](https://github.com/alexfalkowski/nonnative/issues/88)) ([4401a77](https://github.com/alexfalkowski/nonnative/commit/4401a776ccc50dbefa45b06de01945abf4724864))
18
+
19
+ ## [1.46.0](https://github.com/alexfalkowski/nonnative/compare/v1.45.0...v1.46.0) (2021-05-10)
20
+
21
+
22
+ ### Features
23
+
24
+ * add loading config through configure ([#87](https://github.com/alexfalkowski/nonnative/issues/87)) ([a95e8b6](https://github.com/alexfalkowski/nonnative/commit/a95e8b6817380afd732d0aefb170726f905548cb))
25
+
26
+ ## [1.45.0](https://github.com/alexfalkowski/nonnative/compare/v1.44.1...v1.45.0) (2021-05-10)
27
+
28
+
29
+ ### Features
30
+
31
+ * add loading go command through config ([#86](https://github.com/alexfalkowski/nonnative/issues/86)) ([2f500d3](https://github.com/alexfalkowski/nonnative/commit/2f500d34ef6eb536b223651f84213f4f3d10c496))
32
+
33
+ ### [1.44.1](https://github.com/alexfalkowski/nonnative/compare/v1.44.0...v1.44.1) (2021-05-06)
34
+
35
+ ## [1.44.0](https://github.com/alexfalkowski/nonnative/compare/v1.43.0...v1.44.0) (2021-05-01)
36
+
37
+
38
+ ### Features
39
+
40
+ * move to reusable steps ([#84](https://github.com/alexfalkowski/nonnative/issues/84)) ([37b6175](https://github.com/alexfalkowski/nonnative/commit/37b6175e920dfb70f3d6f13226240dd045c2db3d))
41
+
5
42
  ## [1.43.0](https://github.com/alexfalkowski/nonnative/compare/v1.42.2...v1.43.0) (2021-04-30)
6
43
 
7
44
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (1.43.0)
4
+ nonnative (1.48.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.1)
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.15.8)
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.0)
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.2.2)
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.13.0)
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.2.0, < 2.0)
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.4.1)
160
- parser (>= 2.7.1.5)
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)
@@ -207,11 +207,11 @@ PLATFORMS
207
207
  ruby
208
208
 
209
209
  DEPENDENCIES
210
- bundler (~> 2.1, >= 2.1.4)
210
+ bundler (~> 2.2, >= 2.2.17)
211
211
  coveralls (~> 0.8.23)
212
212
  nonnative!
213
- rubocop (~> 1.12)
213
+ rubocop (~> 1.14)
214
214
  solargraph (~> 0.40.4)
215
215
 
216
216
  BUNDLED WITH
217
- 2.1.4
217
+ 2.2.17
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.load_configuration('configuration.yml')
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
- klass: Nonnative::EchoServer
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
- klass: Nonnative::EchoServer
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.load_configuration('configuration.yml')
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
- klass: Nonnative::Features::HTTPServer
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.load_configuration('configuration.yml')
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
- klass: Nonnative::Features::GRPCServer
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.load_configuration('configuration.yml')
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.load_configuration('configuration.yml')
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
- if err := cmd.Execute(); err != nil {
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
- Then to get an executable you do the following:
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 go_executable(output, exec, cmd, *params)
53
- Nonnative::GoCommand.new(exec, output).executable(cmd, params)
55
+ def log_lines(path, predicate)
56
+ File.readlines(path).select { |l| predicate.call(l) }
54
57
  end
55
58
 
56
- def load_configuration(path)
57
- @configuration ||= Nonnative::Configuration.load_file(path) # rubocop:disable Naming/MemoizedInstanceVariableName
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
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'cucumber'
4
-
5
3
  Before do
6
4
  Nonnative.start
7
5
  end
@@ -2,78 +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
- services(file, c)
15
- end
16
- end
17
-
18
- private
19
-
20
- def processes(file, config)
21
- processes = file['processes'] || []
22
- processes.each do |fd|
23
- config.process do |d|
24
- d.name = fd['name']
25
- d.command = fd['command']
26
- d.timeout = fd['timeout']
27
- d.port = fd['port']
28
- d.log = fd['log']
29
- d.signal = fd['signal']
30
-
31
- proxy d, fd['proxy']
32
- end
33
- end
34
- end
35
-
36
- def servers(file, config)
37
- servers = file['servers'] || []
38
- servers.each do |fd|
39
- config.server do |s|
40
- s.name = fd['name']
41
- s.klass = Object.const_get(fd['klass'])
42
- s.timeout = fd['timeout']
43
- s.port = fd['port']
44
- s.log = fd['log']
45
-
46
- proxy s, fd['proxy']
47
- end
48
- end
49
- end
50
-
51
- def services(file, config)
52
- services = file['services'] || []
53
- services.each do |fd|
54
- config.service do |s|
55
- s.name = fd['name']
56
- s.timeout = fd['timeout']
57
- s.port = fd['port']
58
- s.log = fd['log']
59
-
60
- proxy s, fd['proxy']
61
- end
62
- end
63
- end
64
-
65
- def proxy(server, proxy)
66
- return unless proxy
67
-
68
- server.proxy = {
69
- type: proxy['type'],
70
- port: proxy['port'],
71
- log: proxy['log'],
72
- options: proxy['options']
73
- }
74
- end
75
- end
76
-
77
5
  def initialize
78
6
  @strategy = Strategy.new
79
7
  @processes = []
@@ -84,6 +12,16 @@ module Nonnative
84
12
  attr_accessor :processes, :servers, :services
85
13
  attr_reader :strategy
86
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
+
87
25
  def strategy=(value)
88
26
  @strategy = Strategy.new(value)
89
27
  end
@@ -108,5 +46,72 @@ module Nonnative
108
46
 
109
47
  services << service
110
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
111
116
  end
112
117
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nonnative
4
4
  class ConfigurationProcess < ConfigurationRunner
5
- attr_accessor :command, :signal
5
+ attr_accessor :command, :signal, :timeout, :log, :environment
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nonnative
4
4
  class ConfigurationRunner
5
- attr_accessor :name, :timeout, :port, :log
5
+ attr_accessor :name, :port
6
6
  attr_reader :proxy
7
7
 
8
8
  def initialize
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nonnative
4
4
  class ConfigurationServer < ConfigurationRunner
5
- attr_accessor :klass
5
+ attr_accessor :klass, :timeout, :log
6
6
  end
7
7
  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
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nonnative
4
+ class NotFoundError < Nonnative::Error
5
+ end
6
+ end
@@ -17,24 +17,28 @@ module Nonnative
17
17
  end
18
18
 
19
19
  def process_by_name(name)
20
- index = configuration.processes.find_index { |s| s.name == name }
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
- index = configuration.servers.find_index { |s| s.name == name }
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
- index = configuration.services.find_index { |s| s.name == name }
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)]
@@ -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
- spawn(service.command, %i[out err] => [service.log, 'a'])
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?
@@ -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, :timeout
18
+ attr_reader :service
20
19
 
21
20
  def wait_start
22
21
  sleep 0.1
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- VERSION = '1.43.0'
4
+ VERSION = '1.48.0'
5
5
  end
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 = ['Alex Falkowski']
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'
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = 'exe'
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
- spec.required_ruby_version = ['>= 2.7.0', '< 2.8.0']
24
+ spec.required_ruby_version = ['>= 3.0.0', '< 4.0.0']
25
25
 
26
26
  spec.add_dependency 'concurrent-ruby', '~> 1.0', '>= 1.0.5'
27
27
  spec.add_dependency 'cucumber', ['>= 6', '< 7']
@@ -33,8 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency 'rspec-expectations', '~> 3.9', '>= 3.9.2'
34
34
  spec.add_dependency 'sinatra', '~> 2.0', '>= 2.0.8.1'
35
35
 
36
- spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
36
+ spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.17'
37
37
  spec.add_development_dependency 'coveralls', '~> 0.8.23'
38
- spec.add_development_dependency 'rubocop', '~> 1.12'
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.43.0
4
+ version: 1.48.0
5
5
  platform: ruby
6
6
  authors:
7
- - Alex Falkowski
7
+ - Alejandro Falkowski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-30 00:00:00.000000000 Z
11
+ date: 2021-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -178,20 +178,20 @@ dependencies:
178
178
  requirements:
179
179
  - - "~>"
180
180
  - !ruby/object:Gem::Version
181
- version: '2.1'
181
+ version: '2.2'
182
182
  - - ">="
183
183
  - !ruby/object:Gem::Version
184
- version: 2.1.4
184
+ version: 2.2.17
185
185
  type: :development
186
186
  prerelease: false
187
187
  version_requirements: !ruby/object:Gem::Requirement
188
188
  requirements:
189
189
  - - "~>"
190
190
  - !ruby/object:Gem::Version
191
- version: '2.1'
191
+ version: '2.2'
192
192
  - - ">="
193
193
  - !ruby/object:Gem::Version
194
- version: 2.1.4
194
+ version: 2.2.17
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: coveralls
197
197
  requirement: !ruby/object:Gem::Requirement
@@ -212,14 +212,14 @@ dependencies:
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: '1.12'
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.12'
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
@@ -305,17 +307,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
305
307
  requirements:
306
308
  - - ">="
307
309
  - !ruby/object:Gem::Version
308
- version: 2.7.0
310
+ version: 3.0.0
309
311
  - - "<"
310
312
  - !ruby/object:Gem::Version
311
- version: 2.8.0
313
+ version: 4.0.0
312
314
  required_rubygems_version: !ruby/object:Gem::Requirement
313
315
  requirements:
314
316
  - - ">="
315
317
  - !ruby/object:Gem::Version
316
318
  version: '0'
317
319
  requirements: []
318
- rubygems_version: 3.1.4
320
+ rubygems_version: 3.2.3
319
321
  signing_key:
320
322
  specification_version: 4
321
323
  summary: Allows you to keep using the power of ruby to test other systems