Hashar has uploaded a new change for review. https://gerrit.wikimedia.org/r/308889
Change subject: (WIP) Puppet compile an host via rspec (WIP) ...................................................................... (WIP) Puppet compile an host via rspec (WIP) Change-Id: Ib31cbcea02755e54e0e7157b4306a213e6013c47 --- A tests/.rspec A tests/Rakefile A tests/spec/examples.txt A tests/spec/fixtures/hiera.yaml A tests/spec/fixtures/manifests/site.pp A tests/spec/hosts/gallium_spec.rb A tests/spec/spec_helper.rb 7 files changed, 106 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/89/308889/1 diff --git a/tests/.rspec b/tests/.rspec new file mode 100644 index 0000000..f449dae --- /dev/null +++ b/tests/.rspec @@ -0,0 +1,2 @@ +--format doc +--color diff --git a/tests/Rakefile b/tests/Rakefile new file mode 100644 index 0000000..cd3d379 --- /dev/null +++ b/tests/Rakefile @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/rake_tasks' diff --git a/tests/spec/examples.txt b/tests/spec/examples.txt new file mode 100644 index 0000000..9e2074c --- /dev/null +++ b/tests/spec/examples.txt @@ -0,0 +1,3 @@ +example_id | status | run_time | +----------------------------------- | ------ | ------------ | +./spec/hosts/gallium_spec.rb[1:1:1] | failed | 4.48 seconds | diff --git a/tests/spec/fixtures/hiera.yaml b/tests/spec/fixtures/hiera.yaml new file mode 100644 index 0000000..76f4266 --- /dev/null +++ b/tests/spec/fixtures/hiera.yaml @@ -0,0 +1,27 @@ +# *** Auto-generated *** +:backends: + - nuyaml + - role +:role: + :datadir: /home/hashar/projects/operations/puppet/hieradata +:nuyaml: + :datadir: /home/hashar/projects/operations/puppet/hieradata + :expand_path: + - common + - "%{::site}" +:private: + :datadir: /home/hashar/projects/operations/puppet/private/hieradata +:hierarchy: + - "hosts/%{::hostname}" + - "regex/%{::fqdn}" + - "%{::site}" + - "private/hosts/%{::hostname}" # TODO: Remove this once labtest realm dies. DO NOT USE THIS + - "private/%{::site}" + - "common" + - "private/common" + +:role_hierarchy: + - "%{::site}" + - "common" + - "private/%{::site}" + - "private/common" diff --git a/tests/spec/fixtures/manifests/site.pp b/tests/spec/fixtures/manifests/site.pp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/spec/fixtures/manifests/site.pp diff --git a/tests/spec/hosts/gallium_spec.rb b/tests/spec/hosts/gallium_spec.rb new file mode 100644 index 0000000..7980445 --- /dev/null +++ b/tests/spec/hosts/gallium_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +describe "gallium.wikimedia.org" do + + context do + let(:facts) { { + :interfaces => 'eth0', + # eqiad + :ipaddress_eth0 => '10.64.0.1', + # Precise + :lsbdistrelease => '12.04', + :lsbdistid => 'Ubuntu', + :operatingsystem => 'Ubuntu', + } } + before(:each) do + Puppet::Parser::Functions.newfunction(:generate, :type => :rvalue) { |args| + return '' + } + end + + it { is_expected.to compile } + end + +end diff --git a/tests/spec/spec_helper.rb b/tests/spec/spec_helper.rb new file mode 100644 index 0000000..e1f9e31 --- /dev/null +++ b/tests/spec/spec_helper.rb @@ -0,0 +1,49 @@ +require 'rspec-puppet' +require 'puppetlabs_spec_helper/module_spec_helper' + +root_path = File.expand_path(File.join(__FILE__, '..', '..', '..')) +fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) + +def prepare_hiera_config(root_path, fixture_path) + hiera_conf = File.read( + File.join(root_path, + 'modules/puppetmaster/files/production.hiera.yaml')) + hiera_conf.gsub!('/etc/puppet/hieradata', + File.join(root_path, 'hieradata')) + hiera_conf.gsub!('/etc/puppet/private/hieradata', + File.join(root_path, 'private/hieradata')) + hiera_conf.prepend("# *** Auto-generated ***\n") + File.write(File.join(fixture_path, 'hiera.yaml'), hiera_conf) +end + + +RSpec.configure do |c| + c.module_path = [ + File.join(root_path, 'modules'), + File.join(root_path, 'private', 'modules'), + ].join(':') + c.manifest_dir = File.join(root_path, 'manifests') + c.template_dir = File.join(root_path, 'templates') + c.environmentpath = File.join(Dir.pwd, 'spec') + + prepare_hiera_config(root_path, fixture_path) + + c.hiera_config = File.join(fixture_path, 'hiera.yaml') + + # For --next-failure + c.example_status_persistence_file_path = File.join( + File.dirname(__FILE__), 'examples.txt') + + c.before(:each) do + # From Max Lincoln: https://gist.github.com/maxlinc/6382696 + ENV['PUPPET_LOG'] = 'debug' if ENV['PUPPET_DEBUG'] + if ENV['PUPPET_LOG'] + levels = %w(debug info notice warning err alert emerg crit) + if !levels.include?(ENV['PUPPET_LOG']) + raise "Unknown log level for PUPPET_LOG. Must be one of: #{levels}" + end + Puppet::Util::Log.level = :"#{ENV['PUPPET_LOG']}" + Puppet::Util::Log.newdestination(:console) + end + end +end -- To view, visit https://gerrit.wikimedia.org/r/308889 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib31cbcea02755e54e0e7157b4306a213e6013c47 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Hashar <has...@free.fr> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits