rox-rollout 5.0.3 → 5.1.1
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/.github/workflows/e2e_tests.yaml +52 -0
- data/.github/workflows/{ruby.yml → unit_tests.yaml} +4 -5
- data/.gitignore +1 -0
- data/Rakefile +0 -6
- data/e2e-server/.gitignore +1 -0
- data/e2e-server/run_server.sh +7 -3
- data/e2e-server/server.rb +26 -56
- data/example/local.rb +7 -7
- data/lib/rox/core/analytics/backoff_policy.rb +51 -0
- data/lib/rox/core/analytics/client.rb +187 -0
- data/lib/rox/core/analytics/defaults.rb +31 -0
- data/lib/rox/core/analytics/logging.rb +62 -0
- data/lib/rox/core/analytics/message_batch.rb +74 -0
- data/lib/rox/core/analytics/response.rb +17 -0
- data/lib/rox/core/analytics/test_queue.rb +58 -0
- data/lib/rox/core/analytics/transport.rb +144 -0
- data/lib/rox/core/analytics/utils.rb +89 -0
- data/lib/rox/core/analytics/worker.rb +67 -0
- data/lib/rox/core/consts/environment.rb +62 -54
- data/lib/rox/core/core.rb +19 -9
- data/lib/rox/core/entities/flag.rb +3 -1
- data/lib/rox/core/entities/rox_double.rb +3 -1
- data/lib/rox/core/entities/rox_int.rb +3 -1
- data/lib/rox/core/entities/rox_string.rb +3 -2
- data/lib/rox/core/impression/impression_invoker.rb +4 -6
- data/lib/rox/core/network/request_configuration_builder.rb +1 -1
- data/lib/rox/core/network/response.rb +2 -2
- data/lib/rox/core/network/state_sender.rb +1 -1
- data/lib/rox/server/network_configurations_options.rb +20 -0
- data/lib/rox/server/rox_options.rb +3 -9
- data/lib/rox/server/self_managed_options.rb +12 -0
- data/lib/rox/version.rb +1 -1
- data/rox.gemspec +2 -2
- metadata +25 -16
- data/.circleci/config.yml +0 -73
- data/e2e/container.rb +0 -35
- data/e2e/custom_props.rb +0 -55
- data/e2e/rox_e2e_test.rb +0 -157
- data/e2e/test_vars.rb +0 -21
@@ -4,7 +4,9 @@ module Rox
|
|
4
4
|
module Core
|
5
5
|
class RoxInt < RoxString
|
6
6
|
def value(context = nil)
|
7
|
-
internal_value(context, false, Integer)
|
7
|
+
return_value = Rox::Server::NormalizeFlagType.normalize_int(internal_value(context, false, Integer))
|
8
|
+
send_impressions(return_value, context)
|
9
|
+
return_value
|
8
10
|
end
|
9
11
|
end
|
10
12
|
end
|
@@ -43,7 +43,9 @@ module Rox
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def value(context = nil)
|
46
|
-
internal_value(context, false)
|
46
|
+
return_value = internal_value(context, false)
|
47
|
+
send_impressions(return_value, context)
|
48
|
+
return_value
|
47
49
|
end
|
48
50
|
|
49
51
|
def internal_value(context, nil_instead_of_default, evaluated_type = String)
|
@@ -59,7 +61,6 @@ module Rox
|
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
62
|
-
send_impressions(return_value, merged_context)
|
63
64
|
return_value
|
64
65
|
end
|
65
66
|
end
|
@@ -18,7 +18,6 @@ module Rox
|
|
18
18
|
@mutex = Mutex.new
|
19
19
|
end
|
20
20
|
|
21
|
-
# TODO: write analytics client and initiate it before using it
|
22
21
|
def call_analytics_gateway(reporting_value, stickiness_property, context)
|
23
22
|
begin
|
24
23
|
analytics_enabled = @internal_flags.enabled?('rox.internal.analytics')
|
@@ -30,9 +29,9 @@ module Rox
|
|
30
29
|
distinct_id = prop_value if prop_value.instance_of?(String)
|
31
30
|
end
|
32
31
|
|
33
|
-
event_time =
|
32
|
+
event_time = DateTime.now.strftime('%Q').to_i
|
34
33
|
begin
|
35
|
-
event_time = ENV['rox.analytics.ms'].to_i
|
34
|
+
event_time = ENV['rox.analytics.ms'].to_i if ENV['rox.analytics.ms']
|
36
35
|
rescue StandardError
|
37
36
|
end
|
38
37
|
|
@@ -40,7 +39,6 @@ module Rox
|
|
40
39
|
flag: reporting_value.name,
|
41
40
|
value: reporting_value.value,
|
42
41
|
distinctId: distinct_id,
|
43
|
-
experimentVersion: '0',
|
44
42
|
type: 'IMPRESSION',
|
45
43
|
time: event_time
|
46
44
|
})
|
@@ -49,9 +47,9 @@ module Rox
|
|
49
47
|
Logging.logger.error('Failed to send analytics', ex)
|
50
48
|
end
|
51
49
|
end
|
52
|
-
|
50
|
+
|
53
51
|
def invoke(reporting_value, stickiness_property, context)
|
54
|
-
|
52
|
+
call_analytics_gateway(reporting_value, stickiness_property, context)
|
55
53
|
raise_impression_event(ImpressionArgs.new(reporting_value, context))
|
56
54
|
end
|
57
55
|
|
@@ -23,7 +23,7 @@ module Rox
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def build_for_api
|
26
|
-
build_request_with_full_params("#{Rox::Core::Environment.api_path
|
26
|
+
build_request_with_full_params("#{Rox::Core::Environment.api_path}/#{relative_path}")
|
27
27
|
end
|
28
28
|
|
29
29
|
def relative_path
|
@@ -21,8 +21,8 @@ module Rox
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def missing_via_response_body?
|
24
|
-
|
25
|
-
|
24
|
+
# api send state respons returns 200 'OK', application/json filters it
|
25
|
+
@status_code == 200 && @content_type == 'application/json' && @text && [404, '404'].include?(JSON.parse(text)['result'])
|
26
26
|
rescue JSON::ParserError
|
27
27
|
Logging.logger.error("Failed to parse JSON response: #{text}")
|
28
28
|
false
|
@@ -69,7 +69,7 @@ module Rox
|
|
69
69
|
|
70
70
|
def send_state_to_API(rollout_key, md5_signature, state_payload)
|
71
71
|
@request.send_post(
|
72
|
-
"#{Rox::Core::Environment.state_api_path
|
72
|
+
"#{Rox::Core::Environment.state_api_path}/#{rollout_key}/#{md5_signature}", state_payload
|
73
73
|
)
|
74
74
|
end
|
75
75
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Rox
|
2
|
+
module Server
|
3
|
+
class NetworkConfigurationsOptions
|
4
|
+
attr_reader :get_config_api_endpoint, :get_config_cloud_endpoint,
|
5
|
+
:send_state_api_endpoint, :send_state_cloud_endpoint,
|
6
|
+
:analytics_endpoint, :push_notification_endpoint
|
7
|
+
|
8
|
+
def initialize(get_config_api_endpoint:, get_config_cloud_endpoint:,
|
9
|
+
send_state_api_endpoint:, send_state_cloud_endpoint:,
|
10
|
+
analytics_endpoint:, push_notification_endpoint:)
|
11
|
+
@get_config_api_endpoint = get_config_api_endpoint
|
12
|
+
@get_config_cloud_endpoint = get_config_cloud_endpoint
|
13
|
+
@send_state_api_endpoint = send_state_api_endpoint
|
14
|
+
@send_state_cloud_endpoint = send_state_cloud_endpoint
|
15
|
+
@analytics_endpoint = analytics_endpoint
|
16
|
+
@push_notification_endpoint = push_notification_endpoint
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -3,20 +3,12 @@ require 'rox/server/logging/server_logger'
|
|
3
3
|
|
4
4
|
module Rox
|
5
5
|
module Server
|
6
|
-
class SelfManagedOptions
|
7
|
-
attr_reader :server_url, :analytics_url
|
8
|
-
|
9
|
-
def initialize(server_url:, analytics_url:)
|
10
|
-
@server_url = server_url
|
11
|
-
@analytics_url = analytics_url
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
6
|
class RoxOptions
|
16
7
|
attr_reader :dev_mode_key, :version, :fetch_interval,
|
17
8
|
:logger, :impression_handler,
|
18
9
|
:configuration_fetched_handler,
|
19
10
|
:roxy_url, :self_managed_options,
|
11
|
+
:network_configurations_options,
|
20
12
|
:dynamic_property_rule_handler
|
21
13
|
|
22
14
|
def initialize(
|
@@ -28,6 +20,7 @@ module Rox
|
|
28
20
|
configuration_fetched_handler: nil,
|
29
21
|
roxy_url: nil,
|
30
22
|
self_managed_options: nil,
|
23
|
+
network_configurations_options: nil,
|
31
24
|
dynamic_property_rule_handler: nil
|
32
25
|
)
|
33
26
|
@dev_mode_key = dev_mode_key || 'stam'
|
@@ -45,6 +38,7 @@ module Rox
|
|
45
38
|
@configuration_fetched_handler = configuration_fetched_handler
|
46
39
|
@roxy_url = roxy_url
|
47
40
|
@self_managed_options = self_managed_options
|
41
|
+
@network_configurations_options = network_configurations_options
|
48
42
|
@dynamic_property_rule_handler = dynamic_property_rule_handler || proc do |prop_name, context|
|
49
43
|
context ? context[prop_name] : nil
|
50
44
|
end
|
data/lib/rox/version.rb
CHANGED
data/rox.gemspec
CHANGED
@@ -20,11 +20,11 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.required_ruby_version = '>= 2.
|
23
|
+
spec.required_ruby_version = '>= 2.5'
|
24
24
|
|
25
25
|
spec.add_runtime_dependency 'em-eventsource', '~> 0.3.2'
|
26
26
|
|
27
|
-
spec.add_development_dependency 'bundler', '~> 2.
|
27
|
+
spec.add_development_dependency 'bundler', '~> 2.4.6'
|
28
28
|
spec.add_development_dependency 'minitest', '~> 5.11'
|
29
29
|
spec.add_development_dependency 'pry-byebug', '~> 3.7.0'
|
30
30
|
spec.add_development_dependency 'rake', '~> 12.3'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rox-rollout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CloudBees
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: em-eventsource
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.4.6
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.4.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,16 +108,16 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 3.7.5
|
111
|
-
description:
|
111
|
+
description:
|
112
112
|
email:
|
113
113
|
- support@rollout.io
|
114
114
|
executables: []
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
|
-
- ".circleci/config.yml"
|
119
118
|
- ".editorconfig"
|
120
|
-
- ".github/workflows/
|
119
|
+
- ".github/workflows/e2e_tests.yaml"
|
120
|
+
- ".github/workflows/unit_tests.yaml"
|
121
121
|
- ".gitignore"
|
122
122
|
- ".rubocop.yml"
|
123
123
|
- Gemfile
|
@@ -126,14 +126,21 @@ files:
|
|
126
126
|
- Rakefile
|
127
127
|
- bin/console
|
128
128
|
- bin/setup
|
129
|
+
- e2e-server/.gitignore
|
129
130
|
- e2e-server/run_server.sh
|
130
131
|
- e2e-server/server.rb
|
131
|
-
- e2e/container.rb
|
132
|
-
- e2e/custom_props.rb
|
133
|
-
- e2e/rox_e2e_test.rb
|
134
|
-
- e2e/test_vars.rb
|
135
132
|
- example/local.rb
|
136
133
|
- lib/rox.rb
|
134
|
+
- lib/rox/core/analytics/backoff_policy.rb
|
135
|
+
- lib/rox/core/analytics/client.rb
|
136
|
+
- lib/rox/core/analytics/defaults.rb
|
137
|
+
- lib/rox/core/analytics/logging.rb
|
138
|
+
- lib/rox/core/analytics/message_batch.rb
|
139
|
+
- lib/rox/core/analytics/response.rb
|
140
|
+
- lib/rox/core/analytics/test_queue.rb
|
141
|
+
- lib/rox/core/analytics/transport.rb
|
142
|
+
- lib/rox/core/analytics/utils.rb
|
143
|
+
- lib/rox/core/analytics/worker.rb
|
137
144
|
- lib/rox/core/client/buid.rb
|
138
145
|
- lib/rox/core/client/device_properties.rb
|
139
146
|
- lib/rox/core/client/dynamic_api.rb
|
@@ -215,15 +222,17 @@ files:
|
|
215
222
|
- lib/rox/server/flags/rox_string.rb
|
216
223
|
- lib/rox/server/flags/server_entities_provider.rb
|
217
224
|
- lib/rox/server/logging/server_logger.rb
|
225
|
+
- lib/rox/server/network_configurations_options.rb
|
218
226
|
- lib/rox/server/rox_options.rb
|
219
227
|
- lib/rox/server/rox_server.rb
|
228
|
+
- lib/rox/server/self_managed_options.rb
|
220
229
|
- lib/rox/version.rb
|
221
230
|
- rox.gemspec
|
222
231
|
homepage: https://github.com/rollout/rox-ruby
|
223
232
|
licenses:
|
224
233
|
- Nonstandard
|
225
234
|
metadata: {}
|
226
|
-
post_install_message:
|
235
|
+
post_install_message:
|
227
236
|
rdoc_options: []
|
228
237
|
require_paths:
|
229
238
|
- lib
|
@@ -231,15 +240,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
231
240
|
requirements:
|
232
241
|
- - ">="
|
233
242
|
- !ruby/object:Gem::Version
|
234
|
-
version: '2.
|
243
|
+
version: '2.5'
|
235
244
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
245
|
requirements:
|
237
246
|
- - ">="
|
238
247
|
- !ruby/object:Gem::Version
|
239
248
|
version: '0'
|
240
249
|
requirements: []
|
241
|
-
rubygems_version: 3.
|
242
|
-
signing_key:
|
250
|
+
rubygems_version: 3.4.7
|
251
|
+
signing_key:
|
243
252
|
specification_version: 4
|
244
253
|
summary: Feature Management ROX Ruby SDK
|
245
254
|
test_files: []
|
data/.circleci/config.yml
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
version: 2.1
|
2
|
-
jobs:
|
3
|
-
test_2-6: &test-template
|
4
|
-
docker:
|
5
|
-
- image: circleci/ruby:2.6.4
|
6
|
-
|
7
|
-
working_directory: ~/repo
|
8
|
-
|
9
|
-
steps:
|
10
|
-
- checkout
|
11
|
-
|
12
|
-
- run:
|
13
|
-
name: install ssh
|
14
|
-
command: |
|
15
|
-
sudo apt-get update
|
16
|
-
sudo apt-get install libssl-dev
|
17
|
-
|
18
|
-
- run:
|
19
|
-
name: install dependencies
|
20
|
-
command: |
|
21
|
-
bundle install --jobs=4 --retry=3 --path vendor/bundle
|
22
|
-
|
23
|
-
- run:
|
24
|
-
name: run tests
|
25
|
-
command: |
|
26
|
-
bundle exec rake test
|
27
|
-
|
28
|
-
- run:
|
29
|
-
name: run tests
|
30
|
-
command: |
|
31
|
-
bundle exec rake e2e
|
32
|
-
|
33
|
-
test_2-5:
|
34
|
-
<<: *test-template
|
35
|
-
docker:
|
36
|
-
- image: circleci/ruby:2.5.6
|
37
|
-
test_2-4:
|
38
|
-
<<: *test-template
|
39
|
-
docker:
|
40
|
-
- image: circleci/ruby:2.4.7
|
41
|
-
test_2-3:
|
42
|
-
<<: *test-template
|
43
|
-
docker:
|
44
|
-
- image: circleci/ruby:2.3.8
|
45
|
-
|
46
|
-
sdk-integration-test:
|
47
|
-
<<: *test-template
|
48
|
-
steps:
|
49
|
-
- run:
|
50
|
-
name: trigger sdk integration test workflow
|
51
|
-
command: >-
|
52
|
-
curl -X POST https://circleci.com/api/v2/project/gh/rollout/sdk-integration-tests/pipeline
|
53
|
-
--header 'Content-Type: application/json'
|
54
|
-
--header 'Accept: application/json'
|
55
|
-
--header 'x-attribution-login: rox-ruby'
|
56
|
-
--header 'x-attribution-actor-id: rox-ruby'
|
57
|
-
--header 'Circle-Token: '$CircleApiToken
|
58
|
-
--data '{"parameters": {"sdk_triggered_run": true, "repo_name": "'$CIRCLE_PROJECT_REPONAME'", "repo_owner": "'$CIRCLE_PROJECT_USERNAME'", "sha": "'$CIRCLE_SHA1'" }}'
|
59
|
-
|
60
|
-
workflows:
|
61
|
-
version: 2
|
62
|
-
test:
|
63
|
-
jobs:
|
64
|
-
- test_2-6
|
65
|
-
- test_2-5
|
66
|
-
- test_2-4
|
67
|
-
- test_2-3
|
68
|
-
- sdk-integration-test:
|
69
|
-
requires:
|
70
|
-
- test_2-6
|
71
|
-
- test_2-5
|
72
|
-
- test_2-4
|
73
|
-
- test_2-3
|
data/e2e/container.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'rox/server/flags/rox_flag'
|
2
|
-
require 'rox/server/flags/rox_string'
|
3
|
-
|
4
|
-
module E2E
|
5
|
-
class Container
|
6
|
-
attr_accessor :simple_flag, :simple_flag_overwritten, :flag_for_impression,
|
7
|
-
:flag_for_impression_with_experiment_and_context, :flag_custom_properties,
|
8
|
-
:flag_target_groups_all, :flag_target_groups_any, :flag_target_groups_none,
|
9
|
-
:variant_with_context, :variant, :variant_overwritten, :flag_for_dependency,
|
10
|
-
:flag_dependent, :flag_color_dependent_with_context
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@simple_flag = Rox::Server::RoxFlag.new(true)
|
14
|
-
@simple_flag_overwritten = Rox::Server::RoxFlag.new(true)
|
15
|
-
|
16
|
-
@flag_for_impression = Rox::Server::RoxFlag.new(false)
|
17
|
-
@flag_for_impression_with_experiment_and_context = Rox::Server::RoxFlag.new(false)
|
18
|
-
|
19
|
-
@flag_custom_properties = Rox::Server::RoxFlag.new
|
20
|
-
|
21
|
-
@flag_target_groups_all = Rox::Server::RoxFlag.new
|
22
|
-
@flag_target_groups_any = Rox::Server::RoxFlag.new
|
23
|
-
@flag_target_groups_none = Rox::Server::RoxFlag.new
|
24
|
-
|
25
|
-
@variant_with_context = Rox::Server::RoxString.new('red', %w[red blue green])
|
26
|
-
|
27
|
-
@variant = Rox::Server::RoxString.new('red', %w[red blue green])
|
28
|
-
@variant_overwritten = Rox::Server::RoxString.new('red', %w[red blue green])
|
29
|
-
|
30
|
-
@flag_for_dependency = Rox::Server::RoxFlag.new(false)
|
31
|
-
@flag_dependent = Rox::Server::RoxFlag.new(false)
|
32
|
-
@flag_color_dependent_with_context = Rox::Server::RoxString.new('White', %w[White Blue Green Yellow])
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/e2e/custom_props.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module E2E
|
2
|
-
class CustomProps
|
3
|
-
def self.create_custom_props
|
4
|
-
Rox::Server::RoxServer.set_custom_string_property('string_prop1', 'Hello')
|
5
|
-
Rox::Server::RoxServer.set_custom_string_property('string_prop2') do |_context|
|
6
|
-
TestVars.is_computed_string_prop_called = true
|
7
|
-
'World'
|
8
|
-
end
|
9
|
-
|
10
|
-
Rox::Server::RoxServer.set_custom_boolean_property('bool_prop1', true)
|
11
|
-
Rox::Server::RoxServer.set_custom_boolean_property('bool_prop2') do |_context|
|
12
|
-
TestVars.is_computed_boolean_prop_called = true
|
13
|
-
false
|
14
|
-
end
|
15
|
-
|
16
|
-
Rox::Server::RoxServer.set_custom_int_property('int_prop1', 6)
|
17
|
-
Rox::Server::RoxServer.set_custom_int_property('int_prop2') do |_context|
|
18
|
-
TestVars.is_computed_int_prop_called = true
|
19
|
-
28
|
20
|
-
end
|
21
|
-
|
22
|
-
Rox::Server::RoxServer.set_custom_float_property('float_prop1', 3.14)
|
23
|
-
Rox::Server::RoxServer.set_custom_float_property('float_prop2') do |_context|
|
24
|
-
TestVars.is_computed_float_prop_called = true
|
25
|
-
1.618
|
26
|
-
end
|
27
|
-
|
28
|
-
Rox::Server::RoxServer.set_custom_semver_property('smvr_prop1', '9.11.2001')
|
29
|
-
Rox::Server::RoxServer.set_custom_semver_property('smvr_prop2') do |_context|
|
30
|
-
TestVars.is_computed_semver_prop_called = true
|
31
|
-
'20.7.1969'
|
32
|
-
end
|
33
|
-
|
34
|
-
Rox::Server::RoxServer.set_custom_boolean_property('bool_prop_target_group_for_variant') do |context|
|
35
|
-
context['isDuckAndCover']
|
36
|
-
end
|
37
|
-
|
38
|
-
Rox::Server::RoxServer.set_custom_boolean_property('bool_prop_target_group_operand1') do |_context|
|
39
|
-
TestVars.target_group1
|
40
|
-
end
|
41
|
-
|
42
|
-
Rox::Server::RoxServer.set_custom_boolean_property('bool_prop_target_group_operand2') do |_context|
|
43
|
-
TestVars.target_group2
|
44
|
-
end
|
45
|
-
|
46
|
-
Rox::Server::RoxServer.set_custom_boolean_property('bool_prop_target_group_for_dependency') do |_context|
|
47
|
-
TestVars.is_prop_for_target_group_for_dependency
|
48
|
-
end
|
49
|
-
|
50
|
-
Rox::Server::RoxServer.set_custom_boolean_property('bool_prop_target_group_for_variant_dependency') do |context|
|
51
|
-
context['isDuckAndCover']
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
data/e2e/rox_e2e_test.rb
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'rox/server/rox_options'
|
3
|
-
require 'rox/server/rox_server'
|
4
|
-
require_relative 'container'
|
5
|
-
require_relative 'custom_props'
|
6
|
-
require_relative 'test_vars'
|
7
|
-
|
8
|
-
module E2E
|
9
|
-
class Logger
|
10
|
-
def debug(message, _ex = nil)
|
11
|
-
puts 'Before Rox.Setup', message
|
12
|
-
end
|
13
|
-
|
14
|
-
def error(message, ex = nil)
|
15
|
-
puts 'Before Rox.Setup', message, ex
|
16
|
-
end
|
17
|
-
|
18
|
-
def warn(message, _ex = nil)
|
19
|
-
puts 'Before Rox.Setup', message
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class RoxE2ETest < Minitest::Test
|
24
|
-
ENV['ROLLOUT_MODE'] = 'QA'
|
25
|
-
|
26
|
-
configuration_fetched_handler = proc do |e|
|
27
|
-
if !e.nil? && e.fetcher_status == Rox::Core::FetcherStatus::APPLIED_FROM_NETWORK
|
28
|
-
TestVars.configuration_fetched_count += 1
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
impression_handler = proc do |e|
|
33
|
-
if !e.nil? && !e.reporting_value.nil? && (e.reporting_value.name == 'flag_for_impression')
|
34
|
-
TestVars.is_impression_raised = true
|
35
|
-
end
|
36
|
-
TestVars.impression_returned_args = e
|
37
|
-
end
|
38
|
-
|
39
|
-
option = Rox::Server::RoxOptions.new(
|
40
|
-
configuration_fetched_handler: configuration_fetched_handler,
|
41
|
-
impression_handler: impression_handler,
|
42
|
-
dev_mode_key: '67e39e708444aa953414e444',
|
43
|
-
logger: Logger.new
|
44
|
-
)
|
45
|
-
|
46
|
-
@@container = Container.new
|
47
|
-
Rox::Server::RoxServer.register(@@container)
|
48
|
-
CustomProps.create_custom_props
|
49
|
-
Rox::Server::RoxServer.setup('5b82864ebc3aec37aff1fdd5', option).join
|
50
|
-
|
51
|
-
def test_simple_flag
|
52
|
-
assert_equal true, @@container.simple_flag.enabled?
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_simple_flag_overwritten
|
56
|
-
assert_equal false, @@container.simple_flag_overwritten.enabled?
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_string
|
60
|
-
assert_equal 'red', @@container.variant.value
|
61
|
-
end
|
62
|
-
|
63
|
-
def test_variant_overwritten
|
64
|
-
assert_equal 'green', @@container.variant_overwritten.value
|
65
|
-
end
|
66
|
-
|
67
|
-
def test_all_custom_properties
|
68
|
-
assert_equal true, @@container.flag_custom_properties.enabled?
|
69
|
-
|
70
|
-
assert_equal true, TestVars.is_computed_boolean_prop_called
|
71
|
-
assert_equal true, TestVars.is_computed_float_prop_called
|
72
|
-
assert_equal true, TestVars.is_computed_int_prop_called
|
73
|
-
assert_equal true, TestVars.is_computed_semver_prop_called
|
74
|
-
assert_equal true, TestVars.is_computed_string_prop_called
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_fetch_within_timeout
|
78
|
-
number_of_config_fetches = TestVars.configuration_fetched_count
|
79
|
-
timeout = 5
|
80
|
-
thread = Rox::Server::RoxServer.fetch
|
81
|
-
res = thread.join(timeout)
|
82
|
-
|
83
|
-
if res.nil?
|
84
|
-
flunk('timeout')
|
85
|
-
else
|
86
|
-
assert number_of_config_fetches < TestVars.configuration_fetched_count
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_string_with_context
|
91
|
-
some_positive_context = { 'isDuckAndCover' => true }
|
92
|
-
some_negative_context = { 'isDuckAndCover' => false }
|
93
|
-
|
94
|
-
assert_equal 'red', @@container.variant_with_context.value
|
95
|
-
|
96
|
-
assert_equal 'blue', @@container.variant_with_context.value(some_positive_context)
|
97
|
-
assert_equal 'red', @@container.variant_with_context.value(some_negative_context)
|
98
|
-
end
|
99
|
-
|
100
|
-
def test_target_groups_all_any_none
|
101
|
-
TestVars.target_group1 = true
|
102
|
-
TestVars.target_group2 = true
|
103
|
-
|
104
|
-
assert_equal true, @@container.flag_target_groups_all.enabled?
|
105
|
-
assert_equal true, @@container.flag_target_groups_any.enabled?
|
106
|
-
assert_equal false, @@container.flag_target_groups_none.enabled?
|
107
|
-
|
108
|
-
TestVars.target_group1 = false
|
109
|
-
assert_equal false, @@container.flag_target_groups_all.enabled?
|
110
|
-
assert_equal true, @@container.flag_target_groups_any.enabled?
|
111
|
-
assert_equal false, @@container.flag_target_groups_none.enabled?
|
112
|
-
|
113
|
-
TestVars.target_group2 = false
|
114
|
-
assert_equal false, @@container.flag_target_groups_all.enabled?
|
115
|
-
assert_equal false, @@container.flag_target_groups_any.enabled?
|
116
|
-
assert_equal true, @@container.flag_target_groups_none.enabled?
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_impression_handler
|
120
|
-
@@container.flag_for_impression.enabled?
|
121
|
-
assert_equal true, TestVars.is_impression_raised
|
122
|
-
TestVars.is_impression_raised = false
|
123
|
-
|
124
|
-
context = { 'var' => 'val' }
|
125
|
-
flag_impression_value = @@container.flag_for_impression_with_experiment_and_context.enabled?(context)
|
126
|
-
refute_nil TestVars.impression_returned_args
|
127
|
-
refute_nil TestVars.impression_returned_args.reporting_value
|
128
|
-
assert_equal true, TestVars.impression_returned_args.reporting_value.value
|
129
|
-
assert_equal true, flag_impression_value
|
130
|
-
assert_equal 'flag_for_impression_with_experiment_and_context',
|
131
|
-
TestVars.impression_returned_args.reporting_value.name
|
132
|
-
|
133
|
-
refute_nil TestVars.impression_returned_args
|
134
|
-
|
135
|
-
assert_equal 'val', TestVars.impression_returned_args.context['var']
|
136
|
-
end
|
137
|
-
|
138
|
-
def test_flag_dependency
|
139
|
-
TestVars.is_prop_for_target_group_for_dependency = true
|
140
|
-
assert_equal true, @@container.flag_for_dependency.enabled?
|
141
|
-
assert_equal false, @@container.flag_dependent.enabled?
|
142
|
-
|
143
|
-
TestVars.is_prop_for_target_group_for_dependency = false
|
144
|
-
assert_equal true, @@container.flag_dependent.enabled?
|
145
|
-
assert_equal false, @@container.flag_for_dependency.enabled?
|
146
|
-
end
|
147
|
-
|
148
|
-
def test_string_dependency_with_context
|
149
|
-
some_positive_context = { 'isDuckAndCover' => true }
|
150
|
-
some_negative_context = { 'isDuckAndCover' => false }
|
151
|
-
|
152
|
-
assert_equal 'White', @@container.flag_color_dependent_with_context.value
|
153
|
-
assert_equal 'White', @@container.flag_color_dependent_with_context.value(some_negative_context)
|
154
|
-
assert_equal 'Yellow', @@container.flag_color_dependent_with_context.value(some_positive_context)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
end
|
data/e2e/test_vars.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module E2E
|
2
|
-
module TestVars
|
3
|
-
class << self
|
4
|
-
attr_accessor :is_computed_boolean_prop_called, :is_computed_string_prop_called, :is_computed_int_prop_called,
|
5
|
-
:is_computed_float_prop_called, :is_computed_semver_prop_called, :target_group1, :target_group2, :is_impression_raised, :is_prop_for_target_group_for_dependency, :configuration_fetched_count, :impression_returned_args
|
6
|
-
end
|
7
|
-
|
8
|
-
@is_computed_boolean_prop_called = false
|
9
|
-
@is_computed_string_prop_called = false
|
10
|
-
@is_computed_int_prop_called = false
|
11
|
-
@is_computed_float_prop_called = false
|
12
|
-
@is_computed_semver_prop_called = false
|
13
|
-
@target_group1 = false
|
14
|
-
@target_group2 = false
|
15
|
-
@is_impression_raised = false
|
16
|
-
@is_prop_for_target_group_for_dependency = false
|
17
|
-
|
18
|
-
@configuration_fetched_count = 0
|
19
|
-
@impression_returned_args = nil
|
20
|
-
end
|
21
|
-
end
|