What is the best way to do concurrency testing with ruby on rails 3? I have many race conditions on my site and currently testing them is a inexact science that is very time consuming.
Thanks in advance for any responses.
In particular, Ruby concurrency is when two tasks can start, run, and complete in overlapping time periods. It doesn't necessarily mean, though, that they'll ever both be running at the same instant (e.g., multiple threads on a single-core machine).
It's not a common production platform among the RoR community. As a result, Eventhough Rails itself is thread-safe since version 2.2, there isn't yet a good multi-threaded server for it on Windows servers. And you get the best results by running it on *nix servers using multi-process/single-threaded concurrency model.
We can run all of our tests at once by using the bin/rails test command. Or we can run a single test file by passing the bin/rails test command the filename containing the test cases. This will run all test methods from the test case.
This is the initial thread of execution that began when the Ruby program was started. You can wait for a particular thread to finish by calling that thread's Thread. join method. The calling thread will block until the given thread is finished.
I believe that Tourbus can help.
I recently published a post with a solution on how to test concurrency caused by job queue workers in order to validate code fix for race condition. It should apply to other concurrency issues in Rails.
http://ternarylabs.com/2012/04/16/handle-job-queue-workers-concurrency-in-rails/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With