From d660b0f70b773190f7d0fa725ee8a5916f19db72 Mon Sep 17 00:00:00 2001 From: Steffen Planthaber Date: Thu, 28 Aug 2014 10:54:34 +0200 Subject: [PATCH] added test case to check against race conditions of write with the garbage collection --- test/test_tasks.rb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/test/test_tasks.rb b/test/test_tasks.rb index e89446b..1413527 100644 --- a/test/test_tasks.rb +++ b/test/test_tasks.rb @@ -211,16 +211,38 @@ def with_stub_task_context(task_name) end it "returns a code 201 'Created' when the port was written correctly" do - (0..20000).each do with_stub_task_context "task" do |task| port = task.create_input_port 'port', '/double' post "/tasks/localhost/task/ports/port/write", value: "10.0" assert_equal 201, last_response.status assert_equal 10.0, port.read end + end + end + + describe "/GCwrite" do + it "does also work if the GC runs" do + gcruns = 0 + Thread.new do + loop do + #sleep 0.01 + GC.start + gcruns += 1 + end + end + (0..1000).each do |run| + with_stub_task_context "task" do |task| + port = task.create_input_port 'port', '/double' + post "/tasks/localhost/task/ports/port/write", value: "10.0" + assert_equal 201, last_response.status + assert_equal 10.0, port.read + end + p "run #{run} with #{gcruns} GC runs" + gcruns = 0 end end end + end end