Forum: Ruby on Rails Testing concurrent accesses

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Bef7ff8a0537495a1876ffebdc9f8e51?d=identicon&s=25 Lionel Bouton (Guest)
on 2007-07-06 15:45
(Received via mailing list)
Hi,

I've recently come across a bug in one of my applications where
destroying a model can occur while it's locked in another place for
processing. Just for the record: the destroy correctly aborts because of
this but there are files removed by dependent models being destroyed to
that can't be restored when the rollback occurs (after_destroy is not
delayed until the actual commit...).

I know how I can solve this but I would like to create a test before
(TDD/BDD are my friends...) and I don't know how I can handle this in
tests (reproducing a race condition isn't especially easy).

Is there anyone on this list with experience to share on this particular
subject?

Lionel
82a61255b4090da7d3619f870b0794dc?d=identicon&s=25 James Mead (floehopper)
on 2007-07-06 15:55
(Received via mailing list)
You might find this article on the JMock site useful -
http://www.jmock.org/threads.html

They suggest trying to separate out the concurrency as a separate
class and then write unit tests around the business logic while
mocking out the concurrency.

This approach has worked for me in the past.
--
James.
http://blog.floehopper.org
This topic is locked and can not be replied to.