Bootstrap testing of Puppet modules

This change adds the necessary tooling for doing proper testing of our
home-grown Puppet modules.

It also fixes a couple of issues in lma_logging_analytics/metadata.json
file that were never found before.

Change-Id: I807cc5db59dbb4e2278919202e7748014e3475af
This commit is contained in:
Simon Pasquier 2015-08-14 10:23:52 +02:00
parent 56b182c5af
commit 33e52564ed
10 changed files with 172 additions and 3 deletions

View File

@ -0,0 +1,24 @@
# Copyright 2015 Mirantis, Inc.
#
# 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.
source 'https://rubygems.org'
group :development, :test do
gem 'rake'
gem "puppet", ENV['PUPPET_VERSION'] || '~> 3.4.0'
gem 'rspec'
gem 'rspec-puppet'
gem 'rspec-puppet-facts'
gem 'puppetlabs_spec_helper'
gem 'metadata-json-lint'
end

View File

@ -0,0 +1,62 @@
GEM
remote: https://rubygems.org/
specs:
diff-lcs (1.2.5)
facter (1.7.6)
hiera (1.3.4)
json_pure
json (1.8.3)
json_pure (1.8.2)
metaclass (0.0.4)
metadata-json-lint (0.0.6)
json
spdx-licenses (~> 1.0)
mocha (1.1.0)
metaclass (~> 0.0.1)
puppet (3.4.3)
facter (~> 1.6)
hiera (~> 1.0)
rgen (~> 0.6.5)
puppet-lint (1.1.0)
puppet-syntax (2.0.0)
rake
puppetlabs_spec_helper (0.10.3)
mocha
puppet-lint
puppet-syntax
rake
rspec-puppet
rake (10.4.2)
rgen (0.6.6)
rspec (3.3.0)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-core (3.3.2)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-puppet (2.2.0)
rspec
rspec-puppet-facts (0.12.0)
facter
json
rspec-support (3.3.0)
spdx-licenses (1.0.0)
json
PLATFORMS
ruby
DEPENDENCIES
metadata-json-lint
puppet (~> 3.4.0)
puppetlabs_spec_helper
rake
rspec
rspec-puppet
rspec-puppet-facts

View File

@ -0,0 +1,25 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
require 'puppet-syntax/tasks/puppet-syntax'
require 'metadata-json-lint/rake_task'
PuppetLint.configuration.fail_on_warnings = true
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.send('disable_class_parameter_defaults')
exclude_paths = [
"pkg/**/*",
"vendor/**/*",
"spec/**/*",
]
PuppetLint.configuration.ignore_paths = exclude_paths
PuppetSyntax.exclude_paths = exclude_paths
desc "Run metadata_lint, lint, syntax, and spec tests."
task :test => [
:metadata_lint,
:lint,
:syntax,
:spec,
]

View File

@ -2,8 +2,8 @@
"name": "lma_logging_analytics",
"version": "1.0.0",
"author": "Guillaume Thouvenin <gthouvenin@mirantis.com>",
"summary": "Provides additional resources for the LMA logging analytics"
"license": "Apache License 2.0",
"summary": "Provides additional resources for the LMA logging analytics",
"license": "Apache-2.0",
"source": "git://git.openstack.org/cgit/stackforge/fuel-plugin-elasticsearch-kibana.git",
"project_page": "none",
"issues_url": "none",
@ -20,7 +20,7 @@
"description": "Puppet module for configuring the Kibana dashboard and Elasticsearch",
"dependencies": [
{"name": "puppetlabs/stdlib", "version_requirement": "4.x"},
{"name": "jfryman/nginx", "version_requirement": ">= 0.2.2"}
{"name": "jfryman/nginx", "version_requirement": ">= 0.2.2"},
{"name": "elasticsearch/elasticsearch", "version_requirement": ">= 0.9.0"}
]
}

View File

@ -0,0 +1 @@
../../../../manifests

View File

@ -0,0 +1 @@
../../../../templates

View File

@ -0,0 +1,27 @@
# Copyright 2015 Mirantis, Inc.
#
# 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.
require 'spec_helper'
require 'json'
describe 'encode_kibana_dashboard' do
it "should return a JSON hash" do
should run.with_params('bob', 'admin', 'some title', '{}').and_return(/"user":"bob"/).and_return(/"group":"admin"/)
end
it "should fail when invalid number of parameters are passed" do
should run.with_params('bob', 'admin', 'some title').and_raise_error(/wrong number of arguments/i)
should run.with_params('bob', 'admin', 'some title', '{}', 'extra').and_raise_error(/wrong number of arguments/i)
end
end

View File

@ -0,0 +1,6 @@
--format
s
--colour
--loadby
mtime
--backtrace

View File

@ -0,0 +1,22 @@
# Copyright 2015 Mirantis, Inc.
#
# 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.
require 'rspec-puppet'
fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
RSpec.configure do |c|
c.module_path = File.join(fixture_path, 'modules')
c.manifest_dir = File.join(fixture_path, 'manifests')
c.environmentpath = File.join(Dir.pwd, 'spec')
end