diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-28 21:10:01 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-28 21:10:01 +0300 |
commit | f14814c9815f86a95808f089ff219d4e768641c0 (patch) | |
tree | bca9f6f2719c693748479776b766786922b026e2 /spec/features | |
parent | f7f0c0502763777f48964774a87b0a34dfb1d9ab (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/admin/admin_requests_profiles_spec.rb | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/spec/features/admin/admin_requests_profiles_spec.rb b/spec/features/admin/admin_requests_profiles_spec.rb deleted file mode 100644 index e92528d431d..00000000000 --- a/spec/features/admin/admin_requests_profiles_spec.rb +++ /dev/null @@ -1,136 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Admin::RequestsProfilesController' do - let(:tmpdir) { Dir.mktmpdir('profiler-test') } - - before do - stub_const('Gitlab::RequestProfiler::PROFILES_DIR', tmpdir) - admin = create(:admin) - sign_in(admin) - gitlab_enable_admin_mode_sign_in(admin) - end - - after do - FileUtils.rm_rf(tmpdir) - end - - describe 'GET /admin/requests_profiles' do - it 'shows the current profile token' do - allow(Rails).to receive(:cache).and_return(ActiveSupport::Cache::MemoryStore.new) - - visit admin_requests_profiles_path - - expect(page).to have_content("X-Profile-Token: #{Gitlab::RequestProfiler.profile_token}") - end - - context 'when having multiple profiles' do - let(:time1) { 1.hour.ago } - let(:time2) { 2.hours.ago } - - let(:profiles) do - [ - { - request_path: '/gitlab-org/gitlab-foss', - name: "|gitlab-org|gitlab-foss_#{time1.to_i}_execution.html", - created: time1, - profile_mode: 'Execution' - }, - { - request_path: '/gitlab-org/gitlab-foss', - name: "|gitlab-org|gitlab-foss_#{time2.to_i}_execution.html", - created: time2, - profile_mode: 'Execution' - }, - { - request_path: '/gitlab-org/gitlab-foss', - name: "|gitlab-org|gitlab-foss_#{time1.to_i}_memory.html", - created: time1, - profile_mode: 'Memory' - }, - { - request_path: '/gitlab-org/gitlab-foss', - name: "|gitlab-org|gitlab-foss_#{time2.to_i}_memory.html", - created: time2, - profile_mode: 'Memory' - }, - { - request_path: '/gitlab-org/infrastructure', - name: "|gitlab-org|infrastructure_#{time1.to_i}_execution.html", - created: time1, - profile_mode: 'Execution' - }, - { - request_path: '/gitlab-org/infrastructure', - name: "|gitlab-org|infrastructure_#{time2.to_i}_memory.html", - created: time2, - profile_mode: 'Memory' - }, - { - request_path: '/gitlab-org/infrastructure', - name: "|gitlab-org|infrastructure_#{time2.to_i}.html", - created: time2, - profile_mode: 'Unknown' - } - ] - end - - before do - profiles.each do |profile| - FileUtils.touch(File.join(Gitlab::RequestProfiler::PROFILES_DIR, profile[:name])) - end - end - - it 'lists all available profiles' do - visit admin_requests_profiles_path - - profiles.each do |profile| - within('.card', text: profile[:request_path]) do - expect(page).to have_selector( - "a[href='#{admin_requests_profile_path(profile[:name])}']", - text: "#{profile[:created].to_s(:long)} #{profile[:profile_mode]}") - end - end - end - end - end - - describe 'GET /admin/requests_profiles/:profile' do - context 'when a profile exists' do - before do - File.write("#{Gitlab::RequestProfiler::PROFILES_DIR}/#{profile}", content) - end - - context 'when is valid call stack profile' do - let(:content) { 'This is a call stack request profile' } - let(:profile) { "|gitlab-org|gitlab-ce_#{Time.now.to_i}_execution.html" } - - it 'displays the content' do - visit admin_requests_profile_path(profile) - - expect(page).to have_content(content) - end - end - - context 'when is valid memory profile' do - let(:content) { 'This is a memory request profile' } - let(:profile) { "|gitlab-org|gitlab-ce_#{Time.now.to_i}_memory.txt" } - - it 'displays the content' do - visit admin_requests_profile_path(profile) - - expect(page).to have_content(content) - end - end - end - - context 'when a profile does not exist' do - it 'shows an error message' do - visit admin_requests_profile_path('|non|existent_12345.html') - - expect(page).to have_content('Profile not found') - end - end - end -end |