Skip to content

Commit

Permalink
Specs: resources should be created before their consumption
Browse files Browse the repository at this point in the history
We are gonna change code to charge only for consumption since the
resource creation time. First, we need to make sure all our test subject
have proper created_on timestamp.
  • Loading branch information
isimluk committed Jan 10, 2017
1 parent db8bb44 commit e2d0561
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions spec/models/chargeback_container_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let(:base_options) { {:interval_size => 2, :end_interval_offset => 0, :ext_options => {:tz => 'UTC'} } }
let(:hourly_rate) { 0.01 }
let(:starting_date) { Time.parse('2012-09-01 23:59:59Z').utc }
let(:ts) { starting_date.in_time_zone(Metric::Helper.get_time_zone(options[:ext_options])) }
let(:ts) { starting_date.in_time_zone(Metric::Helper.get_time_zone(base_options[:ext_options])) }
let(:report_run_time) { month_end }
let(:month_beginning) { ts.beginning_of_month.utc }
let(:month_end) { ts.end_of_month.utc }
Expand Down Expand Up @@ -32,7 +32,8 @@
ChargebackRate.seed

EvmSpecHelper.create_guid_miq_server_zone
@project = FactoryGirl.create(:container_project, :name => "my project", :ext_management_system => ems)
@project = FactoryGirl.create(:container_project, :name => "my project", :ext_management_system => ems,
:created_on => month_beginning)

temp = {:cb_rate => chargeback_rate, :object => ems}
ChargebackRate.set_assignments(:compute, [temp])
Expand Down
3 changes: 2 additions & 1 deletion spec/models/chargeback_vm/ongoing_time_period_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
let(:tag) { Tag.find_by_name('/managed/environment/prod') }
let(:vm) do
ems = FactoryGirl.create(:ems_vmware)
vm = FactoryGirl.create(:vm_vmware, :name => 'test_vm', :evm_owner => admin, :ems_ref => 'ems_ref')
vm = FactoryGirl.create(:vm_vmware, :name => 'test_vm', :evm_owner => admin, :ems_ref => 'ems_ref',
:created_on => start_of_all_intervals)
vm.tag_with(tag.name, :ns => '*')
host = FactoryGirl.create(:host, :hardware => FactoryGirl.create(:hardware,
:memory_mb => 8124, :cpu_total_cores => 1,
Expand Down
5 changes: 3 additions & 2 deletions spec/models/chargeback_vm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
c = FactoryGirl.create(:classification, :name => "prod", :description => "Production", :parent_id => cat.id)
@tag = Tag.find_by_name("/managed/environment/prod")

@vm1 = FactoryGirl.create(:vm_vmware, :name => "test_vm", :evm_owner => admin, :ems_ref => "ems_ref")
@vm1 = FactoryGirl.create(:vm_vmware, :name => "test_vm", :evm_owner => admin, :ems_ref => "ems_ref",
:created_on => month_beginning)
@vm1.tag_with(@tag.name, :ns => '*')

@host1 = FactoryGirl.create(:host, :hardware => FactoryGirl.create(:hardware, :memory_mb => 8124, :cpu_total_cores => 1, :cpu_speed => 9576), :vms => [@vm1])
Expand Down Expand Up @@ -527,7 +528,7 @@

context 'for SCVMM (hyper-v)' do
let!(:vm1) do
vm = FactoryGirl.create(:vm_microsoft)
vm = FactoryGirl.create(:vm_microsoft, :created_on => report_run_time - 1.day)
vm.tag_with(@tag.name, :ns => '*')
vm
end
Expand Down

0 comments on commit e2d0561

Please sign in to comment.