Last active
August 29, 2015 14:08
-
-
Save jitran/e729f2a89750f691050f to your computer and use it in GitHub Desktop.
Rakefile for running spec tests for puppet modules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run the following tasks inside your puppet directory | |
# run unit tests | |
rake spec:unit | |
# run the default system tests | |
rake spec:system | |
# run the system tests for node1 | |
rake spec:system[node1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake' | |
require 'rspec/core/rake_task' | |
require 'yaml' | |
namespace :spec do | |
desc 'Run unit tests' | |
task :unit do | |
FileList["modules/*/Rakefile"].each do |project| | |
dir = project.pathmap("%d") | |
sh "cd #{dir}; rake spec:unit" | |
end | |
puts "Unit tests complete" | |
end | |
desc 'Run system tests' | |
task :system, [:node] do |t, args| | |
properties = YAML.load_file("tests.yml") | |
node = 'default' | |
if !args[:node].nil? | |
node = args[:node] | |
end | |
modules = properties[node] | |
if !modules.nil? && modules.any? | |
modules.sort.each do |project| | |
if !Dir.glob("modules/#{project}/spec/system/**/*_spec_system.rb").empty? | |
sh "cd modules/#{project}; rake spec:system" | |
end | |
end | |
end | |
puts "System tests complete" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define all the system tests for each node | |
default: | |
- 'network' | |
- 'firewall' | |
node1: | |
- 'network' | |
- 'java' | |
node2: | |
- 'network' | |
- 'python' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment