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

Commit

Permalink
Merge pull request #112 from mburns/mburns/cyberflow/unit-tests
Browse files Browse the repository at this point in the history
Add multi-platform coverage to our unit tests(cyberflow)
  • Loading branch information
mburns authored Mar 19, 2018
2 parents 9856809 + 3fe3c43 commit ce6b106
Show file tree
Hide file tree
Showing 24 changed files with 375 additions and 198 deletions.
2 changes: 2 additions & 0 deletions .foodcritic
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
~FC007
~FC071
4 changes: 2 additions & 2 deletions .kitchen.docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ platforms:
- name: ubuntu-16.04
driver_config:
run_command: /sbin/init
- name: centos-6.4
- name: centos-7.2
- name: centos-6.9
- name: centos-7.4.1708
driver_config:
image: centos:7
provision_command: yum -y install initscripts
Expand Down
24 changes: 11 additions & 13 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: 12.4.1
product_name: chefdk
product_version: 1.3.43
network:
- ["forwarded_port", {guest: 8080, host: 8080, auto_correct: true}]

Expand All @@ -15,17 +16,14 @@ platforms:
- name: ubuntu-16.04
run_list:
- recipe[apt]
- name: centos-6.4
driver_config:
box: opscode-centos-6.4
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
- name: centos-6.9
attributes:
yum:
epel:
mirrorlist: http://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch
gpgkey: http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
sslverify: false
- name: centos-7.2
- name: centos-7.4.1708

suites:
- name: kibana3_apache
Expand All @@ -38,7 +36,7 @@ suites:
- name: kibana3_nginx
run_list:
- 'recipe[netstat]'
- 'recipe[chef_nginx]'
- 'recipe[nginx]'
- 'recipe[kibana]'
- 'recipe[kibana::nginx]'
attributes: {}
Expand All @@ -64,7 +62,7 @@ suites:
listen:
- '*:8080'
kibana:
version: '4'
version: 4
apache:
port: 8080
interface: '0.0.0.0'
Expand All @@ -73,14 +71,14 @@ suites:
- name: kibana4_nginx
run_list:
- 'recipe[netstat]'
- 'recipe[chef_nginx]'
- 'recipe[nginx]'
- 'recipe[java]'
- 'recipe[elasticsearch]'
- 'recipe[kibana]'
- 'recipe[kibana::nginx]'
attributes:
kibana:
version: '4'
version: 4
interface: '0.0.0.0'
nginx:
listen_http: 8080
Expand All @@ -97,7 +95,7 @@ suites:
- '*:8080'
kibana:
install_method: 'package'
version: '4'
version: 4
apache:
port: 8080
interface: '0.0.0.0'
Expand All @@ -106,15 +104,15 @@ suites:
- name: kibana4_nginx_package
run_list:
- 'recipe[netstat]'
- 'recipe[chef_nginx]'
- 'recipe[nginx]'
- 'recipe[java]'
- 'recipe[elasticsearch]'
- 'recipe[kibana]'
- 'recipe[kibana::nginx]'
attributes:
kibana:
install_method: 'package'
version: '4'
version: 4
interface: '0.0.0.0'
nginx:
listen_http: 8080
Expand Down
32 changes: 30 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,43 @@ AllCops:

BlockComments:
Enabled: false
BlockLength:
Enabled: false

Style/RescueModifier:
Exclude:
- 'Rakefile'
- 'libraries/helpers.rb'

LeadingCommentSpace:
Enabled: false

LineLength:
Enabled: false

# Longer classes are okay.
Metrics/BlockLength:
Max: 41
Metrics/LineLength:
Max: 172
Metrics/MethodLength:
Max: 30
Metrics/ModuleLength:
Max: 150

# We're not against complexity.
Metrics/AbcSize:
Max: 55
Metrics/CyclomaticComplexity:
Max: 20
Metrics/PerceivedComplexity:
Max: 20

# Mixlib::ShellOut is nice to have as an older hash syntax
Style/HashSyntax:
Enabled: false

Style/ClassAndModuleChildren:
Enabled: false

Style/FileName:
Exclude:
- 'Berksfile'
Expand Down
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ env:
- TESTS="integration:docker[kibana4-apache-ubuntu-1604]"
- TESTS="integration:docker[kibana4-nginx-ubuntu-1604]"
- TESTS="integration:docker[kibana4-apache-package-ubuntu-1604]"
- TESTS="integration:docker[kibana3-apache-centos-64]"
- TESTS="integration:docker[kibana3-nginx-centos-64]"
- TESTS="integration:docker[kibana4-apache-centos-64]"
- TESTS="integration:docker[kibana4-nginx-centos-64]"
- TESTS="integration:docker[kibana4-apache-centos-72]"
- TESTS="integration:docker[kibana4-nginx-centos-72]"
- TESTS="integration:docker[kibana3-apache-centos-69]"
- TESTS="integration:docker[kibana3-nginx-centos-69]"
- TESTS="integration:docker[kibana4-apache-centos-69]"
- TESTS="integration:docker[kibana4-nginx-centos-69]"
- TESTS="integration:docker[kibana4-apache-centos-741708]"
- TESTS="integration:docker[kibana4-nginx-centos-741708]"

