Hashar has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/399834 )
Change subject: rspec-puppet for all the roles
......................................................................
rspec-puppet for all the roles
Bump rspec-puppet 2.5.0...2.6.9 to catch up with a lot of fixed issues
and implemented features.
Update rspec but stick to 3.5.x for now (ran bundle update rspec-puppet)
Under /puppet add the boilerplate to support rspec-puppet. The usage is
pretty straightforward:
bundle install
cd puppet
bundle exec rake spec
That will look up for all manifests in /puppet/modules/role/manifests/
and attempt to compile the catalog for each of them. That is similar to
what we do on operations/puppet.
Under the hood, it uses rspec, and one can pass it options via the
SPEC_OPTS environment variable:
cd puppet
SPEC_OPTS='--help' bundle exec rake spec
Set spec statuses persistence so one can easily rerun solely the failed
tests via:
cd puppet
SPEC_OPTS='--only-failures'
Pending:
* puppet version is wrong
* should set facts using rspec-puppet-facts
Change-Id: I5e286b88d1dbecb10860afbf2ac99704b33c5e58
X-Notable-Event: Merry-Christmas
---
M Gemfile.lock
M mediawiki-vagrant.gemspec
A puppet/.rspec
A puppet/LICENSE
A puppet/README
A puppet/Rakefile
A puppet/spec/.gitignore
A puppet/spec/integration/roles_spec.rb
A puppet/spec/spec_helper.rb
9 files changed, 100 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant
refs/changes/34/399834/1
diff --git a/Gemfile.lock b/Gemfile.lock
index f9b66af..d0c14ec 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -45,7 +45,7 @@
multi_test (>= 0.1.2)
cucumber-core (1.2.0)
gherkin (~> 2.12.0)
- diff-lcs (1.2.5)
+ diff-lcs (1.3)
domain_name (0.5.20160615)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
@@ -134,7 +134,7 @@
rspec-core (~> 3.5.0)
rspec-expectations (~> 3.5.0)
rspec-mocks (~> 3.5.0)
- rspec-core (3.5.0)
+ rspec-core (3.5.4)
rspec-support (~> 3.5.0)
rspec-expectations (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
@@ -142,7 +142,7 @@
rspec-mocks (3.5.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.5.0)
- rspec-puppet (2.5.0)
+ rspec-puppet (2.6.9)
rspec
rspec-support (3.5.0)
rubocop (0.51.0)
@@ -192,7 +192,7 @@
puppet-strings (~> 1.0.0)
puppetlabs_spec_helper (< 2.0.0)
rake (~> 10.4.2)
- rspec (~> 3.1, >= 3.1.0)
+ rspec (~> 3.5.0)
rubocop (~> 0.51.0)
safe_yaml (~> 1.0.4)
vagrant!
diff --git a/mediawiki-vagrant.gemspec b/mediawiki-vagrant.gemspec
index c406848..cf02b6f 100644
--- a/mediawiki-vagrant.gemspec
+++ b/mediawiki-vagrant.gemspec
@@ -23,6 +23,6 @@
s.require_paths = ['lib']
s.add_development_dependency 'cucumber', '~> 2.0.0.rc4'
- s.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.0'
+ s.add_development_dependency 'rspec', '~> 3.5.0'
s.add_development_dependency 'yard', '~> 0.8', '>= 0.8.7.6'
end
diff --git a/puppet/.rspec b/puppet/.rspec
new file mode 100644
index 0000000..f449dae
--- /dev/null
+++ b/puppet/.rspec
@@ -0,0 +1,2 @@
+--format doc
+--color
diff --git a/puppet/LICENSE b/puppet/LICENSE
new file mode 100644
index 0000000..6f155bb
--- /dev/null
+++ b/puppet/LICENSE
@@ -0,0 +1,21 @@
+Copyright (C) 2016,2017 Antoine Musso <[email protected]>
+Copyright (C) 2016,2016 Wikimedia Foundation Inc.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/puppet/README b/puppet/README
new file mode 100644
index 0000000..5d733c9
--- /dev/null
+++ b/puppet/README
@@ -0,0 +1,25 @@
+Test suite for /puppet
+----------------------
+
+ bundle install
+ bundle exec rake spec
+
+It uses rspec under the hood, you can pass it options via SPEC_OPTS:
+
+ SPEC_OPTS=--help bundle exec rake spec
+
+Some examples:
+
+Filter by example name:
+
+ SPEC_OPTS="-e role::wikitech"
+
+Only run tests that previously failed:
+
+ SPEC_OPTS="--only-failures"
+
+Run next failure:
+
+ SPEC_OPTS="--next-failure"
+
+The spec status are stored in /puppet/rspec_status
diff --git a/puppet/Rakefile b/puppet/Rakefile
new file mode 100644
index 0000000..cd3d379
--- /dev/null
+++ b/puppet/Rakefile
@@ -0,0 +1 @@
+require 'puppetlabs_spec_helper/rake_tasks'
diff --git a/puppet/spec/.gitignore b/puppet/spec/.gitignore
new file mode 100644
index 0000000..cf996da
--- /dev/null
+++ b/puppet/spec/.gitignore
@@ -0,0 +1,2 @@
+/fixtures
+/rspec_status
diff --git a/puppet/spec/integration/roles_spec.rb
b/puppet/spec/integration/roles_spec.rb
new file mode 100644
index 0000000..fcf7816
--- /dev/null
+++ b/puppet/spec/integration/roles_spec.rb
@@ -0,0 +1,13 @@
+require 'spec_helper'
+
+role_manifests = File.join(puppet_path, 'modules/role/manifests')
+puts role_manifests
+
+Dir.glob(File.join(role_manifests, '**/*.pp')).sort.each do |role_file|
+ relative =
Pathname.new(role_file).relative_path_from(Pathname.new(role_manifests))
+ role_name = 'role::' + relative.to_s.gsub(%r{(/|\.pp$)}, { '/' => '::',
'\.pp' => '' })
+
+ describe role_name, :type => :class do
+ it { is_expected.to compile }
+ end
+end
diff --git a/puppet/spec/spec_helper.rb b/puppet/spec/spec_helper.rb
new file mode 100644
index 0000000..71de42a
--- /dev/null
+++ b/puppet/spec/spec_helper.rb
@@ -0,0 +1,31 @@
+require 'rspec-puppet'
+
+def puppet_path
+ File.expand_path(File.join(__FILE__, '../..'))
+end
+
+# Load the modules libraries such as stdlib/wmflib
+Dir.glob(File.join(puppet_path, 'modules/*/lib')).each do |module_lib|
+ $LOAD_PATH.unshift module_lib
+end
+
+def hiera_config_fixture
+ fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures'))
+ conf = File.read(File.join(puppet_path, 'hiera.yaml'))
+ conf.gsub!(%r{/vagrant/puppet}, puppet_path)
+
+ fixture = File.join(fixture_path, 'hiera.yaml')
+ File.write(fixture, conf)
+
+ fixture
+end
+
+RSpec.configure do |c|
+ c.manifest_dir = File.join(puppet_path, 'manifests')
+ c.module_path = File.join(puppet_path, 'modules')
+ c.hiera_config = hiera_config_fixture
+
+ # For --next-failure / --only-failures
+ c.example_status_persistence_file_path = File.join(
+ File.dirname(__FILE__), 'rspec_status')
+end
--
To view, visit https://gerrit.wikimedia.org/r/399834
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5e286b88d1dbecb10860afbf2ac99704b33c5e58
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: Hashar <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits