Commit f3615927 authored by Alper Akgun's avatar Alper Akgun

Merge branch 'update-gitlab-experiment-to-0.7.0' into 'master'

Release gitlab-experiment version 0.7.0

See merge request gitlab-org/gitlab!79299
parents 1b777000 8e60a8ae
...@@ -489,7 +489,7 @@ gem 'flipper', '~> 0.21.0' ...@@ -489,7 +489,7 @@ gem 'flipper', '~> 0.21.0'
gem 'flipper-active_record', '~> 0.21.0' gem 'flipper-active_record', '~> 0.21.0'
gem 'flipper-active_support_cache_store', '~> 0.21.0' gem 'flipper-active_support_cache_store', '~> 0.21.0'
gem 'unleash', '~> 3.2.2' gem 'unleash', '~> 3.2.2'
gem 'gitlab-experiment', '~> 0.6.5' gem 'gitlab-experiment', '~> 0.7.0'
# Structured logging # Structured logging
gem 'lograge', '~> 0.5' gem 'lograge', '~> 0.5'
......
...@@ -460,10 +460,9 @@ GEM ...@@ -460,10 +460,9 @@ GEM
gitlab-dangerfiles (2.8.0) gitlab-dangerfiles (2.8.0)
danger (>= 8.3.1) danger (>= 8.3.1)
danger-gitlab (>= 8.0.0) danger-gitlab (>= 8.0.0)
gitlab-experiment (0.6.5) gitlab-experiment (0.7.0)
activesupport (>= 3.0) activesupport (>= 3.0)
request_store (>= 1.0) request_store (>= 1.0)
scientist (~> 1.6, >= 1.6.0)
gitlab-fog-azure-rm (1.2.0) gitlab-fog-azure-rm (1.2.0)
azure-storage-blob (~> 2.0) azure-storage-blob (~> 2.0)
azure-storage-common (~> 2.0) azure-storage-common (~> 2.0)
...@@ -640,7 +639,7 @@ GEM ...@@ -640,7 +639,7 @@ GEM
mime-types (~> 3.0) mime-types (~> 3.0)
multi_xml (>= 0.5.2) multi_xml (>= 0.5.2)
httpclient (2.8.3) httpclient (2.8.3)
i18n (1.8.11) i18n (1.9.1)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
i18n_data (0.8.0) i18n_data (0.8.0)
icalendar (2.4.1) icalendar (2.4.1)
...@@ -1035,7 +1034,7 @@ GEM ...@@ -1035,7 +1034,7 @@ GEM
declarative (< 0.1.0) declarative (< 0.1.0)
declarative-option (< 0.2.0) declarative-option (< 0.2.0)
uber (< 0.2.0) uber (< 0.2.0)
request_store (1.5.0) request_store (1.5.1)
rack (>= 1.4) rack (>= 1.4)
responders (3.0.0) responders (3.0.0)
actionpack (>= 5.0) actionpack (>= 5.0)
...@@ -1157,7 +1156,6 @@ GEM ...@@ -1157,7 +1156,6 @@ GEM
sawyer (0.8.2) sawyer (0.8.2)
addressable (>= 2.3.5) addressable (>= 2.3.5)
faraday (> 0.8, < 2.0) faraday (> 0.8, < 2.0)
scientist (1.6.2)
sd_notify (0.1.0) sd_notify (0.1.0)
securecompare (1.0.0) securecompare (1.0.0)
seed-fu (2.3.7) seed-fu (2.3.7)
...@@ -1377,7 +1375,7 @@ GEM ...@@ -1377,7 +1375,7 @@ GEM
nokogiri (~> 1.8) nokogiri (~> 1.8)
yajl-ruby (1.4.1) yajl-ruby (1.4.1)
yard (0.9.26) yard (0.9.26)
zeitwerk (2.5.3) zeitwerk (2.5.4)
PLATFORMS PLATFORMS
ruby ruby
...@@ -1470,7 +1468,7 @@ DEPENDENCIES ...@@ -1470,7 +1468,7 @@ DEPENDENCIES
github-markup (~> 1.7.0) github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5) gitlab-chronic (~> 0.10.5)
gitlab-dangerfiles (~> 2.8.0) gitlab-dangerfiles (~> 2.8.0)
gitlab-experiment (~> 0.6.5) gitlab-experiment (~> 0.7.0)
gitlab-fog-azure-rm (~> 1.2.0) gitlab-fog-azure-rm (~> 1.2.0)
gitlab-labkit (~> 0.21.3) gitlab-labkit (~> 0.21.3)
gitlab-license (~> 2.1.0) gitlab-license (~> 2.1.0)
......
...@@ -41,10 +41,6 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp ...@@ -41,10 +41,6 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
# define a default nil control behavior so we can omit it when not needed # define a default nil control behavior so we can omit it when not needed
end end
def track(action, **event_args)
super(action, **tracking_context.merge(event_args))
end
# TODO: remove # TODO: remove
# This is deprecated logic as of v0.6.0 and should eventually be removed, but # This is deprecated logic as of v0.6.0 and should eventually be removed, but
# needs to stay intact for actively running experiments. The new strategy # needs to stay intact for actively running experiments. The new strategy
...@@ -64,12 +60,12 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp ...@@ -64,12 +60,12 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
private private
def tracking_context def tracking_context(event_args)
{ {
namespace: context.try(:namespace) || context.try(:group), namespace: context.try(:namespace) || context.try(:group),
project: context.try(:project), project: context.try(:project),
user: user_or_actor user: user_or_actor
}.compact || {} }.merge(event_args)
end end
def user_or_actor def user_or_actor
......
...@@ -10,6 +10,13 @@ Gitlab::Experiment.configure do |config| ...@@ -10,6 +10,13 @@ Gitlab::Experiment.configure do |config|
# #
config.base_class = 'ApplicationExperiment' config.base_class = 'ApplicationExperiment'
# Customize the logic of our default rollout, which shouldn't include
# assigning the control yet -- we specifically set it to false for now.
#
config.default_rollout = Gitlab::Experiment::Rollout::Percent.new(
include_control: false
)
# Mount the engine and middleware at a gitlab friendly style path. # Mount the engine and middleware at a gitlab friendly style path.
# #
# The middleware currently focuses only on handling redirection logic, which # The middleware currently focuses only on handling redirection logic, which
......
...@@ -117,7 +117,7 @@ RSpec.describe ApplicationExperiment, :experiment do ...@@ -117,7 +117,7 @@ RSpec.describe ApplicationExperiment, :experiment do
describe '#publish_to_database' do describe '#publish_to_database' do
using RSpec::Parameterized::TableSyntax using RSpec::Parameterized::TableSyntax
let(:publish_to_database) { application_experiment.publish_to_database } let(:publish_to_database) { ActiveSupport::Deprecation.silence { application_experiment.publish_to_database } }
shared_examples 'does not record to the database' do shared_examples 'does not record to the database' do
it 'does not create an experiment record' do it 'does not create an experiment record' do
...@@ -358,11 +358,11 @@ RSpec.describe ApplicationExperiment, :experiment do ...@@ -358,11 +358,11 @@ RSpec.describe ApplicationExperiment, :experiment do
stub_feature_flags(namespaced_stub: true) stub_feature_flags(namespaced_stub: true)
end end
it "returns the first variant name" do it "returns an assigned name" do
application_experiment.try(:variant1) {} application_experiment.try(:variant1) {}
application_experiment.try(:variant2) {} application_experiment.try(:variant2) {}
expect(application_experiment.variant.name).to eq('variant1') expect(application_experiment.variant.name).to eq('variant2')
end end
end end
end end
......
...@@ -10,9 +10,23 @@ RSpec.configure do |config| ...@@ -10,9 +10,23 @@ RSpec.configure do |config|
# Disable all caching for experiments in tests. # Disable all caching for experiments in tests.
config.before do config.before do
allow(Gitlab::Experiment::Configuration).to receive(:cache).and_return(nil) allow(Gitlab::Experiment::Configuration).to receive(:cache).and_return(nil)
# Disable all deprecation warnings in the test environment, which can be
# resolved one by one and tracked in:
#
# https://gitlab.com/gitlab-org/gitlab/-/issues/350944
allow(Gitlab::Experiment::Configuration).to receive(:deprecator).and_wrap_original do |method, version|
method.call(version).tap do |deprecator|
deprecator.silenced = true
end
end
end end
config.before(:each, :experiment) do config.before(:each, :experiment) do
stub_snowplow stub_snowplow
end end
end end
# Once you've resolved a given deprecation, you can disallow it here, which
# will raise an exception if it's used anywhere.
ActiveSupport::Deprecation.disallowed_warnings << "`experiment_group?` is deprecated"
# frozen_string_literal: true # frozen_string_literal: true
RSpec.shared_examples 'tracks assignment and records the subject' do |experiment, subject_type| RSpec.shared_examples 'tracks assignment and records the subject' do |experiment, subject_type|
before do
stub_experiments(experiment => true)
end
it 'tracks the assignment', :experiment do it 'tracks the assignment', :experiment do
expect(experiment(experiment)) expect(experiment(experiment))
.to track(:assignment) .to track(:assignment)
...@@ -11,9 +15,7 @@ RSpec.shared_examples 'tracks assignment and records the subject' do |experiment ...@@ -11,9 +15,7 @@ RSpec.shared_examples 'tracks assignment and records the subject' do |experiment
end end
it 'records the subject' do it 'records the subject' do
stub_experiments(experiment => :candidate) expect(Experiment).to receive(:add_subject).with(experiment.to_s, variant: anything, subject: subject)
expect(Experiment).to receive(:add_subject).with(experiment.to_s, variant: :experimental, subject: subject)
action action
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