Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I do Ruby on Rails concurrency testing?

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.

like image 981
Nicolo77 Avatar asked May 25 '11 13:05

Nicolo77


People also ask

How does Ruby handle concurrency?

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).

Is RoR multithreaded?

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.

How do I run a test file in rails?

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.

How do you use multithreading in Ruby?

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.


2 Answers

I believe that Tourbus can help.

like image 89
Roman Avatar answered Sep 19 '22 05:09

Roman


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/

like image 22
Georges Auberger Avatar answered Sep 18 '22 05:09

Georges Auberger