Skip to content

Commit 0f6f5a5

Browse files
committed
Fix CI
1 parent 633216e commit 0f6f5a5

File tree

3 files changed

+40
-3
lines changed

3 files changed

+40
-3
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,19 @@
198198
end
199199

200200
it 'does not create a span on connect when request ignored using a regexp' do
201+
# this works because http://bazqux.com is reachable site; try http://asdfasdfsef.com will fail
201202
uri = URI.parse('http://bazqux.com')
202203
http = Net::HTTP.new(uri.host, uri.port)
203-
http.send(:connect)
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+
204214
http.send(:do_finish)
205215
_(exporter.finished_spans.size).must_equal 0
206216
end
@@ -252,6 +262,10 @@
252262
OpenTelemetry::Common::Utilities.untraced do
253263
uri = URI.parse('http://example.com/body')
254264
http = Net::HTTP.new(uri.host, uri.port)
265+
266+
# Mock the connect
267+
http.define_singleton_method(:connect) { true }
268+
255269
http.send(:connect)
256270
http.send(:do_finish)
257271
end

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,16 @@
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-
http.send(:connect)
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+
160169
http.send(:do_finish)
161170
_(exporter.finished_spans.size).must_equal 0
162171
end

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,19 @@
169169
end
170170

171171
it 'does not create a span on connect when request ignored using a regexp' do
172+
# this works because http://bazqux.com is reachable site; try http://asdfasdfsef.com will fail
172173
uri = URI.parse('http://bazqux.com')
173174
http = Net::HTTP.new(uri.host, uri.port)
174-
http.send(:connect)
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+
175185
http.send(:do_finish)
176186
_(exporter.finished_spans.size).must_equal 0
177187
end
@@ -217,6 +227,10 @@
217227
OpenTelemetry::Common::Utilities.untraced do
218228
uri = URI.parse('http://example.com/body')
219229
http = Net::HTTP.new(uri.host, uri.port)
230+
231+
# Mock the connect
232+
http.define_singleton_method(:connect) { true }
233+
220234
http.send(:connect)
221235
http.send(:do_finish)
222236
end

0 commit comments

Comments
 (0)