File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,11 @@ def connect_with_retry
51
51
52
52
yield http
53
53
rescue *InfluxDB ::NON_RECOVERABLE_EXCEPTIONS => e
54
- http . finish
54
+ http . finish if http . started?
55
55
56
56
raise InfluxDB ::ConnectionError , InfluxDB ::NON_RECOVERABLE_MESSAGE
57
57
rescue Timeout ::Error , *InfluxDB ::RECOVERABLE_EXCEPTIONS => e
58
- http . finish
58
+ http . finish if http . started?
59
59
60
60
retry_count += 1
61
61
unless ( config . retry == -1 || retry_count <= config . retry ) && !stopped?
Original file line number Diff line number Diff line change 39
39
end
40
40
end
41
41
42
+ describe "#connect_with_retry" do
43
+ it "raises InfluxDB::ConnectionError when the hostname is unknown" do
44
+ subject . config . retry = 0
45
+
46
+ allow_any_instance_of ( Net ::HTTP ) . to receive ( :start ) do
47
+ raise SocketError , "simulate getaddrinfo error"
48
+ end
49
+
50
+ error = InfluxDB ::ConnectionError . new "Tried 0 times to reconnect but failed."
51
+ expect { subject . send ( :connect_with_retry ) } . to raise_error ( InfluxDB ::ConnectionError )
52
+ end
53
+ end
54
+
42
55
describe "#full_url" do
43
56
it "returns String" do
44
57
expect ( subject . send ( :full_url , "/unknown" ) ) . to be_a String
You can’t perform that action at this time.
0 commit comments