Skip to content

Commit

Permalink
Merge pull request #158 from dylanratcliffe/create_force_param
Browse files Browse the repository at this point in the history
Added new force param
  • Loading branch information
dylanratcliffe authored Mar 6, 2018
2 parents 3b9f535 + 1dd3e54 commit 379c76a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
15 changes: 15 additions & 0 deletions features/run.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@run
Feature: Run rspec and acceptance test suits
Onceover should allow to run rspec and acceptance test for all profvile and role classes
or for any part of them. Use should set if he wants to see only summary of tests or full
Expand Down Expand Up @@ -26,3 +27,17 @@ Feature: Run rspec and acceptance test suits
Given initialized control repo "control_branch"
When I run onceover command "run spec"
Then the temporary Puppetfile should contain the git branch

Scenario: Run with local modifications
Given initialized control repo "basic"
When I run onceover command "run spec"
And I make local modifications
And I run onceover command "run spec"
Then I should see message pattern "local modifications"

Scenario: Force overwrite local modifications
Given initialized control repo "basic"
When I run onceover command "run spec"
And I make local modifications
And I run onceover command "run spec --force"
Then I should see message pattern "Overwriting local modifications"
2 changes: 1 addition & 1 deletion features/step_definitions/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

Then(/^I should see message pattern "([^"]*)"$/) do |err_msg_regexp|
expect(@cmd.success?).to be true
puts @cmd.output unless @cmd.success?
puts @cmd.output unless @cmd.output =~ Regexp.new(err_msg_regexp)
expect(@cmd.output).to match(err_msg_regexp)
puts @cmd.output.match(err_msg_regexp).to_s
end
4 changes: 4 additions & 0 deletions features/step_definitions/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
git_branch = `git rev-parse --abbrev-ref HEAD`.chomp
step %Q(the temporary Puppetfile should contain /#{git_branch}/)
end

When(/^I make local modifications$/) do
FileUtils.rm_rf("#{@repo.onceover_temp_root_folder}/modules/apache/manifests")
end
1 change: 1 addition & 0 deletions lib/onceover/cli/run.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def self.command
optional :c, :classes, 'A list of classes. Only tests with these classes will be run'
optional :n, :nodes, 'A list of nodes. Only tests with these nodes will be run'
optional :s, :skip_r10k, 'Skip the r10k step'
optional :f, :force, 'Passes --force to r10k, overwriting modules'
optional :sv, :strict_variables, 'Run with strict_variables set to yes'

run do |opts, args, cmd|
Expand Down
7 changes: 6 additions & 1 deletion lib/onceover/testconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class TestConfig
attr_accessor :before_conditions
attr_accessor :after_conditions
attr_accessor :skip_r10k
attr_accessor :force
attr_accessor :strict_variables

def initialize(file, opts = {})
Expand Down Expand Up @@ -68,6 +69,7 @@ def initialize(file, opts = {})
@filter_classes = opts[:classes] ? [opts[:classes].split(',')].flatten.map {|x| Onceover::Class.find(x)} : nil
@filter_nodes = opts[:nodes] ? [opts[:nodes].split(',')].flatten.map {|x| Onceover::Node.find(x)} : nil
@skip_r10k = opts[:skip_r10k] ? true : false
@force = opts[:force] || false

# Loop over all of the items in the test matrix and add those as test
# objects to the list of tests
Expand Down Expand Up @@ -265,7 +267,10 @@ def deploy_local(repo = Onceover::Controlrepo.new, opts = {})
# R10K::Action::Deploy::Environment
prod_dir = "#{repo.tempdir}/#{repo.environmentpath}/production"
Dir.chdir(prod_dir) do
install_cmd = "r10k puppetfile install --verbose --color --puppetfile #{repo.puppetfile}"
install_cmd = []
install_cmd << "r10k puppetfile install --verbose --color --puppetfile #{repo.puppetfile}"
install_cmd << "--force" if @force
install_cmd = install_cmd.join(' ')
logger.debug "Running #{install_cmd} from #{prod_dir}"
system(install_cmd)
raise 'r10k could not install all required modules' unless $?.success?
Expand Down

0 comments on commit 379c76a

Please sign in to comment.