5 | | However, there still has to be some kind of timeout as we cannot wait forever for the database to lock the row. I have set that timeout at 5 seconds, and if the timeout occurs the test is skipped. Alternatively, I could fail if the timeout occurs, but this has potential to fail somewhat randomly as it is doing now. If update_or_create were ever changed such that the locking behavior was removed, the test would fail so it should still serve its purpose. |
| 5 | However, there still has to be some kind of timeout as we cannot wait forever for the database to lock the row. I have set that timeout at 0.5 seconds and have changed the thread/callable sleep time to 0.5 seconds as well to allow for more room for slow databases. There is no reason to have the timeout be any longer than the thread sleep time, because once the main thread waits that long the assertion would pass no matter what anyway. If the timeout expires the test is skipped. |
| 6 | |
| 7 | Alternatively, I could fail if the timeout occurs, but this has potential to fail somewhat randomly as it is doing now. |
| 8 | |
| 9 | If update_or_create were ever changed such that the locking behavior was removed, the test would fail as expected so it should still serve its purpose. |