Skip to content

Commit 104f0ea

Browse files
(PUP-11897) Add integration test for excessive cpu time for EOF in exec
This adds testing for 4f35fd2 which fixes excessive core usage when an exec has received an EOF.
1 parent 584443d commit 104f0ea

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

spec/integration/type/exec_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,19 @@
7575
end
7676
end
7777

78+
context 'when an exec sends an EOF' do
79+
let(:command) { ["/bin/bash", "-c", "exec /bin/sleep 1 >/dev/null 2>&1"] }
80+
81+
it 'should not take significant user time' do
82+
exec = described_class.new :command => command, :path => ENV['PATH']
83+
catalog.add_resource exec
84+
timed_apply = Benchmark.measure { catalog.apply }
85+
# In testing I found the user time before the patch in 4f35fd262e to be above
86+
# 0.3, after the patch it was consistently below 0.1 seconds.
87+
expect(timed_apply.utime).to be < 0.3
88+
end
89+
end
90+
7891
context 'when command is a string' do
7992
let(:command) { "ruby -e 'File.open(\"#{path}\", \"w\") { |f| f.print \"foo\" }'" }
8093

0 commit comments

Comments
 (0)