Skip to content

Provide an experiment rollout strategy based on Feature

What does this MR do and why?

Part of #350944

Migrates logic out of the ApplicationExperiment into a rollout strategy that's based on our Feature flag library. Further documentation about rollout strategies can be found at https://gitlab.com/gitlab-org/ruby/gems/gitlab-experiment#rollout-strategies-1.

The functionality for this already existed, but it's just now being extracted into a strategy concept. This change makes it easier to test the functionality as it relates to the Feature library, and removes the complexity from our base ApplicationExperiment class, which might not always utilize the same rollout strategy.

How to set up and validate locally:

  1. Create a feature flag:

    > bin/feature-flag --type=experiment --group="group::none" --rollout-issue-url="https://gitlab.com" --milestone="0.0" --introduced-by-url="https://gitlab.com" --force example
  2. Try an example experiment in the rails console

    class ExampleExperiment < ApplicationExperiment
      control { }
      candidate { }
    end
    
    ExampleExperiment.new.assigned.name # => "control"
    Feature.enable(:example, true)
    ExampleExperiment.new.assigned.name # => "candidate"
    Feature.enable(:example, false)
    ExampleExperiment.new.assigned.name # => "control"

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Jeremy Jackson

Merge request reports