Skip to content

Commit 74df672

Browse files
authored
Fix parsing memory sample bake task. (#12)
1 parent 33487bb commit 74df672

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

bake/async/container/supervisor.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ def memory_sample(duration: 10, connection_id:)
4444
operation = {do: :memory_sample, duration: duration}
4545

4646
# Use the forward operation to proxy the request to a worker:
47-
return connection.call(do: :forward, operation: operation, connection_id: connection_id)
47+
response = connection.call(do: :forward, operation: operation, connection_id: connection_id)
48+
49+
if response && response.key?(:data)
50+
JSON.parse(response[:data], symbolize_names: true)
51+
else
52+
response
53+
end
4854
end
4955
end
5056

lib/async/container/supervisor/worker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def do_memory_sample(call)
117117
report = sampler.report
118118

119119
dump(call) do |file|
120-
file.puts(report.to_s)
120+
file.puts(report.to_json)
121121
end
122122
ensure
123123
GC.start

test/async/container/supervisor.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def reader_target.dispatch(call); end
117117

118118
# The result should contain a report
119119
expect(result).to have_keys(:data)
120+
121+
report = JSON.parse(result[:data], symbolize_names: true)
122+
123+
expect(report).to have_keys(:total_allocated, :total_retained, :aggregates)
120124
ensure
121125
worker_task&.stop
122126
end

0 commit comments

Comments
 (0)