Rework setup features

Change-Id: Icf090ef1272fb2779f798dad2d8f1c6e0ad3b521
This commit is contained in:
Dmitry Ilyin 2016-02-16 18:23:37 +03:00
parent 01b841d1be
commit ed2b626788
7 changed files with 57 additions and 34 deletions

View File

@ -18,7 +18,7 @@ end
if ENV['PUPPET_GEM_VERSION']
gem 'puppet', ENV['PUPPET_GEM_VERSION']
else
gem 'puppet', '3.4.3'
gem 'puppet', '~> 3.8.0'
end
# vim:ft=ruby

View File

@ -4,6 +4,26 @@ Typical use cases
Let's discuss the most common use cases of the Noop test framework and how it
can be used.
Initial setup
-------------
In most cases you should setup the environment before using the Noop tests
framework. The setup consists of three parts:
- Fixtures repository clone
- Ruby gems installation
- Puppet modules download
There is a wrapper script **tests/noop/setup_and_diagnostics.sh** that will try
to do all these things. First, it will clone the fixtures repository unless
it have already been cloned, then it will run **tests/noop/noop_tests.sh**
with options **-b** and **-B** to create and use the bundle gems folder,
**-l** options will enable Puppet modules update and **-t** option will
initiate check procedures for paths and task library content.
If you are using *RVM* or are managing Ruby gems manually you are free to
bypass this stem and clone fixtures repository manually.
Running all tests using multiple processes
------------------------------------------
@ -199,18 +219,6 @@ and properties actually have after all the catalog logic is processed. It's
very helpful when you are debugging a strange task behaviour or writing a spec
file.
Initial setup options
---------------------
The *tests/noop/noop_tests.sh* script will try to do some initial Ruby
environment setup but there are also **-b** and **-B** options to run the
environment setup using *bundle* and to run rspec processes using *bundle exec*
respectively.
You can also work with the external Puppet modules by using the **-l** and
**-L** options to either install the missing modules or to reset them to the
initial state.
Using external environment variables and custom paths
-----------------------------------------------------

View File

@ -68,10 +68,11 @@ can be used to perform some common actions.
used by many other shortcut scripts.
- **utils/jenkins/fuel_noop_tests.sh** The wrapper script used as an entry point
for the automated Jenkins CI jobs. Runs all tests in parallel mode.
- **tests/noop/rub_all.sh** This wrapper will run all tests in parallel mode.
- **tests/noop/rub_global.sh** This wrapper will run all globals tasks and save
- **tests/noop/run_all.sh** This wrapper will run all tests in parallel mode.
- **tests/noop/run_global.sh** This wrapper will run all globals tasks and save
the generated globals yaml files.
- **tests/noop/rub_diagnostics.sh** This wrapper will run the noop tests in the
- **tests/noop/setup_and_diagnostics.sh** This wrapper will first setup the
Ruby environment, download Fuel Library modules and run the noop tests in the
diagnostics mode to check the presence of all folders in the structure and
the numbers of tasks in the library.
- **run_failed_tasks.sh** This wrapper will load the saved reports files from

View File

@ -94,7 +94,7 @@ module Noop
exit 0
end
#########################################
def main
options
@ -114,7 +114,7 @@ module Noop
end
if options[:update_librarian_puppet]
prepare_library
setup_library
end
if options[:self_check]

View File

@ -17,10 +17,10 @@ module Noop
ENV['SPEC_UPDATE_GLOBALS'] = 'YES'
options[:filter_specs] = [Noop::Config.spec_name_globals]
end
opts.on('-b', '--bundle_setup', 'Setup Ruby environment using Bundle') do
opts.on('-B', '--bundle_setup', 'Setup Ruby environment using Bundle') do
@options[:bundle_setup] = true
end
opts.on('-B', '--bundle_exec', 'Use "bundle exec" to run rspec') do
opts.on('-b', '--bundle_exec', 'Use "bundle exec" to run rspec') do
ENV['SPEC_BUNDLE_EXEC'] = 'YES'
end
opts.on('-l', '--update-librarian', 'Run librarian-puppet update in the deployment directory prior to testing') do

View File

@ -1,10 +1,9 @@
module Noop
class Manager
PUPPET_GEM_VERSION = '~> 3.8.0'
def dir_path_gem_home
return Pathname.new ENV['GEM_HOME'] if ENV['GEM_HOME']
dir_name_bundle = Pathname.new '.bundled_gems'
dir_name_bundle = Pathname.new 'bundled_gems'
Noop::Config.dir_path_workspace + dir_name_bundle
end
@ -13,30 +12,45 @@ module Noop
$?.exitstatus == 0
end
def librarian_installed?
`librarian-puppet version`
$?.exitstatus == 0
end
def setup_bundle
Noop::Utils.error 'Bundle is not installed!' unless bundle_installed?
ENV['GEM_HOME'] = dir_path_gem_home.to_s
ENV['PUPPET_GEM_VERSION'] = PUPPET_GEM_VERSION unless ENV['PUPPET_GEM_VERSION']
Dir.chdir Noop::Config.dir_path_root
bundle_install_and_update
Dir.chdir Noop::Config.dir_path_deployment
bundle_install_and_update
Dir.chdir Noop::Config.dir_path_root
end
def setup_library
ENV['GEM_HOME'] = dir_path_gem_home.to_s
Dir.chdir Noop::Config.dir_path_deployment
update_puppet_modules
Dir.chdir Noop::Config.dir_path_root
end
def bundle_install_and_update
Noop::Utils.error 'Bundle is not installed!' unless bundle_installed?
Noop::Utils.debug "Starting 'bundle install' in the Gem home: #{ENV['GEM_HOME']}"
Noop::Utils.run 'bundle install'
Noop::Utils.run 'bundle update'
Noop::Utils.error 'Could not prepare bundle environment!' if $?.exitstatus != 0
Noop::Utils.debug "Starting 'bundle update' in the Gem home: #{ENV['GEM_HOME']}"
Noop::Utils.run 'bundle update'
Noop::Utils.error 'Could not update bundle environment!' if $?.exitstatus != 0
end
# run librarian-puppet to fetch modules as necessary
def prepare_library
# these are needed to ensure we have the correctly bundle
ENV['PUPPET_GEM_VERSION'] = PUPPET_GEM_VERSION unless ENV['PUPPET_GEM_VERSION']
ENV['BUNDLE_DIR'] = dir_path_gem_home.to_s
ENV['GEM_HOME'] = dir_path_gem_home.to_s
def update_puppet_modules
Noop::Utils.error 'Puppet Librarian is not installed!' unless librarian_installed?
command = './update_modules.sh -v'
# pass the bundle parameter to update_modules if specified for this script
command = command + ' -b' if options[:bundle_exec]
# pass the reset parameter to update_modules if specified for this script
command = command + ' -r' if options[:reset_librarian_puppet]
Noop::Utils.debug 'Starting update_modules script'
Dir.chdir Noop::Config.dir_path_deployment
Noop::Utils.run command
Noop::Utils.error 'Unable to update upstream puppet modules using librarian-puppet!' if $?.exitstatus != 0
Noop::Utils.debug 'Finished update_modules script'

View File

@ -1,7 +1,7 @@
module Noop
class Task
def setup_overrides
# puppet_default_settings
puppet_default_settings
hiera_config_override
puppet_debug_override if ENV['SPEC_PUPPET_DEBUG']
setup_manifest