From ec0a0f597e51e48b9b73a58ef92f95b1273a61b7 Mon Sep 17 00:00:00 2001 From: Pavlo Strokov Date: Thu, 19 Aug 2021 16:15:31 +0300 Subject: test: Parallel tests dependent on the PostgreSQL database As now we create a new database on each call of the glsql.GetDB the test execution time increased. To mitigate that problem we make tests dependent on the PostgreSQL database parallel. It should reduce test execution time and may help us to find new issues in the code because of the shared global state. --- internal/praefect/transaction_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'internal/praefect/transaction_test.go') diff --git a/internal/praefect/transaction_test.go b/internal/praefect/transaction_test.go index 80da5b777..7f79c1430 100644 --- a/internal/praefect/transaction_test.go +++ b/internal/praefect/transaction_test.go @@ -70,6 +70,7 @@ func verifyCounterMetrics(t *testing.T, manager *transactions.Manager, expected } func TestTransactionSucceeds(t *testing.T) { + t.Parallel() ctx, cancel := testhelper.Context() defer cancel() @@ -110,6 +111,7 @@ func TestTransactionSucceeds(t *testing.T) { } func TestTransactionWithMultipleNodes(t *testing.T) { + t.Parallel() testcases := []struct { desc string nodes []string @@ -220,6 +222,7 @@ func TestTransactionWithMultipleNodes(t *testing.T) { } func TestTransactionWithContextCancellation(t *testing.T) { + t.Parallel() ctx, cancel := testhelper.Context() defer cancel() @@ -330,6 +333,7 @@ func TestTransactionRegistrationWithInvalidThresholdFails(t *testing.T) { } func TestTransactionReachesQuorum(t *testing.T) { + t.Parallel() tc := []struct { desc string voters []voter @@ -459,6 +463,7 @@ func TestTransactionReachesQuorum(t *testing.T) { } func TestTransactionWithMultipleVotes(t *testing.T) { + t.Parallel() type multiVoter struct { voteCount uint votes []string @@ -567,6 +572,7 @@ func TestTransactionWithMultipleVotes(t *testing.T) { } func TestTransactionFailures(t *testing.T) { + t.Parallel() ctx, cancel := testhelper.Context() defer cancel() @@ -595,6 +601,7 @@ func TestTransactionFailures(t *testing.T) { } func TestTransactionCancellation(t *testing.T) { + t.Parallel() testcases := []struct { desc string voters []voter @@ -713,6 +720,7 @@ func TestTransactionCancellation(t *testing.T) { } func TestStopTransaction(t *testing.T) { + t.Parallel() hash := sha1.Sum([]byte("foo")) t.Run("stopping nonexisting transaction fails", func(t *testing.T) { -- cgit v1.2.3