Skip to content

Commit

Permalink
Move vip conditional logic from stemcell impl to spec helpers.
Browse files Browse the repository at this point in the history
Previously, we were following the existing approach of using the
stemcell name to determine whether we support certain features. Now,
we're moving towards making the stemcell implementation agnostic to
these details, by refactoring the conditional logic to determine whether
vip networking is supported out into the spec helpers.

[#106771316](https://www.pivotaltracker.com/story/show/106771316)

Signed-off-by: Wagner Camarao <wcamarao@vmware.com>
  • Loading branch information
aaronshurley authored and Wagner Camarao committed Nov 6, 2015
1 parent d03848b commit 93cd071
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 22 deletions.
4 changes: 4 additions & 0 deletions lib/bat/deployment_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ def static_ip
static_ips.first
end

def includes_vip?
!!(@spec['properties']['vip'])
end

def vip
@spec['properties']['vip']
end
Expand Down
4 changes: 0 additions & 4 deletions lib/bat/stemcell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ def supports_raw_ephemeral_storage?
name =~ /aws/
end

def supports_vip?
!!(name =~ /aws/ || name =~ /openstack/)
end

def ==(other)
to_s == other.to_s
end
Expand Down
17 changes: 0 additions & 17 deletions spec/bat/stemcell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,23 +110,6 @@
end
end

describe '#supports_vip?' do
{
'bosh-openstack-kvm-centos-go_agent' => true,
'bosh-openstack-kvm-ubuntu-trusty-go_agent' => true,
'bosh-aws-xen-ubuntu-trusty-go_agent' => true,
'bosh-aws-xen-centos-7-go_agent' => true,
'bosh-vsphere-esxi-ubuntu-trusty-go_agent' => false,
'bosh-vsphere-esxi-centos-7-go_agent' => false,
'bosh-vcloud-esxi-ubuntu-trusty-go_agent' => false,
}.each do |stemcell_name, expected|
it "returns #{expected} for #{stemcell_name}" do
stemcell = Bat::Stemcell.new(stemcell_name, nil)
expect(stemcell.supports_vip?).to be(expected)
end
end
end

describe '#to_s' do
it 'returns "<name>-<version>"' do
expect(stemcell.to_s).to eq('STEMCELL_NAME-STEMCELL_NAME')
Expand Down
2 changes: 1 addition & 1 deletion spec/system/with_release_stemcell_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def matchdata_to_h(matchdata)
end

it 'should have network access to the vm using the vip' do
skip "vip network isn't supported" unless @requirements.stemcell.supports_vip?
skip "vip network isn't supported" unless includes_vip?

expect(vip).not_to be_nil
expect(ssh(vip, 'vcap', '/sbin/ifconfig eth0', @our_ssh_options)).to match /#{static_ip}/
Expand Down

0 comments on commit 93cd071

Please sign in to comment.