From aeb3ea63ec561440c02f9d4c4d4c0ac3a1d096c9 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Wed, 18 Sep 2013 15:59:44 -0400 Subject: Overhaul the spec tests to work in rspec2. This work gets rid of the provider_example_group and reworks everything to work properly against rspec2. I don't know if I'd consider the style "better" but it works. --- Rakefile | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 3e005ff..cd3d379 100644 --- a/Rakefile +++ b/Rakefile @@ -1,13 +1 @@ -require 'spec/rake/spectask' -Spec::Rake::SpecTask.new(:spec) do |spec| - spec.libs << 'lib' << 'spec' - spec.spec_files = FileList['spec/**/*_spec.rb'] -end - -Spec::Rake::SpecTask.new(:rcov) do |spec| - spec.libs << 'lib' << 'spec' - spec.pattern = 'spec/**/*_spec.rb' - spec.rcov = true -end - -task :default => :spec +require 'puppetlabs_spec_helper/rake_tasks' -- cgit v1.2.3 From 79c4a4e6e9638aa4b5f3e7366ada7c3ddbafb8a3 Mon Sep 17 00:00:00 2001 From: Travis Fields Date: Fri, 16 May 2014 12:37:39 -0700 Subject: Add rake tasks to test both beaker and beaker-rspec in one go --- Rakefile | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) mode change 100644 => 100755 Rakefile (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 index cd3d379..3ccf664 --- a/Rakefile +++ b/Rakefile @@ -1 +1,58 @@ require 'puppetlabs_spec_helper/rake_tasks' +require 'rake' + +task 'beaker:test',[:host,:type] => :set_beaker_variables do |t,args| + + Rake::Task['beaker-rspec:test'].invoke(args) + + if File.exists?('./acceptance') + Dir.chdir('./acceptance') + exec(build_beaker_command args) + Dir.chdir('../') + else + puts "No acceptance directory found, not running beaker tests" + end + +end + +desc "Run beaker rspec tasks against pe" +RSpec::Core::RakeTask.new('beaker-rspec:test',[:host,:type]=>:set_beaker_variables) do |t,args| + t.pattern = 'spec/acceptance' + t.rspec_opts = '--color' + t.verbose = true +end + +desc "Run beaker and beaker-rspec tasks" +task 'beaker:test:pe',:host do |t,args| + args.with_defaults(:type=> 'pe') + Rake::Task['beaker:test'].invoke(args[:host],args[:type]) +end + +task 'beaker:test:git',:host do |t,args| + args.with_defaults({:type=> 'git'}) + Rake::Task['beaker:test'].invoke(args[:host],args[:type]) +end + +task :set_beaker_variables do |t,args| + puts 'Setting environment variables for testing' + if args[:host] + ENV['BEAKER_set'] = args[:host] + puts "Host to test #{ENV['BEAKER_set']}" + end + ENV['BEAKER_IS_PE'] = args[:type] == 'pe'? "true": "false" +end + +def build_beaker_command(args) + cmd = ["beaker"] + cmd << "--type #{args[:type]}" unless !args[:type] + if File.exists?("./.beaker-#{args[:type]}.cfg") + cmd << "--options-file ./.beaker-#{args[:type]}.cfg" + end + if File.exists?("config/#{args[:host]}.cfg") + cmd << "--hosts config/#{args[:host]}.cfg" + end + if File.exists?("./tests") + cmd << "--tests ./tests" + end + cmd.join(" ") +end -- cgit v1.2.3 From c2108b67f6349068ae897265b28a7242d230be1b Mon Sep 17 00:00:00 2001 From: John Duarte Date: Wed, 21 May 2014 18:25:54 -0700 Subject: Adjust Rake tasks for beaker testing Adjust Rake tasks for testing beaker-rspec suite, beaker suite, and both in combination. The beaker hosts config file is set via the BEAKER_setfile environmental variable. The hosts defined within this file supersede the host past in as an argument, but the argument is still required. For an arbitrary hosts config file this provides the following options. 1. Run the beaker-rspec test suite BEAKER_setfile=/path/to/my_hosts.cfg rake beaker:rspec:test[foo,pe] 2. Run the beaker test suite BEAKER_setfile=/path/to/my_hosts.cfg rake beaker:test[foo,pe] 3. Run both beaker-rspec and beaker test suites BEAKER_setfile=/path/to/my_hosts.cfg rake beaker:test:all[foo,pe] --- Rakefile | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 3ccf664..36a7998 100755 --- a/Rakefile +++ b/Rakefile @@ -1,18 +1,18 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'rake' -task 'beaker:test',[:host,:type] => :set_beaker_variables do |t,args| +desc "Run beaker-rspec and beaker tests" +task 'beaker:test:all',[:host,:type] => ["rake:beaker:rspec:test", "rake:beaker:test"] do |t,args| +end +desc "Run beaker-rspec tests" +task 'beaker:rspec:test',[:host,:type] => [:set_beaker_variables] do |t,args| Rake::Task['beaker-rspec:test'].invoke(args) +end - if File.exists?('./acceptance') - Dir.chdir('./acceptance') - exec(build_beaker_command args) - Dir.chdir('../') - else - puts "No acceptance directory found, not running beaker tests" - end - +desc "Run beaker tests" +task 'beaker:test',[:host,:type] => [:set_beaker_variables] do |t,args| + sh(build_beaker_command args) end desc "Run beaker rspec tasks against pe" @@ -40,6 +40,9 @@ task :set_beaker_variables do |t,args| puts "Host to test #{ENV['BEAKER_set']}" end ENV['BEAKER_IS_PE'] = args[:type] == 'pe'? "true": "false" + if ENV['BEAKER_setfile'] + @hosts_config = ENV['BEAKER_setfile'] + end end def build_beaker_command(args) @@ -48,11 +51,14 @@ def build_beaker_command(args) if File.exists?("./.beaker-#{args[:type]}.cfg") cmd << "--options-file ./.beaker-#{args[:type]}.cfg" end - if File.exists?("config/#{args[:host]}.cfg") - cmd << "--hosts config/#{args[:host]}.cfg" + if File.exists?(@hosts_config) + cmd << "--hosts #{@hosts_config}" + end + if File.exists?('./spec/acceptance/beaker_helper.rb') + cmd << "--pre-suite ./spec/acceptance/beaker_helper.rb" end - if File.exists?("./tests") - cmd << "--tests ./tests" + if File.exists?("./spec/acceptance/beaker") + cmd << "--tests ./spec/acceptance/beaker" end cmd.join(" ") end -- cgit v1.2.3 From b3b253f2432e5cda15c04b11b89bb3d47e84dc76 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Tue, 27 May 2014 11:04:40 -0700 Subject: Add optional keyfile argument to rake tasks This addition walks over any extra arguments provided to the rake task. If the file is a key file, it is used to set the BEAKER_keyfile ENVIRONMENT variable for beaker-rspec and/or the `--keyfile` command line argument for beaker as needed. Example: BEAKER_setfile=../vcenterhost.cfg rake beaker:rspec:test[foo,pe,'/home/myuser/.ssh/id_rsa-secret'] --- Rakefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 36a7998..b1e0e14 100755 --- a/Rakefile +++ b/Rakefile @@ -43,6 +43,9 @@ task :set_beaker_variables do |t,args| if ENV['BEAKER_setfile'] @hosts_config = ENV['BEAKER_setfile'] end + if File.exists?(check_args_for_keyfile(args.extras)) + ENV['BEAKER_keyfile'] = check_args_for_keyfile(args.extras) + end end def build_beaker_command(args) @@ -60,5 +63,16 @@ def build_beaker_command(args) if File.exists?("./spec/acceptance/beaker") cmd << "--tests ./spec/acceptance/beaker" end + if File.exists?(check_args_for_keyfile(args.extras)) + cmd << "--keyfile #{check_args_for_keyfile(args.extras)}" + end cmd.join(" ") end + +def check_args_for_keyfile(extra_args) + keyfile = '' + extra_args.each do |a| + keyfile = a if (`file -b #{a}`.gsub(/\n/,"").match(/ key/)) + end + return keyfile +end -- cgit v1.2.3 From 22397d9b36938f6537bc83293e5bee0aff403756 Mon Sep 17 00:00:00 2001 From: John Duarte Date: Tue, 27 May 2014 17:18:37 -0700 Subject: Fix logic to validate keyfile --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index b1e0e14..cb80def 100755 --- a/Rakefile +++ b/Rakefile @@ -72,7 +72,7 @@ end def check_args_for_keyfile(extra_args) keyfile = '' extra_args.each do |a| - keyfile = a if (`file -b #{a}`.gsub(/\n/,"").match(/ key/)) + keyfile = a unless (`ssh-keygen -l -f #{a}`.gsub(/\n/,"").match(/is not a .*key file/)) end return keyfile end -- cgit v1.2.3 From 20736ba6566854a274a9f9ac95937a843942aca6 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Wed, 27 Jan 2016 10:33:17 +0000 Subject: (FM-4049) Update to current msync configs [2c99161] --- Rakefile | 85 +++++++--------------------------------------------------------- 1 file changed, 9 insertions(+), 76 deletions(-) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index cb80def..35ce311 100755 --- a/Rakefile +++ b/Rakefile @@ -1,78 +1,11 @@ +require 'puppet_blacksmith/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' require 'puppetlabs_spec_helper/rake_tasks' -require 'rake' -desc "Run beaker-rspec and beaker tests" -task 'beaker:test:all',[:host,:type] => ["rake:beaker:rspec:test", "rake:beaker:test"] do |t,args| -end - -desc "Run beaker-rspec tests" -task 'beaker:rspec:test',[:host,:type] => [:set_beaker_variables] do |t,args| - Rake::Task['beaker-rspec:test'].invoke(args) -end - -desc "Run beaker tests" -task 'beaker:test',[:host,:type] => [:set_beaker_variables] do |t,args| - sh(build_beaker_command args) -end - -desc "Run beaker rspec tasks against pe" -RSpec::Core::RakeTask.new('beaker-rspec:test',[:host,:type]=>:set_beaker_variables) do |t,args| - t.pattern = 'spec/acceptance' - t.rspec_opts = '--color' - t.verbose = true -end - -desc "Run beaker and beaker-rspec tasks" -task 'beaker:test:pe',:host do |t,args| - args.with_defaults(:type=> 'pe') - Rake::Task['beaker:test'].invoke(args[:host],args[:type]) -end - -task 'beaker:test:git',:host do |t,args| - args.with_defaults({:type=> 'git'}) - Rake::Task['beaker:test'].invoke(args[:host],args[:type]) -end - -task :set_beaker_variables do |t,args| - puts 'Setting environment variables for testing' - if args[:host] - ENV['BEAKER_set'] = args[:host] - puts "Host to test #{ENV['BEAKER_set']}" - end - ENV['BEAKER_IS_PE'] = args[:type] == 'pe'? "true": "false" - if ENV['BEAKER_setfile'] - @hosts_config = ENV['BEAKER_setfile'] - end - if File.exists?(check_args_for_keyfile(args.extras)) - ENV['BEAKER_keyfile'] = check_args_for_keyfile(args.extras) - end -end - -def build_beaker_command(args) - cmd = ["beaker"] - cmd << "--type #{args[:type]}" unless !args[:type] - if File.exists?("./.beaker-#{args[:type]}.cfg") - cmd << "--options-file ./.beaker-#{args[:type]}.cfg" - end - if File.exists?(@hosts_config) - cmd << "--hosts #{@hosts_config}" - end - if File.exists?('./spec/acceptance/beaker_helper.rb') - cmd << "--pre-suite ./spec/acceptance/beaker_helper.rb" - end - if File.exists?("./spec/acceptance/beaker") - cmd << "--tests ./spec/acceptance/beaker" - end - if File.exists?(check_args_for_keyfile(args.extras)) - cmd << "--keyfile #{check_args_for_keyfile(args.extras)}" - end - cmd.join(" ") -end - -def check_args_for_keyfile(extra_args) - keyfile = '' - extra_args.each do |a| - keyfile = a unless (`ssh-keygen -l -f #{a}`.gsub(/\n/,"").match(/is not a .*key file/)) - end - return keyfile -end +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.send('relative') +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] -- cgit v1.2.3 From 4e0338bbd79d5e46ccdf330a0520a75728dba503 Mon Sep 17 00:00:00 2001 From: David Schmitt Date: Tue, 16 Feb 2016 16:01:25 +0000 Subject: (FM-4046) Update to current msync configs [006831f] This moves all copyright statements to the NOTICE file in accordance with the ASFs guidelines on applying the Apache-2.0 license. --- Rakefile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Rakefile') diff --git a/Rakefile b/Rakefile index 35ce311..7e9a13d 100755 --- a/Rakefile +++ b/Rakefile @@ -9,3 +9,34 @@ PuppetLint.configuration.send('disable_class_inherits_from_params_class') PuppetLint.configuration.send('disable_documentation') PuppetLint.configuration.send('disable_single_quote_string_with_variables') PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"] + +desc 'Generate pooler nodesets' +task :gen_nodeset do + require 'beaker-hostgenerator' + require 'securerandom' + require 'fileutils' + + agent_target = ENV['TEST_TARGET'] + if ! agent_target + STDERR.puts 'TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat-64default."' + agent_target = 'redhat-64default.' + end + + master_target = ENV['MASTER_TEST_TARGET'] + if ! master_target + STDERR.puts 'MASTER_TEST_TARGET environment variable is not set' + STDERR.puts 'setting to default value of "redhat7-64mdcl"' + master_target = 'redhat7-64mdcl' + end + + targets = "#{master_target}-#{agent_target}" + cli = BeakerHostGenerator::CLI.new([targets]) + nodeset_dir = "tmp/nodesets" + nodeset = "#{nodeset_dir}/#{targets}-#{SecureRandom.uuid}.yaml" + FileUtils.mkdir_p(nodeset_dir) + File.open(nodeset, 'w') do |fh| + fh.print(cli.execute) + end + puts nodeset +end -- cgit v1.2.3