before_install: curl -L https://www.getchef.com/chef/install.sh | sudo bash -s -- -P chefdk
before_install: curl -L https://www.getchef.com/chef/install.sh | sudo bash -s -- -P chefdk -v 1.3.43
install: chef exec bundle install --jobs=3 --retry=3 --without='vagrant'

# https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142455888
Expand Down
5 changes: 4 additions & 1 deletion Berksfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ source 'https://supermarket.chef.io/'

metadata

cookbook 'compat_resource'
cookbook 'chef-sugar'

group :vagrant do
cookbook 'ark'
cookbook 'apt'
cookbook 'apache2'
cookbook 'build-essential'
cookbook 'elasticsearch', '~ 2.4.0'
cookbook 'elasticsearch', '~> 3.4'
cookbook 'java'
cookbook 'netstat'
cookbook 'ohai'
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.3:
* Further test fixes
* Run unit tests on multiple platforms (@mburns)

## 0.2.2:
* Update to fix travis runs for CentOS7 and Ubuntu 16.04. #102 (@drenalin23)
* Update `ark` #103 (@drenalin23)
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ gem 'stove'

group :test do
gem 'buff-extensions'
gem 'chef-sugar'
gem 'chefspec'
gem 'foodcritic'
gem 'rake'
Expand Down
12 changes: 2 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ RuboCop::RakeTask.new(:rubocop) do |task|
task.fail_on_error = true
end

FoodCritic::Rake::LintTask.new do |t|
t.options = {
fail_tags: ['any'],
tags: [
'~FC007', # Don't reflect recipe dependencies
'~FC071' # Don't require LICENSE file
]
}
end
FoodCritic::Rake::LintTask.new

desc 'Run Test Kitchen integration tests'
namespace :integration do
Expand All @@ -50,7 +42,7 @@ desc 'Run chefspec unit tests'
RSpec::Core::RakeTask.new(:unit) do |t|
t.rspec_opts = [].tap do |a|
a.push('--color')
a.push('--format progress')
a.push('--format documentation')
end.join(' ')
t.pattern = 'test/unit/spec/*_spec.rb'
end
Expand Down
4 changes: 2 additions & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#<> Kibana repository Public Signing Key
default['kibana']['repository_key'] = 'https://packages.elastic.co/GPG-KEY-elasticsearch'
#<> The URL to Kibana repository.
default['kibana']['git']['url'] = 'https://github.com/elasticsearch/kibana.git'
default['kibana']['git']['url'] = 'https://github.com/elastic/kibana.git'

#<> The git reference in the Kibana repository.
default['kibana']['git']['reference'] = "v#{node['kibana']['kibana5_version']}"
Expand Down Expand Up @@ -141,7 +141,7 @@
# kibana service configurations - defaults to settings for Ubuntu 14.04
case node['platform']
when 'centos', 'amazon'
if node['platform_version'] < '6.9'
if node['platform_version'] < '7.0'
default['kibana']['service']['provider'] = Chef::Provider::Service::Init::Redhat
default['kibana']['service']['source'] = 'initd.kibana.erb'
default['kibana']['service']['template_file'] = '/etc/init.d/kibana'
Expand Down
1 change: 1 addition & 0 deletions chefignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ test/*
features/*
Guardfile
Procfile
test

# SCM #
#######
Expand Down
5 changes: 4 additions & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
source_url 'https://github.com/realityforge/chef-kibana'
issues_url 'https://github.com/realityforge/chef-kibana/issues'

chef_version '>= 12' if respond_to?(:chef_version)
chef_version '>= 12.7.2' if respond_to?(:chef_version)

supports 'ubuntu'
supports 'debian'
Expand All @@ -20,6 +20,9 @@
depends 'ark'
depends 'apt'

# For compatibility with 12.X versions of Chef
depends 'compat_resource'

# Suggests is not officially valid, that is why these are commented out
# suggests 'apache2', '>= 2.0'
# suggests 'authbind'
Expand Down
2 changes: 2 additions & 0 deletions recipes/nginx.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

apt_update 'update apt' if node['platform_family'] == 'debian'

include_recipe 'nginx'

template File.join(node['nginx']['dir'], 'sites-available', 'kibana') do
Expand Down
12 changes: 12 additions & 0 deletions test/fixtures/environments/chefspec.json
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": {
}
}
27 changes: 27 additions & 0 deletions test/fixtures/nodes/node01.json
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]"
]
}
Loading

0 comments on commit ce6b106

Please sign in to comment.