Skip to content

Commit

Permalink
test: Switch to InSpec verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
legal90 committed Jan 17, 2017
1 parent 556e921 commit c9c4b05
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 124 deletions.
2 changes: 1 addition & 1 deletion .kitchen.dokken.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ transport:
provisioner:
name: dokken
verifier:
root_path: /opt/verifier
name: inspec
platforms:
- name: centos-7
named_run_list: centos
Expand Down
6 changes: 4 additions & 2 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ driver:
provisioner:
name: chef_zero

verifier:
name: inspec

platforms:
- name: ubuntu-16.04
named_run_list: debian
Expand Down Expand Up @@ -52,8 +55,7 @@ suites:
acl_datacenter: FortMeade
acl_default_policy: deny
- name: client
provisioner:
policyfile: test/fixtures/policies/default.rb
named_run_list: client
attributes:
consul:
config:
Expand Down
1 change: 0 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# TODO
- Fix the helpers and clean up the where it injects into DSL.
- Use the InSpec instead of ServerSpec.
1 change: 1 addition & 0 deletions test/fixtures/policies/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
named_run_list :debian, 'apt::default', run_list
named_run_list :freebsd, 'freebsd::default', 'sudo::default', run_list
named_run_list :windows, 'windows::default', run_list
named_run_list :client, 'consul::default'

default['authorization']['sudo']['users'] = %w(kitchen vagrant)
default['authorization']['sudo']['passwordless'] = true
55 changes: 55 additions & 0 deletions test/integration/client/default_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
require_relative '../spec_helper'

consul_executable = "/opt/consul/#{consul_version}/consul"
config_file = '/etc/consul/consul.json'
config_dir = '/etc/consul'

describe file(consul_executable) do
it { should be_file }
it { should be_executable }
end

describe group('consul') do
it { should exist }
end

describe user('consul') do
it { should exist }
its('group') { should eq 'consul' }
end

describe command("su - consul -c 'echo successfully logged in'") do
its(:stdout) { should_not match /successfully logged in/ }
its(:exit_status) { should_not eq 0 }
end

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

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

describe command("#{consul_executable} members -detailed") do
its(:exit_status) { should eq 0 }
its(:stdout) { should match %r{\balive\b} }
its(:stdout) { should match %r{\brole=node\b} }
end

describe file('/usr/local/bin/consul') do
it { should be_symlink }
end

describe file(config_file) do
it { should be_file }
its('mode') { should cmp '0640' }
end

describe file(config_dir) do
it { should be_directory }
its('mode') { should cmp '0755' }
end
76 changes: 0 additions & 76 deletions test/integration/client/serverspec/default_spec.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'spec_helper'

describe command('curl -s "http://localhost:8500/v1/acl/info/anonymous"') do
its(:exit_status) { should eq 0 }
its(:stdout) { should match('"ID":"anonymous"') }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require_relative '../spec_helper'

if windows?
consul_executable = "C:\\Program Files\\consul\\#{consul_version}\\consul.exe"
Expand All @@ -15,12 +15,12 @@

unless windows?
describe group('consul') do
it { should exist }
it { should exist }
end

describe user('consul') do
it { should exist }
it { should belong_to_group('consul') }
its('group') { should eq 'consul' }
end

describe command("su - consul -c 'echo successfully logged in'") do
Expand Down Expand Up @@ -49,13 +49,12 @@
end

unless windows?
config_dir = '/etc/consul'
config_dir = '/etc/consul'

describe file(config_dir) do
it { should be_directory }
it { should be_owned_by 'root' }
describe directory(config_dir) do
it { should be_owned_by 'root' }
it { should be_grouped_into 'consul' }
it { should be_mode 755 }
its('mode') { should cmp '0755' }
end

describe file('/usr/local/bin/consul') do
Expand All @@ -78,7 +77,7 @@
unless windows?
it { should be_owned_by 'root' }
it { should be_grouped_into 'consul' }
it { should be_mode 640 }
its('mode') { should cmp '0640' }
end
end

Expand All @@ -87,16 +86,15 @@
unless windows?
it { should be_owned_by 'root' }
it { should be_grouped_into 'consul' }
it { should be_mode 755 }
its('mode') { should cmp '0755' }
end
end

describe file(data_dir) do
it { should be_directory }
describe directory(data_dir) do
unless windows?
it { should be_owned_by 'consul' }
it { should be_grouped_into 'consul' }
it { should be_mode 750 }
its('mode') { should cmp '0750' }
end
end

Expand All @@ -105,7 +103,7 @@
unless windows?
it { should be_owned_by 'root' }
it { should be_grouped_into 'consul' }
it { should be_mode 640 }
its('mode') { should cmp '0640' }
end
end

Expand All @@ -114,6 +112,6 @@
unless windows?
it { should be_owned_by 'root' }
it { should be_grouped_into 'consul' }
it { should be_mode 640 }
its('mode') { should cmp '0640' }
end
end
26 changes: 0 additions & 26 deletions test/integration/helpers/serverspec/spec_helper.rb

This file was deleted.

7 changes: 7 additions & 0 deletions test/integration/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def windows?
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
end

def consul_version
'0.7.2'
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'spec_helper'
require_relative '../spec_helper'

consul_version = '0.7.1'

Expand Down

0 comments on commit c9c4b05

Please sign in to comment.