Skip to content

Commit 41f2057

Browse files
authored
Try to fix Errno::EADDRINUSE in metrics_spec (#4710)
* in the GitHub unit test action, we often see multiple errors "Address already in use - bind(2) for "127.0.0.1" port 9395" * try to use an ephemeral port for each test
1 parent 25adb2b commit 41f2057

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

spec/request/internal/metrics_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
delegate :app, to: :metrics_webserver
99

1010
before do
11+
# Force Puma to bind to an ephemeral port (0) to avoid EADDRINUSE
12+
allow_any_instance_of(Puma::Server).to receive(:add_tcp_listener).and_wrap_original do |m, host, _|
13+
m.call(host, 0)
14+
end
1115
allow_any_instance_of(VCAP::CloudController::Metrics::PeriodicUpdater).to receive(:update_webserver_stats)
1216
metrics_webserver.start(TestConfig.config_instance)
1317
end

0 commit comments

Comments
 (0)