Commit 3b4bacec authored by Sean McGivern's avatar Sean McGivern

Merge branch 'sh-fix-profiler-spec-try2' into 'master'

Fix intermittent failures in profiler_spec.rb

Closes #206907

See merge request gitlab-org/gitlab!26110
parents b57be28f 27536206
......@@ -195,6 +195,7 @@ describe Gitlab::Profiler do
describe '.print_by_total_time' do
let(:stdout) { StringIO.new }
let(:regexp) { /^\s+\d+\.\d+\s+(\d+\.\d+)/ }
let(:output) do
stdout.rewind
......@@ -202,6 +203,8 @@ describe Gitlab::Profiler do
end
let_it_be(:result) do
Thread.new { sleep 1 }
RubyProf.profile do
sleep 0.1
1.to_s
......@@ -212,23 +215,22 @@ describe Gitlab::Profiler do
stub_const('STDOUT', stdout)
end
it 'prints a profile result sorted by total time', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/206907' do
it 'prints a profile result sorted by total time' do
described_class.print_by_total_time(result)
total_times =
output
.scan(/^\s+\d+\.\d+\s+(\d+\.\d+)/)
.map { |(total)| total.to_f }
expect(output).to include('Kernel#sleep')
if total_times != total_times.sort.reverse
warn "Profiler test failed, output is:"
warn output
end
thread_profiles = output.split('Sort by: total_time').select { |x| x =~ regexp }
expect(total_times).to eq(total_times.sort.reverse)
expect(total_times).not_to eq(total_times.uniq)
thread_profiles.each do |profile|
total_times =
profile
.scan(regexp)
.map { |(total)| total.to_f }
expect(total_times).to eq(total_times.sort.reverse)
expect(total_times).not_to eq(total_times.uniq)
end
end
it 'accepts a max_percent option' do
......
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