Skip to content

Commit f3f5e54

Browse files
committed
Fix: CI on old rubies
1 parent 03545aa commit f3f5e54

File tree

3 files changed

+23
-32
lines changed

3 files changed

+23
-32
lines changed

instrumentation/net_http/test/opentelemetry/instrumentation/net/http/dup/instrumentation_test.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,7 @@
201201
# this works because http://bazqux.com is reachable site; try http://asdfasdfsef.com will fail
202202
uri = URI.parse('http://bazqux.com')
203203
http = Net::HTTP.new(uri.host, uri.port)
204-
205-
fake_socket = Object.new
206-
def fake_socket.setsockopt(*args); end
207-
def fake_socket.close; end
208-
209-
# Replace the TCP socket creation with our fake socket
210-
TCPSocket.stub(:open, fake_socket) do
211-
http.send(:connect)
212-
end
213-
204+
http.send(:connect)
214205
http.send(:do_finish)
215206
_(exporter.finished_spans.size).must_equal 0
216207
end
@@ -229,7 +220,16 @@ def fake_socket.close; end
229220
it 'creates a span on connect for a non-ignored request' do
230221
uri = URI.parse('http://example.com')
231222
http = Net::HTTP.new(uri.host, uri.port)
232-
http.send(:connect)
223+
224+
fake_socket = Object.new
225+
def fake_socket.setsockopt(*args); end
226+
def fake_socket.close; end
227+
228+
# Replace the TCP socket creation with our fake socket
229+
TCPSocket.stub(:open, fake_socket) do
230+
http.send(:connect)
231+
end
232+
233233
http.send(:do_finish)
234234
_(exporter.finished_spans.size).must_equal 1
235235
_(span.name).must_equal('connect')

instrumentation/net_http/test/opentelemetry/instrumentation/net/http/old/instrumentation_test.rb

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,7 @@
156156
# this works because http://bazqux.com is reachable site; try http://asdfasdfsef.com will fail
157157
uri = URI.parse('http://bazqux.com')
158158
http = Net::HTTP.new(uri.host, uri.port)
159-
160-
fake_socket = Object.new
161-
def fake_socket.setsockopt(*args); end
162-
def fake_socket.close; end
163-
164-
# Replace the TCP socket creation with our fake socket
165-
TCPSocket.stub(:open, fake_socket) do
166-
http.send(:connect)
167-
end
168-
159+
http.send(:connect)
169160
http.send(:do_finish)
170161
_(exporter.finished_spans.size).must_equal 0
171162
end

instrumentation/net_http/test/opentelemetry/instrumentation/net/http/stable/instrumentation_test.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,7 @@
172172
# this works because http://bazqux.com is reachable site; try http://asdfasdfsef.com will fail
173173
uri = URI.parse('http://bazqux.com')
174174
http = Net::HTTP.new(uri.host, uri.port)
175-
176-
fake_socket = Object.new
177-
def fake_socket.setsockopt(*args); end
178-
def fake_socket.close; end
179-
180-
# Replace the TCP socket creation with our fake socket
181-
TCPSocket.stub(:open, fake_socket) do
182-
http.send(:connect)
183-
end
184-
175+
http.send(:connect)
185176
http.send(:do_finish)
186177
_(exporter.finished_spans.size).must_equal 0
187178
end
@@ -197,7 +188,16 @@ def fake_socket.close; end
197188
it 'creates a span on connect for a non-ignored request' do
198189
uri = URI.parse('http://example.com')
199190
http = Net::HTTP.new(uri.host, uri.port)
200-
http.send(:connect)
191+
192+
fake_socket = Object.new
193+
def fake_socket.setsockopt(*args); end
194+
def fake_socket.close; end
195+
196+
# Replace the TCP socket creation with our fake socket
197+
TCPSocket.stub(:open, fake_socket) do
198+
http.send(:connect)
199+
end
200+
201201
http.send(:do_finish)
202202
_(exporter.finished_spans.size).must_equal 1
203203
_(span.name).must_equal('connect')

0 commit comments

Comments
 (0)