Commit 8387a827 authored by nmilojevic1's avatar nmilojevic1

Fix broken specs

parent 269e0f43
...@@ -18,8 +18,8 @@ module Gitlab ...@@ -18,8 +18,8 @@ module Gitlab
end end
def initialize(logger: nil, base_log_data: {}) def initialize(logger: nil, base_log_data: {})
self.logger = logger || Logger.new($stdout) @logger = logger || Logger.new($stdout)
self.base_log_data = base_log_data @base_log_data = base_log_data
end end
def with_measuring def with_measuring
...@@ -44,13 +44,13 @@ module Gitlab ...@@ -44,13 +44,13 @@ module Gitlab
private private
attr_accessor :gc_stats, :time_to_finish, :sql_calls_count, :logger, :base_log_data attr_reader :gc_stats, :time_to_finish, :sql_calls_count, :logger, :base_log_data
def with_count_queries(&block) def with_count_queries(&block)
self.sql_calls_count = 0 @sql_calls_count = 0
counter_f = ->(_name, _started, _finished, _unique_id, payload) { counter_f = ->(_name, _started, _finished, _unique_id, payload) {
self.sql_calls_count += 1 unless payload[:name].in? %w[CACHE SCHEMA] @sql_calls_count += 1 unless payload[:name].in? %w[CACHE SCHEMA]
} }
ActiveSupport::Notifications.subscribed(counter_f, "sql.active_record", &block) ActiveSupport::Notifications.subscribed(counter_f, "sql.active_record", &block)
...@@ -67,7 +67,7 @@ module Gitlab ...@@ -67,7 +67,7 @@ module Gitlab
stats_before = GC.stat stats_before = GC.stat
result = yield result = yield
stats_after = GC.stat stats_after = GC.stat
self.gc_stats = stats_after.map do |key, after_value| @gc_stats = stats_after.map do |key, after_value|
before_value = stats_before[key] before_value = stats_before[key]
[key, before: before_value, after: after_value, diff: after_value - before_value] [key, before: before_value, after: after_value, diff: after_value - before_value]
end.to_h end.to_h
...@@ -76,7 +76,7 @@ module Gitlab ...@@ -76,7 +76,7 @@ module Gitlab
def with_measure_time def with_measure_time
result = nil result = nil
self.time_to_finish = Benchmark.realtime do @time_to_finish = Benchmark.realtime do
result = yield result = yield
end end
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
require 'rake_helper' require 'rake_helper'
describe Gitlab::ImportExport::Project::ExportTask do describe Gitlab::ImportExport::Project::ExportTask do
let(:username) { 'root' } let_it_be(:username) { 'root' }
let(:namespace_path) { username } let(:namespace_path) { username }
let!(:user) { create(:user, username: username) } let_it_be(:user) { create(:user, username: username) }
let(:measurement_enabled) { false } let(:measurement_enabled) { false }
let(:file_path) { 'spec/fixtures/gitlab/import_export/test_project_export.tar.gz' } let(:file_path) { 'spec/fixtures/gitlab/import_export/test_project_export.tar.gz' }
let(:project) { create(:project, creator: user, namespace: user.namespace) } let(:project) { create(:project, creator: user, namespace: user.namespace) }
......
...@@ -23,7 +23,7 @@ describe Gitlab::Utils::Measuring do ...@@ -23,7 +23,7 @@ describe Gitlab::Utils::Measuring do
end end
it 'measure execution with Gitlab::Utils::Measuring instance', :aggregate_failure do it 'measure execution with Gitlab::Utils::Measuring instance', :aggregate_failure do
expect(described_class).to receive(:new).with(logger: measurement_logger, base_log_data: base_log_data){ measurement } expect(described_class).to receive(:new).with(logger: measurement_logger, base_log_data: base_log_data) { measurement }
expect(measurement).to receive(:with_measuring) expect(measurement).to receive(:with_measuring)
subject subject
......
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