nonnative 1.40.0 → 1.41.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: 870143059910a181598b40406aebc0e8d7882133aa01b82091da14436dee664a
4
- data.tar.gz: 6a1e9449a4eb21b1c58c6c5b3a8256546956f84db8cd5c09c7a939ea09f33cbc
3
+ metadata.gz: 50953dcfe695bf9196b5d3968a88f15fa6db81c630c0537e8c796ad63486d15f
4
+ data.tar.gz: f910aec0fdb41fd9cea678657be191be85756d2c99ae45d64750a6f31c2534f7
5
5
  SHA512:
6
- metadata.gz: 38f4f40a6460548a9470f707c66e1b5067c3a336a97f49de4415ffdcbb85f07c7f626b61f5948485c630ddcb9d8235b0a6ed069cbd1c6844bfd25b4e9109879c
7
- data.tar.gz: a19898c50a83a2f7d3d330eec829d7420236f87f0f00919256ebe1ab34c4bffd175124cd5ed832b09275942707b9a15fc3f84a7b14e82d85a5d9437e89bcbadf
6
+ metadata.gz: 621d4af2d17163e749f0a706b991a52583f32603f64ba3a0fd978c31961c1de11c4b713a0023e0baf7309a9abf072f8642a4551d5a87d1c33bb4caa8844116b6
7
+ data.tar.gz: 7f1516ab344e4ce99388046490809cb6a63e4de40909aab41c018b73d18e70d3d3b6c76069b9a747a15eed801d9bc94d83e097012bd82cdbcc49ff7a140443eb
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: x3EcMK4Nr770BeIFZengeQ2DLDCDjNfNo
data/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
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.41.0](https://github.com/alexfalkowski/nonnative/compare/v1.40.2...v1.41.0) (2021-04-30)
6
+
7
+
8
+ ### Features
9
+
10
+ * add proxy to processes ([#79](https://github.com/alexfalkowski/nonnative/issues/79)) ([d52b2bb](https://github.com/alexfalkowski/nonnative/commit/d52b2bb6fad91612f9b9a64817c861d1c227ef0b))
11
+
12
+ ### [1.40.2](https://github.com/alexfalkowski/nonnative/compare/v1.40.1...v1.40.2) (2021-04-27)
13
+
14
+ ### [1.40.1](https://github.com/alexfalkowski/nonnative/compare/v1.40.0...v1.40.1) (2021-04-27)
15
+
5
16
  ## [1.40.0](https://github.com/alexfalkowski/nonnative/compare/v1.39.0...v1.40.0) (2021-04-25)
6
17
 
7
18
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (1.40.0)
4
+ nonnative (1.41.0)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.5)
6
6
  cucumber (>= 6, < 7)
7
7
  grpc (>= 1, < 2)
@@ -29,6 +29,12 @@ GEM
29
29
  benchmark-trend (0.4.0)
30
30
  builder (3.2.4)
31
31
  concurrent-ruby (1.1.8)
32
+ coveralls (0.8.23)
33
+ json (>= 1.8, < 3)
34
+ simplecov (~> 0.16.1)
35
+ term-ansicolor (~> 1.3)
36
+ thor (>= 0.19.4, < 2.0)
37
+ tins (~> 1.6)
32
38
  cucumber (6.0.0)
33
39
  builder (~> 3.2, >= 3.2.4)
34
40
  cucumber-core (~> 9.0, >= 9.0.0)
@@ -70,16 +76,17 @@ GEM
70
76
  google-protobuf (3.15.8)
71
77
  googleapis-common-protos-types (1.0.6)
72
78
  google-protobuf (~> 3.14)
73
- grpc (1.37.0)
79
+ grpc (1.37.1)
74
80
  google-protobuf (~> 3.15)
75
81
  googleapis-common-protos-types (~> 1.0)
76
- grpc-tools (1.37.0)
82
+ grpc-tools (1.37.1)
77
83
  http-accept (1.7.0)
78
84
  http-cookie (1.0.3)
79
85
  domain_name (~> 0.5)
80
86
  i18n (1.8.10)
81
87
  concurrent-ruby (~> 1.0)
82
88
  jaro_winkler (1.5.4)
89
+ json (2.5.1)
83
90
  kramdown (2.3.1)
84
91
  rexml
85
92
  kramdown-parser-gfm (1.1.0)
@@ -153,12 +160,11 @@ GEM
153
160
  parser (>= 2.7.1.5)
154
161
  ruby-progressbar (1.11.0)
155
162
  ruby2_keywords (0.0.4)
156
- simplecov (0.21.2)
163
+ simplecov (0.16.1)
157
164
  docile (~> 1.1)
158
- simplecov-html (~> 0.11)
159
- simplecov_json_formatter (~> 0.1)
160
- simplecov-html (0.12.3)
161
- simplecov_json_formatter (0.1.2)
165
+ json (>= 1.8, < 3)
166
+ simplecov-html (~> 0.10.0)
167
+ simplecov-html (0.10.2)
162
168
  sinatra (2.1.0)
163
169
  mustermann (~> 1.0)
164
170
  rack (~> 2.2)
@@ -178,11 +184,16 @@ GEM
178
184
  thor (~> 1.0)
179
185
  tilt (~> 2.0)
180
186
  yard (~> 0.9, >= 0.9.24)
187
+ sync (0.5.0)
181
188
  sys-uname (1.2.2)
182
189
  ffi (~> 1.1)
190
+ term-ansicolor (1.7.1)
191
+ tins (~> 1.0)
183
192
  thor (1.0.1)
184
193
  thread_safe (0.3.6)
185
194
  tilt (2.0.10)
195
+ tins (1.28.0)
196
+ sync
186
197
  tzinfo (2.0.4)
187
198
  concurrent-ruby (~> 1.0)
188
199
  unf (0.1.4)
@@ -197,9 +208,9 @@ PLATFORMS
197
208
 
198
209
  DEPENDENCIES
199
210
  bundler (~> 2.1, >= 2.1.4)
211
+ coveralls (~> 0.8.23)
200
212
  nonnative!
201
213
  rubocop (~> 1.12)
202
- simplecov (~> 0.21.2)
203
214
  solargraph (~> 0.40.4)
204
215
 
205
216
  BUNDLED WITH
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![CircleCI](https://circleci.com/gh/alexfalkowski/nonnative.svg?style=svg)](https://circleci.com/gh/alexfalkowski/nonnative)
2
+ [![Coverage Status](https://coveralls.io/repos/github/alexfalkowski/nonnative/badge.svg?branch=master)](https://coveralls.io/github/alexfalkowski/nonnative?branch=master)
2
3
 
3
4
  # Nonnative
4
5
 
@@ -60,21 +61,21 @@ require 'nonnative'
60
61
  Nonnative.configure do |config|
61
62
  config.strategy = :startup
62
63
 
63
- config.process do |d|
64
- d.name = 'start_1'
65
- d.command = 'features/support/bin/start 12_321'
66
- d.timeout = config.strategy.timeout
67
- d.port = 12_321
68
- d.log = 'features/logs/12_321.log'
69
- d.signal = 'INT' # Possible values are described in Signal.list.keys
64
+ config.process do |p|
65
+ p.name = 'start_1'
66
+ p.command = 'features/support/bin/start 12_321'
67
+ p.timeout = config.strategy.timeout
68
+ p.port = 12_321
69
+ p.log = 'features/logs/12_321.log'
70
+ p.signal = 'INT' # Possible values are described in Signal.list.keys
70
71
  end
71
72
 
72
- config.process do |d|
73
- d.name = 'start_2'
74
- d.command = 'features/support/bin/start 12_322'
75
- d.timeout = 0.5
76
- d.port = 12_322
77
- d.log = 'features/logs/12_322.log'
73
+ config.process do |p|
74
+ p.name = 'start_2'
75
+ p.command = 'features/support/bin/start 12_322'
76
+ p.timeout = 0.5
77
+ p.port = 12_322
78
+ p.log = 'features/logs/12_322.log'
78
79
  end
79
80
  end
80
81
  ```
@@ -320,6 +321,8 @@ We allow different proxies to be configured. These proxies can be used to simula
320
321
  - `none` (this is the default)
321
322
  - `fault_injection`
322
323
 
324
+ ##### Processes
325
+
323
326
  Setup it up programmatically:
324
327
 
325
328
  ```ruby
@@ -328,8 +331,46 @@ require 'nonnative'
328
331
  Nonnative.configure do |config|
329
332
  config.strategy = :manual
330
333
 
331
- config.server do |d|
332
- d.proxy = {
334
+ config.process do |p|
335
+ p.proxy = {
336
+ type: 'fault_injection',
337
+ port: 20_000,
338
+ log: 'features/logs/proxy_server.log',
339
+ options: {
340
+ delay: 5
341
+ }
342
+ }
343
+ end
344
+ end
345
+ ```
346
+
347
+ Setup it up through configuration:
348
+
349
+ ```yaml
350
+ version: 1.0
351
+ strategy: manual
352
+ processes:
353
+ -
354
+ proxy:
355
+ type: fault_injection
356
+ port: 20000
357
+ log: features/logs/proxy_server.log
358
+ options:
359
+ delay: 5
360
+ ```
361
+
362
+ ##### Servers
363
+
364
+ Setup it up programmatically:
365
+
366
+ ```ruby
367
+ require 'nonnative'
368
+
369
+ Nonnative.configure do |config|
370
+ config.strategy = :manual
371
+
372
+ config.server do |s|
373
+ s.proxy = {
333
374
  type: 'fault_injection',
334
375
  port: 20_000,
335
376
  log: 'features/logs/proxy_server.log',
@@ -363,6 +404,20 @@ The `fault_injection` proxy allows you to simulate failures by injecting them. W
363
404
  - `delay` - This delays the communication between the connection. Default is 2 secs can be configured through options.
364
405
  - `invalid_data` - This takes the input and rearranges it to produce invalid data.
365
406
 
407
+ ###### Processes
408
+
409
+ Setup it up programmatically:
410
+
411
+ ```ruby
412
+ name = 'name of process in configuration'
413
+ server = Nonnative.pool.process_by_name(name)
414
+
415
+ server.proxy.close_all # To use close_all.
416
+ server.proxy.reset # To reset it back to a good state.
417
+ ```
418
+
419
+ ###### Servers
420
+
366
421
  Setup it up programmatically:
367
422
 
368
423
  ```ruby
@@ -380,24 +435,27 @@ As we love using go as a language for services we have added support to start bi
380
435
  To get this to work you will need to create a `main_test.go` file with these contents:
381
436
 
382
437
  ```go
438
+ // +build features
439
+
383
440
  package main
384
441
 
385
442
  import (
386
443
  "testing"
444
+
445
+ "github.com/your_location/cmd"
387
446
  )
388
447
 
389
- // TestFeatures is a hack that allows us to figure out what the coverage is during
390
- // integration tests. I would not recommend that you use a binary built using
391
- // this hack outside of a test suite.
392
448
  func TestFeatures(t *testing.T) {
393
- main()
449
+ if err := cmd.Execute(); err != nil {
450
+ t.Fatal(err.Error())
451
+ }
394
452
  }
395
453
  ```
396
454
 
397
455
  Then to compile this binary you will need to do the following:
398
456
 
399
457
  ```sh
400
- go test -mod vendor -c -covermode=count -o your_binary -coverpkg=./... github.com/your_location
458
+ go test -mod vendor -c -tags features -covermode=count -o your_binary -coverpkg=./... github.com/your_location
401
459
  ```
402
460
 
403
461
  Then to get an executable you do the following:
data/lib/nonnative.rb CHANGED
@@ -19,11 +19,12 @@ require 'nonnative/stop_error'
19
19
  require 'nonnative/timeout'
20
20
  require 'nonnative/port'
21
21
  require 'nonnative/configuration'
22
+ require 'nonnative/configuration_service'
22
23
  require 'nonnative/configuration_process'
23
24
  require 'nonnative/configuration_server'
24
25
  require 'nonnative/configuration_proxy'
25
26
  require 'nonnative/service'
26
- require 'nonnative/command'
27
+ require 'nonnative/process'
27
28
  require 'nonnative/pool'
28
29
  require 'nonnative/server'
29
30
  require 'nonnative/http_client'
@@ -26,6 +26,8 @@ module Nonnative
26
26
  d.port = fd['port']
27
27
  d.log = fd['log']
28
28
  d.signal = fd['signal']
29
+
30
+ proxy d, fd['proxy']
29
31
  end
30
32
  end
31
33
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- class ConfigurationProcess
5
- attr_accessor :name, :command, :timeout, :port, :log, :signal
4
+ class ConfigurationProcess < ConfigurationService
5
+ attr_accessor :command, :signal
6
6
  end
7
7
  end
@@ -1,19 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- class ConfigurationServer
5
- attr_accessor :name, :klass, :timeout, :port, :log
6
- attr_reader :proxy
7
-
8
- def initialize
9
- @proxy = Nonnative::ConfigurationProxy.new
10
- end
11
-
12
- def proxy=(value)
13
- proxy.type = value[:type]
14
- proxy.port = value[:port]
15
- proxy.log = value[:log]
16
- proxy.options = value[:options]
17
- end
4
+ class ConfigurationServer < ConfigurationService
5
+ attr_accessor :klass
18
6
  end
19
7
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nonnative
4
+ class ConfigurationService
5
+ attr_accessor :name, :timeout, :port, :log
6
+ attr_reader :proxy
7
+
8
+ def initialize
9
+ @proxy = Nonnative::ConfigurationProxy.new
10
+ end
11
+
12
+ def proxy=(value)
13
+ proxy.type = value[:type]
14
+ proxy.port = value[:port]
15
+ proxy.log = value[:log]
16
+ proxy.options = value[:options]
17
+ end
18
+ end
19
+ end
@@ -14,6 +14,11 @@ module Nonnative
14
14
  [processes, servers].each { |t| process(t, :stop, :closed?, &block) }
15
15
  end
16
16
 
17
+ def process_by_name(name)
18
+ index = configuration.processes.find_index { |s| s.name == name }
19
+ processes[index].first
20
+ end
21
+
17
22
  def server_by_name(name)
18
23
  index = configuration.servers.find_index { |s| s.name == name }
19
24
  servers[index].first
@@ -25,7 +30,7 @@ module Nonnative
25
30
 
26
31
  def processes
27
32
  @processes ||= configuration.processes.map do |d|
28
- [Nonnative::Command.new(d), Nonnative::Port.new(d)]
33
+ [Nonnative::Process.new(d), Nonnative::Port.new(d)]
29
34
  end
30
35
  end
31
36
 
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- class Command < Nonnative::Service
4
+ class Process < Nonnative::Service
5
5
  def start
6
- unless command_exists?
7
- @pid = command_spawn
6
+ unless process_exists?
7
+ proxy.start
8
+ @pid = process_spawn
8
9
  wait_start
9
10
  end
10
11
 
@@ -12,8 +13,9 @@ module Nonnative
12
13
  end
13
14
 
14
15
  def stop
15
- if command_exists?
16
- command_kill
16
+ if process_exists?
17
+ process_kill
18
+ proxy.stop
17
19
  wait_stop
18
20
  end
19
21
 
@@ -24,7 +26,7 @@ module Nonnative
24
26
 
25
27
  def wait_stop
26
28
  timeout.perform do
27
- Process.waitpid2(pid)
29
+ ::Process.waitpid2(pid)
28
30
  end
29
31
  end
30
32
 
@@ -32,20 +34,20 @@ module Nonnative
32
34
 
33
35
  attr_reader :pid
34
36
 
35
- def command_kill
37
+ def process_kill
36
38
  signal = Signal.list[service.signal || 'INT'] || Signal.list['INT']
37
- Process.kill(signal, pid)
39
+ ::Process.kill(signal, pid)
38
40
  end
39
41
 
40
- def command_spawn
42
+ def process_spawn
41
43
  spawn(service.command, %i[out err] => [service.log, 'a'])
42
44
  end
43
45
 
44
- def command_exists?
46
+ def process_exists?
45
47
  return false if pid.nil?
46
48
 
47
49
  signal = Signal.list['EXIT']
48
- Process.kill(signal, pid)
50
+ ::Process.kill(signal, pid)
49
51
  true
50
52
  rescue Errno::ESRCH
51
53
  false
@@ -4,12 +4,6 @@ module Nonnative
4
4
  class Server < Nonnative::Service
5
5
  attr_reader :proxy
6
6
 
7
- def initialize(service)
8
- @proxy = Nonnative::ProxyFactory.create(service)
9
-
10
- super service
11
- end
12
-
13
7
  def start
14
8
  unless thread
15
9
  proxy.start
@@ -2,9 +2,12 @@
2
2
 
3
3
  module Nonnative
4
4
  class Service
5
+ attr_reader :proxy
6
+
5
7
  def initialize(service)
6
8
  @service = service
7
9
  @timeout = Nonnative::Timeout.new(service.timeout)
10
+ @proxy = Nonnative::ProxyFactory.create(service)
8
11
  end
9
12
 
10
13
  def name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- VERSION = '1.40.0'
4
+ VERSION = '1.41.0'
5
5
  end
data/nonnative.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'sinatra', '~> 2.0', '>= 2.0.8.1'
35
35
 
36
36
  spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
37
+ spec.add_development_dependency 'coveralls', '~> 0.8.23'
37
38
  spec.add_development_dependency 'rubocop', '~> 1.12'
38
- spec.add_development_dependency 'simplecov', '~> 0.21.2'
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.40.0
4
+ version: 1.41.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Falkowski
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-25 00:00:00.000000000 Z
11
+ date: 2021-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -193,33 +193,33 @@ dependencies:
193
193
  - !ruby/object:Gem::Version
194
194
  version: 2.1.4
195
195
  - !ruby/object:Gem::Dependency
196
- name: rubocop
196
+ name: coveralls
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
199
  - - "~>"
200
200
  - !ruby/object:Gem::Version
201
- version: '1.12'
201
+ version: 0.8.23
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - "~>"
207
207
  - !ruby/object:Gem::Version
208
- version: '1.12'
208
+ version: 0.8.23
209
209
  - !ruby/object:Gem::Dependency
210
- name: simplecov
210
+ name: rubocop
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
213
  - - "~>"
214
214
  - !ruby/object:Gem::Version
215
- version: 0.21.2
215
+ version: '1.12'
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.21.2
222
+ version: '1.12'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: solargraph
225
225
  requirement: !ruby/object:Gem::Requirement
@@ -243,6 +243,7 @@ extra_rdoc_files: []
243
243
  files:
244
244
  - ".circleci/config.yml"
245
245
  - ".config/cucumber.yml"
246
+ - ".coveralls.yml"
246
247
  - ".editorconfig"
247
248
  - ".gitignore"
248
249
  - ".rubocop.yml"
@@ -258,11 +259,11 @@ files:
258
259
  - lib/nonnative.rb
259
260
  - lib/nonnative/before.rb
260
261
  - lib/nonnative/close_all_socket_pair.rb
261
- - lib/nonnative/command.rb
262
262
  - lib/nonnative/configuration.rb
263
263
  - lib/nonnative/configuration_process.rb
264
264
  - lib/nonnative/configuration_proxy.rb
265
265
  - lib/nonnative/configuration_server.rb
266
+ - lib/nonnative/configuration_service.rb
266
267
  - lib/nonnative/delay_socket_pair.rb
267
268
  - lib/nonnative/error.rb
268
269
  - lib/nonnative/fault_injection_proxy.rb
@@ -276,6 +277,7 @@ files:
276
277
  - lib/nonnative/observability.rb
277
278
  - lib/nonnative/pool.rb
278
279
  - lib/nonnative/port.rb
280
+ - lib/nonnative/process.rb
279
281
  - lib/nonnative/proxy.rb
280
282
  - lib/nonnative/proxy_factory.rb
281
283
  - lib/nonnative/server.rb