(POOLER-70) Update migrate_vm_and_record_timing for VM Provider

Previously the Pool Manager would use vSphere objects directly.  This commit
- Modifies the migrate_vm_and_record_timing method to use VM and Pool names
  instead of VM and Pool objects.
This commit is contained in:
Glenn Sarti 2017-03-31 14:23:56 -07:00
parent cf15829f05
commit 3f6ead8134
2 changed files with 11 additions and 15 deletions

View file

@ -506,11 +506,11 @@ module Vmpooler
end
end
def migrate_vm_and_record_timing(vm_object, vm_name, pool, host, source_host_name, dest_host_name, provider)
def migrate_vm_and_record_timing(vm_name, pool_name, source_host_name, dest_host_name, provider)
start = Time.now
provider.migrate_vm_host(vm_object, host)
provider.migrate_vm_to_host(pool_name, vm_name, dest_host_name)
finish = '%.2f' % (Time.now - start)
$metrics.timing("migrate.#{pool}", finish)
$metrics.timing("migrate.#{pool_name}", finish)
$metrics.increment("migrate_from.#{source_host_name}")
$metrics.increment("migrate_to.#{dest_host_name}")
checkout_to_migration = '%.2f' % (Time.now - Time.parse($redis.hget("vmpooler__vm__#{vm_name}", 'checkout')))

View file

@ -1981,45 +1981,41 @@ EOT
end
describe '#migrate_vm_and_record_timing' do
let(:provider) { double('provider') }
let(:vm_object) { double('vm_object') }
let(:source_host_name) { 'source_host' }
let(:dest_host_name) { 'dest_host' }
before do
expect(subject).not_to be_nil
end
before(:each) do
create_vm(vm,token)
expect(provider).to receive(:migrate_vm_host).with(vm_object, host)
expect(subject).not_to be_nil
expect(provider).to receive(:migrate_vm_to_host).with(pool, vm, dest_host_name)
end
it 'should return the elapsed time for the migration' do
result = subject.migrate_vm_and_record_timing(vm_object, vm, pool, host, source_host_name, dest_host_name, provider)
result = subject.migrate_vm_and_record_timing(vm, pool, source_host_name, dest_host_name, provider)
expect(result).to match(/0\.[\d]+/)
end
it 'should add timing metric' do
expect(metrics).to receive(:timing).with("migrate.#{pool}",String)
subject.migrate_vm_and_record_timing(vm_object, vm, pool, host, source_host_name, dest_host_name, provider)
subject.migrate_vm_and_record_timing(vm, pool, source_host_name, dest_host_name, provider)
end
it 'should increment from_host and to_host metric' do
expect(metrics).to receive(:increment).with("migrate_from.#{source_host_name}")
expect(metrics).to receive(:increment).with("migrate_to.#{dest_host_name}")
subject.migrate_vm_and_record_timing(vm_object, vm, pool, host, source_host_name, dest_host_name, provider)
subject.migrate_vm_and_record_timing(vm, pool, source_host_name, dest_host_name, provider)
end
it 'should set migration_time metric in redis' do
expect(redis.hget("vmpooler__vm__#{vm}", 'migration_time')).to be_nil
subject.migrate_vm_and_record_timing(vm_object, vm, pool, host, source_host_name, dest_host_name, provider)
subject.migrate_vm_and_record_timing(vm, pool, source_host_name, dest_host_name, provider)
expect(redis.hget("vmpooler__vm__#{vm}", 'migration_time')).to match(/0\.[\d]+/)
end
it 'should set checkout_to_migration metric in redis' do
expect(redis.hget("vmpooler__vm__#{vm}", 'checkout_to_migration')).to be_nil
subject.migrate_vm_and_record_timing(vm_object, vm, pool, host, source_host_name, dest_host_name, provider)
subject.migrate_vm_and_record_timing(vm, pool, source_host_name, dest_host_name, provider)
expect(redis.hget("vmpooler__vm__#{vm}", 'checkout_to_migration')).to match(/0\.[\d]+/)
end
end