From 522d962c2c201e77d2595a6468333344ce437045 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Tue, 18 Aug 2015 10:51:48 +0200 Subject: [PATCH] Improve Puppet tests Change-Id: I1df0899acdff98386f7f71599afccf480aa2f9ce --- .../modules/lma_collector/.fixtures.yml | 9 +++++++ .../puppet/modules/lma_collector/Gemfile | 3 +++ .../puppet/modules/lma_collector/Gemfile.lock | 8 +++++- .../modules/lma_collector/metadata.json | 2 +- .../spec/classes/lma_collector_spec.rb | 25 +++++++++++++++++++ 5 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 deployment_scripts/puppet/modules/lma_collector/spec/classes/lma_collector_spec.rb diff --git a/deployment_scripts/puppet/modules/lma_collector/.fixtures.yml b/deployment_scripts/puppet/modules/lma_collector/.fixtures.yml index d2d4ae699..8635a2e8d 100644 --- a/deployment_scripts/puppet/modules/lma_collector/.fixtures.yml +++ b/deployment_scripts/puppet/modules/lma_collector/.fixtures.yml @@ -3,6 +3,15 @@ fixtures: stdlib: repo: "git://github.com/puppetlabs/puppetlabs-stdlib" ref: "4.7.0" + concat: + repo: "git://github.com/puppetlabs/puppetlabs-concat" + ref: "1.2.4" + collectd: + repo: "git://github.com/puppet-community/puppet-collectd" + ref: "v3.2.0" + apache: + repo: "git://github.com/puppetlabs/puppetlabs-apache" + ref: "1.4.0" symlinks: lma_collector: "#{source_dir}" heka: "#{source_dir}/../heka" diff --git a/deployment_scripts/puppet/modules/lma_collector/Gemfile b/deployment_scripts/puppet/modules/lma_collector/Gemfile index b85b0a070..af473a65a 100644 --- a/deployment_scripts/puppet/modules/lma_collector/Gemfile +++ b/deployment_scripts/puppet/modules/lma_collector/Gemfile @@ -21,4 +21,7 @@ group :development, :test do gem 'rspec-puppet-facts' gem 'puppetlabs_spec_helper' gem 'metadata-json-lint' + # 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/modules/lma_collector/Gemfile.lock b/deployment_scripts/puppet/modules/lma_collector/Gemfile.lock index 624d7fcb1..7ff3095d3 100644 --- a/deployment_scripts/puppet/modules/lma_collector/Gemfile.lock +++ b/deployment_scripts/puppet/modules/lma_collector/Gemfile.lock @@ -1,3 +1,9 @@ +GIT + remote: https://github.com/rodjek/puppet-lint.git + revision: 2546fed6be894bbcff15c3f48d4b6f6bc15d94d1 + specs: + puppet-lint (0.3.2) + GEM remote: https://rubygems.org/ specs: @@ -17,7 +23,6 @@ GEM 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) @@ -55,6 +60,7 @@ PLATFORMS DEPENDENCIES metadata-json-lint puppet (~> 3.4.0) + puppet-lint! puppetlabs_spec_helper rake rspec diff --git a/deployment_scripts/puppet/modules/lma_collector/metadata.json b/deployment_scripts/puppet/modules/lma_collector/metadata.json index 6478dc48c..c8b984c0f 100644 --- a/deployment_scripts/puppet/modules/lma_collector/metadata.json +++ b/deployment_scripts/puppet/modules/lma_collector/metadata.json @@ -21,7 +21,7 @@ "dependencies": [ {"name": "puppetlabs/apache", "version_requirement": ">= 1.4.0"}, {"name": "puppetlabs/stdlib", "version_requirement": "4.x"}, - {"name": "pdxcat/collectd", "version_requirement": "3.x"}, + {"name": "pdxcat/collectd", "version_requirement": ">= 3.2.0"}, {"name": "mirantis/heka", "version_requirement": "1.x"} ] } diff --git a/deployment_scripts/puppet/modules/lma_collector/spec/classes/lma_collector_spec.rb b/deployment_scripts/puppet/modules/lma_collector/spec/classes/lma_collector_spec.rb new file mode 100644 index 000000000..d53baa9f6 --- /dev/null +++ b/deployment_scripts/puppet/modules/lma_collector/spec/classes/lma_collector_spec.rb @@ -0,0 +1,25 @@ +# 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' + +describe 'lma_collector' do + let(:facts) do + {:kernel => 'Linux', :operatingsystem => 'Ubuntu', + :osfamily => 'Debian'} + end + + describe 'with defaults' do + it { is_expected.to contain_class('Heka') } + end +end