diff --git a/app/models/metering_container_image.rb b/app/models/metering_container_image.rb index b486630fc01..ec53e322f5f 100644 --- a/app/models/metering_container_image.rb +++ b/app/models/metering_container_image.rb @@ -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]}, diff --git a/app/models/metering_container_project.rb b/app/models/metering_container_project.rb index 0bfa3402253..d7f4edc9cba 100644 --- a/app/models/metering_container_project.rb +++ b/app/models/metering_container_project.rb @@ -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 diff --git a/app/models/metering_vm.rb b/app/models/metering_vm.rb index d32b89370eb..92b66071571 100644 --- a/app/models/metering_vm.rb +++ b/app/models/metering_vm.rb @@ -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]}, diff --git a/spec/models/metering_container_image_spec.rb b/spec/models/metering_container_image_spec.rb index 35a168f358d..0b64bb58a27 100644 --- a/spec/models/metering_container_image_spec.rb +++ b/spec/models/metering_container_image_spec.rb @@ -4,6 +4,7 @@ let(:hourly_rate) { 0.01 } let(:count_hourly_rate) { 1.00 } let(:starting_date) { Time.parse('2012-09-01 23:59:59Z').utc } + let(:options) { base_options } let(:ts) { starting_date.in_time_zone(Metric::Helper.get_time_zone(options[:ext_options])) } let(:report_run_time) { month_end } let(:month_beginning) { ts.beginning_of_month.utc } @@ -59,4 +60,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 diff --git a/spec/models/metering_container_project_spec.rb b/spec/models/metering_container_project_spec.rb index 4574c75ff4f..77abaf6fd81 100644 --- a/spec/models/metering_container_project_spec.rb +++ b/spec/models/metering_container_project_spec.rb @@ -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 diff --git a/spec/models/metering_vm_spec.rb b/spec/models/metering_vm_spec.rb index c8ae09718ac..59ac50ee0bf 100644 --- a/spec/models/metering_vm_spec.rb +++ b/spec/models/metering_vm_spec.rb @@ -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