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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +14 -13
- data/lib/nonnative/configuration.rb +8 -1
- data/lib/nonnative/configuration_runner.rb +1 -1
- data/lib/nonnative/configuration_service.rb +28 -0
- data/lib/nonnative/fault_injection_proxy.rb +3 -3
- data/lib/nonnative/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3e20a9fa436249c182c4fc90bfaaeeaed91035899d31340eba35d1f4208a31ab
|
|
4
|
+
data.tar.gz: c68e618e0a2a48cf9958210a8200a96c2aff7c0406eeec332bea01cf9290e860
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c228d28fa41f6e9d526c107feedb4aebfed673aca7b47d7262913db7ceb04468772a1ca068fd4cf696a46a50fc52f01f3dfb9934547945c6ef78b03298cd6cc4
|
|
7
|
+
data.tar.gz: 60ebed64503ac1505ccd4398330290627600f14519d40389ba96a5e02189762e7d54b314ee98fdd31220f9aba560fc6e09ad7340ffc3925b3f3359747bcf0c0f
|
data/Gemfile.lock
CHANGED
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
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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
|
-
|
|
587
|
-
- 5432
|
|
590
|
+
port: 5432
|
|
588
591
|
-
|
|
589
592
|
name: redis
|
|
590
593
|
host: 127.0.0.1
|
|
591
|
-
|
|
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.
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
|
@@ -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
|
|
22
|
-
#
|
|
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
|
|
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]
|
data/lib/nonnative/version.rb
CHANGED