Skip to content
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

Allow bootstrapped variants when client is disabled #138

Merged
merged 5 commits into from
May 15, 2023

Conversation

jdurkee-mdsol
Copy link
Contributor

About the changes

Attempts to address #137

Variants in a bootstrap configuration are ignored with the client is disabled. These changes remove that limitation, so disabled clients can interact with bootstrapped variants.

Auxiliary changes:
Calling get_variant allows passing a nil context, however attributes of this context are referenced when calculating the variant salt resulting in undefined method ... for nil errors. Account for a nil context in this method which results in the default: random number.

@jdurkee-mdsol jdurkee-mdsol changed the title Fix/respect bootstrapped variants Allow bootstrapped variants when client is disabled Apr 27, 2023
@jdurkee-mdsol jdurkee-mdsol marked this pull request as ready for review April 28, 2023 16:28
Copy link
Collaborator

@rarruda rarruda left a comment

Choose a reason for hiding this comment

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

Looks good, but would like tests in get_variant() that test explicitly the case where context is nil.

Comment on lines 100 to 103
return context.get_by_name(stickiness) unless stickiness == "default" || context.nil?
return context.user_id unless context&.user_id.to_s.empty?
return context.session_id unless context&.session_id.to_s.empty?
return context.remote_address unless context&.remote_address.to_s.empty?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add an explicit test for this case?

I think it should be somewhere around:

Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that since this is a private method, the test should be in the closest public method that calls this. Probably in get_variant() in FeatureToggle and/or Client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean tests that pass in a context missing one of user_id, session_id, remote_address additively each time?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am working on some extra tests in FeatureToggle, so it can make sense to call it out of scope for the PR.

But the fix in feature_toggle.rb that I mention could be addressed here right away. FYI: I found the issue when writing these extra tests locally.

@coveralls
Copy link

coveralls commented May 2, 2023

Pull Request Test Coverage Report for Build 4983808189

  • 7 of 8 (87.5%) changed or added relevant lines in 2 files are covered.
  • 17 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.02%) to 96.5%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/unleash/feature_toggle.rb 4 5 80.0%
Files with Coverage Reduction New Missed Lines %
lib/unleash/variant.rb 1 92.31%
spec/unleash/client_spec.rb 4 67.39%
lib/unleash/client.rb 12 72.0%
Totals Coverage Status
Change from base Build 4526417167: 0.02%
Covered Lines: 2178
Relevant Lines: 2257

💛 - Coveralls

jdurkee-mdsol and others added 2 commits May 2, 2023 13:27
Co-authored-by: Renato Arruda <git@rarruda.org>
lib/unleash/feature_toggle.rb Outdated Show resolved Hide resolved
Comment on lines 100 to 103
return context.get_by_name(stickiness) unless stickiness == "default" || context.nil?
return context.user_id unless context&.user_id.to_s.empty?
return context.session_id unless context&.session_id.to_s.empty?
return context.remote_address unless context&.remote_address.to_s.empty?
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am working on some extra tests in FeatureToggle, so it can make sense to call it out of scope for the PR.

But the fix in feature_toggle.rb that I mention could be addressed here right away. FYI: I found the issue when writing these extra tests locally.

Copy link
Collaborator

@rarruda rarruda left a comment

Choose a reason for hiding this comment

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

I am working on some extra tests in FeatureToggle, so it can make sense to call it out of scope for the PR.

But the fix in feature_toggle.rb that I mention could be addressed here right away. FYI: I found the issue when writing these extra tests locally.

Co-authored-by: Renato Arruda <git@rarruda.org>
Copy link
Collaborator

@rarruda rarruda left a comment

Choose a reason for hiding this comment

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

It looks awesome now! Thanks for finding the issue and creating the PR!

@rarruda rarruda merged commit 81f66d8 into Unleash:main May 15, 2023
19 of 20 checks passed
@jdurkee-mdsol
Copy link
Contributor Author

It looks awesome now! Thanks for finding the issue and creating the PR!

Your welcome. Thank you for taking the time to consider, and being so timely with the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants