diff --git a/.kitchen.yml b/.kitchen.yml index 164cab4b..10a19d16 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -26,6 +26,13 @@ platforms: named_run_list: freebsd - name: windows-2012r2 named_run_list: windows + driver_config: + network: + - ["forwarded_port", {guest: 3389, host: 3389}] + - ["forwarded_port", {guest: 5985, host: 5985}] + communicator: winrm + customize: + usbehci: "off" suites: - name: default diff --git a/test/fixtures/policies/_base.rb b/test/fixtures/policies/_base.rb index 790336d4..7e44fa7e 100644 --- a/test/fixtures/policies/_base.rb +++ b/test/fixtures/policies/_base.rb @@ -1,8 +1,8 @@ default_source :community default_source :chef_repo, '..' cookbook 'consul', path: '../../..' -run_list 'sudo::default', 'consul::default', "consul_spec::#{name}" -named_run_list :centos, 'yum::default', 'yum-centos::default', run_list +run_list 'consul::default', "consul_spec::#{name}" +named_run_list :centos, 'yum::default', 'yum-centos::default', 'sudo::default',run_list named_run_list :debian, 'apt::default', run_list -named_run_list :freebsd, 'freebsd::default', run_list +named_run_list :freebsd, 'freebsd::default', 'sudo::default', run_list named_run_list :windows, 'windows::default', run_list diff --git a/test/integration/default/serverspec/default_spec.rb b/test/integration/default/serverspec/default_spec.rb index 0b14405f..f8cc3ae6 100644 --- a/test/integration/default/serverspec/default_spec.rb +++ b/test/integration/default/serverspec/default_spec.rb @@ -1,25 +1,34 @@ require 'spec_helper' consul_version = '0.7.0' -consul_executable = "/opt/consul/#{consul_version}/consul" + +if windows? + consul_executable = "C:\\Program Files\\consul\\#{consul_version}\\consul.exe" + consul_command = "& '#{consul_executable}'" +else + consul_executable = "/opt/consul/#{consul_version}/consul" + consul_command = consul_executable +end describe file(consul_executable) do it { should be_file } - it { should be_executable } + it { should be_executable } unless windows? end -describe group('consul') do - it { should exist } -end +unless windows? + describe group('consul') do + it { should exist } + end -describe user('consul') do - it { should exist } - it { should belong_to_group('consul') } -end + describe user('consul') do + it { should exist } + it { should belong_to_group('consul') } + end -describe command("su - consul -c 'echo successfully logged in'") do - its(:stdout) { should_not match /successfully logged in/ } - its(:exit_status) { should_not eq 0 } + describe command("su - consul -c 'echo successfully logged in'") do + its(:stdout) { should_not match /successfully logged in/ } + its(:exit_status) { should_not eq 0 } + end end describe service('consul') do @@ -33,7 +42,7 @@ end end -describe command('/opt/consul/0.7.0/consul members -detailed') do +describe command("#{consul_command} members -detailed") do its(:exit_status) { should eq 0 } its(:stdout) { should match %r{\balive\b} } its(:stdout) { should match %r{\brole=consul\b} } @@ -41,55 +50,68 @@ its(:stdout) { should match %r{\bdc=fortmeade\b} } end -config_dir = '/etc/consul' -config_file = '/etc/consul/consul.json' -confd_dir = '/etc/consul/conf.d' -data_dir = '/var/lib/consul' +unless windows? + config_dir = '/etc/consul' -describe file(config_dir) do - it { should be_directory } - it { should be_owned_by 'root' } - it { should be_grouped_into 'consul' } + describe file(config_dir) do + it { should be_directory } + it { should be_owned_by 'root' } + it { should be_grouped_into 'consul' } + it { should be_mode 755 } + end +end - it { should be_mode 755 } +if windows? + config_file = 'C:\Program Files\consul\consul.json' + confd_dir = 'C:\Program Files\consul\conf.d' + data_dir = 'C:\Program Files\consul\data' +else + config_file = '/etc/consul/consul.json' + confd_dir = '/etc/consul/conf.d' + data_dir = '/var/lib/consul' end describe file(config_file) do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'consul' } - - it { should be_mode 640 } + unless windows? + it { should be_owned_by 'root' } + it { should be_grouped_into 'consul' } + it { should be_mode 640 } + end end describe file(confd_dir) do it { should be_directory } - it { should be_owned_by 'root' } - it { should be_grouped_into 'consul' } - - it { should be_mode 755 } + unless windows? + it { should be_owned_by 'root' } + it { should be_grouped_into 'consul' } + it { should be_mode 755 } + end end describe file(data_dir) do it { should be_directory } - it { should be_owned_by 'consul' } - it { should be_grouped_into 'consul' } - - it { should be_mode 750 } + unless windows? + it { should be_owned_by 'consul' } + it { should be_grouped_into 'consul' } + it { should be_mode 750 } + end end describe file("#{confd_dir}/consul_definition_check.json") do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'consul' } - - it { should be_mode 640 } + unless windows? + it { should be_owned_by 'root' } + it { should be_grouped_into 'consul' } + it { should be_mode 640 } + end end describe file("#{confd_dir}/consul_watch_check.json") do it { should be_file } - it { should be_owned_by 'root' } - it { should be_grouped_into 'consul' } - - it { should be_mode 640 } + unless windows? + it { should be_owned_by 'root' } + it { should be_grouped_into 'consul' } + it { should be_mode 640 } + end end diff --git a/test/integration/helpers/serverspec/spec_helper.rb b/test/integration/helpers/serverspec/spec_helper.rb index c606a37c..5b6ee36f 100644 --- a/test/integration/helpers/serverspec/spec_helper.rb +++ b/test/integration/helpers/serverspec/spec_helper.rb @@ -1,10 +1,15 @@ require 'serverspec' -if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil? +def windows? + (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil +end + +if !windows? set :backend, :exec else set :backend, :cmd set :os, family: 'windows' + set :architecture, :x86_64 end # Tells serverspec to use a login shell for running chkconfig/service,