@@ -135,11 +135,14 @@ class ClientTest < TinyTds::TestCase
135
135
it 'raises TinyTds exception with tcp socket network failure' do
136
136
skip if ENV [ 'CI' ] && ENV [ 'APPVEYOR_BUILD_FOLDER' ] # only CI using docker
137
137
begin
138
- client = new_connection timeout : 1 , port : 1234
138
+ client = new_connection timeout : 2 , port : 1234
139
139
assert_client_works ( client )
140
- action = lambda { client . execute ( "waitfor delay '00:00:02'" ) . do }
141
- # Delay the TCP socket from closing until delay has elapsed.
142
- Toxiproxy [ :sqlserver_test ] . toxic ( :slow_close , delay : 500 ) . apply do
140
+ action = lambda { client . execute ( "waitfor delay '00:00:05'" ) . do }
141
+
142
+ # Use toxiproxy to close the TCP socket after 1 second.
143
+ # TinyTds shuuld be able to execute the statement, hit the timeout configured above, and then not be able to use the network to cancel
144
+ # the network connection needs to close after the sql batch is sent and before the timeout above is hit
145
+ Toxiproxy [ :sqlserver_test ] . toxic ( :slow_close , delay : 1000 ) . apply do
143
146
assert_raise_tinytds_error ( action ) do |e |
144
147
assert_equal 20003 , e . db_error_number
145
148
assert_equal 6 , e . severity
@@ -154,11 +157,14 @@ class ClientTest < TinyTds::TestCase
154
157
it 'raises TinyTds exception with dead connection network failure' do
155
158
skip if ENV [ 'CI' ] && ENV [ 'APPVEYOR_BUILD_FOLDER' ] # only CI using docker
156
159
begin
157
- client = new_connection timeout : 1 , port : 1234
160
+ client = new_connection timeout : 2 , port : 1234
158
161
assert_client_works ( client )
159
- action = lambda { client . execute ( "waitfor delay '00:00:02'" ) . do }
160
- # Stops all data from getting through, and closes the connection after timeout
161
- Toxiproxy [ :sqlserver_test ] . toxic ( :timeout , timeout : 500 ) . apply do
162
+ action = lambda { client . execute ( "waitfor delay '00:00:05'" ) . do }
163
+
164
+ # Use toxiproxy to close the network connection after 1 second.
165
+ # We want TinyTds to execute the statement, hit the timeout configured above, and then not be able to use the network to cancel
166
+ # the network connection needs to close after the sql batch is sent and before the timeout above is hit
167
+ Toxiproxy [ :sqlserver_test ] . toxic ( :timeout , timeout : 1000 ) . apply do
162
168
assert_raise_tinytds_error ( action ) do |e |
163
169
assert_equal 20047 , e . db_error_number
164
170
assert_includes [ 1 , 9 ] , e . severity
0 commit comments