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

feature (multi-rollout): Added support for multiple rollouts. #247

Merged
merged 7 commits into from
Apr 1, 2020

Conversation

yasirfolio3
Copy link
Contributor

@yasirfolio3 yasirfolio3 commented Mar 26, 2020

Summary

Added support for multiple rollouts in rollout_service, this includes:

  • Evaluating next available experiment if audience evaluation fails for previous.
  • Falling back to the last experiment evaluation if bucketing fails for any of the experiments.

rsLogger.Debug(fmt.Sprintf(`User "%s" failed targeting for feature rollout with key "%s".`, userContext.ID, feature.Key))
return featureDecision, nil
index := 0
for index < numberOfExperiments {
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be numberOfExperiments-1

if decision.Variation == nil && index < numberOfExperiments-1 {
// Evaluate fall back rule / last rule now
index = numberOfExperiments - 1
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

it should be break

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 everyoneElse rule.

"github.com/optimizely/go-sdk/pkg/logging"

"github.com/optimizely/go-sdk/pkg/entities"
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert it.

evalResult, _ := r.audienceTreeEvaluator.Evaluate(experiment.AudienceConditionTree, condTreeParams)
if !evalResult { // Evaluate this user for the next rule
featureDecision.Reason = reasons.FailedRolloutTargeting
r.logger.Debug(fmt.Sprintf(`User "%s" failed targeting for feature rollout with key "%s".`, userContext.ID, feature.Key))
Copy link
Contributor

Choose a reason for hiding this comment

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

are we loggin in other sdks?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes we do.

mockConfig *mockProjectConfig
mockAudienceTreeEvaluator *MockAudienceTreeEvaluator
mockExperimentService *MockExperimentDecisionService
testExperiment1112DecisionContext ExperimentDecisionContext
Copy link
Contributor

Choose a reason for hiding this comment

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

what is it 1112?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it represents the experimentID.

}
decision, _ := testRolloutService.GetDecision(s.testFeatureDecisionContext, s.testUserContext)
s.Equal(expectedFeatureDecision, decision)
s.mockAudienceTreeEvaluator.AssertExpectations(s.T())
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also assert, number of rolloutrules experiments were in it? and the returned mocked roleout rule was the last one. Also throw exception for all other roleout rules so I can be sure, it didn't iterate once fallen into audience evaluation but didn't bucket.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since there are 3 rollout rules experiments in this test, we have only mocked response for Evaluate and GetDecision methods of 1st and last rule, This makes sure that if these methods were called for any other experiments, the test will fail. We assert that the returned rollout rule was the last one already by providing testExp1118 in expectedFeatureDecision.

@msohailhussain msohailhussain marked this pull request as ready for review March 31, 2020 18:16
@msohailhussain msohailhussain requested a review from a team as a code owner March 31, 2020 18:16
Copy link
Contributor

@pawels-optimizely pawels-optimizely left a comment

Choose a reason for hiding this comment

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

first pass done, provided the feedback offline, the new implementation will follow python logic.

featureDecision := FeatureDecision{
Source: Rollout,
}
feature := decisionContext.Feature
rollout := feature.Rollout

evaluateConditionTree := func(experiment entities.Experiment) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is a help function, can you try passing by reference instead of value?

Copy link
Contributor

@pawels-optimizely pawels-optimizely left a comment

Choose a reason for hiding this comment

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

this is looks good, and much more cleaner , easy to follow. thank you for making these changes.
(one small comment)

@pawels-optimizely pawels-optimizely merged commit 3ae7201 into master Apr 1, 2020
@pawels-optimizely pawels-optimizely deleted the yasir/targeted-rollout branch April 1, 2020 22:41
mikeproeng37 pushed a commit that referenced this pull request May 21, 2020
feature (multi-rollout): Added support for multiple rollouts
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.

3 participants