Commit a065a997 authored by Jeremy Jackson's avatar Jeremy Jackson Committed by jejacks0n

Update gitlab-experiment to version 0.7.0

parent ab695c19
......@@ -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', git: 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-experiment', branch: 'release-0.7.0'
# Structured logging
gem 'lograge', '~> 0.5'
......
GIT
remote: https://gitlab.com/gitlab-org/ruby/gems/gitlab-experiment.git
revision: 176d767486217ae5080785247f29dc4549d85a4a
branch: release-0.7.0
specs:
gitlab-experiment (0.7.0)
activesupport (>= 3.0)
request_store (>= 1.0)
PATH
remote: vendor/gems/mail-smtp_pool
specs:
......@@ -460,10 +469,6 @@ GEM
gitlab-dangerfiles (2.8.0)
danger (>= 8.3.1)
danger-gitlab (>= 8.0.0)
gitlab-experiment (0.6.5)
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)
......@@ -1157,7 +1162,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)
......@@ -1470,7 +1474,7 @@ DEPENDENCIES
github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5)
gitlab-dangerfiles (~> 2.8.0)
gitlab-experiment (~> 0.6.5)
gitlab-experiment!
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,24 @@ 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