Skip to content

Commit bc5538b

Browse files
Merge pull request #8768 from rubygems/deivid-rodriguez/fix-flakies
Potentially fix some flakies in mirror probe specs
2 parents f5767e6 + e28b5e3 commit bc5538b

1 file changed

Lines changed: 23 additions & 26 deletions

File tree

bundler/spec/install/gems/mirror_probe_spec.rb

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# frozen_string_literal: true
22

33
RSpec.describe "fetching dependencies with a not available mirror" do
4-
let(:mirror) { @mirror_uri }
5-
let(:original) { @server_uri }
6-
let(:server_port) { @server_port }
74
let(:host) { "127.0.0.1" }
85

96
before do
@@ -20,13 +17,13 @@
2017

2118
context "with a specific fallback timeout" do
2219
before do
23-
global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/__FALLBACK_TIMEOUT/" => "true",
24-
"BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror)
20+
global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/__FALLBACK_TIMEOUT/" => "true",
21+
"BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/" => @mirror_uri)
2522
end
2623

2724
it "install a gem using the original uri when the mirror is not responding" do
2825
gemfile <<-G
29-
source "#{original}"
26+
source "#{@server_uri}"
3027
gem 'weakling'
3128
G
3229

@@ -41,12 +38,12 @@
4138
context "with a global fallback timeout" do
4239
before do
4340
global_config("BUNDLE_MIRROR__ALL__FALLBACK_TIMEOUT/" => "1",
44-
"BUNDLE_MIRROR__ALL" => mirror)
41+
"BUNDLE_MIRROR__ALL" => @mirror_uri)
4542
end
4643

4744
it "install a gem using the original uri when the mirror is not responding" do
4845
gemfile <<-G
49-
source "#{original}"
46+
source "#{@server_uri}"
5047
gem 'weakling'
5148
G
5249

@@ -60,61 +57,61 @@
6057

6158
context "with a specific mirror without a fallback timeout" do
6259
before do
63-
global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{server_port}/" => mirror)
60+
global_config("BUNDLE_MIRROR__HTTP://127__0__0__1:#{@server_port}/" => @mirror_uri)
6461
end
6562

66-
it "fails to install the gem with a timeout error" do
63+
it "fails to install the gem with a timeout error when the mirror is not responding" do
6764
gemfile <<-G
68-
source "#{original}"
65+
source "#{@server_uri}"
6966
gem 'weakling'
7067
G
7168

7269
bundle :install, artifice: nil, raise_on_error: false
7370

74-
expect(out).to include("Fetching source index from #{mirror}")
71+
expect(out).to include("Fetching source index from #{@mirror_uri}")
7572

7673
err_lines = err.split("\n")
77-
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
78-
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
79-
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
80-
expect(err_lines).to include(%r{\ACould not fetch specs from #{mirror}/ due to underlying error <})
74+
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
75+
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
76+
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
77+
expect(err_lines).to include(%r{\ACould not fetch specs from #{@mirror_uri}/ due to underlying error <})
8178
end
8279
end
8380

8481
context "with a global mirror without a fallback timeout" do
8582
before do
86-
global_config("BUNDLE_MIRROR__ALL" => mirror)
83+
global_config("BUNDLE_MIRROR__ALL" => @mirror_uri)
8784
end
8885

89-
it "fails to install the gem with a timeout error" do
86+
it "fails to install the gem with a timeout error when the mirror is not responding" do
9087
gemfile <<-G
91-
source "#{original}"
88+
source "#{@server_uri}"
9289
gem 'weakling'
9390
G
9491

9592
bundle :install, artifice: nil, raise_on_error: false
9693

97-
expect(out).to include("Fetching source index from #{mirror}")
94+
expect(out).to include("Fetching source index from #{@mirror_uri}")
9895

9996
err_lines = err.split("\n")
100-
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
101-
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
102-
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{mirror}/ due to underlying error <})
103-
expect(err_lines).to include(%r{\ACould not fetch specs from #{mirror}/ due to underlying error <})
97+
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(2/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
98+
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(3/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
99+
expect(err_lines).to include(%r{\ARetrying fetcher due to error \(4/4\): Bundler::HTTPError Could not fetch specs from #{@mirror_uri}/ due to underlying error <})
100+
expect(err_lines).to include(%r{\ACould not fetch specs from #{@mirror_uri}/ due to underlying error <})
104101
end
105102
end
106103

107104
def setup_server
108105
@server_port = find_unused_port
109106
@server_uri = "http://#{host}:#{@server_port}"
110107

111-
require_relative "../../support/artifice/endpoint"
108+
require_relative "../../support/artifice/compact_index"
112109
require_relative "../../support/silent_logger"
113110

114111
require "rackup/server"
115112

116113
@server_thread = Thread.new do
117-
Rackup::Server.start(app: Endpoint,
114+
Rackup::Server.start(app: CompactIndexAPI,
118115
Host: host,
119116
Port: @server_port,
120117
server: "webrick",

0 commit comments

Comments
 (0)