Merge pull request #283 from mattkirby/remove_find_pool

(MAINT) Remove find_pool and update pending tests
This commit is contained in:
Spencer McElmurry 2018-07-16 10:25:16 -07:00 committed by GitHub
commit 5ca85beb18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 277 deletions

View file

@ -858,14 +858,13 @@ EOT
end
it 'should honor the insecure setting' do
pending('Resolution of issue https://github.com/puppetlabs/vmpooler/issues/207')
config[:providers][:vsphere][:insecure] = false
config[:providers][:vsphere][:insecure] = true
expect(RbVmomi::VIM).to receive(:connect).with({
:host => credentials['server'],
:user => credentials['username'],
:password => credentials['password'],
:insecure => false,
:insecure => true,
}).and_return(connection)
subject.connect_to_vsphere
end
@ -1527,17 +1526,6 @@ EOT
end
end
context 'with a VM with the same name as a folder in a single layer folder hierarchy' do
it 'should not return a VM' do
pending('https://github.com/puppetlabs/vmpooler/issues/204')
result = subject.find_vm_folder(foldername,connection,datacenter_name)
expect(result).to_not be_nil
expect(result.name).to eq(foldername)
expect(result.is_a? RbVmomi::VIM::VirtualMachine).to be false
end
end
context 'with a multi layer folder hierarchy' do
let(:foldername) { 'folder2/folder4/folder' }
let(:folder_object) { mock_RbVmomi_VIM_Folder({ :name => foldername}) }
@ -2908,248 +2896,6 @@ EOT
end
end
describe '#find_pool' do
let(:poolname) { 'pool'}
let(:missing_poolname) { 'missing_pool'}
context 'with empty folder hierarchy' do
let(:connection_options) {{
:serviceContent => {
:datacenters => [
{ :name => datacenter_name }
]
}
}}
it 'should ensure the connection' do
pending('https://github.com/puppetlabs/vmpooler/issues/209')
expect(subject).to receive(:ensure_connected)
subject.find_pool(poolname,connection,datacenter_name)
end
it 'should return nil if the pool is not found' do
pending('https://github.com/puppetlabs/vmpooler/issues/209')
expect(subject.find_pool(missing_poolname,connection,datacenter_name)).to be_nil
end
end
context 'with multiple datacenters' do
let(:poolpath) { 'pool' }
let(:connection_options) {{
:serviceContent => {
:datacenters => [
{ :name => 'AnotherDC',
:hostfolder_tree => {
'folder1' => nil,
'folder2' => nil,
},
},
{ :name => datacenter_name,
:hostfolder_tree => {
'folder3' => nil,
'pool' => {:object_type => 'resource_pool'},
'folder4' => nil,
},
}
]
}
}}
it 'should return the pool when found' do
result = subject.find_pool(poolpath,connection, datacenter_name)
expect(result).to_not be_nil
expect(result.name).to eq('pool')
expect(result.is_a?(RbVmomi::VIM::ResourcePool)).to be true
end
end
[
# Single layer Host folder hierarchy
{
:context => 'single layer folder hierarchy with a resource pool',
:poolpath => 'pool',
:poolname => 'pool',
:hostfolder_tree => {
'folder1' => nil,
'folder2' => nil,
'pool' => {:object_type => 'resource_pool'},
'folder3' => nil,
},
},
{
:context => 'single layer folder hierarchy with a child resource pool',
:poolpath => 'parentpool/pool',
:poolname => 'pool',
:hostfolder_tree => {
'folder1' => nil,
'folder2' => nil,
'parentpool' => {:object_type => 'resource_pool', :children => {
'pool' => {:object_type => 'resource_pool'},
}},
'folder3' => nil,
},
},
{
:context => 'single layer folder hierarchy with a resource pool within a cluster',
:poolpath => 'cluster/pool',
:poolname => 'pool',
:hostfolder_tree => {
'folder1' => nil,
'folder2' => nil,
'cluster' => {:object_type => 'cluster_compute_resource', :children => {
'pool' => {:object_type => 'resource_pool'},
}},
'folder3' => nil,
},
},
# Multi layer Host folder hierarchy
{
:context => 'multi layer folder hierarchy with a resource pool',
:poolpath => 'folder2/folder4/pool',
:poolname => 'pool',
:hostfolder_tree => {
'folder1' => nil,
'folder2' => { :children => {
'folder3' => nil,
'folder4' => { :children => {
'pool' => {:object_type => 'resource_pool'},
}},
}},
'folder5' => nil,
},
},
{
:context => 'multi layer folder hierarchy with a child resource pool',
:poolpath => 'folder2/folder4/parentpool/pool',
:poolname => 'pool',
:hostfolder_tree => {
'folder1' => nil,
'folder2' => { :children => {
'folder3' => nil,
'folder4' => { :children => {
'parentpool' => {:object_type => 'resource_pool', :children => {
'pool' => {:object_type => 'resource_pool'},
}},
}},
}},
'folder5' => nil,
},
},
{
:context => 'multi layer folder hierarchy with a resource pool within a cluster',
:poolpath => 'folder2/folder4/cluster/pool',
:poolname => 'pool',
:hostfolder_tree => {
'folder1' => nil,
'folder2' => { :children => {
'folder3' => nil,
'folder4' => { :children => {
'cluster' => {:object_type => 'cluster_compute_resource', :children => {
'pool' => {:object_type => 'resource_pool'},
}},
}},
}},
'folder5' => nil,
},
},
].each do |testcase|
context testcase[:context] do
let(:connection_options) {{
:serviceContent => {
:datacenters => [
{ :name => datacenter_name,
:hostfolder_tree => testcase[:hostfolder_tree],
}
]
}
}}
it 'should return the pool when found' do
result = subject.find_pool(testcase[:poolpath],connection,datacenter_name)
expect(result).to_not be_nil
expect(result.name).to eq(testcase[:poolname])
expect(result.is_a?(RbVmomi::VIM::ResourcePool)).to be true
end
it 'should return nil if the poolname is not found' do
pending('https://github.com/puppetlabs/vmpooler/issues/209')
expect(subject.find_pool(missing_poolname,connection,datacenter_name)).to be_nil
end
end
end
# Tests for issue https://github.com/puppetlabs/vmpooler/issues/210
[
{
:context => 'multi layer folder hierarchy with a resource pool the same name as a folder',
:poolpath => 'folder2/folder4/cluster/pool',
:poolname => 'pool',
:hostfolder_tree => {
'folder1' => nil,
'folder2' => { :children => {
'folder3' => nil,
'bad_pool' => {:object_type => 'resource_pool', :name => 'folder4'},
'folder4' => { :children => {
'cluster' => {:object_type => 'cluster_compute_resource', :children => {
'pool' => {:object_type => 'resource_pool'},
}},
}},
}},
'folder5' => nil,
},
},
{
:context => 'multi layer folder hierarchy with a cluster the same name as a folder',
:poolpath => 'folder2/folder4/cluster/pool',
:poolname => 'pool',
:hostfolder_tree => {
'folder1' => nil,
'folder2' => { :children => {
'folder3' => nil,
'bad_cluster' => {:object_type => 'cluster_compute_resource', :name => 'folder4'},
'folder4' => { :children => {
'cluster' => {:object_type => 'cluster_compute_resource', :children => {
'pool' => {:object_type => 'resource_pool'},
}},
}},
}},
'folder5' => nil,
},
},
].each do |testcase|
context testcase[:context] do
let(:connection_options) {{
:serviceContent => {
:datacenters => [
{ :name => datacenter_name,
:hostfolder_tree => testcase[:hostfolder_tree],
}
]
}
}}
it 'should ensure the connection' do
pending('https://github.com/puppetlabs/vmpooler/issues/210')
expect(subject).to receive(:ensure_connected)
subject.find_pool(testcase[:poolpath],connection,datacenter_name)
end
it 'should return the pool when found' do
pending('https://github.com/puppetlabs/vmpooler/issues/210')
result = subject.find_pool(testcase[:poolpath],connection,datacenter_name)
expect(result).to_not be_nil
expect(result.name).to eq(testcase[:poolname])
expect(result.is_a?(RbVmomi::VIM::ResourcePool)).to be true
end
end
end
end
describe '#find_snapshot' do
let(:snapshot_name) {'snapshot'}
let(:missing_snapshot_name) {'missing_snapshot'}