Skip to content

Commit 2c551eb

Browse files
authored
Merge pull request #346 from paybyphone/windows_integration_tests
Added integration tests for Windows
2 parents a43dc10 + ebf82b0 commit 2c551eb

File tree

4 files changed

+80
-46
lines changed

4 files changed

+80
-46
lines changed

.kitchen.yml

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ platforms:
2626
named_run_list: freebsd
2727
- name: windows-2012r2
2828
named_run_list: windows
29+
driver_config:
30+
network:
31+
- ["forwarded_port", {guest: 3389, host: 3389}]
32+
- ["forwarded_port", {guest: 5985, host: 5985}]
33+
communicator: winrm
34+
customize:
35+
usbehci: "off"
2936

3037
suites:
3138
- name: default

test/fixtures/policies/_base.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
default_source :community
22
default_source :chef_repo, '..'
33
cookbook 'consul', path: '../../..'
4-
run_list 'sudo::default', 'consul::default', "consul_spec::#{name}"
5-
named_run_list :centos, 'yum::default', 'yum-centos::default', run_list
4+
run_list 'consul::default', "consul_spec::#{name}"
5+
named_run_list :centos, 'yum::default', 'yum-centos::default', 'sudo::default',run_list
66
named_run_list :debian, 'apt::default', run_list
7-
named_run_list :freebsd, 'freebsd::default', run_list
7+
named_run_list :freebsd, 'freebsd::default', 'sudo::default', run_list
88
named_run_list :windows, 'windows::default', run_list
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
require 'spec_helper'
22

33
consul_version = '0.7.0'
4-
consul_executable = "/opt/consul/#{consul_version}/consul"
4+
5+
if windows?
6+
consul_executable = "C:\\Program Files\\consul\\#{consul_version}\\consul.exe"
7+
consul_command = "& '#{consul_executable}'"
8+
else
9+
consul_executable = "/opt/consul/#{consul_version}/consul"
10+
consul_command = consul_executable
11+
end
512

613
describe file(consul_executable) do
714
it { should be_file }
8-
it { should be_executable }
15+
it { should be_executable } unless windows?
916
end
1017

11-
describe group('consul') do
12-
it { should exist }
13-
end
18+
unless windows?
19+
describe group('consul') do
20+
it { should exist }
21+
end
1422

15-
describe user('consul') do
16-
it { should exist }
17-
it { should belong_to_group('consul') }
18-
end
23+
describe user('consul') do
24+
it { should exist }
25+
it { should belong_to_group('consul') }
26+
end
1927

20-
describe command("su - consul -c 'echo successfully logged in'") do
21-
its(:stdout) { should_not match /successfully logged in/ }
22-
its(:exit_status) { should_not eq 0 }
28+
describe command("su - consul -c 'echo successfully logged in'") do
29+
its(:stdout) { should_not match /successfully logged in/ }
30+
its(:exit_status) { should_not eq 0 }
31+
end
2332
end
2433

2534
describe service('consul') do
@@ -33,63 +42,76 @@
3342
end
3443
end
3544

36-
describe command('/opt/consul/0.7.0/consul members -detailed') do
45+
describe command("#{consul_command} members -detailed") do
3746
its(:exit_status) { should eq 0 }
3847
its(:stdout) { should match %r{\balive\b} }
3948
its(:stdout) { should match %r{\brole=consul\b} }
4049
its(:stdout) { should match %r{\bbootstrap=1\b} }
4150
its(:stdout) { should match %r{\bdc=fortmeade\b} }
4251
end
4352

44-
config_dir = '/etc/consul'
45-
config_file = '/etc/consul/consul.json'
46-
confd_dir = '/etc/consul/conf.d'
47-
data_dir = '/var/lib/consul'
53+
unless windows?
54+
config_dir = '/etc/consul'
4855

49-
describe file(config_dir) do
50-
it { should be_directory }
51-
it { should be_owned_by 'root' }
52-
it { should be_grouped_into 'consul' }
56+
describe file(config_dir) do
57+
it { should be_directory }
58+
it { should be_owned_by 'root' }
59+
it { should be_grouped_into 'consul' }
60+
it { should be_mode 755 }
61+
end
62+
end
5363

54-
it { should be_mode 755 }
64+
if windows?
65+
config_file = 'C:\Program Files\consul\consul.json'
66+
confd_dir = 'C:\Program Files\consul\conf.d'
67+
data_dir = 'C:\Program Files\consul\data'
68+
else
69+
config_file = '/etc/consul/consul.json'
70+
confd_dir = '/etc/consul/conf.d'
71+
data_dir = '/var/lib/consul'
5572
end
5673

5774
describe file(config_file) do
5875
it { should be_file }
59-
it { should be_owned_by 'root' }
60-
it { should be_grouped_into 'consul' }
61-
62-
it { should be_mode 640 }
76+
unless windows?
77+
it { should be_owned_by 'root' }
78+
it { should be_grouped_into 'consul' }
79+
it { should be_mode 640 }
80+
end
6381
end
6482

6583
describe file(confd_dir) do
6684
it { should be_directory }
67-
it { should be_owned_by 'root' }
68-
it { should be_grouped_into 'consul' }
69-
70-
it { should be_mode 755 }
85+
unless windows?
86+
it { should be_owned_by 'root' }
87+
it { should be_grouped_into 'consul' }
88+
it { should be_mode 755 }
89+
end
7190
end
7291

7392
describe file(data_dir) do
7493
it { should be_directory }
75-
it { should be_owned_by 'consul' }
76-
it { should be_grouped_into 'consul' }
77-
78-
it { should be_mode 750 }
94+
unless windows?
95+
it { should be_owned_by 'consul' }
96+
it { should be_grouped_into 'consul' }
97+
it { should be_mode 750 }
98+
end
7999
end
80100

81101
describe file("#{confd_dir}/consul_definition_check.json") do
82102
it { should be_file }
83-
it { should be_owned_by 'root' }
84-
it { should be_grouped_into 'consul' }
85-
86-
it { should be_mode 640 }
103+
unless windows?
104+
it { should be_owned_by 'root' }
105+
it { should be_grouped_into 'consul' }
106+
it { should be_mode 640 }
107+
end
87108
end
88109

89110
describe file("#{confd_dir}/consul_watch_check.json") do
90111
it { should be_file }
91-
it { should be_owned_by 'root' }
92-
it { should be_grouped_into 'consul' }
93-
94-
it { should be_mode 640 }
112+
unless windows?
113+
it { should be_owned_by 'root' }
114+
it { should be_grouped_into 'consul' }
115+
it { should be_mode 640 }
116+
end
95117
end

test/integration/helpers/serverspec/spec_helper.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
require 'serverspec'
22

3-
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
3+
def windows?
4+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
5+
end
6+
7+
if !windows?
48
set :backend, :exec
59
else
610
set :backend, :cmd
711
set :os, family: 'windows'
12+
set :architecture, :x86_64
813
end
914

1015
# Tells serverspec to use a login shell for running chkconfig/service,

0 commit comments

Comments
 (0)