@@ -405,9 +405,9 @@ def connect *args
405
405
end
406
406
407
407
it "should timeout if we wait longer than :read_timeout" do
408
- client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :read_timeout => 1 ) )
408
+ client = Mysql2 ::Client . new ( DatabaseCredentials [ 'root' ] . merge ( :read_timeout => 0 ) )
409
409
lambda {
410
- client . query ( " SELECT sleep(2)" )
410
+ client . query ( ' SELECT SLEEP(0.1)' )
411
411
} . should raise_error ( Mysql2 ::Error )
412
412
end
413
413
@@ -420,18 +420,18 @@ def connect *args
420
420
begin
421
421
mark [ :START ] = Time . now
422
422
pid = fork do
423
- sleep 1 # wait for client "SELECT sleep(2)" query to start
423
+ sleep 0. 1 # wait for client query to start
424
424
Process . kill ( :USR1 , Process . ppid )
425
425
sleep # wait for explicit kill to prevent GC disconnect
426
426
end
427
- @client . query ( " SELECT sleep(2)" )
427
+ @client . query ( ' SELECT SLEEP(0.2)' )
428
428
mark [ :END ] = Time . now
429
429
mark . include? ( :USR1 ) . should be_true
430
- ( mark [ :USR1 ] - mark [ :START ] ) . should >= 1
431
- ( mark [ :USR1 ] - mark [ :START ] ) . should < 1.3
432
- ( mark [ :END ] - mark [ :USR1 ] ) . should > 0.9
433
- ( mark [ :END ] - mark [ :START ] ) . should >= 2
434
- ( mark [ :END ] - mark [ :START ] ) . should < 2.3
430
+ ( mark [ :USR1 ] - mark [ :START ] ) . should >= 0. 1
431
+ ( mark [ :USR1 ] - mark [ :START ] ) . should < 0.13
432
+ ( mark [ :END ] - mark [ :USR1 ] ) . should > 0.09
433
+ ( mark [ :END ] - mark [ :START ] ) . should >= 0. 2
434
+ ( mark [ :END ] - mark [ :START ] ) . should < 0.23
435
435
Process . kill ( :TERM , pid )
436
436
Process . waitpid2 ( pid )
437
437
ensure
@@ -455,7 +455,7 @@ def connect *args
455
455
it 'should be impervious to connection-corrupting timeouts ' do
456
456
pending ( '`Thread.handle_interrupt` is not defined' ) unless Thread . respond_to? ( :handle_interrupt )
457
457
# attempt to break the connection
458
- expect { Timeout . timeout ( 0.1 ) { @client . query ( 'SELECT SLEEP(1 )' ) } } . to raise_error ( Timeout ::Error )
458
+ expect { Timeout . timeout ( 0.1 ) { @client . query ( 'SELECT SLEEP(0.2 )' ) } } . to raise_error ( Timeout ::Error )
459
459
460
460
# expect the connection to not be broken
461
461
expect { @client . query ( 'SELECT 1' ) } . to_not raise_error
0 commit comments