Commit 86a789cd authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '294462-fix-reinstate-49244' into 'master'

Fix & reinstate !49244 (second attempt) [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!50909
parents 296d9fa1 417dc2b8
---
name: ci_syntax_templates_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48141
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/281057
milestone: '13.8'
type: experiment
group: group::activation
default_enabled: false
---
name: customize_homepage_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/39348
rollout_issue_url: https://gitlab.com/gitlab-org/growth/team-tasks/-/issues/187
milestone: '13.4'
type: experiment
group: group::expansion
default_enabled: false
---
name: default_to_issues_board_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43939
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/268298
milestone: '13.5'
type: experiment
group: group::conversion
default_enabled: true
---
name: invite_members_empty_group_version_a_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45689
rollout_issue_url: https://gitlab.com/gitlab-org/growth/team-tasks/-/issues/280
milestone: '13.6'
type: experiment
group: group::expansion
default_enabled: false
---
name: invite_members_empty_project_version_a_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49588
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/262014
milestone: '13.7'
type: experiment
group: group::expansion
default_enabled: false
---
name: invite_members_new_dropdown_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/50069
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/268129
milestone: '13.8'
type: experiment
group: group::expansion
default_enabled: false
---
name: invite_members_version_a_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45689/
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/219239
milestone: '13.6'
type: experiment
group: group::expansion
default_enabled: false
---
name: invite_members_version_b_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/43900
rollout_issue_url: https://gitlab.com/gitlab-org/growth/team-tasks/-/issues/214
milestone: '13.5'
type: experiment
group: group::expansion
default_enabled: false
---
name: jobs_empty_state_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48686
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/281054
milestone: '13.7'
type: experiment
group: group::activation
default_enabled: false
---
name: onboarding_issues_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/31656/
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/224515
milestone: '13.0'
type: experiment
group: group::conversion
default_enabled: true
---
name: pipelines_empty_state_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/47952
rollout_issue_url: https://gitlab.com/gitlab-org/growth/team-tasks/-/issues/289
milestone: '13.8'
type: experiment
group: group::activation
default_enabled: false
---
name: ci_notification_dot_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/27626
rollout_issue_url: https://gitlab.com/gitlab-org/growth/team-tasks/-/issues/101
milestone: '12.10'
type: experiment
group: group::expansion
default_enabled: false
---
name: contact_sales_btn_in_app_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38508
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/238207
milestone: '13.3'
type: experiment
group: group::conversion
default_enabled: true
---
name: group_only_trials_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40564
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/258629
milestone: '13.5'
type: experiment
group: group::conversion
default_enabled: false
---
name: remove_known_trial_form_fields_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45634/
rollout_issue_url: https://gitlab.com/gitlab-org/growth/team-tasks/-/issues/281
milestone: '13.7'
type: experiment
group: group::conversion
default_enabled: false
---
name: show_trial_status_in_sidebar_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/50090
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/281019
milestone: '13.8'
type: experiment
group: group::conversion
default_enabled: false
---
name: trial_during_signup_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45147/
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/251231
milestone: '13.8'
type: experiment
group: group::conversion
default_enabled: false
---
name: trial_onboarding_issues_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48052
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/276703
milestone: '13.8'
type: experiment
group: group::conversion
default_enabled: false
---
name: trial_registration_with_social_signin_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45633
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/262853
milestone: '13.7'
type: experiment
group: group::conversion
default_enabled: false
---
name: trimmed_skip_trial_copy_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48110
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/284956
milestone: '13.7'
type: experiment
group: group::conversion
default_enabled: false
---
name: upgrade_link_in_user_menu_a_experiment_percentage
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/29428
rollout_issue_url: https://gitlab.com/gitlab-org/growth/team-tasks/-/issues/126
milestone: '13.0'
type: experiment
group: group::expansion
default_enabled: false
......@@ -20,6 +20,8 @@ RSpec.describe API::Experiments do
end
before do
skip_feature_flags_yaml_validation
skip_default_enabled_yaml_check
stub_const('Gitlab::Experimentation::EXPERIMENTS', experiments)
Feature.enable_percentage_of_time('experiment_1_experiment_percentage', 10)
Feature.disable('experiment_2_experiment_percentage')
......
......@@ -53,10 +53,12 @@ class Feature
description: 'Short lived, used specifically to run A/B/n experiments.',
optional: true,
rollout_issue: true,
ee_only: true,
ee_only: false,
default_enabled: false,
example: <<-EOS
experiment(:my_experiment, project: project, actor: current_user) { ...variant code... }
# or
Gitlab::Experimentation.in_experiment_group?(:my_experiment, subject: current_user)
EOS
}
}.freeze
......
......@@ -3,17 +3,21 @@
module Gitlab
module Experimentation
class Experiment
FEATURE_FLAG_SUFFIX = "_experiment_percentage"
attr_reader :key, :tracking_category, :use_backwards_compatible_subject_index
def initialize(key, **params)
@key = key
@tracking_category = params[:tracking_category]
@use_backwards_compatible_subject_index = params[:use_backwards_compatible_subject_index]
@experiment_percentage = Feature.get(:"#{key}_experiment_percentage").percentage_of_time_value # rubocop:disable Gitlab/AvoidFeatureGet
end
def active?
# TODO: just touch a feature flag
# Temporary change, we will change `experiment_percentage` in future to `Feature.enabled?
Feature.enabled?(feature_flag_name, type: :experiment, default_enabled: :yaml)
::Gitlab.dev_env_or_com? && experiment_percentage > 0
end
......@@ -25,7 +29,17 @@ module Gitlab
private
attr_reader :experiment_percentage
def experiment_percentage
feature_flag.percentage_of_time_value
end
def feature_flag
Feature.get(feature_flag_name) # rubocop:disable Gitlab/AvoidFeatureGet
end
def feature_flag_name
:"#{key}#{FEATURE_FLAG_SUFFIX}"
end
end
end
end
......@@ -14,8 +14,10 @@ RSpec.describe Gitlab::Experimentation::Experiment do
end
before do
feature = double('FeatureFlag', percentage_of_time_value: percentage )
expect(Feature).to receive(:get).with(:experiment_key_experiment_percentage).and_return(feature)
skip_feature_flags_yaml_validation
skip_default_enabled_yaml_check
feature = double('FeatureFlag', percentage_of_time_value: percentage, enabled?: true)
allow(Feature).to receive(:get).with(:experiment_key_experiment_percentage).and_return(feature)
end
subject(:experiment) { described_class.new(:experiment_key, **params) }
......
......@@ -38,6 +38,8 @@ RSpec.describe Gitlab::Experimentation do
}
})
skip_feature_flags_yaml_validation
skip_default_enabled_yaml_check
Feature.enable_percentage_of_time(:backwards_compatible_test_experiment_experiment_percentage, enabled_percentage)
Feature.enable_percentage_of_time(:test_experiment_experiment_percentage, enabled_percentage)
allow(Gitlab).to receive(:com?).and_return(true)
......
......@@ -11,6 +11,7 @@ module StubExperiments
allow(Gitlab::Experimentation).to receive(:active?).and_call_original
experiments.each do |experiment_key, enabled|
Feature.persist_used!("#{experiment_key}#{feature_flag_suffix}")
allow(Gitlab::Experimentation).to receive(:active?).with(experiment_key) { enabled }
end
end
......@@ -25,7 +26,14 @@ module StubExperiments
allow(Gitlab::Experimentation).to receive(:in_experiment_group?).and_call_original
experiments.each do |experiment_key, enabled|
Feature.persist_used!("#{experiment_key}#{feature_flag_suffix}")
allow(Gitlab::Experimentation).to receive(:in_experiment_group?).with(experiment_key, anything) { enabled }
end
end
private
def feature_flag_suffix
Gitlab::Experimentation::Experiment::FEATURE_FLAG_SUFFIX
end
end
......@@ -66,4 +66,8 @@ module StubFeatureFlags
def skip_feature_flags_yaml_validation
allow(Feature::Definition).to receive(:valid_usage!)
end
def skip_default_enabled_yaml_check
allow(Feature::Definition).to receive(:default_enabled?).and_return(false)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment