forked from jerakia/jerakia
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
67 lines (53 loc) · 1.96 KB
/
Rakefile
File metadata and controls
67 lines (53 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
ENV['SPEC_OPTS'] = '--format documentation --color'
require 'rake'
@top_dir=Dir.pwd
ENV['RUBYLIB'] = "#{@top_dir}/lib:#{@top_dir}/jerakia-puppet/lib"
ENV['JERAKIA_CONFIG'] = "#{@top_dir}/test/fixtures/etc/jerakia/jerakia.yaml"
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
rescue LoadError
end
def run_puppet (type, modulename, facts={})
args = [ 'puppet', 'apply', '--debug' ]
case type
when :hiera
args << '--hiera_config'
args << "#{@top_dir}/test/int/puppet/hiera.yaml"
when :databinding
args << '--data_binding_terminus'
args << 'jerakia'
end
args << [ '--modulepath', "#{@top_dir}/test/int/puppet/modules",'-e', " class barz() {} class { 'barz': } class { '#{modulename}': before => Class['barz'] }" ]
facts.each { |fact,val| ENV["FACTER_#{fact}"] = val }
sh(*args.flatten)
facts.keys.each { |fact| ENV["FACTER_#{fact}"]=nil }
end
task :test_hiera do
run_puppet(:hiera, "test", { "env" => "dev" })
run_puppet(:hiera, "test::binding", { "env" => "dev" })
end
task :test_hiera_compat do
facts={ "jerakia_policy" => "hiera" }
run_puppet(:hiera, "hiera", facts)
run_puppet(:hiera, "hiera::subclass", facts)
run_puppet(:databinding, "hiera", facts)
run_puppet(:databinding, "hiera::subclass", facts)
end
task :test_hiera_compat_with_autorun do
facts={ "jerakia_policy" => "autorun" }
run_puppet(:hiera, "hiera", facts)
run_puppet(:hiera, "hiera::subclass", facts)
run_puppet(:databinding, "hiera", facts)
run_puppet(:databinding, "hiera::subclass", facts)
end
task :test_data_binding do
run_puppet(:databinding, "test::binding", { "env" => "dev" })
end
task :test_policy_override do
facts={ "jerakia_policy" => "dummy" }
run_puppet(:hiera, "test::dummy", facts)
run_puppet(:databinding, "test::dummy", facts)
end
task :integration_tests => [:test_hiera, :test_hiera_compat, :test_hiera_compat_with_autorun, :test_data_binding, :test_policy_override]
task :default => [:integration_tests, :spec]