Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Testing transactions

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

in reply to Testing transactions


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


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2021-03-03 03:23 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (69 votes). Check out past polls.