Commit d89a0220 authored by Stan Hu's avatar Stan Hu

Fix failing EE builds due to blacklisted Web connections

If unicorn_spec.rb were run before Elasticsearch specs, it would
disable all outbound network connections, which would prevent the
latter from being able to communicate with Elasticsearch in CI. To
fix this, we restore the original WebMock settings after finishing
the spec.

Closes #2507
parent 211679e2
require 'webmock' require 'webmock'
require 'webmock/rspec' require 'webmock/rspec'
allowed = %w[elasticsearch registry.gitlab.com-gitlab-org-test-elastic-image] def webmock_setup_defaults
allowed = %w[elasticsearch registry.gitlab.com-gitlab-org-test-elastic-image]
if ENV.has_key?('ELASTIC_URL') if ENV.has_key?('ELASTIC_URL')
url = URI.parse(ENV['ELASTIC_URL']) url = URI.parse(ENV['ELASTIC_URL'])
allowed << url.host allowed << url.host
allowed.uniq! allowed.uniq!
end
WebMock.disable_net_connect!(allow_localhost: true, allow: allowed)
end end
WebMock.disable_net_connect!(allow_localhost: true, allow: allowed) webmock_setup_defaults
...@@ -62,7 +62,7 @@ describe 'Unicorn' do ...@@ -62,7 +62,7 @@ describe 'Unicorn' do
end end
after(:all) do after(:all) do
WebMock.disable_net_connect!(allow_localhost: true) webmock_setup_defaults
Process.kill('TERM', @unicorn_master_pid) Process.kill('TERM', @unicorn_master_pid)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment