Skip to content

Commit

Permalink
Calculate total for hours of exitstence in metering reports
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Mar 1, 2018
1 parent 65d2667 commit 17b989b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/models/metering_container_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def self.report_col_options
{
"cpu_cores_allocated_metric" => {:grouping => [:total]},
"cpu_cores_used_metric" => {:grouping => [:total]},
"existence_hours_metric" => {:grouping => [:total]},
"fixed_compute_metric" => {:grouping => [:total]},
"memory_allocated_metric" => {:grouping => [:total]},
"memory_used_metric" => {:grouping => [:total]},
Expand Down
11 changes: 6 additions & 5 deletions app/models/metering_container_project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ class MeteringContainerProject < ChargebackContainerProject

def self.report_col_options
{
"cpu_cores_used_metric" => {:grouping => [:total]},
"fixed_compute_metric" => {:grouping => [:total]},
"memory_used_metric" => {:grouping => [:total]},
"metering_used_metric" => {:grouping => [:total]},
"net_io_used_metric" => {:grouping => [:total]},
"cpu_cores_used_metric" => {:grouping => [:total]},
"existence_hours_metric" => {:grouping => [:total]},
"fixed_compute_metric" => {:grouping => [:total]},
"memory_used_metric" => {:grouping => [:total]},
"metering_used_metric" => {:grouping => [:total]},
"net_io_used_metric" => {:grouping => [:total]},
}
end

Expand Down
1 change: 1 addition & 0 deletions app/models/metering_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def self.report_col_options
"cpu_allocated_metric" => {:grouping => [:total]},
"cpu_used_metric" => {:grouping => [:total]},
"disk_io_used_metric" => {:grouping => [:total]},
"existence_hours_metric" => {:grouping => [:total]},
"fixed_compute_metric" => {:grouping => [:total]},
"memory_allocated_metric" => {:grouping => [:total]},
"memory_used_metric" => {:grouping => [:total]},
Expand Down
17 changes: 17 additions & 0 deletions spec/models/metering_container_image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,21 @@
expect(subject.cpu_cores_allocated_metric).to eq(@container.limit_memory_bytes / 1.megabytes)
end
end

let(:report_col_options) do
{
"cpu_cores_allocated_metric" => {:grouping => [:total]},
"cpu_cores_used_metric" => {:grouping => [:total]},
"existence_hours_metric" => {:grouping => [:total]},
"fixed_compute_metric" => {:grouping => [:total]},
"memory_allocated_metric" => {:grouping => [:total]},
"memory_used_metric" => {:grouping => [:total]},
"metering_used_metric" => {:grouping => [:total]},
"net_io_used_metric" => {:grouping => [:total]},
}
end

it 'sets grouping settings for all related columns' do
expect(described_class.report_col_options).to eq(report_col_options)
end
end
15 changes: 15 additions & 0 deletions spec/models/metering_container_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,19 @@
expect(subject.net_io_used_metric).to eq(net_usage_rate_average * count_of_metric_rollup)
end
end

let(:report_col_options) do
{
"cpu_cores_used_metric" => {:grouping => [:total]},
"existence_hours_metric" => {:grouping => [:total]},
"fixed_compute_metric" => {:grouping => [:total]},
"memory_used_metric" => {:grouping => [:total]},
"metering_used_metric" => {:grouping => [:total]},
"net_io_used_metric" => {:grouping => [:total]},
}
end

it 'sets grouping settings for all related columns' do
expect(described_class.report_col_options).to eq(report_col_options)
end
end
20 changes: 20 additions & 0 deletions spec/models/metering_vm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,24 @@
it 'lists proper attributes' do
expect(described_class.attribute_names).to match_array(allowed_attributes)
end

let(:report_col_options) do
{
"cpu_allocated_metric" => {:grouping => [:total]},
"cpu_used_metric" => {:grouping => [:total]},
"disk_io_used_metric" => {:grouping => [:total]},
"existence_hours_metric" => {:grouping => [:total]},
"fixed_compute_metric" => {:grouping => [:total]},
"memory_allocated_metric" => {:grouping => [:total]},
"memory_used_metric" => {:grouping => [:total]},
"metering_used_metric" => {:grouping => [:total]},
"net_io_used_metric" => {:grouping => [:total]},
"storage_allocated_metric" => {:grouping => [:total]},
"storage_used_metric" => {:grouping => [:total]},
}
end

it 'sets grouping settings for all related columns' do
expect(described_class.report_col_options).to eq(report_col_options)
end
end

0 comments on commit 17b989b

Please sign in to comment.