Skip to content

Commit

Permalink
Extend networking tests to test both VR and VPC using same set
Browse files Browse the repository at this point in the history
  • Loading branch information
bheuvel committed May 6, 2016
1 parent 9f42cdc commit 8514e4e
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 69 deletions.
131 changes: 74 additions & 57 deletions functional-tests/networking/Vagrantfile.advanced_networking
Original file line number Diff line number Diff line change
Expand Up @@ -5,61 +5,78 @@
VAGRANTFILE_API_VERSION = '2'

Vagrant.require_version '>= 1.5.0'
cloudstack_pf_ip_address = ENV['PUBLIC_SOURCE_NAT_IP']
machines = {
box1: {
# Test fixed public port
pf_public_port: ENV['PUBLIC_SSH_PORT'],
# Test fixed private port
pf_private_port: ENV['PRIVATE_SSH_PORT'],
firewall_rules: [
# Full Firewall rule
{:ipaddress => cloudstack_pf_ip_address, :protocol => 'tcp', :startport => 1111, :endport => 1111},
# Firewall rule without ':ipaddress' which defaults to 'cloudstack_pf_ip_address'
{:protocol => 'tcp', :startport => 1122, :endport => 1122},
# Firewall rule without ':protocol', which defaults to 'tcp'
{:startport => 1133, :endport => 1133},
# Firewall rule without ':endport', which defaults to ':startport' if present
{:startport => 1144},
# Firewall rule without ':start', which defaults to ':endport' if present
{:endport => 22}
],
port_forwarding_rules: [
# Full portforwarding rule
{:ipaddress => cloudstack_pf_ip_address, :protocol => "tcp", :publicport => 1111, :privateport => 22, :openfirewall => false},
# Portforwarding rule without ':ipaddress' which defaults to 'cloudstack_pf_ip_address'
{:protocol => "tcp", :publicport => 1122, :privateport => 22, :openfirewall => false},
# Portforwarding rule without ':protocol', which defaults to 'tcp'
{:publicport => 1133, :privateport => 22, :openfirewall => false},
# Portforwarding rule without ':openfirewall', which defaults to 'cloudstack.pf_open_firewall'
{:publicport => 1144, :privateport => 22},
# Portforwarding rule without ':publicport', which defaults to ':privateport'
{:privateport => 22},
# Portforwarding rule with ':generate_firewall', which generates an apropriate
# Firewall rule based ':publicport' => ':startport', and other defaults
{:publicport => 1155, :privateport => 22, :generate_firewall => true},
# Portforwarding rule which instructs CloudStack to create a Firewall rule
{:publicport => 1166, :privateport => 22, :openfirewall => true},
],
# Trusted network as array, instead of string. Add some networks to make sure it's an (multi element) Array
pf_trusted_networks: [ENV['SOURCE_CIDR'], ',172.31.1.172/32', '172.31.1.173/32'],
# Ignore security groups
security_groups: [{
:name => "Awesome_security_group",
:description => "Created from the Vagrantfile",
:rules => [{:type => "ingress", :protocol => "TCP", :startport => 22, :endport => 22, :cidrlist => "0.0.0.0/0"}]
}],
# Ignore security groups
security_group_names: ['default', 'Awesome_security_group'],
},
box2: {
# NO pf_public_port; test auto generated public port
# NO pf_private_port; test detection of Communicator port (SSH/Winrm)
# NO firewall rules for Communicator (SSH/WinRM), test auto generation
# Trusted networks as string instead of array. Add some networks to make sure it supports multiple network-string
pf_trusted_networks: ENV['SOURCE_CIDR'] + ',172.31.1.172/32,172.31.1.173/32'
}
networks = {
VR: {
network_name: ENV['VR_NETWORK_NAME'],
public_ip: ENV['VR_PUBLIC_IP']
},
VPC: {
network_name: ENV['VPC_TIER_NAME'],
public_ip: ENV['VPC_PUBLIC_IP']
}
}
machines = {}
networks.each_pair do |net_name, net_options|
box_number = 0
machines["#{net_name}box#{box_number+=1}"] = {
# Test fixed public port
pf_public_port: ENV['PUBLIC_SSH_PORT'],
# Test fixed private port
pf_private_port: ENV['PRIVATE_SSH_PORT'],
#
pf_ip_address: net_options[:public_ip],
network_name: net_options[:network_name],
firewall_rules: [
# Full Firewall rule
{:ipaddress => net_options[:public_ip], :protocol => 'tcp', :startport => 1111, :endport => 1111},
# Firewall rule without ':ipaddress' which defaults to 'cloudstack_pf_ip_address'
{:protocol => 'tcp', :startport => 1122, :endport => 1122},
# Firewall rule without ':protocol', which defaults to 'tcp'
{:startport => 1133, :endport => 1133},
# Firewall rule without ':endport', which defaults to ':startport' if present
{:startport => 1144},
# Firewall rule without ':start', which defaults to ':endport' if present
{:endport => 22}
],
port_forwarding_rules: [
# Full portforwarding rule
{:ipaddress => net_options[:public_ip], :protocol => "tcp", :publicport => 1111, :privateport => 22, :openfirewall => false},
# Portforwarding rule without ':ipaddress' which defaults to 'cloudstack_pf_ip_address'
{:protocol => "tcp", :publicport => 1122, :privateport => 22, :openfirewall => false},
# Portforwarding rule without ':protocol', which defaults to 'tcp'
{:publicport => 1133, :privateport => 22, :openfirewall => false},
# Portforwarding rule without ':openfirewall', which defaults to 'cloudstack.pf_open_firewall'
{:publicport => 1144, :privateport => 22},
# Portforwarding rule without ':publicport', which defaults to ':privateport'
{:privateport => 22},
# Portforwarding rule with ':generate_firewall', which generates an apropriate
# Firewall rule based ':publicport' => ':startport', and other defaults
{:publicport => 1155, :privateport => 22, :generate_firewall => true},
# Portforwarding rule which instructs CloudStack to create a Firewall rule
{:publicport => 1166, :privateport => 22, :openfirewall => true},
],
# Trusted network as array, instead of string. Add some networks to make sure it's an (multi element) Array
pf_trusted_networks: [ENV['SOURCE_CIDR'], ',172.31.1.172/32', '172.31.1.173/32'],
# Ignore security groups
security_groups: [{
:name => "Awesome_security_group",
:description => "Created from the Vagrantfile",
:rules => [{:type => "ingress", :protocol => "TCP", :startport => 22, :endport => 22, :cidrlist => "0.0.0.0/0"}]
}],
# Ignore security groups
security_group_names: ['default', 'Awesome_security_group'],
}

machines["#{net_name}box#{box_number+=1}"] = {
network_name: net_options[:network_name],
pf_ip_address: net_options[:public_ip],
# NO pf_public_port; test auto generated public port
# NO pf_private_port; test detection of Communicator port (SSH/Winrm)
# NO firewall rules for Communicator (SSH/WinRM), test auto generation
# Trusted networks as string instead of array. Add some networks to make sure it supports multiple network-string
pf_trusted_networks: ENV['SOURCE_CIDR'] + ',172.31.1.172/32,172.31.1.173/32'
}
end

Vagrant.configure(VAGRANTFILE_API_VERSION) do |global_config|
machines.each_pair do |name, options|
Expand All @@ -77,13 +94,13 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |global_config|
cloudstack.api_key = ENV['CLOUDSTACK_API_KEY']
cloudstack.secret_key = ENV['CLOUDSTACK_SECRET_KEY']
cloudstack.zone_name = ENV['ZONE_NAME']
cloudstack.network_name = ENV['NETWORK_NAME']
cloudstack.network_name = options[:network_name]
cloudstack.service_offering_name = ENV['SERVICE_OFFERING_NAME']
cloudstack.ssh_key = ENV['SSH_KEY'] unless ENV['SSH_KEY'].nil?
cloudstack.ssh_user = ENV['SSH_USER'] unless ENV['SSH_USER'].nil?
cloudstack.expunge_on_destroy == true
cloudstack.expunge_on_destroy = ENV['EXPUNGE_ON_DESTROY']=="true"

cloudstack.pf_ip_address = cloudstack_pf_ip_address
cloudstack.pf_ip_address = options[:pf_ip_address]
cloudstack.pf_public_port = options[:pf_public_port] unless options[:pf_public_port].nil?
cloudstack.pf_private_port = options[:pf_private_port] unless options[:pf_private_port].nil?
cloudstack.pf_open_firewall = false
Expand Down
14 changes: 14 additions & 0 deletions functional-tests/networking/networking_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe 'Networking features' do
it 'creates firewall and portwarding rules for both Virtual Router and VPC' do
expect(`vagrant up`).to include(
'VRbox1: Machine is booted and ready for use!',
'VRbox2: Machine is booted and ready for use!',
'VPCbox1: Machine is booted and ready for use!',
'VPCbox2: Machine is booted and ready for use!'
)
expect($?.exitstatus).to eq(0)

expect(`vagrant destroy --force`).to include('Terminating the instance...')
expect($?.exitstatus).to eq(0)
end
end
12 changes: 0 additions & 12 deletions functional-tests/networking/rsync_spec.rb

This file was deleted.

0 comments on commit 8514e4e

Please sign in to comment.