WorkflowXtra tests: Deal with race conditions

This page tests that the Rivendell WorkflowXtra functionality sensibly handles optimistic locking and race conditions (where multiple people edit same item close together).

Results - Create an approved record

Create an approved record in normal manner that we can then edit.

Test Expected Actual Result
Initial insert returns PK Primary Key (number) 213 PASS
Initial version is v1 1 1 PASS

Results - Simulate two concurrent updates

Update the intitial approved record twice as per two users that have opened it spearately to each other. The key here is that we pass the same original PK in for both updates meaning the second update is dealing with a stale record.

Test Expected Actual Result
First edit should succeed Primary Key (number) 214 PASS
Current item should be accessible Rows = 1 Rows = 1 PASS
Current item should be fresh true true PASS
First change should be saved "Edited first" "Edited first" PASS
Version number should be bumped 2 2 PASS
Test Expected Actual Result
Second edit should fail (stale record) Errors = 1 Errors = 1 PASS
Error message should tell me why __RecordError: stale record __RecordError: stale record PASS

Results - Create a draft record

Create an approved record than add a draft record in normal manner that we can then edit further.

Test Expected Actual Result
Initial insert returns PK Primary Key (number) 215 (215) PASS
Initial version is v1 1 1 PASS
First edit returns PK Primary Key (number) 216 PASS
Second version is v2 2 2 PASS
Second version is approved 10 10 PASS

Results - Simulate two concurrent updates

Update the draft record twice as per two users that have opened it spearately to each other. The key here is that we pass the same original PK in for both updates meaning the second update is dealing with a stale record. This differs from previous tests in that this time the first edit saves as draft (creating a fresh new version but leaving an approved one still in place) and the second save then also creates a fresh new version unless dealt with inside Rivendell (stale record error).

Test Expected Actual Result
First edit should succeed Primary Key (number) 217 PASS
Current item should be accessible Rows = 1 Rows = 1 PASS
Current item should be fresh true true PASS
First change should be saved "Edited first" "Edited first" PASS
Version number should be set 3 3 PASS
Test Expected Actual Result
Second edit should fail (stale record) Errors = 1 Errors = 1 PASS
Error message should tell me why __RecordError: stale record __RecordError: stale record PASS

Debug

Ref W Ref State Fresh Version
213 213 9 false 1
214 213 10 true 2
215 215 9 false 1
216 215 10 false 2
217 215 0 true 3