Skip to content

Commit

Permalink
(PUP-6675) Add exec test using large output
Browse files Browse the repository at this point in the history
This test passes lots of data over pipes when performing an exec, to
attempt to catch any issues with buffered reads over pipes. On *nix the
standand buffer size is 64KB.
  • Loading branch information
MikaelSmith committed May 8, 2017
1 parent 15ab173 commit 84d758d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions acceptance/tests/resource/exec/should_accept_large_output.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
test_name "tests that puppet correctly captures large and empty output."

@testfilename = master.tmpfile('should_accept_large_output').split('/')[-1]

agents.each do |agent|
testfile =
if /windows/ =~ agent[:platform]
"C:/#{@testfilename}"
else
"/tmp/#{@testfilename}"
end

# Generate >64KB file to exceed pipe buffer.
lorem_ipsum = <<EOF
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
EOF
create_remote_file(agent, testfile, lorem_ipsum*1024)

apply_manifest_on(agent, "exec {'cat #{testfile}': path => ['/bin', '/usr/bin', 'C:/cygwin32/bin', 'C:/cygwin64/bin'], logoutput => true}") do
fail_test "didn't seem to run the command" unless
stdout.include? 'executed successfully'
fail_test "didn't print output correctly" unless
stdout.lines.select {|line| line =~ /\/returns:/}.count == 4097
end

apply_manifest_on(agent, "exec {'echo': path => ['/bin', '/usr/bin', 'C:/cygwin32/bin', 'C:/cygwin64/bin'], logoutput => true}") do
fail_test "didn't seem to run the command" unless
stdout.include? 'executed successfully'
end
end

0 comments on commit 84d758d

Please sign in to comment.