Skip to content

Commit

Permalink
Merge pull request #1006 from puppetlabs/qeng-3063/flush-output-to-pr…
Browse files Browse the repository at this point in the history
…event-reboot-timeout-problems

[QENG-3063] Fix reboot test timeout issues on jenkins
  • Loading branch information
kevpl committed Nov 4, 2015
2 parents d5a7c08 + 666e794 commit 7a273b7
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,18 @@
remote_filename = File.join(remote_tmpdir, "testfile.txt")
contents = fixture_contents("simple_text_file")

create_remote_file default, remote_filename, contents, { :protocol => "rsync" }

remote_contents = on(default, "cat #{remote_filename}").stdout
assert_equal contents, remote_contents
result = create_remote_file default, remote_filename, contents, { :protocol => "rsync" }

fails_intermittently("https://tickets.puppetlabs.com/browse/BKR-612",
"default" => default,
"remote_tmpdir" => remote_tmpdir,
"remote_filename" => remote_filename,
"contents" => contents,
"result" => result
) do
remote_contents = on(default, "cat #{remote_filename}").stdout
assert_equal contents, remote_contents
end
end
end

Expand Down Expand Up @@ -154,15 +162,26 @@

step "#create_remote_file creates remote files on all remote hosts, when given an array, using rsync" do
remote_tmpdir = tmpdir_on default

# NOTE: we do not do this step in the non-hosts-array version of the test, not sure why
on hosts, "mkdir -p #{remote_tmpdir}"

remote_filename = File.join(remote_tmpdir, "testfile.txt")
contents = fixture_contents("simple_text_file")

create_remote_file hosts, remote_filename, contents, { :protocol => 'rsync' }
result = create_remote_file hosts, remote_filename, contents, { :protocol => 'rsync' }

hosts.each do |host|
remote_contents = on(host, "cat #{remote_filename}").stdout
assert_equal contents, remote_contents
fails_intermittently("https://tickets.puppetlabs.com/browse/BKR-612",
"host" => host,
"remote_tmpdir" => remote_tmpdir,
"remote_filename" => remote_filename,
"contents" => contents,
"result" => result
) do
remote_contents = on(host, "cat #{remote_filename}").stdout
assert_equal contents, remote_contents
end
end
end
end
Expand Down
27 changes: 21 additions & 6 deletions acceptance/tests/base/dsl/helpers/host_helpers/rsync_to_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,21 @@
Dir.mktmpdir do |local_dir|
local_filename, contents = create_local_file_from_fixture("simple_text_file", local_dir, "testfile.txt")
remote_tmpdir = tmpdir_on default
remote_filename = File.join(remote_tmpdir, "testfile.txt")

result = rsync_to default, local_filename, remote_tmpdir

remote_filename = File.join(remote_tmpdir, "testfile.txt")
remote_contents = on(default, "cat #{remote_filename}").stdout

fails_intermittently("https://tickets.puppetlabs.com/browse/QENG-3053",
"result" => result,
"default" => default,
"contents" => contents,
"local_filename" => local_filename,
"local_dir" => local_dir,
"remote_filename" => remote_filename,
"remote_tmdir" => remote_tmpdir,
"result" => result.inspect,
) do
remote_contents = on(default, "cat #{remote_filename}").stdout
assert_equal contents, remote_contents
end
end
Expand All @@ -103,11 +107,22 @@
on hosts, "mkdir -p #{remote_tmpdir}"
remote_filename = File.join(remote_tmpdir, "testfile.txt")

rsync_to hosts, local_filename, remote_tmpdir
result = rsync_to hosts, local_filename, remote_tmpdir

hosts.each do |host|
remote_contents = on(host, "cat #{remote_filename}").stdout
assert_equal contents, remote_contents
fails_intermittently("https://tickets.puppetlabs.com/browse/QENG-3053",
"result" => result,
"host" => host,
"contents" => contents,
"local_filename" => local_filename,
"local_dir" => local_dir,
"remote_filename" => remote_filename,
"remote_tmdir" => remote_tmpdir,
"result" => result.inspect,
) do
remote_contents = on(host, "cat #{remote_filename}").stdout
assert_equal contents, remote_contents
end
end
end
end
Expand Down
15 changes: 5 additions & 10 deletions acceptance/tests/base/host_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,8 @@
end
end

# TODO: re-enable via resolution of QENG-3063
#
# step "#reboot: can reboot the host"
# hosts.each do |host|
# host.reboot
# fails_intermittently("https://tickets.puppetlabs.com/browse/QENG-3063",
# "host" => "#{host}") do
# on host, "echo #{host} rebooted!"
# end
# end
step "#reboot: can reboot the host"
hosts.each do |host|
host.reboot
on host, "echo #{host} rebooted!"
end
1 change: 1 addition & 0 deletions lib/beaker/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ def optionally_color color_code, msg, add_newline = true
to.print color_code if @color
to.send print_statement, msg
to.print NORMAL if @color unless color_code == NONE
to.flush
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/beaker/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module Beaker
describe Logger do
let(:my_io) { MockIO.new }
let(:my_io) { StringIO.new }
let(:logger) { Logger.new(my_io, :quiet => true) }
let(:test_dir) { 'tmp/tests' }
let(:dummy_prefix) { 'dummy' }
Expand Down
13 changes: 0 additions & 13 deletions spec/mocks.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
require 'rspec/mocks'

class MockIO < IO
def initialize
end

methods.each do |meth|
define_method(:meth) {}
end

def === other
super other
end
end

module MockNet
class HTTP

Expand Down

0 comments on commit 7a273b7

Please sign in to comment.