Skip to content
This repository has been archived by the owner on May 20, 2020. It is now read-only.

5.1.0-RC #32

Merged
merged 4 commits into from
Feb 16, 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
23 changes: 19 additions & 4 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ suites:
- oel-6.6
- ami-2014.03

- name: custom
run_list:
- recipe[mongodb3-test::custom]
attributes:
chef_client:
config:
force_logger: true
log_level: info
build-essential:
compile_time: false
provisioner:
client_rb:
environment: dev
includes:
- ubuntu-14.04
- centos-7.2

- name: chef-client-11
driver:
vm_hostname: mongo3
Expand All @@ -69,7 +86,6 @@ suites:
- debian-7.8
- oel-6.6
- ami-2014.03
- ubuntu-14.04

- name: default-30x
run_list:
Expand Down Expand Up @@ -210,14 +226,13 @@ suites:
- debian-7.8
- centos-7.2

- name: ami-default
- name: amazon
driver:
vm_hostname: mongo3
run_list:
- recipe[mongodb3-test::amazon]
- recipe[mongodb3::default]
attributes:
mongodb3:
version: 3.2.0
chef_client:
config:
force_logger: true
Expand Down
15 changes: 15 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
recursive true
end

# Create the systemLog directory.
directory File.dirname(node['mongodb3']['config']['mongod']['systemLog']['path']).to_s do
owner node['mongodb3']['user']
group node['mongodb3']['group']
mode '0755'
action :create
recursive true
end

unless node['mongodb3']['config']['key_file_content'].to_s.empty?
# Create the key file if it is not exist
key_file = node['mongodb3']['config']['mongod']['security']['keyFile']
Expand Down Expand Up @@ -70,6 +79,12 @@

# Start the mongod service
service 'mongod' do
case node['platform']
when 'ubuntu'
if node['platform_version'].to_f >= 14.04
provider Chef::Provider::Service::Upstart
end
end
supports :start => true, :stop => true, :restart => true, :status => true
action :enable
subscribes :restart, "template[#{node['mongodb3']['mongod']['config_file']}]", :delayed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Cookbook Name:: mongodb3-test
# Attribute:: default-30x
# Recipe:: amazon
#
# Copyright 2016, Sunggun Yu
#
Expand All @@ -17,4 +17,6 @@
# limitations under the License.
#

default['mongodb3']['version'] = '3.0.9'
file '/etc/redhat-release' do
content 'Amazon Linux AMI'
end
23 changes: 23 additions & 0 deletions test/cookbooks/mongodb3-test/recipes/custom.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Cookbook Name:: mongodb3-test
# Recipe:: custom
#
# Copyright 2016, Sunggun Yu
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

node.set['mongodb3']['config']['mongod']['storage']['dbPath'] = '/var/lib/mongodb/custom'
node.set['mongodb3']['config']['mongod']['systemLog']['path'] = '/var/log/mongodb/custom/mongod.log'

include_recipe 'mongodb3::default'
2 changes: 2 additions & 0 deletions test/cookbooks/mongodb3-test/recipes/default-30x.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
# limitations under the License.
#

node.set['mongodb3']['version'] = '3.0.9'

include_recipe 'mongodb3::default'
58 changes: 58 additions & 0 deletions test/integration/custom/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
require 'spec_helper'

# RHEL and Debian family has different value for some of mongodb settings.
if os[:family] == 'redhat'
mongo_user = 'mongod'
elsif ['debian', 'ubuntu']
mongo_user = 'mongodb'
end

mongo_data_dir = '/var/lib/mongodb/custom'
mongo_syslog_path = '/var/log/mongodb/custom/mongod.log'

# Test `mongodb-org-server` package is installed.
describe package('mongodb-org-server') do
it { should be_installed }
end

# Test `mongod` service is running.
describe service('mongod') do
it { should be_enabled }
it { should be_running }
end

# Test mongodb port `27017` is listening.
describe port(27017) do
it { should be_listening }
end

# Test mongod process starts with expected mongodb config file
describe command('ps -ef | grep mongod') do
its(:stdout) { should contain('/etc/mongod.conf') }
end

# Test mongodb config file is created with right permission.
describe file('/etc/mongod.conf') do
it { should be_file }
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
end

# Test mongodb data directory is created with right permission.
describe file(mongo_data_dir) do
it { should be_directory }
it { should be_mode 755 }
it { should be_owned_by mongo_user }
it { should be_grouped_into mongo_user }
end

# Test mongodb log file is created with right permission.
describe file(mongo_syslog_path) do
it { should be_file }
it { should be_owned_by mongo_user }
end

# Test mongod process starts with expected mongodb config file
describe command('mongo --eval "db.version()"') do
its(:stdout) { should contain('3.2.1') }
end