Sha256: 751cfe645a0c09ef89d97336a41851b63eeece3f34dc90c168297ad5f8bf70c6

Contents?: true

Size: 1.38 KB

Versions: 6

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe LitmusPaper::Metric::CPULoad do
  describe "#current_health" do
    it "is the percent of available cpu capacity" do
      facter = StubFacter.new({"processorcount" => "4", "loadaverage" => "1.00 0.40 0.10"})
      cpu_load = LitmusPaper::Metric::CPULoad.new(40, facter)
      cpu_load.current_health.should == 30
    end

    it "is one when the load is above one per core" do
      facter = StubFacter.new({"processorcount" => "4", "loadaverage" => "20.00 11.40 10.00"})
      cpu_load = LitmusPaper::Metric::CPULoad.new(50, facter)
      cpu_load.current_health.should == 1
    end
  end

  describe "#processor_count" do
    it "is a positive integer" do
      cpu_load = LitmusPaper::Metric::CPULoad.new(50)
      cpu_load.processor_count.should > 0
    end

    it "is cached" do
      Facter.should_receive(:value).once.and_return("10")
      cpu_load = LitmusPaper::Metric::CPULoad.new(50)
      cpu_load.processor_count
      cpu_load.processor_count
      cpu_load.processor_count
    end
  end

  describe "#load_average" do
    it "is a floating point" do
      cpu_load = LitmusPaper::Metric::CPULoad.new(50)
      cpu_load.load_average.should > 0.0
    end
  end

  describe "#to_s" do
    it "is the check name and the maximum weight" do
      cpu_load = LitmusPaper::Metric::CPULoad.new(50)
      cpu_load.to_s.should == "Metric::CPULoad(50)"
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
litmus_paper-0.9.6 spec/litmus_paper/metric/cpu_load_spec.rb
litmus_paper-0.9.5 spec/litmus_paper/metric/cpu_load_spec.rb
litmus_paper-0.9.4 spec/litmus_paper/metric/cpu_load_spec.rb
litmus_paper-0.9.3 spec/litmus_paper/metric/cpu_load_spec.rb
litmus_paper-0.9.2 spec/litmus_paper/metric/cpu_load_spec.rb
litmus_paper-0.9.1 spec/litmus_paper/metric/cpu_load_spec.rb