nonnative 1.23.0 → 1.24.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: 2265811d2fdb090bd12cb35065038272974519ad6a7758bb2b7c281ca7b804c1
4
- data.tar.gz: c08f324e5de548b1457f3ff16585569f7917340b6367dc0b9d1cc1ceae2d4645
3
+ metadata.gz: 39dfda3ff344a41e06816d7f7cbc152a53d8b5bc98090113e1c79109ea2faf95
4
+ data.tar.gz: b1fbf5078dfa16d8fb89fc0699af0bebdc2a47473b455d71f3b7cd7bab390b8c
5
5
  SHA512:
6
- metadata.gz: dfe2d40e5c27f6d9425fbfc7059ce3d3723fdb00451a7a72a399d359627f7424699b044115848c45a7e180606919f81d03a439d6942acfbbcd8584350e35499a
7
- data.tar.gz: 6b2221ac50779bf621e5377ae1940f0621e4f1b4d6349aead6f9adac575d37f9f3d04e12aa65f9118fdc8b277d8021e653566c77cc1dee2815ef501d8b936073
6
+ metadata.gz: a797cf86fe77a38f9ebb5fa78f0dd20f24ce9e91f5666ae0c264ce1a37c9e91bba4ff19389da82c5de6fa48099d0187b6789fa1abb296383a8a186280b3b8ab0
7
+ data.tar.gz: 7a559c54037a22f2b01c995787cac36a076b5afbd8c68a3f1c72ed9f50f4543ff73d060514ea747c4db6964348d568d0a38c222476a33fa8886919e10b8ca093
@@ -9,7 +9,7 @@ Metrics/MethodLength:
9
9
  Max: 20
10
10
 
11
11
  Metrics/BlockLength:
12
- Max: 60
12
+ Max: 70
13
13
 
14
14
  Metrics/AbcSize:
15
15
  Max: 20
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (1.23.0)
4
+ nonnative (1.24.0)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.5)
6
6
  cucumber (>= 4, < 5)
7
7
  grpc (>= 1, < 2)
data/README.md CHANGED
@@ -311,7 +311,10 @@ Nonnative.configure do |config|
311
311
  config.server do |d|
312
312
  d.proxy = {
313
313
  type: 'chaos',
314
- port: 20_000
314
+ port: 20_000,
315
+ options: {
316
+ delay: 5
317
+ }
315
318
  }
316
319
  end
317
320
  end
@@ -327,13 +330,15 @@ servers:
327
330
  proxy:
328
331
  type: chaos
329
332
  port: 20000
333
+ options:
334
+ delay: 5
330
335
  ```
331
336
 
332
337
  ##### Fault Injection
333
338
 
334
339
  The `chaos` proxy allows you to simulate failures by injecting them. We currently support the following:
335
340
  - `close_all` - Closes the socket as soon as it connects.
336
- - `delay` - This delays the communication between the connection.
341
+ - `delay` - This delays the communication between the connection. Default is 2 secs can be configured through options.
337
342
  - `invalid_data` - This takes the input and rearranges it to produce invalid data.
338
343
 
339
344
  Setup it up programmatically:
@@ -47,7 +47,7 @@ module Nonnative
47
47
  def perform_start
48
48
  loop do
49
49
  thread = Thread.start(tcp_server.accept) do |local_socket|
50
- SocketPairFactory.create(read_state, port).connect(local_socket)
50
+ SocketPairFactory.create(read_state, service.proxy).connect(local_socket)
51
51
  connections.delete(Thread.current.object_id)
52
52
  end
53
53
  thread.report_on_exception = false
@@ -44,7 +44,8 @@ module Nonnative
44
44
  if proxy
45
45
  s.proxy = {
46
46
  type: proxy['type'],
47
- port: proxy['port']
47
+ port: proxy['port'],
48
+ options: proxy['options']
48
49
  }
49
50
  end
50
51
  end
@@ -2,11 +2,12 @@
2
2
 
3
3
  module Nonnative
4
4
  class ConfigurationProxy
5
- attr_accessor :type, :port
5
+ attr_accessor :type, :port, :options
6
6
 
7
7
  def initialize
8
8
  self.type = 'none'
9
9
  self.port = 0
10
+ self.options = {}
10
11
  end
11
12
  end
12
13
  end
@@ -3,7 +3,6 @@
3
3
  module Nonnative
4
4
  class ConfigurationServer
5
5
  attr_accessor :name, :klass, :timeout, :port
6
-
7
6
  attr_reader :proxy
8
7
 
9
8
  def initialize
@@ -13,6 +12,7 @@ module Nonnative
13
12
  def proxy=(value)
14
13
  proxy.type = value[:type]
15
14
  proxy.port = value[:port]
15
+ proxy.options = value[:options]
16
16
  end
17
17
  end
18
18
  end
@@ -3,7 +3,8 @@
3
3
  module Nonnative
4
4
  class DelaySocketPair < SocketPair
5
5
  def read(socket)
6
- sleep 2
6
+ duration = proxy.options.dig(:delay) || 2
7
+ sleep duration
7
8
 
8
9
  super socket
9
10
  end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Nonnative
4
4
  class SocketPair
5
- def initialize(port)
6
- @port = port
5
+ def initialize(proxy)
6
+ @proxy = proxy
7
7
  end
8
8
 
9
9
  def connect(local_socket)
@@ -22,10 +22,10 @@ module Nonnative
22
22
 
23
23
  protected
24
24
 
25
- attr_reader :port
25
+ attr_reader :proxy
26
26
 
27
27
  def create_remote_socket
28
- ::TCPSocket.new('0.0.0.0', port)
28
+ ::TCPSocket.new('0.0.0.0', proxy.port)
29
29
  end
30
30
 
31
31
  def pipe(ready, socket1, socket2)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- VERSION = '1.23.0'
4
+ VERSION = '1.24.0'
5
5
  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: 1.23.0
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Falkowski