Skip to content

Commit

Permalink
Test case for average in allocated calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Jul 20, 2017
1 parent 33464b8 commit 02a9a47
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions spec/models/chargeback_vm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,27 @@
end
end

context "Monthly" do
context "calculation of allocated metrics by average" do
let(:start_time) { report_run_time - 17.hours }
let(:finish_time) { report_run_time - 14.hours }
let(:options) { base_options.merge(:interval => 'monthly', :method_for_allocated_metrics => :avg) }

before do
mid_point = month_beginning + 10.days
add_metric_rollups_for(@vm1, month_beginning...mid_point, 1.hour, metric_rollup_params)
add_metric_rollups_for(@vm1, mid_point...month_end, 1.hour, metric_rollup_params.merge!(:derived_vm_numvcpus => 2))
end

subject { ChargebackVm.build_results_for_report_ChargebackVm(options).first.first }

it "calculates cpu allocated metric" do
expect(subject.cpu_allocated_metric).to eq(1.6666666666666667)
expect(subject.cpu_allocated_cost).to eq(1200) # ?
end
end
end

context "Monthly" do
let(:options) { base_options.merge(:interval => 'monthly') }
before do
Expand Down

0 comments on commit 02a9a47

Please sign in to comment.