mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 01:58:41 -05:00
Fix missing function when moving metrics from pool_manager to api/v1
Fix dependency function component_to_test for jenkins metrics that was not copied from pool_manager to api/v1 in https://github.com/puppetlabs/vmpooler/pull/455
This commit is contained in:
parent
a28d142f50
commit
c88f5d8b5a
3 changed files with 12 additions and 49 deletions
|
|
@ -236,6 +236,18 @@ module Vmpooler
|
|||
result
|
||||
end
|
||||
|
||||
def component_to_test(match, labels_string)
|
||||
return if labels_string.nil?
|
||||
|
||||
labels_string_parts = labels_string.split(',')
|
||||
labels_string_parts.each do |part|
|
||||
key, value = part.split('=')
|
||||
next if value.nil?
|
||||
return value if key == match
|
||||
end
|
||||
'none'
|
||||
end
|
||||
|
||||
def update_user_metrics(operation, vmname)
|
||||
backend.multi
|
||||
backend.hget("vmpooler__vm__#{vmname}", 'tag:jenkins_build_url')
|
||||
|
|
|
|||
|
|
@ -478,18 +478,6 @@ module Vmpooler
|
|||
dereference_mutex(vm)
|
||||
end
|
||||
|
||||
def component_to_test(match, labels_string)
|
||||
return if labels_string.nil?
|
||||
|
||||
labels_string_parts = labels_string.split(',')
|
||||
labels_string_parts.each do |part|
|
||||
key, value = part.split('=')
|
||||
next if value.nil?
|
||||
return value if key == match
|
||||
end
|
||||
'none'
|
||||
end
|
||||
|
||||
def purge_unused_vms_and_folders
|
||||
global_purge = $config[:config]['purge_unconfigured_folders']
|
||||
providers = $config[:providers].keys
|
||||
|
|
|
|||
|
|
@ -1062,43 +1062,6 @@ EOT
|
|||
end
|
||||
end
|
||||
|
||||
describe '#component_to_test' do
|
||||
let(:matching_key) { 'LABEL_ONE' }
|
||||
let(:matching_value) { 'test' }
|
||||
let(:labels_string) { "#{matching_key}=#{matching_value},LABEL_TWO=test2,LABEL_THREE=test3" }
|
||||
let(:nonmatrix_string) { 'test,stuff,and,things' }
|
||||
|
||||
context 'when string contains a matching key' do
|
||||
it 'should print the corresponding value' do
|
||||
expect(subject.component_to_test(matching_key, labels_string)).to eq(matching_value)
|
||||
end
|
||||
|
||||
context 'when match contains no value' do
|
||||
it 'should return none' do
|
||||
expect(subject.component_to_test(matching_key, matching_key)).to eq('none')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when string contains no key value pairs' do
|
||||
it 'should return' do
|
||||
expect(subject.component_to_test(matching_key, nonmatrix_string)).to eq('none')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when labels_string is a job number' do
|
||||
it 'should return nil' do
|
||||
expect(subject.component_to_test(matching_key, '25')).to eq('none')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when labels_string is nil' do
|
||||
it 'should return nil' do
|
||||
expect(subject.component_to_test(matching_key, nil)).to be nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#purge_unused_vms_and_folders' do
|
||||
let(:config) { YAML.load(<<-EOT
|
||||
---
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue