Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Testing transactions

by roboticus (Chancellor)
on Jan 24, 2008 at 12:18 UTC ( [id://663993]=note: print w/replies, xml ) Need Help??


in reply to Testing transactions

matija:

For a simple method, have your test code open *two* handles to the database. Then start the first transaction on one item, then start the second transaction, and switch back and forth as desired.

Slightly better might be two create two threads or processes and insert some time delays at various points to "usually" interleave the bits you want to test. (Usually because it won't be deterministic, as timing variations will come into play. But usually this is good enough.)

If "good enough" isn't good enough ;^), you could always add mutexes, semaphores, or even directory creation/removal to enforce interleaving.

However, I haven't used Dbix::Class before, so I don't know if anything in it would invalidate what I said. I'm also assuming that your transactions have multiple steps that you control.

The techniques I suggested won't work for testing transactions that use a single call to the database. For that, you may want to write your own DBD class so you can monitor which actions occur when, and put in your own delays and/or semaphores or state variables to encourage actions to occur in the desired order for testing.

I hope this is useful....

...roboticus

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://663993]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2024-04-18 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found