nonnative 3.0.0 → 3.1.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: 786062cd10bbaba4298dd41abc683bc7a5fd769ea7c41a05e39a9f41bc2c5d96
4
- data.tar.gz: 1d0e8303858861f849aacbcb54ba2bac1f5a8336fdb74c44d09cb48881658c9f
3
+ metadata.gz: 3e20a9fa436249c182c4fc90bfaaeeaed91035899d31340eba35d1f4208a31ab
4
+ data.tar.gz: c68e618e0a2a48cf9958210a8200a96c2aff7c0406eeec332bea01cf9290e860
5
5
  SHA512:
6
- metadata.gz: 729e1141493b2b21c5c9014216a73aade7f7ec1ab03686ab581cbcb1b1c28d2d469a4fd5e416bcd391c2f8056725433a0befe40c283357166b0743f3f4f2d834
7
- data.tar.gz: e17dfe6bd69bbf4d0faf76d0b37502a32abf1ca0943d24f261c4c32301be86fff18e302f65dc9af32ac499ca73d5fe4a08ede17422d2de715a15b4c986ea64c7
6
+ metadata.gz: c228d28fa41f6e9d526c107feedb4aebfed673aca7b47d7262913db7ceb04468772a1ca068fd4cf696a46a50fc52f01f3dfb9934547945c6ef78b03298cd6cc4
7
+ data.tar.gz: 60ebed64503ac1505ccd4398330290627600f14519d40389ba96a5e02189762e7d54b314ee98fdd31220f9aba560fc6e09ad7340ffc3925b3f3359747bcf0c0f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (3.0.0)
4
+ nonnative (3.1.0)
5
5
  concurrent-ruby (>= 1, < 2)
6
6
  config (>= 5, < 6)
7
7
  cucumber (>= 7, < 12)
data/README.md CHANGED
@@ -58,19 +58,23 @@ High-level configuration fields:
58
58
 
59
59
  Common runner fields:
60
60
  - `name`: runner name used for lookup.
61
- - `host`/`ports`: client-facing address. `host` defaults to `127.0.0.1`. For processes and servers, this address is also used for readiness/shutdown port checks. When a `fault_injection` proxy is enabled, clients should hit the first configured port.
61
+ - `host`: client-facing host. Defaults to `127.0.0.1`.
62
62
 
63
63
  Process/server fields:
64
+ - `ports`: client-facing ports. These are also used for readiness/shutdown port checks. When a `fault_injection` proxy is enabled, clients should hit the first configured port.
64
65
  - `timeout`: max time (seconds) for readiness/shutdown port checks.
65
66
  - `wait`: small sleep (seconds) between lifecycle steps.
66
67
  - `log`: per-runner log file used by process output redirection or server implementations.
67
68
 
69
+ Service fields:
70
+ - `port`: client-facing proxy port. Services do not get TCP readiness/shutdown checks from Nonnative.
71
+
68
72
  For `fault_injection`, the nested `proxy.host`/`proxy.port` describe the upstream target behind the proxy. Nested `proxy.host` also defaults to `127.0.0.1`. In-process server implementations typically bind there via `proxy.host` / `proxy.port`.
69
73
 
70
74
  > [!IMPORTANT]
71
- > When a proxy is enabled, tests and clients connect to the runner `host` and first configured `ports` entry; the nested `proxy.host`/`proxy.port` is the upstream target behind the proxy.
75
+ > When a proxy is enabled, tests and clients connect to the runner `host` and client-facing endpoint (`ports` first entry for processes/servers, `port` for services); the nested `proxy.host`/`proxy.port` is the upstream target behind the proxy.
72
76
 
73
- Nonnative readiness and shutdown checks are TCP-only. Configure ports that are dedicated to the test run; if another process is already listening on the same `host`/`ports` endpoint, results are undefined.
77
+ Nonnative readiness and shutdown checks are TCP-only. Configure process/server ports that are dedicated to the test run; if another process is already listening on the same endpoint, results are undefined.
74
78
 
75
79
  > [!WARNING]
76
80
  > Readiness and shutdown checks only prove that a TCP port opened or closed. They do not verify HTTP status, gRPC health, schema readiness, migrations, or application-specific health.
@@ -561,13 +565,13 @@ Nonnative.configure do |config|
561
565
  config.service do |s|
562
566
  s.name = 'postgres'
563
567
  s.host = '127.0.0.1'
564
- s.ports = [5432]
568
+ s.port = 5432
565
569
  end
566
570
 
567
571
  config.service do |s|
568
572
  s.name = 'redis'
569
573
  s.host = '127.0.0.1'
570
- s.ports = [6379]
574
+ s.port = 6379
571
575
  end
572
576
  end
573
577
  ```
@@ -583,13 +587,11 @@ services:
583
587
  -
584
588
  name: postgres
585
589
  host: 127.0.0.1
586
- ports:
587
- - 5432
590
+ port: 5432
588
591
  -
589
592
  name: redis
590
593
  host: 127.0.0.1
591
- ports:
592
- - 6379
594
+ port: 6379
593
595
  ```
594
596
 
595
597
  Then load the file with:
