Adjust smoke test to search in examples directory.

The latest puppet recommendation are for examples of working manifest to
be put in the examples directory.  This patch ensure that we first
search this one before moving on the tests directory, for backward
compatibility.

Change-Id: I2699eaa3a10589c9a0c680bb1de489994fe01b67
This commit is contained in:
Sofer Athlan-Guyot 2016-07-05 14:17:35 +02:00
parent aa0b0ff4c5
commit a08d680054
2 changed files with 22 additions and 11 deletions

View File

@ -8,9 +8,9 @@ shared_examples_for 'puppet_apply_success' do |manifest|
end
end
# Test a normal puppet run with idempotency using files in the tests
# directory (smoke testing)
shared_examples_for 'puppet_apply_success_from_tests' do |test_file|
# Test a normal puppet run with idempotency using files in the
# examples/tests directory (smoke testing)
shared_examples_for 'puppet_apply_success_from_example' do |test_file|
it 'should apply the manifest without error' do
apply_manifest(smoke_test_named(test_file), :catch_failures => true)
end

View File

@ -1,19 +1,30 @@
module PuppetOpenstackSpecHelpers
module SmokeTest
def smoke_test_named(file)
smoke_dir = File.join(project_root_directory, 'tests')
smoke_manifest_file = File.join(smoke_dir,
file.sub(/\.pp$/, '') + '.pp')
unless File.exists?(smoke_manifest_file)
raise ArgumentError,
"Cannot find smoke manifest file '#{smoke_manifest_file}'"
end
smoke_manifest_file = example_file(file)
File.read(smoke_manifest_file)
end
def project_root_directory
RSpec::Core::RubyProject.root
end
private
def example_file(file)
smoke_manifest_file = ''
found = true
['examples', 'tests'].each do |ex_dir|
smoke_dir = File.join(project_root_directory, ex_dir)
smoke_manifest_file = File.join(smoke_dir,
file.sub(/\.pp$/, '') + '.pp')
break if File.exists?(smoke_manifest_file)
found = false
end
unless found
raise ArgumentError,
"Cannot find smoke manifest file '#{file}' in 'tests' or 'examples' directory"
end
smoke_manifest_file
end
end
end