diff options
author | Sean McGivern <sean@gitlab.com> | 2016-08-24 18:06:19 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-08-25 08:28:35 +0100 |
commit | 085e1f89f327ad4d679696fe4673d09e1840b236 (patch) | |
tree | 585a47ab6e78653692d249158cb0f689bdd573d3 /spec/features/admin/admin_system_info_spec.rb | |
parent | b2bf01f4c271be66e93ed6f4b48a1da4d50e558d (diff) | |
download | gitlab-ce-085e1f89f327ad4d679696fe4673d09e1840b236.tar.gz |
Handle unavailable system info
For Linux with the grsecurity patches applied, paths in `/proc` may not
be readable, so handle those cases and show a message rather than
blowing up.
Diffstat (limited to 'spec/features/admin/admin_system_info_spec.rb')
-rw-r--r-- | spec/features/admin/admin_system_info_spec.rb | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/spec/features/admin/admin_system_info_spec.rb b/spec/features/admin/admin_system_info_spec.rb index f4e5c26b519..1df972843e2 100644 --- a/spec/features/admin/admin_system_info_spec.rb +++ b/spec/features/admin/admin_system_info_spec.rb @@ -6,12 +6,49 @@ describe 'Admin System Info' do end describe 'GET /admin/system_info' do - it 'shows system info page' do - visit admin_system_info_path + let(:cpu) { double(:cpu, length: 2) } + let(:memory) { double(:memory, active_bytes: 4294967296, total_bytes: 17179869184) } - expect(page).to have_content 'CPU' - expect(page).to have_content 'Memory' - expect(page).to have_content 'Disks' + context 'when all info is available' do + before do + allow(Vmstat).to receive(:cpu).and_return(cpu) + allow(Vmstat).to receive(:memory).and_return(memory) + visit admin_system_info_path + end + + it 'shows system info page' do + expect(page).to have_content 'CPU 2 cores' + expect(page).to have_content 'Memory 4 GB / 16 GB' + expect(page).to have_content 'Disks' + end + end + + context 'when CPU info is not available' do + before do + allow(Vmstat).to receive(:cpu).and_raise(Errno::ENOENT) + allow(Vmstat).to receive(:memory).and_return(memory) + visit admin_system_info_path + end + + it 'shows system info page with no CPU info' do + expect(page).to have_content 'CPU Unable to collect CPU info' + expect(page).to have_content 'Memory 4 GB / 16 GB' + expect(page).to have_content 'Disks' + end + end + + context 'when memory info is not available' do + before do + allow(Vmstat).to receive(:cpu).and_return(cpu) + allow(Vmstat).to receive(:memory).and_raise(Errno::ENOENT) + visit admin_system_info_path + end + + it 'shows system info page with no CPU info' do + expect(page).to have_content 'CPU 2 cores' + expect(page).to have_content 'Memory Unable to collect memory info' + expect(page).to have_content 'Disks' + end end end end |