nonnative 2.0 → 2.8.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/.circleci/config.yml +5 -4
- data/AGENTS.md +86 -202
- data/Gemfile.lock +22 -20
- data/README.md +21 -12
- data/lib/nonnative/configuration.rb +11 -10
- data/lib/nonnative/configuration_proxy.rb +13 -1
- data/lib/nonnative/cucumber.rb +199 -103
- data/lib/nonnative/http_proxy_server.rb +36 -9
- data/lib/nonnative/pool.rb +114 -23
- data/lib/nonnative/process.rb +2 -1
- data/lib/nonnative/version.rb +1 -1
- data/lib/nonnative.rb +59 -15
- data/nonnative.gemspec +1 -0
- metadata +15 -1
data/lib/nonnative.rb
CHANGED
|
@@ -53,7 +53,6 @@ require 'rest-client'
|
|
|
53
53
|
require 'retriable'
|
|
54
54
|
require 'concurrent'
|
|
55
55
|
require 'config'
|
|
56
|
-
require 'cucumber'
|
|
57
56
|
require 'get_process_mem'
|
|
58
57
|
require 'rspec-benchmark'
|
|
59
58
|
require 'rspec/expectations'
|
|
@@ -109,10 +108,10 @@ require 'nonnative/header'
|
|
|
109
108
|
# @see Nonnative::Pool for lifecycle orchestration once started
|
|
110
109
|
module Nonnative
|
|
111
110
|
class << self
|
|
112
|
-
# Returns the current runner pool (created on {Nonnative.start}).
|
|
111
|
+
# Returns or overrides the current runner pool (created on {Nonnative.start}).
|
|
113
112
|
#
|
|
114
113
|
# @return [Nonnative::Pool, nil] the pool instance, or `nil` if not started yet
|
|
115
|
-
|
|
114
|
+
attr_accessor :pool
|
|
116
115
|
|
|
117
116
|
# Loads one or more configuration files using the `config` gem.
|
|
118
117
|
#
|
|
@@ -210,13 +209,19 @@ module Nonnative
|
|
|
210
209
|
def start
|
|
211
210
|
@pool ||= Nonnative::Pool.new(configuration)
|
|
212
211
|
errors = []
|
|
213
|
-
|
|
214
|
-
@pool.start do |name, values, result|
|
|
212
|
+
errors.concat(@pool.start do |name, values, result|
|
|
215
213
|
id, started = values
|
|
216
|
-
errors << "Started #{name} with id #{id}, though did respond in time" if !started || !result
|
|
217
|
-
end
|
|
214
|
+
errors << "Started #{name} with id #{id}, though did not respond in time" if !started || !result
|
|
215
|
+
end)
|
|
216
|
+
nil
|
|
217
|
+
rescue StandardError => e
|
|
218
|
+
errors << unexpected_lifecycle_error(:start, e)
|
|
219
|
+
ensure
|
|
220
|
+
if errors.any?
|
|
221
|
+
errors.concat(rollback_start)
|
|
218
222
|
|
|
219
|
-
|
|
223
|
+
raise Nonnative::StartError, errors.join("\n")
|
|
224
|
+
end
|
|
220
225
|
end
|
|
221
226
|
|
|
222
227
|
# Stops all configured processes and servers, then services, and waits for shutdown.
|
|
@@ -224,14 +229,16 @@ module Nonnative
|
|
|
224
229
|
# @return [void]
|
|
225
230
|
# @raise [Nonnative::StopError] if one or more runners fail to stop in time
|
|
226
231
|
def stop
|
|
227
|
-
return if @pool.nil?
|
|
228
|
-
|
|
229
232
|
errors = []
|
|
233
|
+
return if @pool.nil?
|
|
230
234
|
|
|
231
|
-
@pool.stop do |name, id, result|
|
|
232
|
-
errors << "Stopped #{name} with id #{id}, though did respond in time" unless result
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
+
errors.concat(@pool.stop do |name, id, result|
|
|
236
|
+
errors << "Stopped #{name} with id #{id}, though did not respond in time" unless result
|
|
237
|
+
end)
|
|
238
|
+
nil
|
|
239
|
+
rescue StandardError => e
|
|
240
|
+
errors << unexpected_lifecycle_error(:stop, e)
|
|
241
|
+
ensure
|
|
235
242
|
raise Nonnative::StopError, errors.join("\n") unless errors.empty?
|
|
236
243
|
end
|
|
237
244
|
|
|
@@ -242,6 +249,22 @@ module Nonnative
|
|
|
242
249
|
@configuration = nil
|
|
243
250
|
end
|
|
244
251
|
|
|
252
|
+
# Closes and clears the memoized logger instance.
|
|
253
|
+
#
|
|
254
|
+
# @return [void]
|
|
255
|
+
def clear_logger
|
|
256
|
+
@logger&.close
|
|
257
|
+
ensure
|
|
258
|
+
@logger = nil
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Clears the memoized observability client.
|
|
262
|
+
#
|
|
263
|
+
# @return [void]
|
|
264
|
+
def clear_observability
|
|
265
|
+
@observability = nil
|
|
266
|
+
end
|
|
267
|
+
|
|
245
268
|
# Clears the memoized pool instance.
|
|
246
269
|
#
|
|
247
270
|
# @return [void]
|
|
@@ -249,10 +272,12 @@ module Nonnative
|
|
|
249
272
|
@pool = nil
|
|
250
273
|
end
|
|
251
274
|
|
|
252
|
-
# Clears memoized configuration and pool.
|
|
275
|
+
# Clears memoized configuration, logger, observability client, and pool.
|
|
253
276
|
#
|
|
254
277
|
# @return [void]
|
|
255
278
|
def clear
|
|
279
|
+
clear_logger
|
|
280
|
+
clear_observability
|
|
256
281
|
clear_configuration
|
|
257
282
|
clear_pool
|
|
258
283
|
end
|
|
@@ -264,5 +289,24 @@ module Nonnative
|
|
|
264
289
|
def reset
|
|
265
290
|
Nonnative.pool.reset
|
|
266
291
|
end
|
|
292
|
+
|
|
293
|
+
private
|
|
294
|
+
|
|
295
|
+
def rollback_start
|
|
296
|
+
errors = []
|
|
297
|
+
return errors if @pool.nil?
|
|
298
|
+
|
|
299
|
+
errors.concat(@pool.rollback do |name, id, result|
|
|
300
|
+
errors << "Rollback failed for #{name} with id #{id}, because it did not stop in time" unless result
|
|
301
|
+
end)
|
|
302
|
+
rescue StandardError => e
|
|
303
|
+
errors << unexpected_lifecycle_error(:rollback, e)
|
|
304
|
+
ensure
|
|
305
|
+
clear_pool if errors.empty?
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
def unexpected_lifecycle_error(action, error)
|
|
309
|
+
"#{action.to_s.capitalize} failed with #{error.class}: #{error.message}"
|
|
310
|
+
end
|
|
267
311
|
end
|
|
268
312
|
end
|
data/nonnative.gemspec
CHANGED
|
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.add_dependency 'concurrent-ruby', '>= 1', '< 2'
|
|
28
28
|
spec.add_dependency 'config', '>= 5', '< 6'
|
|
29
29
|
spec.add_dependency 'cucumber', '>= 7', '< 11'
|
|
30
|
+
spec.add_dependency 'cucumber-cucumber-expressions', '< 19'
|
|
30
31
|
spec.add_dependency 'get_process_mem', '>= 1', '< 2'
|
|
31
32
|
spec.add_dependency 'grpc', '>= 1', '< 2'
|
|
32
33
|
spec.add_dependency 'puma', '>= 7', '< 8'
|
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:
|
|
4
|
+
version: 2.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alejandro Falkowski
|
|
@@ -69,6 +69,20 @@ dependencies:
|
|
|
69
69
|
- - "<"
|
|
70
70
|
- !ruby/object:Gem::Version
|
|
71
71
|
version: '11'
|
|
72
|
+
- !ruby/object:Gem::Dependency
|
|
73
|
+
name: cucumber-cucumber-expressions
|
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
|
75
|
+
requirements:
|
|
76
|
+
- - "<"
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '19'
|
|
79
|
+
type: :runtime
|
|
80
|
+
prerelease: false
|
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - "<"
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '19'
|
|
72
86
|
- !ruby/object:Gem::Dependency
|
|
73
87
|
name: get_process_mem
|
|
74
88
|
requirement: !ruby/object:Gem::Requirement
|