From 53e2344f135b5dde1d13e51432dca90ef4bea8be Mon Sep 17 00:00:00 2001 From: Guillaume Thouvenin Date: Fri, 8 Jan 2016 14:17:33 +0100 Subject: [PATCH] Add initial tests for influxdb module This change implements the necessary bits and pieces for testing the influxdb module. Change-Id: I47ff671b1ca2ca8929071c693758c8706f37661d --- .../puppet/modules/influxdb/.fixtures.yml | 10 +++++++ .../puppet/modules/influxdb/.gitignore | 4 +++ .../puppet/modules/influxdb/Gemfile | 24 +++++++++++++++++ .../puppet/modules/influxdb/Rakefile | 25 ++++++++++++++++++ .../puppet/modules/influxdb/metadata.json | 4 +-- .../influxdb/spec/classes/influxdb_spec.rb | 26 +++++++++++++++++++ .../puppet/modules/influxdb/spec/spec.opts | 6 +++++ .../modules/influxdb/spec/spec_helper.rb | 22 ++++++++++++++++ tox.ini | 13 +++++++++- 9 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 deployment_scripts/puppet/modules/influxdb/.fixtures.yml create mode 100644 deployment_scripts/puppet/modules/influxdb/.gitignore create mode 100644 deployment_scripts/puppet/modules/influxdb/Gemfile create mode 100644 deployment_scripts/puppet/modules/influxdb/Rakefile create mode 100644 deployment_scripts/puppet/modules/influxdb/spec/classes/influxdb_spec.rb create mode 100644 deployment_scripts/puppet/modules/influxdb/spec/spec.opts create mode 100644 deployment_scripts/puppet/modules/influxdb/spec/spec_helper.rb diff --git a/deployment_scripts/puppet/modules/influxdb/.fixtures.yml b/deployment_scripts/puppet/modules/influxdb/.fixtures.yml new file mode 100644 index 00000000..fe69026b --- /dev/null +++ b/deployment_scripts/puppet/modules/influxdb/.fixtures.yml @@ -0,0 +1,10 @@ +fixtures: + repositories: + stdlib: + repo: "git://github.com/puppetlabs/puppetlabs-stdlib" + ref: "4.7.0" + inifile: + repo: "git://github.com/puppetlabs/puppetlabs-inifile" + ref: "1.4.1" + symlinks: + influxdb: "#{source_dir}" diff --git a/deployment_scripts/puppet/modules/influxdb/.gitignore b/deployment_scripts/puppet/modules/influxdb/.gitignore new file mode 100644 index 00000000..b766602a --- /dev/null +++ b/deployment_scripts/puppet/modules/influxdb/.gitignore @@ -0,0 +1,4 @@ +spec/fixtures/modules/* +spec/fixtures/manifests/* +Gemfile.lock +.bundle diff --git a/deployment_scripts/puppet/modules/influxdb/Gemfile b/deployment_scripts/puppet/modules/influxdb/Gemfile new file mode 100644 index 00000000..a1228975 --- /dev/null +++ b/deployment_scripts/puppet/modules/influxdb/Gemfile @@ -0,0 +1,24 @@ +# Copyright 2016 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 diff --git a/deployment_scripts/puppet/modules/influxdb/Rakefile b/deployment_scripts/puppet/modules/influxdb/Rakefile new file mode 100644 index 00000000..b5e3f5b4 --- /dev/null +++ b/deployment_scripts/puppet/modules/influxdb/Rakefile @@ -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, +] diff --git a/deployment_scripts/puppet/modules/influxdb/metadata.json b/deployment_scripts/puppet/modules/influxdb/metadata.json index bd6239de..f2a849e1 100644 --- a/deployment_scripts/puppet/modules/influxdb/metadata.json +++ b/deployment_scripts/puppet/modules/influxdb/metadata.json @@ -3,7 +3,7 @@ "version": "1.0.0", "author": "Guillaume Thouvenin ", "summary": "Install and configure InfluxDB", - "license": "Apache License 2.0", + "license": "Apache-2.0", "source": "git://git.openstack.org/cgit/stackforge/fuel-plugin-influxdb-grafana.git", "project_page": "none", "issues_url": "none", @@ -20,6 +20,6 @@ "description": "Puppet module for installing and configuring InfluxDB", "dependencies": [ {"name": "puppetlabs/stdlib", "version_requirement": "4.x"}, - {"name": "puppetlabs/inifile", "version_requirement": ">= 1.0.0" }, + {"name": "puppetlabs/inifile", "version_requirement": ">= 1.0.0"} ] } diff --git a/deployment_scripts/puppet/modules/influxdb/spec/classes/influxdb_spec.rb b/deployment_scripts/puppet/modules/influxdb/spec/classes/influxdb_spec.rb new file mode 100644 index 00000000..f6f32408 --- /dev/null +++ b/deployment_scripts/puppet/modules/influxdb/spec/classes/influxdb_spec.rb @@ -0,0 +1,26 @@ +# Copyright 2016 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 'influxdb' do + let(:facts) do + {:kernel => 'Linux', :operatingsystem => 'Ubuntu', + :osfamily => 'Debian'} + end + + describe 'with defaults' do + it { is_expected.to compile } + end +end + diff --git a/deployment_scripts/puppet/modules/influxdb/spec/spec.opts b/deployment_scripts/puppet/modules/influxdb/spec/spec.opts new file mode 100644 index 00000000..91cd6427 --- /dev/null +++ b/deployment_scripts/puppet/modules/influxdb/spec/spec.opts @@ -0,0 +1,6 @@ +--format +s +--colour +--loadby +mtime +--backtrace diff --git a/deployment_scripts/puppet/modules/influxdb/spec/spec_helper.rb b/deployment_scripts/puppet/modules/influxdb/spec/spec_helper.rb new file mode 100644 index 00000000..e09fb60b --- /dev/null +++ b/deployment_scripts/puppet/modules/influxdb/spec/spec_helper.rb @@ -0,0 +1,22 @@ +# Copyright 2016 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 diff --git a/tox.ini b/tox.ini index eb9e728f..4c3a07d3 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = manifests,lma_monitoring_analytics,docs,build_plugin +envlist = manifests,influxdb,lma_monitoring_analytics,docs,build_plugin skipsdist = True [testenv] @@ -17,6 +17,17 @@ commands = bundle install --path {toxinidir}/.bundled_gems bundle exec rake test +[testenv:influxdb] +deps = +changedir = {toxinidir}/deployment_scripts/puppet/modules/{envname} +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 = changedir = {toxinidir}/deployment_scripts/puppet/modules/{envname}