@@ -742,7 +744,7 @@ Nonnative.configure do |config|
742
744
  config.service do |s|
743
745
  s.name = 'redis'
744
746
  s.host = '127.0.0.1'
745
- s.ports = [16_379]
747
+ s.port = 16_379
746
748
 
747
749
  s.proxy = {
748
750
  kind: 'fault_injection',
@@ -769,8 +771,7 @@ services:
769
771
  -
770
772
  name: redis
771
773
  host: 127.0.0.1
772
- ports:
773
- - 16379
774
+ port: 16379
774
775
  proxy:
775
776
  kind: fault_injection
776
777
  host: 127.0.0.1
@@ -785,7 +786,7 @@ services:
785
786
 
786
787
  The `fault_injection` proxy allows you to simulate failures by injecting them. We currently support the following:
787
788
 
788
- Clients connect to the runner `host` and first configured `ports` entry, while the proxy forwards traffic to nested `proxy.host`/`proxy.port`.
789
+ Clients connect to the runner `host` and client-facing endpoint, while the proxy forwards traffic to nested `proxy.host`/`proxy.port`.
789
790
 
790
791
  - `close_all` - Closes the socket as soon as it connects.
791
792
  - `delay` - Delays traffic on the connection. Defaults to 2 seconds and can be configured through options.
@@ -165,7 +165,7 @@ module Nonnative
165
165
  service do |service_config|
166
166
  service_config.name = loaded_service.name
167
167
  service_config.host = loaded_service.host if loaded_service.host
168
- assign_ports(service_config, loaded_service)
168
+ assign_service_port(service_config, loaded_service)
169
169
 
170
170
  assign_proxy(service_config, loaded_service.proxy)
171
171
  end
@@ -193,6 +193,13 @@ module Nonnative
193
193
  runner.ports = loaded.ports if loaded.ports
194
194
  end
195
195
 
196
+ def assign_service_port(service, loaded)
197
+ values = loaded.to_h
198
+ raise ArgumentError, "Use 'port' instead of 'ports' for service '#{loaded.name}'" if values.key?(:ports) || values.key?('ports')
199
+
200
+ service.port = loaded.port if loaded.port
201
+ end
202
+
196
203
  def assign_proxy(runner, loaded_proxy)
197
204
  return unless loaded_proxy
198
205
 
@@ -41,7 +41,7 @@ module Nonnative
41
41
  # @return [void]
42
42
  def initialize
43
43
  self.host = '127.0.0.1'
44
- self.ports = [0]
44
+ @ports = [0]
45
45
  self.wait = 0.1
46
46
 
47
47
  @proxy = Nonnative::ConfigurationProxy.new
@@ -11,5 +11,33 @@ module Nonnative
11
11
  # @see Nonnative::Configuration
12
12
  # @see Nonnative::Service
13
13
  class ConfigurationService < ConfigurationRunner
14
+ # @return [Integer] client-facing port used by the service proxy
15
+ attr_accessor :port
16
+
17
+ # Creates a service configuration with defaults.
18
+ #
19
+ # @return [void]
20
+ def initialize
21
+ super
22
+
23
+ self.port = 0
24
+ end
25
+
26
+ # Services expose a single proxy listener, so plural runner ports are not supported.
27
+ #
28
+ # @return [void]
29
+ # @raise [ArgumentError] when plural service ports are read
30
+ def ports
31
+ raise ArgumentError, "Use 'port' instead of 'ports' for service '#{name}'"
32
+ end
33
+
34
+ # Services expose a single proxy listener, so plural runner ports are not supported.
35
+ #
36
+ # @param _value [Array<Integer>] ignored plural ports
37
+ # @return [void]
38
+ # @raise [ArgumentError] when plural service ports are assigned
39
+ def ports=(_value)
40
+ raise ArgumentError, "Use 'port' instead of 'ports' for service '#{name}'"
41
+ end
14
42
  end
15
43
  end
@@ -18,8 +18,8 @@ module Nonnative
18
18
  #
19
19
  # ## Wiring
20
20
  #
21
- # When enabled, your test/client should connect to the runner `host` and first configured port (the
22
- # proxy endpoint), and the proxy will forward traffic to the upstream target exposed by {#host}:{#port}.
21
+ # When enabled, your test/client should connect to the runner `host` and primary port (the proxy
22
+ # endpoint), and the proxy will forward traffic to the upstream target exposed by {#host}:{#port}.
23
23
  #
24
24
  # ## Configuration
25
25
  #
@@ -62,7 +62,7 @@ module Nonnative
62
62
 
63
63
  # Starts the proxy accept loop in a background thread.
64
64
  #
65
- # This binds a TCP server on the underlying runner’s `service.host` and first configured port.
65
+ # This binds a TCP server on the underlying runner’s `service.host` and primary port.
66
66
  # Clients connect to that runner endpoint, while upstream traffic is forwarded to {#host}:{#port}.
67
67
  #
68
68
  # @return [void]
@@ -4,5 +4,5 @@ module Nonnative
4
4
  # The current gem version.
5
5
  #
6
6
  # @return [String]
7
- VERSION = '3.0.0'
7
+ VERSION = '3.1.0'
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nonnative
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Falkowski