This repository has been archived by the owner on Jan 28, 2020. It is now read-only.
forked from realityforge/chef-kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use cyberflow's unit testing logic from realityforge#101
- Loading branch information
Showing
12 changed files
with
302 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ test/* | |
features/* | ||
Guardfile | ||
Procfile | ||
test | ||
|
||
# SCM # | ||
####### | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "chefspec", | ||
"description": "Stubbed Environment for Chefspec", | ||
"cookbook_versions": { | ||
}, | ||
"json_class": "Chef::Environment", | ||
"chef_type": "environment", | ||
"default_attributes": { | ||
}, | ||
"override_attributes": { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "node01", | ||
"chef_environment": "_default", | ||
"json_class": "Chef::Node", | ||
"automatic": { | ||
"hostname": "vagrant.vm", | ||
"recipes": [ | ||
"kibana::default" | ||
], | ||
"roles": [ | ||
], | ||
"ipaddress": "192.168.0.1" | ||
}, | ||
"tags": [ | ||
"app" | ||
], | ||
"normal": { | ||
}, | ||
"chef_type": "node", | ||
"default": { | ||
}, | ||
"override": { | ||
}, | ||
"run_list": [ | ||
"recipe[kibana::default]" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,73 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'chefspec' | ||
require_relative 'spec_helper' | ||
|
||
# for ubuntu 14.04 upstart | ||
describe 'kibana::_service' do | ||
before { stub_resources } | ||
let(:chef_run) { ChefSpec::SoloRunner.new(UBUNTU_OPTS).converge(described_recipe) } | ||
let(:template) { chef_run.template('/etc/init/kibana.conf') } | ||
it 'creates an upstart template at /etc/init/kibana.conf' do | ||
expect(chef_run).to create_template('/etc/init/kibana.conf') | ||
end | ||
it 'enables a kibana service' do | ||
expect(chef_run).to enable_service('kibana') | ||
end | ||
it 'sends a restart notification to the service' do | ||
expect(template).to notify('service[kibana]').to(:restart) | ||
end | ||
end | ||
# describe 'kibana::_service' do | ||
# before { stub_resources } | ||
# let(:chef_run) { ChefSpec::SoloRunner.new(UBUNTU_OPTS).converge(described_recipe) } | ||
# let(:template) { chef_run.template('/etc/init/kibana.conf') } | ||
# it 'creates an upstart template at /etc/init/kibana.conf' do | ||
# expect(chef_run).to create_template('/etc/init/kibana.conf') | ||
# end | ||
# end | ||
# | ||
# # for ubuntu 16.04 systemd | ||
# describe 'kibana::_service' do | ||
# before { stub_resources } | ||
# let(:chef_run) { ChefSpec::SoloRunner.new(UBUNTU_1604_OPTS).converge(described_recipe) } | ||
# let(:template) { chef_run.template('/lib/systemd/system/kibana.service') } | ||
# it 'creates an upstart template at /lib/systemd/system/kibana.service' do | ||
# expect(chef_run).to create_template('/lib/systemd/system/kibana.service') | ||
# end | ||
# end | ||
# | ||
# # for centos 6.x init | ||
# describe 'kibana::_service' do | ||
# before { stub_resources } | ||
# let(:chef_run) { ChefSpec::SoloRunner.new(CENTOS_OPTS).converge(described_recipe) } | ||
# let(:template) { chef_run.template('/usr/lib/systemd/system/kibana.service') } | ||
# | ||
# it 'creates an init.d template at /usr/lib/systemd/system/kibana.service' do | ||
# expect(chef_run).to create_template('/usr/lib/systemd/system/kibana.service') | ||
# end | ||
# end | ||
# | ||
# # for centos 7.x systemd | ||
# describe 'kibana::_service' do | ||
# before { stub_resources } | ||
# let(:chef_run) { ChefSpec::SoloRunner.new(CENTOS7_OPTS).converge(described_recipe) } | ||
# let(:template) { chef_run.template('/usr/lib/systemd/system/kibana.service') } | ||
# it 'creates an init.d template at /usr/lib/systemd/system/kibana.service' do | ||
# expect(chef_run).to create_template('/usr/lib/systemd/system/kibana.service') | ||
# end | ||
# end | ||
|
||
# for ubuntu 16.04 systemd | ||
describe 'kibana::_service' do | ||
before { stub_resources } | ||
let(:chef_run) { ChefSpec::SoloRunner.new(UBUNTU_1604_OPTS).converge(described_recipe) } | ||
let(:template) { chef_run.template('/lib/systemd/system/kibana.service') } | ||
it 'creates an upstart template at /lib/systemd/system/kibana.service' do | ||
expect(chef_run).to create_template('/lib/systemd/system/kibana.service') | ||
end | ||
it 'enables a kibana service' do | ||
expect(chef_run).to enable_service('kibana') | ||
end | ||
it 'sends a restart notification to the service' do | ||
expect(template).to notify('service[kibana]').to(:restart) | ||
end | ||
end | ||
supported_platforms.each do |platform, versions| | ||
versions.each do |version| | ||
context "on #{platform.capitalize} #{version}" do | ||
let(:chef_run) do | ||
ChefSpec::ServerRunner.new(platform: platform, version: version) do |node, server| | ||
node_resources(node) # data for this node | ||
stub_chef_zero(platform, version, server) # stub other nodes in chef-zero | ||
end.converge(described_recipe) | ||
end | ||
|
||
# for centos 6.x init | ||
describe 'kibana::_service' do | ||
before { stub_resources } | ||
let(:chef_run) { ChefSpec::SoloRunner.new(CENTOS_OPTS).converge(described_recipe) } | ||
let(:template) { chef_run.template('/usr/lib/systemd/system/kibana.service') } | ||
# any platform specific data you want available to your test can be loaded here | ||
_property = load_platform_properties(platform: platform, platform_version: version) | ||
|
||
it 'creates an init.d template at /usr/lib/systemd/system/kibana.service' do | ||
expect(chef_run).to create_template('/usr/lib/systemd/system/kibana.service') | ||
end | ||
it 'enables a kibana service' do | ||
expect(chef_run).to enable_service('kibana') | ||
end | ||
it 'sends a restart notification to the service' do | ||
expect(template).to notify('service[kibana]').to(:restart) | ||
end | ||
end | ||
# tempalte kibana service | ||
|
||
# for centos 7.x systemd | ||
describe 'kibana::_service' do | ||
before { stub_resources } | ||
let(:chef_run) { ChefSpec::SoloRunner.new(CENTOS7_OPTS).converge(described_recipe) } | ||
let(:template) { chef_run.template('/usr/lib/systemd/system/kibana.service') } | ||
it 'creates an init.d template at /usr/lib/systemd/system/kibana.service' do | ||
expect(chef_run).to create_template('/usr/lib/systemd/system/kibana.service') | ||
end | ||
it 'enables a kibana service' do | ||
expect(chef_run).to enable_service('kibana') | ||
end | ||
it 'sends a restart notification to the service' do | ||
expect(template).to notify('service[kibana]').to(:restart) | ||
it 'enables a kibana service' do | ||
expect(chef_run).to enable_service('kibana') | ||
end | ||
|
||
# it 'sends a restart notification to the service' do | ||
# expect(template).to notify('service[kibana]').to(:restart) | ||
# end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,41 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'chefspec' | ||
require_relative 'spec_helper' | ||
|
||
describe 'kibana::default' do | ||
before { stub_resources } | ||
supported_platforms.each do |platform, versions| | ||
versions.each do |version| | ||
context "on #{platform.capitalize} #{version}" do | ||
let(:chef_run) do | ||
ChefSpec::ServerRunner.new(platform: platform, version: version) do |node, server| | ||
node_resources(node) | ||
stub_chef_zero(platform, version, server) | ||
end.converge(described_recipe) | ||
end | ||
|
||
let(:chef_run) { ChefSpec::SoloRunner.new(UBUNTU_OPTS).converge(described_recipe) } | ||
# any platform specific data you want available to your test can be loaded here | ||
_property = load_platform_properties(platform: platform, platform_version: version) | ||
|
||
it 'creates kibana group' do | ||
expect(chef_run).to create_group('kibana') | ||
end | ||
it 'creates kibana user' do | ||
expect(chef_run).to create_user('kibana').with( | ||
gid: 'kibana', | ||
home: '/opt/kibana', | ||
shell: '/bin/bash' | ||
) | ||
end | ||
it 'creates kibana base directory' do | ||
expect(chef_run).to create_directory('/opt/kibana').with( | ||
owner: 'kibana', | ||
group: 'kibana' | ||
) | ||
it 'creates kibana group' do | ||
expect(chef_run).to create_group('kibana') | ||
end | ||
|
||
it 'creates kibana user' do | ||
expect(chef_run).to create_user('kibana').with( | ||
gid: 'kibana', | ||
home: '/opt/kibana', | ||
shell: '/bin/bash' | ||
) | ||
end | ||
|
||
it 'creates kibana base directory' do | ||
expect(chef_run).to create_directory('/opt/kibana').with( | ||
owner: 'kibana', | ||
group: 'kibana' | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,71 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'chefspec' | ||
require_relative 'spec_helper' | ||
|
||
describe 'kibana::kibana3' do | ||
before { stub_resources } | ||
supported_platforms.each do |platform, versions| | ||
versions.each do |version| | ||
context "on #{platform.capitalize} #{version}" do | ||
let(:chef_run) do | ||
ChefSpec::ServerRunner.new(platform: platform, version: version) do |node, server| | ||
node_resources(node) | ||
stub_chef_zero(platform, version, server) | ||
end.converge(described_recipe) | ||
end | ||
|
||
let(:chef_run) { ChefSpec::SoloRunner.new(UBUNTU_OPTS).converge(described_recipe) } | ||
_property = load_platform_properties(platform: platform, platform_version: version) | ||
|
||
it 'includes kibana recipe' do | ||
expect(chef_run).to include_recipe('kibana::default') | ||
end | ||
it 'includes kibana recipe' do | ||
expect(chef_run).to include_recipe('kibana::default') | ||
end | ||
|
||
it 'installs kibana3 with ark' do | ||
expect(chef_run).to install_ark('kibana') | ||
end | ||
it 'installs kibana3 with ark' do | ||
expect(chef_run).to install_ark('kibana') | ||
end | ||
|
||
it 'creates a template for kibana' do | ||
expect(chef_run).to create_template('/opt/kibana/current/config.js').with( | ||
owner: 'kibana', | ||
group: 'kibana', | ||
mode: '0644' | ||
) | ||
it 'creates a template for kibana' do | ||
expect(chef_run).to create_template('/opt/kibana/current/config.js').with( | ||
owner: 'kibana', | ||
group: 'kibana', | ||
mode: '0644' | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
# if source install is requested test this path | ||
describe 'kibana::kibana3' do | ||
before { stub_resources } | ||
supported_platforms.each do |platform, versions| | ||
versions.each do |version| | ||
context "on #{platform.capitalize} #{version}" do | ||
let(:chef_run) do | ||
ChefSpec::ServerRunner.new(platform: platform, version: version) do |node, server| | ||
node_resources(node) | ||
stub_chef_zero(platform, version, server) | ||
end.converge(described_recipe) | ||
end | ||
|
||
let(:chef_run) do | ||
ChefSpec::SoloRunner.new(UBUNTU_OPTS) do |node| | ||
node.override['kibana']['install_method'] = 'source' | ||
end.converge(described_recipe) | ||
end | ||
_property = load_platform_properties(platform: platform, platform_version: version) | ||
|
||
it 'installs package git' do | ||
expect(chef_run).to install_package('git') | ||
end | ||
it 'checks out /opt/kibana' do | ||
expect(chef_run).to checkout_git('/opt/kibana/current').with(repository: 'https://github.com/elasticsearch/kibana.git') | ||
end | ||
it 'installs package git' do | ||
expect(chef_run).to install_package('git') | ||
end | ||
it 'checks out /opt/kibana' do | ||
expect(chef_run).to checkout_git('/opt/kibana/current').with(repository: 'https://github.com/elasticsearch/kibana.git') | ||
end | ||
|
||
it 'creates a template for kibana' do | ||
expect(chef_run).to create_template('/opt/kibana/current/src/config.js').with( | ||
owner: 'kibana', | ||
group: 'kibana', | ||
mode: '0644' | ||
) | ||
it 'creates a template for kibana' do | ||
expect(chef_run).to create_template('/opt/kibana/current/src/config.js').with( | ||
owner: 'kibana', | ||
group: 'kibana', | ||
mode: '0644' | ||
) | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.