diff options
Diffstat (limited to 'spec')
-rw-r--r-- | spec/config_spec.rb | 15 | ||||
-rw-r--r-- | spec/one_node/Vagrantfile | 24 | ||||
-rw-r--r-- | spec/one_node/vyos_spec.rb | 12 | ||||
-rw-r--r-- | spec/site_to_site_vpn/Vagrantfile | 24 | ||||
-rw-r--r-- | spec/site_to_site_vpn/vyos1_spec.rb | 12 | ||||
-rw-r--r-- | spec/site_to_site_vpn/vyos2_spec.rb | 12 | ||||
-rw-r--r-- | spec/site_to_site_vpn/vyos3_spec.rb | 12 | ||||
-rw-r--r-- | spec/site_to_site_vpn/vyos4_spec.rb | 12 |
8 files changed, 49 insertions, 74 deletions
diff --git a/spec/config_spec.rb b/spec/config_spec.rb new file mode 100644 index 0000000..f9b3980 --- /dev/null +++ b/spec/config_spec.rb @@ -0,0 +1,15 @@ +require 'serverspec_vyos_config' + +def config_spec + test = ENV['TARGET_TEST'] + host = ENV['TARGET_HOST'] + + File.open("spec/#{test}/#{host}_script.sh") do |file| + file.each_line do |l| + next unless l.start_with?('set') + describe vyos_config(l.gsub(/set /, '')) do + it { should be_exists } + end + end + end +end diff --git a/spec/one_node/Vagrantfile b/spec/one_node/Vagrantfile index 03b9ff7..bfa380c 100644 --- a/spec/one_node/Vagrantfile +++ b/spec/one_node/Vagrantfile @@ -1,28 +1,28 @@ require 'yaml' -configs = YAML.load_file("config.yaml") +configs = YAML.load_file('config.yaml') -Vagrant.configure("2") do |config| +Vagrant.configure('2') do |config| config.vm.provider :libvirt do |libvirt| libvirt.cpu_mode = 'host-passthrough' end configs.keys.each do |host| config.vm.define host.to_sym do |c| - c.vm.box = "higebu/vyos" - c.vm.synced_folder "./", "/vagrant", - :owner => "vagrant", - :group => "vyattacfg", - :mount_options => ["dmode=775,fmode=775"] + c.vm.box = 'higebu/vyos' + c.vm.synced_folder './', '/vagrant', + owner: 'vagrant', + group: 'vyattacfg', + mount_options: ['dmode=775,fmode=775'] c.vm.hostname = host - if !configs[host].nil? and configs[host].has_key? :networks + if !configs[host].nil? && configs[host].key?(:networks) configs[host][:networks].keys.each do |net| c.vm.network :private_network, - :ip => configs[host][:networks][net], - :libvirt__network_name => net, - :libvirt__dhcp_enabled => false + ip: configs[host][:networks][net], + libvirt__network_name: net, + libvirt__dhcp_enabled: false end end - c.vm.provision "shell", path: "#{host}_script.sh" + c.vm.provision 'shell', path: "#{host}_script.sh" end end end diff --git a/spec/one_node/vyos_spec.rb b/spec/one_node/vyos_spec.rb index ec0e11f..76740d4 100644 --- a/spec/one_node/vyos_spec.rb +++ b/spec/one_node/vyos_spec.rb @@ -1,12 +1,4 @@ require_relative '../spec_helper' -require 'serverspec_vyos_config' +require_relative '../config_spec' -File.open('spec/one_node/vyos_script.sh') do |file| - file.each_line do |l| - if l.start_with?("set") - describe vyos_config(l.gsub(/set /, '')) do - it { should be_exists } - end - end - end -end +config_spec diff --git a/spec/site_to_site_vpn/Vagrantfile b/spec/site_to_site_vpn/Vagrantfile index 03b9ff7..bfa380c 100644 --- a/spec/site_to_site_vpn/Vagrantfile +++ b/spec/site_to_site_vpn/Vagrantfile @@ -1,28 +1,28 @@ require 'yaml' -configs = YAML.load_file("config.yaml") +configs = YAML.load_file('config.yaml') -Vagrant.configure("2") do |config| +Vagrant.configure('2') do |config| config.vm.provider :libvirt do |libvirt| libvirt.cpu_mode = 'host-passthrough' end configs.keys.each do |host| config.vm.define host.to_sym do |c| - c.vm.box = "higebu/vyos" - c.vm.synced_folder "./", "/vagrant", - :owner => "vagrant", - :group => "vyattacfg", - :mount_options => ["dmode=775,fmode=775"] + c.vm.box = 'higebu/vyos' + c.vm.synced_folder './', '/vagrant', + owner: 'vagrant', + group: 'vyattacfg', + mount_options: ['dmode=775,fmode=775'] c.vm.hostname = host - if !configs[host].nil? and configs[host].has_key? :networks + if !configs[host].nil? && configs[host].key?(:networks) configs[host][:networks].keys.each do |net| c.vm.network :private_network, - :ip => configs[host][:networks][net], - :libvirt__network_name => net, - :libvirt__dhcp_enabled => false + ip: configs[host][:networks][net], + libvirt__network_name: net, + libvirt__dhcp_enabled: false end end - c.vm.provision "shell", path: "#{host}_script.sh" + c.vm.provision 'shell', path: "#{host}_script.sh" end end end diff --git a/spec/site_to_site_vpn/vyos1_spec.rb b/spec/site_to_site_vpn/vyos1_spec.rb index 6506d93..76740d4 100644 --- a/spec/site_to_site_vpn/vyos1_spec.rb +++ b/spec/site_to_site_vpn/vyos1_spec.rb @@ -1,12 +1,4 @@ require_relative '../spec_helper' -require 'serverspec_vyos_config' +require_relative '../config_spec' -File.open('spec/site_to_site_vpn/vyos1_script.sh') do |file| - file.each_line do |l| - if l.start_with?("set") - describe vyos_config(l.gsub(/set /, '')) do - it { should be_exists } - end - end - end -end +config_spec diff --git a/spec/site_to_site_vpn/vyos2_spec.rb b/spec/site_to_site_vpn/vyos2_spec.rb index 23a0a57..76740d4 100644 --- a/spec/site_to_site_vpn/vyos2_spec.rb +++ b/spec/site_to_site_vpn/vyos2_spec.rb @@ -1,12 +1,4 @@ require_relative '../spec_helper' -require 'serverspec_vyos_config' +require_relative '../config_spec' -File.open('spec/site_to_site_vpn/vyos2_script.sh') do |file| - file.each_line do |l| - if l.start_with?("set") - describe vyos_config(l.gsub(/set /, '')) do - it { should be_exists } - end - end - end -end +config_spec diff --git a/spec/site_to_site_vpn/vyos3_spec.rb b/spec/site_to_site_vpn/vyos3_spec.rb index 3aa75d6..6f67d61 100644 --- a/spec/site_to_site_vpn/vyos3_spec.rb +++ b/spec/site_to_site_vpn/vyos3_spec.rb @@ -1,15 +1,7 @@ require_relative '../spec_helper' -require 'serverspec_vyos_config' +require_relative '../config_spec' -File.open('spec/site_to_site_vpn/vyos3_script.sh') do |file| - file.each_line do |l| - if l.start_with?("set") - describe vyos_config(l.gsub(/set /, '')) do - it { should be_exists } - end - end - end -end +config_spec describe host('10.0.3.14') do it { should be_reachable } diff --git a/spec/site_to_site_vpn/vyos4_spec.rb b/spec/site_to_site_vpn/vyos4_spec.rb index 2da7341..b657b9e 100644 --- a/spec/site_to_site_vpn/vyos4_spec.rb +++ b/spec/site_to_site_vpn/vyos4_spec.rb @@ -1,15 +1,7 @@ require_relative '../spec_helper' -require 'serverspec_vyos_config' +require_relative '../config_spec' -File.open('spec/site_to_site_vpn/vyos4_script.sh') do |file| - file.each_line do |l| - if l.start_with?("set") - describe vyos_config(l.gsub(/set /, '')) do - it { should be_exists } - end - end - end -end +config_spec describe host('10.0.2.13') do it { should be_reachable } |