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

API updates & Add encrypt param #56

Merged
merged 1 commit into from
Oct 16, 2014
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
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ suites:
datacenter: FortMeade
bind_interface: eth0
advertise_interface: eth0
encrypt: CGXC2NsXW4AvuB4h5ODYzQ==
- name: runit
run_list:
- recipe[consul::default]
Expand Down
2 changes: 1 addition & 1 deletion recipes/_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
end

copy_params = [
:bind_addr, :datacenter, :domain, :log_level, :node_name, :advertise_addr, :enable_syslog
:bind_addr, :datacenter, :domain, :log_level, :node_name, :advertise_addr, :enable_syslog, :encrypt
]
copy_params.each do |key|
if node['consul'][key]
Expand Down
4 changes: 2 additions & 2 deletions recipes/ui.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
install_checksum = node['consul']['checksums'].fetch(install_version)

ark 'consul_ui' do
path node['consul']['ui_dir']
path node['consul']['data_dir']
home_dir node['consul']['ui_dir']

This comment was marked as outdated.

This comment was marked as outdated.

version node['consul']['version']
checksum install_checksum
url ::URI.join(node['consul']['base_url'], "#{install_version}.zip").to_s
action :put
end
4 changes: 4 additions & 0 deletions spec/support/matchers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ def put_ark(name)
def dump_ark(name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :dump, name)
end

def install_ark(name)
ChefSpec::Matchers::ResourceMatcher.new(:ark, :install, name)
end
2 changes: 2 additions & 0 deletions spec/unit/recipes/_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
it do
expect(chef_run).to create_directory('/etc/consul.d')
.with(mode: 0755)
expect(chef_run).to create_directory('/var/log/consul')
.with(mode: 0755)
end
it do
expect(chef_run).to create_user('consul service user: consul')
Expand Down
5 changes: 3 additions & 2 deletions spec/unit/recipes/ui_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
describe_recipe 'consul::ui' do
it { expect(chef_run).to include_recipe('ark::default') }
it do
expect(chef_run).to put_ark('consul_ui')
.with(path: '/var/lib/consul/ui')
expect(chef_run).to install_ark('consul_ui')
.with(path: '/var/lib/consul')
.with(home_dir: '/var/lib/consul/ui')
.with(version: '0.4.0')
end
end
23 changes: 14 additions & 9 deletions test/integration/default/serverspec/localhost/consul_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

describe command('which consul') do
it { should return_exit_status 0 }
its(:exit_status) { should eq 0 }
its(:stdout) { should match '/usr/local/bin/consul' }
end

Expand All @@ -25,22 +25,27 @@
end

describe command 'consul members -detailed' do
it { should return_exit_status 0 }
it { should return_stdout %r{\balive\b} }
it { should return_stdout %r{\brole=consul\b} }
it { should return_stdout %r{\bbootstrap=1\b} }
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} }
end

describe 'config file attributes' do
context command 'consul members -detailed' do
it { should return_stdout %r{\bdc=FortMeade\b} }
its(:stdout) { should match %r{\bdc=FortMeade\b} }
end
end

eth0_ip = command("/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'").stdout.strip
describe command("grep #{eth0_ip} /etc/consul.d/default.json") do
it { should return_exit_status 0 }
its(:exit_status) { should eq 0 }
# bind_addr should only be in the config if node[:consul][:bind_addr] is set
it { should return_stdout %r{"bind_addr":\s"#{eth0_ip}"}}
it { should return_stdout %r{"advertise_addr":\s"#{eth0_ip}"}}
its(:stdout) { should match %r{"bind_addr":\s"#{eth0_ip}"}}
its(:stdout) { should match %r{"advertise_addr":\s"#{eth0_ip}"}}
end

describe command('grep encrypt /etc/consul.d/default.json') do
its(:exit_status) { should eq 0 }
its(:stdout) { should match %r{"encrypt":\s"([^\"]*)"} }
end
3 changes: 1 addition & 2 deletions test/integration/default/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'serverspec'

include SpecInfra::Helper::Exec
include SpecInfra::Helper::DetectOS
set :backend, :exec

RSpec.configure do |c|
c.path = '/usr/local/bin:/sbin:/bin:/usr/bin'
Expand Down
4 changes: 2 additions & 2 deletions test/integration/ui/serverspec/localhost/consul_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

eth0_ip = command("/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'").stdout.strip
describe command("wget -q -O- http://#{eth0_ip}:8500/ui/index.html") do
it { should return_exit_status 0 }
its(:stdout) { should == File.read('/var/lib/consul/ui/index.html') }
its(:exit_status) { should eq 0 }
its(:stdout) { should eq File.read('/var/lib/consul/ui/index.html') }
end
16 changes: 2 additions & 14 deletions test/integration/ui/serverspec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
begin
require 'rspec/its'
rescue LoadError
require 'rubygems/dependency_installer'
Gem::DependencyInstaller.new.install('rspec-its')
require 'rspec/its'
end

require 'serverspec'

include SpecInfra::Helper::Exec
include SpecInfra::Helper::DetectOS

RSpec.configure do |c|
c.path = '/usr/local/bin:/sbin:/bin:/usr/bin'
end
set :backend, :exec
set :path, '$PATH:/usr/local/bin:/sbin:/bin:/usr/bin'