|
1 | 1 | require 'spec_helper'
|
2 | 2 |
|
3 | 3 | 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 |
5 | 12 |
|
6 | 13 | describe file(consul_executable) do
|
7 | 14 | it { should be_file }
|
8 |
| - it { should be_executable } |
| 15 | + it { should be_executable } unless windows? |
9 | 16 | end
|
10 | 17 |
|
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 |
14 | 22 |
|
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 |
19 | 27 |
|
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 |
23 | 32 | end
|
24 | 33 |
|
25 | 34 | describe service('consul') do
|
|
33 | 42 | end
|
34 | 43 | end
|
35 | 44 |
|
36 |
| -describe command('/opt/consul/0.7.0/consul members -detailed') do |
| 45 | +describe command("#{consul_command} members -detailed") do |
37 | 46 | its(:exit_status) { should eq 0 }
|
38 | 47 | its(:stdout) { should match %r{\balive\b} }
|
39 | 48 | its(:stdout) { should match %r{\brole=consul\b} }
|
40 | 49 | its(:stdout) { should match %r{\bbootstrap=1\b} }
|
41 | 50 | its(:stdout) { should match %r{\bdc=fortmeade\b} }
|
42 | 51 | end
|
43 | 52 |
|
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' |
48 | 55 |
|
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 |
53 | 63 |
|
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' |
55 | 72 | end
|
56 | 73 |
|
57 | 74 | describe file(config_file) do
|
58 | 75 | 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 |
63 | 81 | end
|
64 | 82 |
|
65 | 83 | describe file(confd_dir) do
|
66 | 84 | 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 |
71 | 90 | end
|
72 | 91 |
|
73 | 92 | describe file(data_dir) do
|
74 | 93 | 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 |
79 | 99 | end
|
80 | 100 |
|
81 | 101 | describe file("#{confd_dir}/consul_definition_check.json") do
|
82 | 102 | 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 |
87 | 108 | end
|
88 | 109 |
|
89 | 110 | describe file("#{confd_dir}/consul_watch_check.json") do
|
90 | 111 | 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 |
95 | 117 | end
|
0 commit comments