diff --git a/src/acct/test/helper/mock_client.rb b/src/acct/test/helper/mock_client.rb index 87086ed8da..1f04f5c098 100644 --- a/src/acct/test/helper/mock_client.rb +++ b/src/acct/test/helper/mock_client.rb @@ -36,9 +36,9 @@ class MockClient def add_vm(id, values) if values[:state] == 6 - @done_vms[id] = values - elsif - @vms[id] = values + @done_vms[id] = values.clone + else + @vms[id] = values.clone end end diff --git a/src/acct/test/monitoring_spec.rb b/src/acct/test/monitoring_spec.rb index 34e7d76915..f3f7272a17 100644 --- a/src/acct/test/monitoring_spec.rb +++ b/src/acct/test/monitoring_spec.rb @@ -88,16 +88,15 @@ describe "1 Vm 1 10 steps" do ] } - @mock_client.add_vm(1, values) - @mock_client.add_vm(2, values) + values[:state] = 7 + @mock_client.add_vm(i+100, values) + values[:state] = 3 + @mock_client.add_vm(i+10, values) @monitoring.insert(create_vmpool_hash) - #@db[:vms].count.should eql(1) - #@db[:vm_samples].count.should eql(1+i > 5 ? 5 : 1+i) - #pp @watch_client.vm_monitoring(1, ['cpu', 'net_tx']) - # "total" - pp @watch_client.vm_total('total') + @db[:vm_samples].count + total = @watch_client.vm_total([:total, :error, :active]) } end end \ No newline at end of file diff --git a/src/acct/watch_helper.rb b/src/acct/watch_helper.rb index 90532fdf73..367e7211bf 100644 --- a/src/acct/watch_helper.rb +++ b/src/acct/watch_helper.rb @@ -324,7 +324,7 @@ module WatchHelper VmSample.multi_insert(@@samples_cache) Vm.each { |vm| - if vm.samples.count > CONF[:WINDOW_SIZE] -1 + if vm.samples.count > CONF[:WINDOW_SIZE] vm.samples.first.delete end } @@ -371,7 +371,7 @@ module WatchHelper HostSample.multi_insert(@@samples_cache) Host.all.each { |host| - if host.samples.count > CONF[:WINDOW_SIZE] -1 + if host.samples.count > CONF[:WINDOW_SIZE] host.samples.first.delete end }