nolint:paralleltest,tparallel // Tests must run serially
(t *testing.T)
| 703 | |
| 704 | // nolint:paralleltest,tparallel // Tests must run serially |
| 705 | func TestWorkspaceSerialization(t *testing.T) { |
| 706 | t.Parallel() |
| 707 | |
| 708 | db, _ := dbtestutil.NewDB(t) |
| 709 | |
| 710 | user := dbgen.User(t, db, database.User{}) |
| 711 | otherUser := dbgen.User(t, db, database.User{}) |
| 712 | |
| 713 | org := dbfake.Organization(t, db). |
| 714 | EveryoneAllowance(20). |
| 715 | Members(user, otherUser). |
| 716 | Group(database.Group{ |
| 717 | QuotaAllowance: 10, |
| 718 | }, user, otherUser). |
| 719 | Group(database.Group{ |
| 720 | QuotaAllowance: 10, |
| 721 | }, user). |
| 722 | Do() |
| 723 | |
| 724 | otherOrg := dbfake.Organization(t, db). |
| 725 | EveryoneAllowance(20). |
| 726 | Members(user, otherUser). |
| 727 | Group(database.Group{ |
| 728 | QuotaAllowance: 10, |
| 729 | }, user, otherUser). |
| 730 | Group(database.Group{ |
| 731 | QuotaAllowance: 10, |
| 732 | }, user). |
| 733 | Do() |
| 734 | |
| 735 | // TX mixing tests. **DO NOT** run these in parallel. |
| 736 | // The goal here is to mess around with different ordering of |
| 737 | // transactions and queries. |
| 738 | |
| 739 | // UpdateBuildDeadline bumps a workspace deadline while doing a quota |
| 740 | // commit to the same workspace build. |
| 741 | // |
| 742 | // Note: This passes if the interrupt is run before 'GetQuota()' |
| 743 | // Passing orders: |
| 744 | // - BeginTX -> Bump! -> GetQuota -> GetAllowance -> UpdateCost -> EndTx |
| 745 | // - BeginTX -> GetQuota -> GetAllowance -> UpdateCost -> Bump! -> EndTx |
| 746 | t.Run("UpdateBuildDeadline", func(t *testing.T) { |
| 747 | t.Log("Expected to fail. As long as quota & deadline are on the same " + |
| 748 | " table and affect the same row, this will likely always fail.") |
| 749 | |
| 750 | // +------------------------------+------------------+ |
| 751 | // | Begin Tx | | |
| 752 | // +------------------------------+------------------+ |
| 753 | // | GetQuota(user) | | |
| 754 | // +------------------------------+------------------+ |
| 755 | // | | BumpDeadline(w1) | |
| 756 | // +------------------------------+------------------+ |
| 757 | // | GetAllowance(user) | | |
| 758 | // +------------------------------+------------------+ |
| 759 | // | UpdateWorkspaceBuildCost(w1) | | |
| 760 | // +------------------------------+------------------+ |
| 761 | // | CommitTx() | | |
| 762 | // +------------------------------+------------------+ |
nothing calls this directly
no test coverage detected