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'
gem 'flipper-active_record', '~> 0.21.0'
gem 'flipper-active_support_cache_store', '~> 0.21.0'
gem 'unleash', '~> 3.2.2'
gem 'gitlab-experiment', '~> 0.6.5'
gem 'gitlab-experiment', '~> 0.7.0'
# Structured logging
gem 'lograge', '~> 0.5'
......
......@@ -460,10 +460,9 @@ GEM
gitlab-dangerfiles (2.8.0)
danger (>= 8.3.1)
danger-gitlab (>= 8.0.0)
gitlab-experiment (0.6.5)
gitlab-experiment (0.7.0)
activesupport (>= 3.0)
request_store (>= 1.0)
scientist (~> 1.6, >= 1.6.0)
gitlab-fog-azure-rm (1.2.0)
azure-storage-blob (~> 2.0)
azure-storage-common (~> 2.0)
......@@ -640,7 +639,7 @@ GEM
mime-types (~> 3.0)
multi_xml (>= 0.5.2)
httpclient (2.8.3)
i18n (1.8.11)
i18n (1.9.1)
concurrent-ruby (~> 1.0)
i18n_data (0.8.0)
icalendar (2.4.1)
......@@ -1035,7 +1034,7 @@ GEM
declarative (< 0.1.0)
declarative-option (< 0.2.0)
uber (< 0.2.0)
request_store (1.5.0)
request_store (1.5.1)
rack (>= 1.4)
responders (3.0.0)
actionpack (>= 5.0)
......@@ -1157,7 +1156,6 @@ GEM
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
scientist (1.6.2)
sd_notify (0.1.0)
securecompare (1.0.0)
seed-fu (2.3.7)
......@@ -1377,7 +1375,7 @@ GEM
nokogiri (~> 1.8)
yajl-ruby (1.4.1)
yard (0.9.26)
zeitwerk (2.5.3)
zeitwerk (2.5.4)
PLATFORMS
ruby
......@@ -1470,7 +1468,7 @@ DEPENDENCIES
github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5)
gitlab-dangerfiles (~> 2.8.0)
gitlab-experiment (~> 0.6.5)
gitlab-experiment (~> 0.7.0)
gitlab-fog-azure-rm (~> 1.2.0)
gitlab-labkit (~> 0.21.3)
gitlab-license (~> 2.1.0)
......
......@@ -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
end
def track(action, **event_args)
super(action, **tracking_context.merge(event_args))
end
# TODO: remove
# 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
......@@ -64,12 +60,12 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
private
def tracking_context
def tracking_context(event_args)
{
namespace: context.try(:namespace) || context.try(:group),
project: context.try(:project),
user: user_or_actor
}.compact || {}
}.merge(event_args)
end
def user_or_actor
......
......@@ -10,6 +10,13 @@ Gitlab::Experiment.configure do |config|
#
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.
#
# The middleware currently focuses only on handling redirection logic, which
......
......@@ -117,7 +117,7 @@ RSpec.describe ApplicationExperiment, :experiment do
describe '#publish_to_database' do
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
it 'does not create an experiment record' do
......@@ -358,11 +358,11 @@ RSpec.describe ApplicationExperiment, :experiment do
stub_feature_flags(namespaced_stub: true)
end
it "returns the first variant name" do
it "returns an assigned name" do
application_experiment.try(:variant1) {}
application_experiment.try(:variant2) {}
expect(application_experiment.variant.name).to eq('variant1')
expect(application_experiment.variant.name).to eq('variant2')
end
end
end
......
......@@ -10,9 +10,23 @@ RSpec.configure do |config|
# Disable all caching for experiments in tests.
config.before do
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
config.before(:each, :experiment) do
stub_snowplow
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
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
expect(experiment(experiment))
.to track(:assignment)
......@@ -11,9 +15,7 @@ RSpec.shared_examples 'tracks assignment and records the subject' do |experiment
end
it 'records the subject' do
stub_experiments(experiment => :candidate)
expect(Experiment).to receive(:add_subject).with(experiment.to_s, variant: :experimental, subject: subject)
expect(Experiment).to receive(:add_subject).with(experiment.to_s, variant: anything, subject: subject)
action
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