Skip to content

Commit

Permalink
removed unnecessary bucketing reason
Browse files Browse the repository at this point in the history
  • Loading branch information
zashraf1985 committed Dec 22, 2020
1 parent 5720f83 commit dd4add4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
1 change: 0 additions & 1 deletion lib/optimizely/bucketer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def find_bucket(bucketing_id, user_id, parent_id, traffic_allocations)

message = "Assigned bucket #{bucket_value} to user '#{user_id}' with bucketing ID: '#{bucketing_id}'."
@logger.log(Logger::DEBUG, message)
decide_reasons.push(message)

traffic_allocations.each do |traffic_allocation|
current_end_of_range = traffic_allocation['endOfRange']
Expand Down
11 changes: 4 additions & 7 deletions spec/bucketing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def get_bucketing_key(bucketing_id, entity_id = nil)
variation_received, reasons = bucketer.bucket(config, experiment, 'bucket_id_ignored', 'test_user')
expect(variation_received).to be_nil
expect(reasons).to eq([
"Assigned bucket 3000 to user 'test_user' with bucketing ID: 'bucket_id_ignored'.",
"User 'test_user' is not in experiment 'group1_exp2' of group 101."
])
expect(spy_logger).to have_received(:log)
Expand All @@ -112,7 +111,7 @@ def get_bucketing_key(bucketing_id, entity_id = nil)
expected_variation = config.get_variation_from_id('group2_exp1', '144443')
variation_received, reasons = bucketer.bucket(config, experiment, 'bucket_id_ignored', 'test_user')
expect(variation_received).to eq(expected_variation)
expect(reasons).to eq(["Assigned bucket 3000 to user 'test_user' with bucketing ID: 'bucket_id_ignored'."])
expect(reasons).to eq([])
expect(spy_logger).to have_received(:log).once
expect(spy_logger).to have_received(:log)
.with(Logger::DEBUG, "Assigned bucket 3000 to user 'test_user' with bucketing ID: 'bucket_id_ignored'.")
Expand All @@ -123,7 +122,7 @@ def get_bucketing_key(bucketing_id, entity_id = nil)

experiment = config.get_experiment_from_key('group2_exp1')
variation_received, reasons = bucketer.bucket(config, experiment, 'bucket_id_ignored', 'test_user')
expect(reasons).to eq(["Assigned bucket 50000 to user 'test_user' with bucketing ID: 'bucket_id_ignored'."])
expect(reasons).to eq([])
expect(variation_received).to be_nil
expect(spy_logger).to have_received(:log).once
expect(spy_logger).to have_received(:log)
Expand Down Expand Up @@ -170,14 +169,14 @@ def get_bucketing_key(bucketing_id, entity_id = nil)
expected_variation = config.get_variation_from_id('test_experiment', '111128')
variation_received, reasons = bucketer.bucket(config, experiment, 'test_user', 'test_user')
expect(variation_received).to be(expected_variation)
expect(reasons).to eq(["Assigned bucket 4577 to user 'test_user' with bucketing ID: 'test_user'."])
expect(reasons).to eq([])

# Bucketing with bucketing id - 'any_string789111127' produces bucket value btw 5000 to 10,000
# thus buckets to variation
expected_variation = config.get_variation_from_id('test_experiment', '111129')
variation_received, reasons = bucketer.bucket(config, experiment, 'any_string789', 'test_user')
expect(variation_received).to be(expected_variation)
expect(reasons).to eq(["Assigned bucket 9941 to user 'test_user' with bucketing ID: 'any_string789'."])
expect(reasons).to eq([])
end

# Bucketing with invalid experiment key and bucketing ID
Expand All @@ -196,14 +195,12 @@ def get_bucketing_key(bucketing_id, entity_id = nil)
variation_received, reasons = bucketer.bucket(config, experiment, 'test_user', 'test_user')
expect(variation_received).to be(expected_variation)
expect(reasons).to eq([
"Assigned bucket 7543 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is not in experiment 'group1_exp1' of group 101."
])
expected_variation = config.get_variation_from_id('group1_exp1', '130002')
variation_received, = bucketer.bucket(config, experiment, '123456789', 'test_user')
expect(variation_received).to be(expected_variation)
expect(reasons).to eq([
"Assigned bucket 7543 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is not in experiment 'group1_exp1' of group 101."
])
end
Expand Down
10 changes: 0 additions & 10 deletions spec/decision_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@

expect(reasons).to eq([
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 4577 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is in variation 'control' of experiment 'test_experiment'."
])

Expand Down Expand Up @@ -229,7 +228,6 @@
expect(reasons).to eq([
"User 'forced_user_with_invalid_variation' is whitelisted into variation 'invalid_variation', which is not in the datafile.",
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 877 to user 'forced_user_with_invalid_variation' with bucketing ID: 'forced_user_with_invalid_variation'.",
"User 'forced_user_with_invalid_variation' is in variation 'control' of experiment 'test_experiment'."
])
expect(spy_logger).to have_received(:log)
Expand Down Expand Up @@ -259,7 +257,6 @@
expect(variation_received).to eq('111128')
expect(reasons).to eq([
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 4577 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is in variation 'control' of experiment 'test_experiment'."
])

Expand Down Expand Up @@ -290,7 +287,6 @@
expect(variation_received).to eq('111129')
expect(reasons).to eq([
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 8933 to user 'test_user' with bucketing ID: 'pid'.",
"User 'test_user' is in variation 'variation' of experiment 'test_experiment'."
])

Expand Down Expand Up @@ -347,7 +343,6 @@
expect(variation_received).to eq('111128')
expect(reasons).to eq([
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 4577 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is in variation 'control' of experiment 'test_experiment'."
])

Expand Down Expand Up @@ -387,7 +382,6 @@
expect(reasons).to eq([
"User '' was previously bucketed into variation ID '111111' for experiment '111127', but no matching variation was found. Re-bucketing user.",
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 4577 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is in variation 'control' of experiment 'test_experiment'."
])

Expand All @@ -414,7 +408,6 @@
expect(reasons).to eq([
"Error while looking up user profile for user ID 'test_user': uncaught throw :LookupError.",
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 4577 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is in variation 'control' of experiment 'test_experiment'."
])

Expand All @@ -431,7 +424,6 @@
expect(variation_received).to eq('111128')
expect(reasons).to eq([
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 4577 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is in variation 'control' of experiment 'test_experiment'."
])

Expand All @@ -448,7 +440,6 @@
expect(variation_received).to eq('111128')
expect(reasons).to eq([
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 4577 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is in variation 'control' of experiment 'test_experiment'."
])

Expand All @@ -466,7 +457,6 @@
expect(variation_received).to eq('111128')
expect(reasons).to eq([
"Audiences for experiment 'test_experiment' collectively evaluated to TRUE.",
"Assigned bucket 4577 to user 'test_user' with bucketing ID: 'test_user'.",
"User 'test_user' is in variation 'control' of experiment 'test_experiment'."
])

Expand Down

0 comments on commit dd4add4

Please sign in to comment.