-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return the summed up memory bytes and cpu for the Puma process and its worker subprocesses.
- Loading branch information
1 parent
b467d90
commit a105b64
Showing
2 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe VCAP::Stats do | ||
describe '#process_memory_bytes_and_cpu' do | ||
before do | ||
allow(VCAP::Stats).to receive_messages(ps_pid: "123456 7.8\n", ps_ppid: "121212 3.4\n343434 5.6\n") | ||
end | ||
|
||
it 'returns the memory bytes and cpu for the process' do | ||
rss_bytes, pcpu = VCAP::Stats.process_memory_bytes_and_cpu | ||
|
||
expect(rss_bytes).to eq(126_418_944) | ||
expect(pcpu).to eq(8) | ||
end | ||
|
||
context 'when Puma is configured as webserver' do | ||
before do | ||
TestConfig.override(webserver: 'puma') | ||
end | ||
|
||
it 'returns the summed up memory bytes and cpu for the process and its subprocesses' do | ||
rss_bytes, pcpu = VCAP::Stats.process_memory_bytes_and_cpu | ||
|
||
expect(rss_bytes).to eq(602_216_448) | ||
expect(pcpu).to eq(17) | ||
end | ||
end | ||
end | ||
end |