From 1c4fe921e677c52dd01c9ce9aa12933fe0688b88 Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Thu, 22 Sep 2016 11:11:13 -0400 Subject: Switch puppet-tripleo to use puppet-openstack_spec_helper Align puppet-tripleo with other Puppet OpenStack modules to use puppet-openstack_spec_helper. Here are the benefits: - Allow to use Depends-On between Puppet OpenStack modules and puppet-tripleo, and unit tests will work correctly with dependencies. - Use the Puppet OpenStack gemspec file that handle gems dependencies to test the module. - Allow to re-use ruby helper that Puppet OpenStack modules have in unit tests, to avoid duplicated code. - Don't manage .fixtures.yml file, it will be generated by Puppet OpenStack tooling. TripleO dependencies will live in Puppetfile_extras. Change-Id: Ic66e9f872c57545327a9fb4b8ae86fbf0abbd8be --- .fixtures.yml | 32 -------------------------------- .gitignore | 1 + Gemfile | 27 ++++----------------------- Puppetfile_extras | 31 +++++++++++++++++++++++++++++++ Rakefile | 22 +--------------------- spec/spec_helper.rb | 5 +++++ 6 files changed, 42 insertions(+), 76 deletions(-) delete mode 100644 .fixtures.yml create mode 100644 Puppetfile_extras diff --git a/.fixtures.yml b/.fixtures.yml deleted file mode 100644 index fae4a8c..0000000 --- a/.fixtures.yml +++ /dev/null @@ -1,32 +0,0 @@ -fixtures: - repositories: - 'firewall': 'git://github.com/puppetlabs/puppetlabs-firewall.git' - 'stdlib': 'git://github.com/puppetlabs/puppetlabs-stdlib.git' - 'haproxy': 'git://github.com/puppetlabs/puppetlabs-haproxy.git' - 'concat': 'git://github.com/puppetlabs/puppetlabs-concat.git' - 'openstacklib': 'git://github.com/openstack/puppet-openstacklib.git' - 'swift': 'git://github.com/openstack/puppet-swift.git' - 'memcached': 'git://github.com/saz/puppet-memcached.git' - 'midonet': - repo: 'git://github.com/midonet/puppet-midonet.git' - ref: 'v2015.06.7' - 'tomcat': - repo: 'git://github.com/puppetlabs/puppetlabs-tomcat.git' - ref: '1.3.2' - 'inifile': - repo: 'git://github.com/puppetlabs/puppetlabs-inifile.git' - ref: '1.4.2' - 'cassandra': - repo: 'git://github.com/locp/cassandra.git' - ref: '1.9.2' - 'zookeeper': - repo: 'git://github.com/deric/puppet-zookeeper.git' - ref: 'v0.3.9' - 'datacat': - repo: 'git://github.com/richardc/puppet-datacat' - ref: '0.6.2' - 'java': - repo: 'git://github.com/puppetlabs/puppetlabs-java' - ref: '1.4.2' - symlinks: - "tripleo": "#{source_dir}" diff --git a/.gitignore b/.gitignore index 4dd84f0..15c55ef 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ coverage/ .idea/ *.swp *.iml +openstack/ diff --git a/Gemfile b/Gemfile index 6181b3b..1fab608 100644 --- a/Gemfile +++ b/Gemfile @@ -1,28 +1,9 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org" -group :development, :test do - gem 'puppetlabs_spec_helper', :require => 'false' - gem 'rspec-puppet', '~> 2.2.0', :require => 'false' - gem 'rspec-puppet-facts', :require => 'false' - gem 'metadata-json-lint', :require => 'false' - gem 'puppet-lint-param-docs', :require => 'false' - gem 'puppet-lint-absolute_classname-check', :require => 'false' - gem 'puppet-lint-absolute_template_path', :require => 'false' - gem 'puppet-lint-trailing_newline-check', :require => 'false' - gem 'puppet-lint-unquoted_string-check', :require => 'false' - gem 'puppet-lint-leading_zero-check', :require => 'false' - gem 'puppet-lint-variable_contains_upcase', :require => 'false' - gem 'puppet-lint-numericvariable', :require => 'false' - gem 'json', :require => 'false' - # adding 'psych' explicitly - # https://github.com/bundler/bundler/issues/2068 - # TODO: drop it in a future release of 'bundle'. - gem 'psych', :require => 'false' -end - -group :system_tests do - gem 'beaker-rspec', :require => 'false' - gem 'beaker-puppet_install_helper', :require => 'false' +group :development, :test, :system_tests do + gem 'puppet-openstack_spec_helper', + :git => 'https://git.openstack.org/openstack/puppet-openstack_spec_helper', + :require => false end if facterversion = ENV['FACTER_GEM_VERSION'] diff --git a/Puppetfile_extras b/Puppetfile_extras new file mode 100644 index 0000000..b9f664f --- /dev/null +++ b/Puppetfile_extras @@ -0,0 +1,31 @@ + +## TripleO Puppet modules + +mod 'haproxy', + :git => 'https://github.com/puppetlabs/puppetlabs-haproxy', + :ref => 'master' + +mod 'midonet', + :git => 'https://github.com/midonet/puppet-midonet', + :ref => 'v2015.06.7' + +mod 'tomcat', + :git => 'https://github.com/puppetlabs/puppetlabs-tomcat', + :ref => '1.3.2' + +mod 'java', + :git => 'https://github.com/puppetlabs/puppetlabs-java', + :ref => '1.4.2' + +mod 'cassandra', + :git => 'https://github.com/locp/cassandra', + :ref => '1.9.2' + +mod 'zookeeper', + :git => 'https://github.com/deric/puppet-zookeeper', + :ref => 'v0.3.9' + +mod 'datacat', + :git => 'https://github.com/richardc/puppet-datacat', + :ref => '0.6.2' + diff --git a/Rakefile b/Rakefile index 7dcaeb9..168d108 100644 --- a/Rakefile +++ b/Rakefile @@ -1,21 +1 @@ -require 'puppetlabs_spec_helper/rake_tasks' -require 'puppet-lint/tasks/puppet-lint' -require 'puppet-syntax/tasks/puppet-syntax' - -PuppetSyntax.exclude_paths ||= [] -PuppetSyntax.exclude_paths << "spec/fixtures/**/*" -PuppetSyntax.exclude_paths << "pkg/**/*" -PuppetSyntax.exclude_paths << "vendor/**/*" - -Rake::Task[:lint].clear -PuppetLint::RakeTask.new :lint do |config| - config.ignore_paths = ["spec/**/*.pp", "vendor/**/*.pp"] - config.fail_on_warnings = true - config.log_format = '%{path}:%{linenumber}:%{KIND}: %{message}' - config.disable_checks = ["80chars", "class_inherits_from_params_class", "only_variable_string"] -end - -desc "Run acceptance tests" -RSpec::Core::RakeTask.new(:acceptance) do |t| - t.pattern = 'spec/acceptance' -end +require 'puppet-openstack_spec_helper/rake_tasks' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index be9532a..b06b436 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,9 @@ +# Load libraries from openstacklib here to simulate how they live together in a real puppet run (for provider unit tests) +$LOAD_PATH.push(File.join(File.dirname(__FILE__), 'fixtures', 'modules', 'openstacklib', 'lib')) require 'puppetlabs_spec_helper/module_spec_helper' require 'shared_examples' + +require 'puppet-openstack_spec_helper/defaults' require 'rspec-puppet-facts' include RspecPuppetFacts @@ -8,6 +12,7 @@ fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) RSpec.configure do |c| c.alias_it_should_behave_like_to :it_configures, 'configures' c.alias_it_should_behave_like_to :it_raises, 'raises' + c.hiera_config = File.join(fixture_path, 'hiera.yaml') c.module_path = File.join(fixture_path, 'modules') c.manifest_dir = File.join(fixture_path, 'manifests') -- cgit 1.2.3-korg