Skip to content

Commit

Permalink
fixup! Remove passenger-related methods
Browse files Browse the repository at this point in the history
  • Loading branch information
mhashizume committed Feb 7, 2024
1 parent 8a68fbc commit 54c5858
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 90 deletions.
14 changes: 2 additions & 12 deletions lib/beaker-puppet/helpers/puppet_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,13 @@ def puppet_group(host)
# Test Puppet running in a certain run mode with specific options.
# This ensures the following steps are performed:
# 1. The pre-test Puppet configuration is backed up
# 2. A new Puppet configuraton file is layed down
# 2. A new Puppet configuraton file is lay down
# 3. Puppet is started or restarted in the specified run mode
# 4. Ensure Puppet has started correctly
# 5. Further tests are yielded to
# 6. Revert Puppet to the pre-test state
# 7. Testing artifacts are saved in a folder named for the test
#
# @note Whether Puppet is started or restarted depends on what kind of
# server you're running. Passenger and puppetserver are restarted before.
# Webrick is started before and stopped after yielding, unless you're using
# service scripts, then it'll behave like passenger & puppetserver.
# Passenger and puppetserver (or webrick using service scripts)
# restart after yielding by default. You can stop this from happening
# by setting the :restart_when_done flag of the conf_opts argument.
#
# @param [Host] host One object that act like Host
#
# @param [Hash{Symbol=>String}] conf_opts Represents puppet settings.
Expand All @@ -117,8 +109,6 @@ def puppet_group(host)
# Will stop puppet if false. Default behavior
# is to restart, but you can override this on the
# host or with this option.
# (Note: only works for passenger & puppetserver
# masters (or webrick using the service scripts))
# @param [File] testdir The temporary directory which will hold backup
# configuration, and other test artifacts.
#
Expand Down Expand Up @@ -192,7 +182,7 @@ def with_puppet_running_on(host, conf_opts, testdir = host.tmpdir(File.basename(
puppet_config(host, 'confdir', section: 'master'),
testdir,
'puppet.conf')
lay_down_new_puppet_conf host, conf_opts, testdir
lay_down_new_puppet_conf(host, conf_opts, testdir)
bounce_service(host, host['puppetservice'], curl_retries)

yield self if block_given?
Expand Down
78 changes: 0 additions & 78 deletions spec/beaker-puppet/helpers/puppet_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -953,60 +953,6 @@ def stub_post_setup
end
end

context 'running from source' do
it 'does not try to stop if not started' do
expect(subject).to receive(:start_puppet_from_source_on!).and_return false
expect(subject).to_not receive(:stop_puppet_from_source_on)

subject.with_puppet_running_on(host, {})
end

context 'successfully' do
before do
expect(host).to receive(:port_open?).with(8140).and_return(true)
end

it 'starts puppet from source' do
subject.with_puppet_running_on(host, {})
end

it 'stops puppet from source' do
subject.with_puppet_running_on(host, {})
expect(host).to execute_commands_matching(/^kill [^-]/).once
expect(host).to execute_commands_matching(/^kill -0/).once
end

it 'yields between starting and stopping' do
execution = 0
expect do
subject.with_puppet_running_on(host, {}) do
expect(host).to execute_commands_matching(/^puppet master/).once
execution += 1
end
end.to change { execution }.by(1)
expect(host).to execute_commands_matching(/^kill [^-]/).once
expect(host).to execute_commands_matching(/^kill -0/).once
end

it 'passes on commandline args' do
subject.with_puppet_running_on(host, { __commandline_args__: '--with arg' })
expect(host).to execute_commands_matching(/^puppet master --with arg/).once
end

it 'is not affected by the :restart_when_done flag' do
execution = 0
expect do
subject.with_puppet_running_on(host, { restart_when_done: true }) do
expect(host).to execute_commands_matching(/^puppet master/).once
execution += 1
end
end.to change { execution }.by(1)
expect(host).to execute_commands_matching(/^kill [^-]/).once
expect(host).to execute_commands_matching(/^kill -0/).once
end
end
end

describe 'backup and restore of puppet.conf' do
before :each do
allow(subject).to receive(:puppet_config).with(host, 'confdir', anything).and_return('/root/mock')
Expand Down Expand Up @@ -1039,30 +985,6 @@ def stub_post_setup
/ensure=running/)
end
end

context 'when a puppetservice is not used' do
before do
expect(host).to receive(:port_open?).with(8140).and_return(true)
end

it 'backs up puppet.conf' do
subject.with_puppet_running_on(host, {})
expect(host).to execute_commands_matching(/cp #{original_location} #{backup_location}/).once
expect(host).to execute_commands_matching(/cat #{new_location} > #{original_location}/).once
end

it 'restores puppet.conf after restarting when a puppetservice is not used' do
subject.with_puppet_running_on(host, {})
expect(host).to execute_commands_matching_in_order(/kill [^-]/,
/cat '#{backup_location}' > '#{original_location}'/m)
end

it "doesn't restore a non-existent file" do
allow(subject).to receive(:backup_the_file)
subject.with_puppet_running_on(host, {})
expect(host).to execute_commands_matching(/rm -f '#{original_location}'/)
end
end
end

let(:logger) { double.as_null_object }
Expand Down

0 comments on commit 54c5858

Please sign in to comment.