From c9814584d0cb3b92abcdb1aaf2db1cda8a48040a Mon Sep 17 00:00:00 2001 From: Olav Loite Date: Fri, 13 Sep 2019 18:32:46 +0200 Subject: [PATCH] spanner: Set timeout of all integration tests to 5 minutes Some integration tests had timeouts of 60 or 120 seconds, others had no timeouts at all, while the majority had a timeout of 5 minutes. All integration tests that create and drop a test database have now been given a timeout of 5 minutes. This should reduce the chance that an integration test will fail because of a timeout during database creation or deletion. Updates #1571. Change-Id: I93283383789a75e009b5e9a1681e5e29ddf66517 Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/45411 Reviewed-by: kokoro Reviewed-by: Jean de Klerk --- spanner/integration_test.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/spanner/integration_test.go b/spanner/integration_test.go index 9be8d752f2d5..8dd1e9e15aae 100644 --- a/spanner/integration_test.go +++ b/spanner/integration_test.go @@ -169,7 +169,7 @@ func initIntegrationTests() func() { // Test SingleUse transaction. func TestIntegration_SingleUse(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() // Set up testing environment. client, _, cleanup := prepareIntegrationTest(ctx, t, singerDBStatements) @@ -365,7 +365,7 @@ func TestIntegration_SingleUse(t *testing.T) { } func TestIntegration_SingleUse_ReadingWithLimit(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() // Set up testing environment. client, _, cleanup := prepareIntegrationTest(ctx, t, singerDBStatements) @@ -622,7 +622,7 @@ func TestIntegration_UpdateDuringRead(t *testing.T) { // Test ReadWriteTransaction. func TestIntegration_ReadWriteTransaction(t *testing.T) { // Give a longer deadline because of transaction backoffs. - ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() client, _, cleanup := prepareIntegrationTest(ctx, t, singerDBStatements) defer cleanup() @@ -776,7 +776,7 @@ func TestIntegration_Reads(t *testing.T) { func TestIntegration_EarlyTimestamp(t *testing.T) { // Test that we can get the timestamp from a read-only transaction as // soon as we have read at least one row. - ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() // Set up testing environment. client, _, cleanup := prepareIntegrationTest(ctx, t, readDBStatements) @@ -821,7 +821,8 @@ func TestIntegration_EarlyTimestamp(t *testing.T) { func TestIntegration_NestedTransaction(t *testing.T) { // You cannot use a transaction from inside a read-write transaction. - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() client, _, cleanup := prepareIntegrationTest(ctx, t, singerDBStatements) defer cleanup() @@ -850,7 +851,7 @@ func TestIntegration_NestedTransaction(t *testing.T) { // Test client recovery on database recreation. func TestIntegration_DbRemovalRecovery(t *testing.T) { - ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) defer cancel() client, dbPath, cleanup := prepareIntegrationTest(ctx, t, singerDBStatements) defer cleanup() @@ -1130,7 +1131,8 @@ func TestIntegration_StructTypes(t *testing.T) { } func TestIntegration_StructParametersUnsupported(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() client, _, cleanup := prepareIntegrationTest(ctx, t, nil) defer cleanup() @@ -1172,7 +1174,8 @@ func TestIntegration_StructParametersUnsupported(t *testing.T) { // Test queries of the form "SELECT expr". func TestIntegration_QueryExpressions(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() client, _, cleanup := prepareIntegrationTest(ctx, t, nil) defer cleanup() @@ -1225,7 +1228,8 @@ func TestIntegration_QueryExpressions(t *testing.T) { } func TestIntegration_QueryStats(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() client, _, cleanup := prepareIntegrationTest(ctx, t, singerDBStatements) defer cleanup() @@ -1283,7 +1287,8 @@ func TestIntegration_InvalidDatabase(t *testing.T) { } func TestIntegration_ReadErrors(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() client, _, cleanup := prepareIntegrationTest(ctx, t, readDBStatements) defer cleanup() @@ -1894,8 +1899,8 @@ func TestIntegration_DML(t *testing.T) { } func TestIntegration_StructParametersBind(t *testing.T) { - t.Parallel() - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute) + defer cancel() client, _, cleanup := prepareIntegrationTest(ctx, t, nil) defer cleanup()