system_spec.rb 1.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
require 'spec_helper'

describe Gitlab::Metrics::System do
  if File.exist?('/proc')
    describe '.memory_usage' do
      it "returns the process' memory usage in bytes" do
        expect(described_class.memory_usage).to be > 0
      end
    end

    describe '.file_descriptor_count' do
      it 'returns the amount of open file descriptors' do
        expect(described_class.file_descriptor_count).to be > 0
      end
    end
  else
    describe '.memory_usage' do
      it 'returns 0.0' do
        expect(described_class.memory_usage).to eq(0.0)
      end
    end

    describe '.file_descriptor_count' do
      it 'returns 0' do
        expect(described_class.file_descriptor_count).to eq(0)
      end
    end
  end
29 30

  describe '.cpu_time' do
31
    it 'returns a Fixnum' do
Douwe Maan's avatar
Douwe Maan committed
32
      expect(described_class.cpu_time).to be_an(Integer)
33 34 35 36
    end
  end

  describe '.real_time' do
37
    it 'returns a Fixnum' do
Douwe Maan's avatar
Douwe Maan committed
38
      expect(described_class.real_time).to be_an(Integer)
39 40 41 42
    end
  end

  describe '.monotonic_time' do
43
    it 'returns a Fixnum' do
Douwe Maan's avatar
Douwe Maan committed
44
      expect(described_class.monotonic_time).to be_an(Integer)
45 46
    end
  end
47
end