@@ -349,8 +349,9 @@ func TestWorkspaceSerialization(t *testing.T) {
349
349
// - BeginTX -> Bump! -> GetQuota -> GetAllowance -> UpdateCost -> EndTx
350
350
// - BeginTX -> GetQuota -> GetAllowance -> UpdateCost -> Bump! -> EndTx
351
351
t .Run ("UpdateBuildDeadline" , func (t * testing.T ) {
352
- t .Skip ("Expected to fail. As long as quota & deadline are on the same " +
352
+ t .Log ("Expected to fail. As long as quota & deadline are on the same " +
353
353
" table and affect the same row, this will likely always fail." )
354
+
354
355
// +------------------------------+------------------+
355
356
// | Begin Tx | |
356
357
// +------------------------------+------------------+
@@ -393,12 +394,17 @@ func TestWorkspaceSerialization(t *testing.T) {
393
394
// Run order
394
395
395
396
quota := newCommitter (t , db , myWorkspace .Workspace , myWorkspace .Build )
396
- quota .GetQuota (ctx , t ) // Step 1
397
- bumpDeadline () // Interrupt
398
- quota .GetAllowance (ctx , t ) // Step 2
399
- quota .UpdateWorkspaceBuildCostByID (ctx , t , 10 ) // Step 3
397
+ quota .GetQuota (ctx , t ) // Step 1
398
+ bumpDeadline () // Interrupt
399
+ quota .GetAllowance (ctx , t ) // Step 2
400
+
401
+ err := quota .DBTx .UpdateWorkspaceBuildCostByID (ctx , database.UpdateWorkspaceBuildCostByIDParams {
402
+ ID : myWorkspace .Build .ID ,
403
+ DailyCost : 10 ,
404
+ }) // Step 3
405
+ require .ErrorContains (t , err , "could not serialize access due to concurrent update" )
400
406
// End commit
401
- require .NoError (t , quota .Done ())
407
+ require .ErrorContains (t , quota .Done (), "failed transaction" )
402
408
})
403
409
404
410
// UpdateOtherBuildDeadline bumps a user's other workspace deadline
@@ -465,7 +471,7 @@ func TestWorkspaceSerialization(t *testing.T) {
465
471
})
466
472
467
473
t .Run ("ActivityBump" , func (t * testing.T ) {
468
- t .Skip ("Expected to fail. As long as quota & deadline are on the same " +
474
+ t .Log ("Expected to fail. As long as quota & deadline are on the same " +
469
475
" table and affect the same row, this will likely always fail." )
470
476
// +---------------------+----------------------------------+
471
477
// | W1 Quota Tx | |
@@ -510,10 +516,14 @@ func TestWorkspaceSerialization(t *testing.T) {
510
516
511
517
assert .NoError (t , err )
512
518
513
- one .UpdateWorkspaceBuildCostByID (ctx , t , 10 )
519
+ err = one .DBTx .UpdateWorkspaceBuildCostByID (ctx , database.UpdateWorkspaceBuildCostByIDParams {
520
+ ID : myWorkspace .Build .ID ,
521
+ DailyCost : 10 ,
522
+ })
523
+ require .ErrorContains (t , err , "could not serialize access due to concurrent update" )
514
524
515
525
// End commit
516
- assert .NoError (t , one .Done ())
526
+ assert .ErrorContains (t , one .Done (), "failed transaction" )
517
527
})
518
528
519
529
t .Run ("BumpLastUsedAt" , func (t * testing.T ) {
@@ -724,7 +734,7 @@ func TestWorkspaceSerialization(t *testing.T) {
724
734
// QuotaCommit 2 workspaces in the same org.
725
735
// Workspaces do not share templates
726
736
t .Run ("DoubleQuotaUserWorkspaces" , func (t * testing.T ) {
727
- t .Skip ("Setting a new build cost to a workspace in a org affects other " +
737
+ t .Log ("Setting a new build cost to a workspace in a org affects other " +
728
738
"workspaces in the same org. This is expected to fail." )
729
739
// +---------------------+---------------------+
730
740
// | W1 Quota Tx | W2 Quota Tx |
@@ -779,7 +789,7 @@ func TestWorkspaceSerialization(t *testing.T) {
779
789
780
790
// End commit
781
791
assert .NoError (t , one .Done ())
782
- assert .NoError (t , two .Done ())
792
+ assert .ErrorContains (t , two .Done (), "could not serialize access due to read/write dependencies among transactions" )
783
793
})
784
794
}
785
795
0 commit comments