Skip to content

Commit e5b05a9

Browse files
committed
Speed up some tests
1 parent c118d26 commit e5b05a9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

spec/mysql2/client_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,9 @@ def connect *args
405405
end
406406

407407
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))
409409
lambda {
410-
client.query("SELECT sleep(2)")
410+
client.query('SELECT SLEEP(0.1)')
411411
}.should raise_error(Mysql2::Error)
412412
end
413413

@@ -420,18 +420,18 @@ def connect *args
420420
begin
421421
mark[:START] = Time.now
422422
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
424424
Process.kill(:USR1, Process.ppid)
425425
sleep # wait for explicit kill to prevent GC disconnect
426426
end
427-
@client.query("SELECT sleep(2)")
427+
@client.query('SELECT SLEEP(0.2)')
428428
mark[:END] = Time.now
429429
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
435435
Process.kill(:TERM, pid)
436436
Process.waitpid2(pid)
437437
ensure
@@ -455,7 +455,7 @@ def connect *args
455455
it 'should be impervious to connection-corrupting timeouts ' do
456456
pending('`Thread.handle_interrupt` is not defined') unless Thread.respond_to?(:handle_interrupt)
457457
# 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)
459459

460460
# expect the connection to not be broken
461461
expect { @client.query('SELECT 1') }.to_not raise_error

0 commit comments

Comments
 (0)