Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows data path #275

Merged
merged 2 commits into from
Feb 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,20 @@ suites:
acl_master_token: doublesecret
acl_datacenter: fortmeade
acl_default_policy: deny
excludes:
- windows-2012r2
- centos-7.2
- centos-6.7
- name: windefault
includes:
- windows-2012r2
run_list:
- recipe[consul::default]
attributes:
consul:
service_user: vagrant
config: *default-config
service:
nssm_params:
AppStdout: C:\foo\bar\out.log
AppStderr: C:\foo\bar\err.log
4 changes: 2 additions & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
default['consul']['config']['bag_item'] = 'consul'

default['consul']['config']['path'] = join_path config_prefix_path, 'consul.json'
default['consul']['config']['data_dir'] = windows? ? join_path(data_prefix_path, 'data') : data_prefix_path
default['consul']['config']['data_dir'] = data_path
default['consul']['config']['ca_file'] = join_path config_prefix_path, 'ssl', 'CA', 'ca.crt'
default['consul']['config']['cert_file'] = join_path config_prefix_path, 'ssl', 'certs', 'consul.crt'
default['consul']['config']['key_file'] = join_path config_prefix_path, 'ssl', 'private', 'consul.key'
Expand Down Expand Up @@ -44,7 +44,7 @@

# Windows only
default['consul']['service']['nssm_params'] = {
'AppDirectory' => join_path(data_prefix_path, 'data'),
'AppDirectory' => data_path,
'AppStdout' => join_path(config_prefix_path, 'stdout.log'),
'AppStderr' => join_path(config_prefix_path, 'error.log'),
'AppRotateFiles' => 1,
Expand Down
4 changes: 2 additions & 2 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def config_prefix_path
windows? ? join_path(program_files, 'consul') : join_path('/etc', 'consul')
end

def data_prefix_path
windows? ? join_path(program_files, 'consul') : join_path('/var/lib', 'consul')
def data_path
windows? ? join_path(program_files, 'consul', 'data') : join_path('/var/lib', 'consul')
end

def command(config_file, config_dir)
Expand Down
28 changes: 28 additions & 0 deletions test/integration/default/serverspec/localhost/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,31 @@
its(:stdout) { should match %r{\bbootstrap=1\b} }
its(:stdout) { should match %r{\bdc=fortmeade\b} }
end

config_file = '/etc/consul/consul.json'
config_dir = '/etc/consul/conf.d'
data_dir = '/var/lib/consul'

describe file(config_file) do
it { should be_file }
it { should be_owned_by 'consul' }
it { should be_grouped_into 'consul' }

it { should be_mode 640 }
end

describe file(config_dir) do
it { should be_directory }
it { should be_owned_by 'consul' }
it { should be_grouped_into 'consul' }

it { should be_mode 755 }
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 755 }
end
7 changes: 6 additions & 1 deletion test/integration/helpers/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
require 'serverspec'

set :backend, :exec
if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil?
set :backend, :exec
else
set :backend, :cmd
set :os, family: 'windows'
end
40 changes: 40 additions & 0 deletions test/integration/windefault/serverspec/localhost/default_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
require 'spec_helper'

describe file('C:\Program Files\consul\consul.exe') do
it { should be_file }
end

describe service('consul') do
it { should be_enabled }
it { should be_running }
end

[8300, 8400, 8500, 8600].each do |p|
describe port(p) do
it { should be_listening }
end
end

describe command('& "C:\Program Files\consul\consul.exe" members -detailed') do
its(:exit_status) { should eq 0 }
its(:stdout) { should match %r{\balive\b} }
its(:stdout) { should match %r{\brole=consul\b} }
its(:stdout) { should match %r{\bbootstrap=1\b} }
its(:stdout) { should match %r{\bdc=fortmeade\b} }
end

config_file = 'C:\Program Files\consul\consul.json'
config_dir = 'C:\Program Files\consul\conf.d'
data_dir = 'C:\Program Files\consul\data'

describe file(config_file) do
it { should be_file }
end

describe file(config_dir) do
it { should be_directory }
end

describe file(data_dir) do
it { should be_directory }
end
11 changes: 11 additions & 0 deletions test/integration/windefault/serverspec/localhost/logging_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'spec_helper'

context 'logging' do
describe file('C:\foo\bar\out.log') do
it { should be_file }
end

describe file('C:\foo\bar\err.log') do
it { should be_file }
end
end