fuel-library/tests/noop/make_specs.rb
Aleksandr Didenko dc8edb6e66 Modular noop tests
We can run noop tests via 'rake spec'. This will allow us to:

  - Make sure that catalog compiles and there are no dependency
    cycles in the graph.
  - Use RSpec tests to check that needed puppet resources present
    in the catalog for specific astute.yaml configuration.

In order to test just execute these commands:
  export WORKSPACE=/tmp/fuel_noop_tests
  mkdir -p $WORKSPACE
  ./utils/jenkins/fuel_noop_tests.sh

It iterates over astsute.yaml files and runs rspec tests for puppet
tasks configured in the astute.yaml for the node.

In order to run specific test and/or specific astute.yaml, you can
set appropriate env variables. For example:
  export NOOP_TEST="keystone/*"
  export NOOP_YAMLS="tests/noop/astute.yaml/novanet_flat.primary-controller.yaml"
  ./utils/jenkins/fuel_noop_tests.sh

If you also want to store puppet logs in case of errors, please set
PUPPET_LOGS_DIR env variable:
  export PUPPET_LOGS_DIR=/tmp/puppet_error_logs

If you want to store all the delcarated File and Package resources,
please set NOOP_SAVE_RESOURCES_DIR env variable:
  export NOOP_SAVE_RESOURCES_DIR=/tmp/puppet_resources

Related-bug: #1402738
Implement blueprint deployment-dryrun

Fuel CI temporarily disabled since this change does not affect
MOS deplyoment process, only CI itself.

Fuel-CI: disable

Change-Id: I38b23832d1e8701440aacb300256f513c466c762
2015-04-09 11:56:33 +03:00

26 lines
812 B
Ruby

#!/usr/bin/env ruby
require 'find'
require 'fileutils'
DIR=File.dirname __FILE__
Dir.chdir DIR or raise "Cannot cd to #{DIR}"
MODULAR_DIR='../../deployment/puppet/osnailyfacter/modular/'
SPEC_DIR='generate'
BASE_SPEC='spec/hosts/hiera/hiera_spec.rb'
base_spec_content = File.read BASE_SPEC
Find.find(MODULAR_DIR) do |file|
next unless File.file? file
next unless file.end_with? '.pp'
next if file.end_with? '/globals/globals.pp'
short_name = file.gsub MODULAR_DIR, ''
spec_path = File.join SPEC_DIR, short_name.gsub('.pp', '_spec.rb')
spec_content = base_spec_content.gsub 'hiera/hiera.pp', short_name
puts "Write spec: '#{spec_path}'"
spec_dir = File.dirname spec_path
FileUtils.mkdir_p spec_dir unless File.directory? spec_dir
File.open(spec_path, 'w') { |f| f.write spec_content }
end