chore: increase parallelism of TestWorkspaceQuota (#6710)

This does a lot of build operations, so having multiple provisioner
daemons is great.

We were actually approaching the ceiling here for test duration!
This commit is contained in:
Kyle Carberry
2023-03-21 17:44:01 -05:00
committed by GitHub
parent 5cbe360176
commit abe1e89f80
4 changed files with 90 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import (
"testing"
"github.com/google/uuid"
"github.com/lib/pq"
"github.com/stretchr/testify/require"
"github.com/coder/coder/coderd/database"
@ -15,6 +16,36 @@ import (
"github.com/coder/coder/coderd/database/postgres"
)
func TestSerializedRetry(t *testing.T) {
t.Parallel()
if testing.Short() {
t.SkipNow()
}
sqlDB := testSQLDB(t)
db := database.New(sqlDB)
called := 0
txOpts := &sql.TxOptions{Isolation: sql.LevelSerializable}
err := db.InTx(func(tx database.Store) error {
// Test nested error
return tx.InTx(func(tx database.Store) error {
// The easiest way to mock a serialization failure is to
// return a serialization failure error.
called++
return &pq.Error{
Code: "40001",
Message: "serialization_failure",
}
}, txOpts)
}, txOpts)
require.Error(t, err, "should fail")
// The double "execute transaction: execute transaction" is from the nested transactions.
// Just want to make sure we don't try 9 times.
require.Equal(t, err.Error(), "transaction failed after 3 attempts: execute transaction: execute transaction: pq: serialization_failure", "error message")
require.Equal(t, called, 3, "should retry 3 times")
}
func TestNestedInTx(t *testing.T) {
t.Parallel()
if testing.Short() {