From 4b39101bd2f37184ed9ccd66409758c4fec1b982 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Thu, 17 Sep 2015 17:53:19 +0200 Subject: [PATCH] Add tox environment to test Puppet manifests This change adds syntax checking and lint tests for the Puppet manifests located in deployment_scripts/puppet/manifests. Change-Id: I943913ab56338e6cc64ec4cf07dae46d237d2f6c --- .../puppet/manifests/.gitignore | 2 ++ deployment_scripts/puppet/manifests/Gemfile | 23 +++++++++++++++++++ deployment_scripts/puppet/manifests/Rakefile | 13 +++++++++++ .../lma_monitoring_analytics/.gitignore | 1 + tox.ini | 18 +++++++++++---- 5 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 deployment_scripts/puppet/manifests/.gitignore create mode 100644 deployment_scripts/puppet/manifests/Gemfile create mode 100644 deployment_scripts/puppet/manifests/Rakefile diff --git a/deployment_scripts/puppet/manifests/.gitignore b/deployment_scripts/puppet/manifests/.gitignore new file mode 100644 index 00000000..25e75852 --- /dev/null +++ b/deployment_scripts/puppet/manifests/.gitignore @@ -0,0 +1,2 @@ +Gemfile.lock +.bundle diff --git a/deployment_scripts/puppet/manifests/Gemfile b/deployment_scripts/puppet/manifests/Gemfile new file mode 100644 index 00000000..05624064 --- /dev/null +++ b/deployment_scripts/puppet/manifests/Gemfile @@ -0,0 +1,23 @@ +# 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 'puppetlabs_spec_helper' + # Need to use master branch of puppet-lint because of + # https://github.com/rodjek/puppet-lint/issues/355 + gem 'puppet-lint', :git => 'https://github.com/rodjek/puppet-lint.git' +end diff --git a/deployment_scripts/puppet/manifests/Rakefile b/deployment_scripts/puppet/manifests/Rakefile new file mode 100644 index 00000000..c1242200 --- /dev/null +++ b/deployment_scripts/puppet/manifests/Rakefile @@ -0,0 +1,13 @@ +require 'puppet-lint/tasks/puppet-lint' +require 'puppet-syntax/tasks/puppet-syntax' + +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') + +desc "Run lint, and syntax tests." +task :test => [ + :lint, + :syntax, +] diff --git a/deployment_scripts/puppet/modules/lma_monitoring_analytics/.gitignore b/deployment_scripts/puppet/modules/lma_monitoring_analytics/.gitignore index b844b143..25e75852 100644 --- a/deployment_scripts/puppet/modules/lma_monitoring_analytics/.gitignore +++ b/deployment_scripts/puppet/modules/lma_monitoring_analytics/.gitignore @@ -1 +1,2 @@ Gemfile.lock +.bundle diff --git a/tox.ini b/tox.ini index 5515982b..eb9e728f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,21 @@ [tox] -envlist = lma_monitoring_analytics,docs,build_plugin +envlist = manifests,lma_monitoring_analytics,docs,build_plugin skipsdist = True [testenv] deps = -r{toxinidir}/test-requirements.txt +passenv = HOME + +[testenv:manifests] +deps = +changedir = {toxinidir}/deployment_scripts/puppet/manifests +whitelist_externals = + bundle + mkdir +commands = + mkdir -p {toxinidir}/.bundled_gems + bundle install --path {toxinidir}/.bundled_gems + bundle exec rake test [testenv:lma_monitoring_analytics] deps = @@ -11,11 +23,9 @@ changedir = {toxinidir}/deployment_scripts/puppet/modules/{envname} whitelist_externals = bundle mkdir -setenv = - GEM_HOME={toxinidir}/.bundled_gems commands = mkdir -p {toxinidir}/.bundled_gems - bundle install + bundle install --path {toxinidir}/.bundled_gems bundle exec rake test [testenv:docs]