Skip to content

Commit

Permalink
spanner: Set timeout of all integration tests to 5 minutes
Browse files Browse the repository at this point in the history
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 <noreply+kokoro@google.com>
Reviewed-by: Jean de Klerk <deklerk@google.com>
  • Loading branch information
olavloite committed Sep 16, 2019
1 parent 21ffce3 commit c981458
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions spanner/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit c981458

Please sign in to comment.