Skip to content

Commit

Permalink
Merge pull request #56 from benjaminws/api-updates-and-encrypt-param
Browse files Browse the repository at this point in the history
API updates & Add encrypt param
  • Loading branch information
reset committed Oct 16, 2014
2 parents f8f2cf1 + a23a150 commit 3b298b8
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
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']
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'

0 comments on commit 3b298b8

Please sign in to comment.