Sha256: d1445ca6060a67772c6fa4d0d655e04ad388a0ae20da5a98b62b30b1f3cd2ad7

Contents?: true

Size: 762 Bytes

Versions: 20

Compression:

Stored size: 762 Bytes

Contents

require "spec_helper"
require "gitlab_exporter/memstats"

describe GitLab::Exporter::MemStats do
  let(:pid) { 100 }
  let(:smaps_data) { File.open("spec/fixtures/smaps/sample.txt") }

  subject { described_class::Aggregator.new(pid) }

  before do
    expect(File).to receive(:open).with("/proc/#{pid}/smaps").and_yield(smaps_data)
  end

  it "parses the data properly" do
    expect(subject.valid?).to be_truthy

    nonzero_fields = %w(size rss shared_clean shared_dirty private_dirty pss)
    zero_fields = %w(private_clean swap)

    nonzero_fields.each do |field|
      expect(subject.totals[field]).to be > 0 # rubocop:disable Style/NumericPredicate
    end

    zero_fields.each do |field|
      expect(subject.totals[field]).to eq(0)
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
gitlab-exporter-8.0.0 spec/memstats_spec.rb
gitlab-exporter-7.2.0 spec/memstats_spec.rb
gitlab-exporter-7.1.2 spec/memstats_spec.rb
gitlab-exporter-7.1.1 spec/memstats_spec.rb
gitlab-exporter-7.1.0 spec/memstats_spec.rb
gitlab-exporter-7.0.6 spec/memstats_spec.rb
gitlab-exporter-7.0.5 spec/memstats_spec.rb
gitlab-exporter-7.0.4 spec/memstats_spec.rb
gitlab-exporter-7.0.3 spec/memstats_spec.rb
gitlab-exporter-7.0.2 spec/memstats_spec.rb
gitlab-exporter-7.0.1 spec/memstats_spec.rb
gitlab-exporter-7.0.0 spec/memstats_spec.rb
gitlab-exporter-6.1.0 spec/memstats_spec.rb
gitlab-exporter-6.0.0 spec/memstats_spec.rb
gitlab-exporter-5.2.2 spec/memstats_spec.rb
gitlab-exporter-5.2.1 spec/memstats_spec.rb
gitlab-exporter-5.2.0 spec/memstats_spec.rb
gitlab-exporter-5.1.0 spec/memstats_spec.rb
gitlab-exporter-5.0.1 spec/memstats_spec.rb
gitlab-exporter-5.0.0 spec/memstats_spec.rb