Skip to content

Commit d1c61e1

Browse files
committed
Reduce sleep overhead in tests.
1 parent 83c00a8 commit d1c61e1

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

test/async/container/.dots.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def setup(container)
1414
instance.ready!
1515

1616
# This is to avoid race conditions in the controller in test conditions.
17-
sleep 0.1
17+
sleep 0.001
1818

1919
$stdout.write "."
2020

test/async/container/.graceful.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def setup(container)
1414
instance.ready!
1515

1616
# This is to avoid race conditions in the controller in test conditions.
17-
sleep 0.1
17+
sleep 0.001
1818

1919
clock = Async::Clock.start
2020

@@ -34,7 +34,7 @@ def setup(container)
3434
end
3535
end
3636

37-
controller = Graceful.new(graceful_stop: 1)
37+
controller = Graceful.new(graceful_stop: 0.01)
3838

3939
begin
4040
controller.run

test/async/container/controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ def controller.setup(container)
1818
container.spawn(key: "test") do |instance|
1919
instance.ready!
2020

21-
sleep(0.2)
21+
sleep(0.02)
2222

2323
@output.write(".")
2424
@output.flush
2525

26-
sleep(0.4)
26+
sleep(0.04)
2727
end
2828

2929
container.spawn do |instance|
3030
instance.ready!
3131

32-
sleep(0.3)
32+
sleep(0.03)
3333

3434
@output.write(",")
3535
@output.flush
@@ -64,7 +64,7 @@ def controller.setup(container)
6464
it "can spawn a reactor" do
6565
def controller.setup(container)
6666
container.async do |task|
67-
task.sleep 1
67+
task.sleep 0.001
6868
end
6969
end
7070

@@ -123,7 +123,7 @@ def after(error = nil)
123123
expect(input.gets).to be == "Exiting...\n"
124124
exit_time = input.gets.to_f
125125

126-
expect(exit_time - graceful_shutdown_time).to be >= 1.0
126+
expect(exit_time - graceful_shutdown_time).to be >= 0.01
127127
end
128128
end
129129

test/async/container/notify/.notify.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
class MyController < Async::Container::Controller
1010
def setup(container)
1111
container.run(restart: false) do |instance|
12-
sleep(rand)
12+
sleep(0.001)
1313

1414
instance.ready!
1515

16-
sleep(rand)
16+
sleep(0.001)
1717
end
1818
end
1919
end

0 commit comments

Comments
 (0)