Skip to content

Feature - Bucketing IDs #68

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 12, 2017

Conversation

oakbani
Copy link
Contributor

@oakbani oakbani commented Oct 9, 2017

🖊 Please note that since data file in Ruby SDK is different from PHP-SDK, the resulting experiment/variation values and the flow of resulting log statements due to bucketing may differ in the unit tests.

oakbani and others added 2 commits October 9, 2017 12:12
* 🖊  Non - testing changes done

* ✏️  Fixed broken unit tests due to method def change
* ✏️ : Added debug messages. Will remove later

* ✏️  Changes in previous unit tests

* ✏️  Bucket Id unit tests

* ✏️ : More development

* 🖊  refactoring

* 🖊 : final minor ticks
# Conflicts:
#	lib/optimizely/event_builder.rb
@optibot
Copy link

optibot commented Oct 9, 2017

Can one of the admins verify this patch?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 99.794% when pulling 1015e2f on msohailhussain:rev_bucketing_id into a1e6b6f on optimizely:master.

# Determines ID of variation to be shown for a given experiment key and user ID.
#
# experiment - Experiment for which visitor is to be bucketed.
# bucketing_id - String A customer-assigned value used to generate bucketing key
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the bucketing key

expect(bucketer.bucket(experiment,'123456789', 'test_user')).to be(expected_variation)
end
end

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the cases when the bucketing key fallbacks to the user ID. This happens when the bucketing key is null. So, to clarify:
• Bucketing with bucketing ID
-Non null bucketing ID
-Null bucketing ID
• Bucketing with invalid experiment key and bucketing ID
-Non null bucketing ID
-Null bucketing ID
• Bucketing with grouped experiments and bucketing ID
-Non null bucketing ID
-Null bucketing ID

I've updated the doc with these corner cases.

You can look at the PHP example:
https://github.com/optimizely/php-sdk/blob/master/tests/BucketerTest.php#L298

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alda-optimizely I have a question regarding this. Please see my comments here:
msohailhussain/php-sdk#6

Copy link
Contributor

@alda-optimizely alda-optimizely Oct 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oakbani Yea you're right. I don't remember why I did that...maybe it was some legacy implementation that I forgot to update? The main goal for the test is to make sure that the bucketing ID is being used and not the userID for the bucketing. So, userID should bucket to the non expected variation. I've updated my PHP tests.

@@ -75,9 +75,9 @@ def get_bucketing_id(user_id, entity_id=nil)
expect(bucketer).to receive(:generate_bucket_value).once.and_return(3000)

experiment = config.get_experiment_from_key('group1_exp2')
expect(bucketer.bucket(experiment, 'test_user')).to be_nil
expect(bucketer.bucket(experiment,'bucket_id_ignored', 'test_user')).to be_nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the bucketing key: bucketing_id_ignored do?
how is it ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have used this string in all those cases where we mock the method generate_bucket_value to test traffic allocations as in above
expect(bucketer).to receive(:generate_bucket_value).twice.and_return(3000)
This makes it more readable to the developer that the string passed as bucketing id does not have an impact

@@ -162,6 +195,31 @@
.with(Logger::INFO, "Saved variation ID 111128 of experiment ID 111127 for user 'test_user'.")
end

it 'should look up the UserProfile, bucket normally (using Bucketing ID attrbiute), and save the result if no saved profile is found' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sp: attribute

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 99.794% when pulling a1715f7 on msohailhussain:rev_bucketing_id into a1e6b6f on optimizely:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 99.794% when pulling 0693b4c on msohailhussain:rev_bucketing_id into a1e6b6f on optimizely:master.

@oakbani
Copy link
Contributor Author

oakbani commented Oct 11, 2017

@alda-optimizely Updated with required changes. Let me know if there is anything else

@alda-optimizely alda-optimizely mentioned this pull request Oct 11, 2017
Copy link
Contributor

@alda-optimizely alda-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This passes e2e, so I'll go ahead and merge this to master. Thanks!

@alda-optimizely alda-optimizely merged commit 7e84102 into optimizely:master Oct 12, 2017
rashidsp pushed a commit to msohailhussain/ruby-sdk that referenced this pull request Dec 12, 2017
rashidsp pushed a commit to msohailhussain/ruby-sdk that referenced this pull request Dec 12, 2017
@oakbani oakbani deleted the rev_bucketing_id branch January 15, 2018 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants