nonnative 1.39.0 → 1.44.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05eabed13ed77a7eea02eb898db4a670c53286639168190c1f068e8683606e9d
4
- data.tar.gz: a50f29b97792cf8248187e30f3aabfb5d204fae05235821b5b358176feca7997
3
+ metadata.gz: f2baafe2a724951013706a01a247386b01a6eecde9194f6cefbc04348e787f07
4
+ data.tar.gz: 99d3a81f1ba4ac6bbc217d0aa48f8d37b11682e6bc18067c07a2e9cf62cd6580
5
5
  SHA512:
6
- metadata.gz: dbed996363616c31404a70079bdfa475aa8917b8f7edc492af04cff257db468599ffc04ab68ac452f47071bee00ffefc0d4e49186f9c58c7cb8a242bb0ea9240
7
- data.tar.gz: 2190e7f96f504645c9e4069660d3af06309a08e48ecb13984656dcc68ee93edd813bbf8ab275eea7f3fee9c7efe2fa9a2c22df9017b5fbfcc673c244a35c0fba
6
+ metadata.gz: cf6dc4e8c8e5e7501c83f05080faba0cda93813ce47cb6b548341114c83f41757228dd0a9c58a2e326c828e7873cb7b85cd121e8ed5eb52ce92a6ebfa636581b
7
+ data.tar.gz: 831daa9769dcb510ac649010bd430bc74d335e93ce9f1791ebd420b37570735ba7cbb46ddb810310ccc0ed659138526e8b84060117c4e048cf55b9e9e8388298
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ repo_token: x3EcMK4Nr770BeIFZengeQ2DLDCDjNfNo
data/CHANGELOG.md CHANGED
@@ -2,6 +2,54 @@
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.44.0](https://github.com/alexfalkowski/nonnative/compare/v1.43.0...v1.44.0) (2021-05-01)
6
+
7
+
8
+ ### Features
9
+
10
+ * move to reusable steps ([#84](https://github.com/alexfalkowski/nonnative/issues/84)) ([37b6175](https://github.com/alexfalkowski/nonnative/commit/37b6175e920dfb70f3d6f13226240dd045c2db3d))
11
+
12
+ ## [1.43.0](https://github.com/alexfalkowski/nonnative/compare/v1.42.2...v1.43.0) (2021-04-30)
13
+
14
+
15
+ ### Features
16
+
17
+ * release version 1.43.0 ([#83](https://github.com/alexfalkowski/nonnative/issues/83)) ([b51526d](https://github.com/alexfalkowski/nonnative/commit/b51526d99d24522a26f534d28769cc8cdee4af04))
18
+
19
+ ### [1.42.2](https://github.com/alexfalkowski/nonnative/compare/v1.42.1...v1.42.2) (2021-04-30)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * make sure we parse services config ([#82](https://github.com/alexfalkowski/nonnative/issues/82)) ([2a52af7](https://github.com/alexfalkowski/nonnative/commit/2a52af74b75443674a2235c424d69f15516ab60f))
25
+
26
+ ### [1.42.1](https://github.com/alexfalkowski/nonnative/compare/v1.42.0...v1.42.1) (2021-04-30)
27
+
28
+ ## [1.42.0](https://github.com/alexfalkowski/nonnative/compare/v1.41.0...v1.42.0) (2021-04-30)
29
+
30
+
31
+ ### Features
32
+
33
+ * add services ([#80](https://github.com/alexfalkowski/nonnative/issues/80)) ([454980e](https://github.com/alexfalkowski/nonnative/commit/454980e1eb141995c96203fcf9254bfe2cb0133e))
34
+
35
+ ## [1.41.0](https://github.com/alexfalkowski/nonnative/compare/v1.40.2...v1.41.0) (2021-04-30)
36
+
37
+
38
+ ### Features
39
+
40
+ * add proxy to processes ([#79](https://github.com/alexfalkowski/nonnative/issues/79)) ([d52b2bb](https://github.com/alexfalkowski/nonnative/commit/d52b2bb6fad91612f9b9a64817c861d1c227ef0b))
41
+
42
+ ### [1.40.2](https://github.com/alexfalkowski/nonnative/compare/v1.40.1...v1.40.2) (2021-04-27)
43
+
44
+ ### [1.40.1](https://github.com/alexfalkowski/nonnative/compare/v1.40.0...v1.40.1) (2021-04-27)
45
+
46
+ ## [1.40.0](https://github.com/alexfalkowski/nonnative/compare/v1.39.0...v1.40.0) (2021-04-25)
47
+
48
+
49
+ ### Features
50
+
51
+ * update deps ([#76](https://github.com/alexfalkowski/nonnative/issues/76)) ([83c9e16](https://github.com/alexfalkowski/nonnative/commit/83c9e16b5e5f9f14ed2cc5fd2eb29b83147c1e53))
52
+
5
53
  ## [1.39.0](https://github.com/alexfalkowski/nonnative/compare/v1.38.0...v1.39.0) (2021-04-23)
6
54
 
7
55
 
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (1.39.0)
4
+ nonnative (1.44.0)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.5)
6
- cucumber (>= 5, < 6)
6
+ cucumber (>= 6, < 7)
7
7
  grpc (>= 1, < 2)
8
+ grpc-tools (>= 1, < 2)
8
9
  puma (~> 5.0)
9
10
  rest-client (~> 2.1)
10
11
  rspec-benchmark (~> 0.6.0)
@@ -28,37 +29,44 @@ GEM
28
29
  benchmark-trend (0.4.0)
29
30
  builder (3.2.4)
30
31
  concurrent-ruby (1.1.8)
31
- cucumber (5.3.0)
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)
38
+ cucumber (6.0.0)
32
39
  builder (~> 3.2, >= 3.2.4)
33
- cucumber-core (~> 8.0, >= 8.0.1)
34
- cucumber-create-meta (~> 2.0, >= 2.0.2)
35
- cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
36
- cucumber-gherkin (~> 15.0, >= 15.0.2)
37
- cucumber-html-formatter (~> 9.0, >= 9.0.0)
38
- cucumber-messages (~> 13.1, >= 13.1.0)
39
- cucumber-wire (~> 4.0, >= 4.0.1)
40
+ cucumber-core (~> 9.0, >= 9.0.0)
41
+ cucumber-create-meta (~> 4.0, >= 4.0.0)
42
+ cucumber-cucumber-expressions (~> 12.1, >= 12.1.1)
43
+ cucumber-gherkin (~> 18.1, >= 18.1.0)
44
+ cucumber-html-formatter (~> 13.0, >= 13.0.0)
45
+ cucumber-messages (~> 15.0, >= 15.0.0)
46
+ cucumber-wire (~> 5.0, >= 5.0.0)
40
47
  diff-lcs (~> 1.4, >= 1.4.4)
48
+ mime-types (~> 3.3, >= 3.3.1)
41
49
  multi_test (~> 0.1, >= 0.1.2)
42
- sys-uname (~> 1.2, >= 1.2.1)
43
- cucumber-core (8.0.1)
44
- cucumber-gherkin (~> 15.0, >= 15.0.2)
45
- cucumber-messages (~> 13.0, >= 13.0.1)
46
- cucumber-tag-expressions (~> 2.0, >= 2.0.4)
47
- cucumber-create-meta (2.0.4)
48
- cucumber-messages (~> 13.1, >= 13.1.0)
49
- sys-uname (~> 1.2, >= 1.2.1)
50
- cucumber-cucumber-expressions (10.3.0)
51
- cucumber-gherkin (15.0.2)
52
- cucumber-messages (~> 13.0, >= 13.0.1)
53
- cucumber-html-formatter (9.0.0)
54
- cucumber-messages (~> 13.0, >= 13.0.1)
55
- cucumber-messages (13.2.1)
50
+ sys-uname (~> 1.2, >= 1.2.2)
51
+ cucumber-core (9.0.0)
52
+ cucumber-gherkin (~> 18.1, >= 18.1.0)
53
+ cucumber-messages (~> 15.0, >= 15.0.0)
54
+ cucumber-tag-expressions (~> 3.0, >= 3.0.1)
55
+ cucumber-create-meta (4.0.0)
56
+ cucumber-messages (~> 15.0, >= 15.0.0)
57
+ sys-uname (~> 1.2, >= 1.2.2)
58
+ cucumber-cucumber-expressions (12.1.1)
59
+ cucumber-gherkin (18.1.1)
60
+ cucumber-messages (~> 15.0, >= 15.0.0)
61
+ cucumber-html-formatter (13.0.0)
62
+ cucumber-messages (~> 15.0, >= 15.0.0)
63
+ cucumber-messages (15.0.0)
56
64
  protobuf-cucumber (~> 3.10, >= 3.10.8)
57
- cucumber-tag-expressions (2.0.4)
58
- cucumber-wire (4.0.1)
59
- cucumber-core (~> 8.0, >= 8.0.1)
60
- cucumber-cucumber-expressions (~> 10.3, >= 10.3.0)
61
- cucumber-messages (~> 13.0, >= 13.0.1)
65
+ cucumber-tag-expressions (3.0.1)
66
+ cucumber-wire (5.0.0)
67
+ cucumber-core (~> 9.0, >= 9.0.0)
68
+ cucumber-cucumber-expressions (~> 12.1, >= 12.1.1)
69
+ cucumber-messages (~> 15.0, >= 15.0.0)
62
70
  diff-lcs (1.4.4)
63
71
  docile (1.3.5)
64
72
  domain_name (0.5.20190701)
@@ -68,16 +76,17 @@ GEM
68
76
  google-protobuf (3.15.8)
69
77
  googleapis-common-protos-types (1.0.6)
70
78
  google-protobuf (~> 3.14)
71
- grpc (1.37.0)
79
+ grpc (1.37.1)
72
80
  google-protobuf (~> 3.15)
73
81
  googleapis-common-protos-types (~> 1.0)
74
- grpc-tools (1.37.0)
82
+ grpc-tools (1.37.1)
75
83
  http-accept (1.7.0)
76
84
  http-cookie (1.0.3)
77
85
  domain_name (~> 0.5)
78
86
  i18n (1.8.10)
79
87
  concurrent-ruby (~> 1.0)
80
88
  jaro_winkler (1.5.4)
89
+ json (2.5.1)
81
90
  kramdown (2.3.1)
82
91
  rexml
83
92
  kramdown-parser-gfm (1.1.0)
@@ -151,12 +160,11 @@ GEM
151
160
  parser (>= 2.7.1.5)
152
161
  ruby-progressbar (1.11.0)
153
162
  ruby2_keywords (0.0.4)
154
- simplecov (0.21.2)
163
+ simplecov (0.16.1)
155
164
  docile (~> 1.1)
156
- simplecov-html (~> 0.11)
157
- simplecov_json_formatter (~> 0.1)
158
- simplecov-html (0.12.3)
159
- simplecov_json_formatter (0.1.2)
165
+ json (>= 1.8, < 3)
166
+ simplecov-html (~> 0.10.0)
167
+ simplecov-html (0.10.2)
160
168
  sinatra (2.1.0)
161
169
  mustermann (~> 1.0)
162
170
  rack (~> 2.2)
@@ -176,11 +184,16 @@ GEM
176
184
  thor (~> 1.0)
177
185
  tilt (~> 2.0)
178
186
  yard (~> 0.9, >= 0.9.24)
187
+ sync (0.5.0)
179
188
  sys-uname (1.2.2)
180
189
  ffi (~> 1.1)
190
+ term-ansicolor (1.7.1)
191
+ tins (~> 1.0)
181
192
  thor (1.0.1)
182
193
  thread_safe (0.3.6)
183
194
  tilt (2.0.10)
195
+ tins (1.28.0)
196
+ sync
184
197
  tzinfo (2.0.4)
185
198
  concurrent-ruby (~> 1.0)
186
199
  unf (0.1.4)
@@ -195,10 +208,9 @@ PLATFORMS
195
208
 
196
209
  DEPENDENCIES
197
210
  bundler (~> 2.1, >= 2.1.4)
198
- grpc-tools (>= 1, < 2)
211
+ coveralls (~> 0.8.23)
199
212
  nonnative!
200
213
  rubocop (~> 1.12)
201
- simplecov (~> 0.21.2)
202
214
  solargraph (~> 0.40.4)
203
215
 
204
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
 
@@ -32,12 +33,12 @@ Or install it yourself as:
32
33
 
33
34
  Configure nonnative with the following:
34
35
 
35
- - Process/Server that you want to start.
36
+ - Process, Server or Service that you want to start.
36
37
  - A timeout value.
37
38
  - Port to verify.
38
39
  - The class for servers.
39
40
  - The log for servers/processes
40
- - The strategy for processes/servers.
41
+ - The strategy for processes, servers and services.
41
42
 
42
43
  ### Strategy
43
44
 
@@ -52,6 +53,8 @@ This can be overridden by the following environment variables:
52
53
 
53
54
  ### Processes
54
55
 
56
+ A process is some sort of command that you would run locally.
57
+
55
58
  Setup it up programmatically:
56
59
 
57
60
  ```ruby
@@ -60,21 +63,21 @@ require 'nonnative'
60
63
  Nonnative.configure do |config|
61
64
  config.strategy = :startup
62
65
 
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
66
+ config.process do |p|
67
+ p.name = 'start_1'
68
+ p.command = 'features/support/bin/start 12_321'
69
+ p.timeout = config.strategy.timeout
70
+ p.port = 12_321
71
+ p.log = 'features/logs/12_321.log'
72
+ p.signal = 'INT' # Possible values are described in Signal.list.keys
70
73
  end
71
74
 
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'
75
+ config.process do |p|
76
+ p.name = 'start_2'
77
+ p.command = 'features/support/bin/start 12_322'
78
+ p.timeout = 0.5
79
+ p.port = 12_322
80
+ p.log = 'features/logs/12_322.log'
78
81
  end
79
82
  end
80
83
  ```
@@ -83,7 +86,7 @@ Setup it up through configuration:
83
86
 
84
87
  ```yaml
85
88
  version: 1.0
86
- strategy: manual
89
+ strategy: startup
87
90
  processes:
88
91
  -
89
92
  name: start_1
@@ -110,6 +113,8 @@ Nonnative.load_configuration('configuration.yml')
110
113
 
111
114
  ### Servers
112
115
 
116
+ A server is a dependency to some external API.
117
+
113
118
  Define your server:
114
119
 
115
120
  ```ruby
@@ -139,7 +144,7 @@ Setup it up programmatically:
139
144
  require 'nonnative'
140
145
 
141
146
  Nonnative.configure do |config|
142
- config.strategy = :manual
147
+ config.strategy = :startup
143
148
 
144
149
  config.server do |s|
145
150
  s.name = 'server_1'
@@ -163,7 +168,7 @@ Setup it up through configuration:
163
168
 
164
169
  ```yaml
165
170
  version: 1.0
166
- strategy: manual
171
+ strategy: startup
167
172
  servers:
168
173
  -
169
174
  name: server_1
@@ -219,7 +224,7 @@ Setup it up programmatically:
219
224
  require 'nonnative'
220
225
 
221
226
  Nonnative.configure do |config|
222
- config.strategy = :manual
227
+ config.strategy = :startup
223
228
 
224
229
  config.server do |s|
225
230
  s.name = 'http_server_1'
@@ -235,7 +240,7 @@ Setup it up through configuration:
235
240
 
236
241
  ```yaml
237
242
  version: 1.0
238
- strategy: manual
243
+ strategy: startup
239
244
  servers:
240
245
  -
241
246
  name: http_server_1
@@ -281,7 +286,7 @@ Setup it up programmatically:
281
286
  require 'nonnative'
282
287
 
283
288
  Nonnative.configure do |config|
284
- config.strategy = :manual
289
+ config.strategy = :startup
285
290
 
286
291
  config.server do |s|
287
292
  s.name = 'grpc_server_1'
@@ -297,7 +302,7 @@ Setup it up through configuration:
297
302
 
298
303
  ```yaml
299
304
  version: 1.0
300
- strategy: manual
305
+ strategy: startup
301
306
  servers:
302
307
  -
303
308
  name: grpc_server_1
@@ -314,22 +319,71 @@ require 'nonnative'
314
319
 
315
320
  Nonnative.load_configuration('configuration.yml')
316
321
  ```
322
+
323
+ ### Services
324
+
325
+ A service is an external dependency to your system. This is usually an expensive process to start like a DB and you would prefer to be managed externally. Services are not really exciting by themselves, it's when we add proxies that they allow us to do some extra work.
326
+
327
+ Setup it up programmatically:
328
+
329
+ ```ruby
330
+ require 'nonnative'
331
+
332
+ Nonnative.configure do |config|
333
+ config.strategy = :startup
334
+
335
+ config.service do |s|
336
+ s.name = 'postgres'
337
+ p.port = 5432
338
+ end
339
+
340
+ config.service do |s|
341
+ s.name = 'redis'
342
+ s.port = 6379
343
+ end
344
+ end
345
+ ```
346
+
347
+ Setup it up through configuration:
348
+
349
+ ```yaml
350
+ version: 1.0
351
+ strategy: startup
352
+ processes:
353
+ -
354
+ name: postgres
355
+ port: 5432
356
+ -
357
+ name: redis
358
+ port: 6379
359
+ ```
360
+
361
+ Then load the file with
362
+
363
+ ```ruby
364
+ require 'nonnative'
365
+
366
+ Nonnative.load_configuration('configuration.yml')
367
+ ```
368
+
317
369
  #### Proxies
318
370
 
319
371
  We allow different proxies to be configured. These proxies can be used to simulate all kind of situations. The proxies that can be configured are:
320
372
  - `none` (this is the default)
321
373
  - `fault_injection`
322
374
 
375
+ ##### Processes
376
+
323
377
  Setup it up programmatically:
324
378
 
325
379
  ```ruby
326
380
  require 'nonnative'
327
381
 
328
382
  Nonnative.configure do |config|
329
- config.strategy = :manual
383
+ config.strategy = :startup
330
384
 
331
- config.server do |d|
332
- d.proxy = {
385
+ config.process do |p|
386
+ p.proxy = {
333
387
  type: 'fault_injection',
334
388
  port: 20_000,
335
389
  log: 'features/logs/proxy_server.log',
@@ -345,7 +399,45 @@ Setup it up through configuration:
345
399
 
346
400
  ```yaml
347
401
  version: 1.0
348
- strategy: manual
402
+ strategy: startup
403
+ processes:
404
+ -
405
+ proxy:
406
+ type: fault_injection
407
+ port: 20000
408
+ log: features/logs/proxy_server.log
409
+ options:
410
+ delay: 5
411
+ ```
412
+
413
+ ##### Servers
414
+
415
+ Setup it up programmatically:
416
+
417
+ ```ruby
418
+ require 'nonnative'
419
+
420
+ Nonnative.configure do |config|
421
+ config.strategy = :startup
422
+
423
+ config.server do |s|
424
+ s.proxy = {
425
+ type: 'fault_injection',
426
+ port: 20_000,
427
+ log: 'features/logs/proxy_server.log',
428
+ options: {
429
+ delay: 5
430
+ }
431
+ }
432
+ end
433
+ end
434
+ ```
435
+
436
+ Setup it up through configuration:
437
+
438
+ ```yaml
439
+ version: 1.0
440
+ strategy: startup
349
441
  servers:
350
442
  -
351
443
  proxy:
@@ -356,6 +448,44 @@ servers:
356
448
  delay: 5
357
449
  ```
358
450
 
451
+ ##### Services
452
+
453
+ Setup it up programmatically:
454
+
455
+ ```ruby
456
+ require 'nonnative'
457
+
458
+ Nonnative.configure do |config|
459
+ config.strategy = :startup
460
+
461
+ config.service do |s|
462
+ s.proxy = {
463
+ type: 'fault_injection',
464
+ port: 20_000,
465
+ log: 'features/logs/proxy_server.log',
466
+ options: {
467
+ delay: 5
468
+ }
469
+ }
470
+ end
471
+ end
472
+ ```
473
+
474
+ Setup it up through configuration:
475
+
476
+ ```yaml
477
+ version: 1.0
478
+ strategy: startup
479
+ services:
480
+ -
481
+ proxy:
482
+ type: fault_injection
483
+ port: 20000
484
+ log: features/logs/proxy_server.log
485
+ options:
486
+ delay: 5
487
+ ```
488
+
359
489
  ##### Fault Injection
360
490
 
361
491
  The `fault_injection` proxy allows you to simulate failures by injecting them. We currently support the following:
@@ -363,6 +493,27 @@ The `fault_injection` proxy allows you to simulate failures by injecting them. W
363
493
  - `delay` - This delays the communication between the connection. Default is 2 secs can be configured through options.
364
494
  - `invalid_data` - This takes the input and rearranges it to produce invalid data.
365
495
 
496
+ ###### Processes
497
+
498
+ Setup it up programmatically:
499
+
500
+ ```ruby
501
+ name = 'name of process in configuration'
502
+ server = Nonnative.pool.process_by_name(name)
503
+
504
+ server.proxy.close_all # To use close_all.
505
+ server.proxy.reset # To reset it back to a good state.
506
+ ```
507
+
508
+ With cucumber:
509
+
510
+ ```cucumber
511
+ Given I set the proxy for process 'process_1' to 'close_all'
512
+ Then And I should reset the proxy for process 'process_1'
513
+ ```
514
+
515
+ ###### Servers
516
+
366
517
  Setup it up programmatically:
367
518
 
368
519
  ```ruby
@@ -373,6 +524,32 @@ server.proxy.close_all # To use close_all.
373
524
  server.proxy.reset # To reset it back to a good state.
374
525
  ```
375
526
 
527
+ With cucumber:
528
+
529
+ ```cucumber
530
+ Given I set the proxy for server 'server_1' to 'close_all'
531
+ Then And I should reset the proxy for server 'server_1'
532
+ ```
533
+
534
+ ###### Services
535
+
536
+ Setup it up programmatically:
537
+
538
+ ```ruby
539
+ name = 'name of service in configuration'
540
+ service = Nonnative.pool.service_by_name(name)
541
+
542
+ service.proxy.close_all # To use close_all.
543
+ service.proxy.reset # To reset it back to a good state.
544
+ ```
545
+
546
+ With cucumber:
547
+
548
+ ```cucumber
549
+ Given I set the proxy for service 'service_1' to 'close_all'
550
+ Then And I should reset the proxy for service 'service_1'
551
+ ```
552
+
376
553
  ### Go
377
554
 
378
555
  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`
@@ -380,24 +557,27 @@ As we love using go as a language for services we have added support to start bi
380
557
  To get this to work you will need to create a `main_test.go` file with these contents:
381
558
 
382
559
  ```go
560
+ // +build features
561
+
383
562
  package main
384
563
 
385
564
  import (
386
565
  "testing"
566
+
567
+ "github.com/your_location/cmd"
387
568
  )
388
569
 
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
570
  func TestFeatures(t *testing.T) {
393
- main()
571
+ if err := cmd.Execute(); err != nil {
572
+ t.Fatal(err.Error())
573
+ }
394
574
  }
395
575
  ```
396
576
 
397
577
  Then to compile this binary you will need to do the following:
398
578
 
399
579
  ```sh
400
- go test -mod vendor -c -covermode=count -o your_binary -coverpkg=./... github.com/your_location
580
+ go test -mod vendor -c -tags features -covermode=count -o your_binary -coverpkg=./... github.com/your_location
401
581
  ```
402
582
 
403
583
  Then to get an executable you do the following:
data/lib/nonnative.rb CHANGED
@@ -11,21 +11,26 @@ 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'
24
+ require 'nonnative/configuration_runner'
22
25
  require 'nonnative/configuration_process'
23
26
  require 'nonnative/configuration_server'
27
+ require 'nonnative/configuration_service'
24
28
  require 'nonnative/configuration_proxy'
29
+ require 'nonnative/runner'
30
+ require 'nonnative/process'
31
+ require 'nonnative/server'
25
32
  require 'nonnative/service'
26
- require 'nonnative/command'
27
33
  require 'nonnative/pool'
28
- require 'nonnative/server'
29
34
  require 'nonnative/http_client'
30
35
  require 'nonnative/http_server'
31
36
  require 'nonnative/grpc_server'
@@ -41,6 +46,7 @@ require 'nonnative/invalid_data_socket_pair'
41
46
  require 'nonnative/socket_pair_factory'
42
47
  require 'nonnative/strategy'
43
48
  require 'nonnative/go_command'
49
+ require 'nonnative/cucumber'
44
50
 
45
51
  module Nonnative
46
52
  class << self
@@ -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
@@ -3,7 +3,6 @@
3
3
  module Nonnative
4
4
  class CloseAllSocketPair < SocketPair
5
5
  def connect(local_socket)
6
- ensure
7
6
  local_socket.close
8
7
  end
9
8
  end
@@ -11,6 +11,7 @@ module Nonnative
11
11
 
12
12
  processes(file, c)
13
13
  servers(file, c)
14
+ services(file, c)
14
15
  end
15
16
  end
16
17
 
@@ -26,6 +27,8 @@ module Nonnative
26
27
  d.port = fd['port']
27
28
  d.log = fd['log']
28
29
  d.signal = fd['signal']
30
+
31
+ proxy d, fd['proxy']
29
32
  end
30
33
  end
31
34
  end
@@ -45,6 +48,20 @@ module Nonnative
45
48
  end
46
49
  end
47
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
+
48
65
  def proxy(server, proxy)
49
66
  return unless proxy
50
67
 
@@ -61,9 +78,10 @@ module Nonnative
61
78
  @strategy = Strategy.new
62
79
  @processes = []
63
80
  @servers = []
81
+ @services = []
64
82
  end
65
83
 
66
- attr_accessor :processes, :servers
84
+ attr_accessor :processes, :servers, :services
67
85
  attr_reader :strategy
68
86
 
69
87
  def strategy=(value)
@@ -83,5 +101,12 @@ module Nonnative
83
101
 
84
102
  servers << server
85
103
  end
104
+
105
+ def service
106
+ service = Nonnative::ConfigurationService.new
107
+ yield service
108
+
109
+ services << service
110
+ end
86
111
  end
87
112
  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 < ConfigurationRunner
5
+ attr_accessor :command, :signal
6
6
  end
7
7
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nonnative
4
+ class ConfigurationRunner
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
@@ -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 < ConfigurationRunner
5
+ attr_accessor :klass
18
6
  end
19
7
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nonnative
4
+ class ConfigurationService < ConfigurationRunner
5
+ end
6
+ 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
@@ -17,8 +17,8 @@ module Nonnative
17
17
  end
18
18
 
19
19
  def stop
20
- thread.terminate
21
- tcp_server.close
20
+ thread&.terminate
21
+ tcp_server&.close
22
22
  end
23
23
 
24
24
  def close_all
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nonnative
4
+ class NotFoundError < Nonnative::Error
5
+ end
6
+ end
@@ -7,34 +7,54 @@ module Nonnative
7
7
  end
8
8
 
9
9
  def start(&block)
10
+ services.each(&:start)
10
11
  [servers, processes].each { |t| process(t, :start, :open?, &block) }
11
12
  end
12
13
 
13
14
  def stop(&block)
14
15
  [processes, servers].each { |t| process(t, :stop, :closed?, &block) }
16
+ services.each(&:stop)
17
+ end
18
+
19
+ def process_by_name(name)
20
+ processes[runner_index(configuration.processes, name)].first
15
21
  end
16
22
 
17
23
  def server_by_name(name)
18
- index = configuration.servers.find_index { |s| s.name == name }
19
- servers[index].first
24
+ servers[runner_index(configuration.servers, name)].first
25
+ end
26
+
27
+ def service_by_name(name)
28
+ services[runner_index(configuration.services, name)]
20
29
  end
21
30
 
22
31
  private
23
32
 
24
33
  attr_reader :configuration
25
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
+
26
42
  def processes
27
- @processes ||= configuration.processes.map do |d|
28
- [Nonnative::Command.new(d), Nonnative::Port.new(d)]
43
+ @processes ||= configuration.processes.map do |p|
44
+ [Nonnative::Process.new(p), Nonnative::Port.new(p)]
29
45
  end
30
46
  end
31
47
 
32
48
  def servers
33
- @servers ||= configuration.servers.map do |d|
34
- [d.klass.new(d), Nonnative::Port.new(d)]
49
+ @servers ||= configuration.servers.map do |s|
50
+ [s.klass.new(s), Nonnative::Port.new(s)]
35
51
  end
36
52
  end
37
53
 
54
+ def services
55
+ @services ||= configuration.services.map { |s| Nonnative::Service.new(s) }
56
+ end
57
+
38
58
  def process(all, type_method, port_method, &block)
39
59
  types = []
40
60
  pids = []
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- class Command < Nonnative::Service
4
+ class Process < Runner
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
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nonnative
4
+ class Runner
5
+ attr_reader :proxy
6
+
7
+ def initialize(service)
8
+ @service = service
9
+ @timeout = Nonnative::Timeout.new(service.timeout)
10
+ @proxy = Nonnative::ProxyFactory.create(service)
11
+ end
12
+
13
+ def name
14
+ service.name
15
+ end
16
+
17
+ protected
18
+
19
+ attr_reader :service, :timeout
20
+
21
+ def wait_start
22
+ sleep 0.1
23
+ end
24
+
25
+ def wait_stop
26
+ sleep 0.1
27
+ end
28
+ end
29
+ end
@@ -1,15 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- class Server < Nonnative::Service
5
- attr_reader :proxy
6
-
7
- def initialize(service)
8
- @proxy = Nonnative::ProxyFactory.create(service)
9
-
10
- super service
11
- end
12
-
4
+ class Server < Runner
13
5
  def start
14
6
  unless thread
15
7
  proxy.start
@@ -1,26 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- class Service
5
- def initialize(service)
6
- @service = service
7
- @timeout = Nonnative::Timeout.new(service.timeout)
4
+ class Service < Runner
5
+ def start
6
+ proxy.start
8
7
  end
9
8
 
10
- def name
11
- service.name
12
- end
13
-
14
- protected
15
-
16
- attr_reader :service, :timeout
17
-
18
- def wait_start
19
- sleep 0.1
20
- end
21
-
22
- def wait_stop
23
- sleep 0.1
9
+ def stop
10
+ proxy.stop
24
11
  end
25
12
  end
26
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- VERSION = '1.39.0'
4
+ VERSION = '1.44.0'
5
5
  end
data/nonnative.gemspec CHANGED
@@ -24,8 +24,9 @@ Gem::Specification.new do |spec|
24
24
  spec.required_ruby_version = ['>= 2.7.0', '< 2.8.0']
25
25
 
26
26
  spec.add_dependency 'concurrent-ruby', '~> 1.0', '>= 1.0.5'
27
- spec.add_dependency 'cucumber', ['>= 5', '< 6']
27
+ spec.add_dependency 'cucumber', ['>= 6', '< 7']
28
28
  spec.add_dependency 'grpc', ['>= 1', '< 2']
29
+ spec.add_dependency 'grpc-tools', ['>= 1', '< 2']
29
30
  spec.add_dependency 'puma', '~> 5.0'
30
31
  spec.add_dependency 'rest-client', '~> 2.1'
31
32
  spec.add_dependency 'rspec-benchmark', '~> 0.6.0'
@@ -33,8 +34,7 @@ Gem::Specification.new do |spec|
33
34
  spec.add_dependency 'sinatra', '~> 2.0', '>= 2.0.8.1'
34
35
 
35
36
  spec.add_development_dependency 'bundler', '~> 2.1', '>= 2.1.4'
36
- spec.add_development_dependency 'grpc-tools', ['>= 1', '< 2']
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.39.0
4
+ version: 1.44.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-23 00:00:00.000000000 Z
11
+ date: 2021-05-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -36,20 +36,20 @@ dependencies:
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '5'
39
+ version: '6'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '6'
42
+ version: '7'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: '5'
49
+ version: '6'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '6'
52
+ version: '7'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: grpc
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -70,6 +70,26 @@ dependencies:
70
70
  - - "<"
71
71
  - !ruby/object:Gem::Version
72
72
  version: '2'
73
+ - !ruby/object:Gem::Dependency
74
+ name: grpc-tools
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '1'
80
+ - - "<"
81
+ - !ruby/object:Gem::Version
82
+ version: '2'
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '1'
90
+ - - "<"
91
+ - !ruby/object:Gem::Version
92
+ version: '2'
73
93
  - !ruby/object:Gem::Dependency
74
94
  name: puma
75
95
  requirement: !ruby/object:Gem::Requirement
@@ -173,25 +193,19 @@ dependencies:
173
193
  - !ruby/object:Gem::Version
174
194
  version: 2.1.4
175
195
  - !ruby/object:Gem::Dependency
176
- name: grpc-tools
196
+ name: coveralls
177
197
  requirement: !ruby/object:Gem::Requirement
178
198
  requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- version: '1'
182
- - - "<"
199
+ - - "~>"
183
200
  - !ruby/object:Gem::Version
184
- version: '2'
201
+ version: 0.8.23
185
202
  type: :development
186
203
  prerelease: false
187
204
  version_requirements: !ruby/object:Gem::Requirement
188
205
  requirements:
189
- - - ">="
190
- - !ruby/object:Gem::Version
191
- version: '1'
192
- - - "<"
206
+ - - "~>"
193
207
  - !ruby/object:Gem::Version
194
- version: '2'
208
+ version: 0.8.23
195
209
  - !ruby/object:Gem::Dependency
196
210
  name: rubocop
197
211
  requirement: !ruby/object:Gem::Requirement
@@ -206,20 +220,6 @@ dependencies:
206
220
  - - "~>"
207
221
  - !ruby/object:Gem::Version
208
222
  version: '1.12'
209
- - !ruby/object:Gem::Dependency
210
- name: simplecov
211
- requirement: !ruby/object:Gem::Requirement
212
- requirements:
213
- - - "~>"
214
- - !ruby/object:Gem::Version
215
- version: 0.21.2
216
- type: :development
217
- prerelease: false
218
- version_requirements: !ruby/object:Gem::Requirement
219
- requirements:
220
- - - "~>"
221
- - !ruby/object:Gem::Version
222
- version: 0.21.2
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,13 @@ 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
+ - lib/nonnative/configuration_runner.rb
265
266
  - lib/nonnative/configuration_server.rb
267
+ - lib/nonnative/configuration_service.rb
268
+ - lib/nonnative/cucumber.rb
266
269
  - lib/nonnative/delay_socket_pair.rb
267
270
  - lib/nonnative/error.rb
268
271
  - lib/nonnative/fault_injection_proxy.rb
@@ -273,11 +276,14 @@ files:
273
276
  - lib/nonnative/invalid_data_socket_pair.rb
274
277
  - lib/nonnative/manual.rb
275
278
  - lib/nonnative/no_proxy.rb
279
+ - lib/nonnative/not_found_error.rb
276
280
  - lib/nonnative/observability.rb
277
281
  - lib/nonnative/pool.rb
278
282
  - lib/nonnative/port.rb
283
+ - lib/nonnative/process.rb
279
284
  - lib/nonnative/proxy.rb
280
285
  - lib/nonnative/proxy_factory.rb
286
+ - lib/nonnative/runner.rb
281
287
  - lib/nonnative/server.rb
282
288
  - lib/nonnative/service.rb
283
289
  - lib/nonnative/socket_pair.rb