test(bigtable): fix flaky CreateInstance integration test
Addresses , by extending timeout on Context and putting in retry logic.
Fixes
Fixes
@@ -1462,7 +1462,7 @@ func TestIntegration_AdminCreateInstance(t *testing.T) {
t.Skip("emulator doesn't support instance creation")
}
- timeout := 5 * time.Minute
+ timeout := 7 * time.Minute
ctx, _ := context.WithTimeout(context.Background(), timeout)
iAdminClient, err := testEnv.NewInstanceAdminClient()
@@ -1482,9 +1482,13 @@ func TestIntegration_AdminCreateInstance(t *testing.T) {
InstanceType: DEVELOPMENT,
Labels: map[string]string{"test-label-key": "test-label-value"},
}
+
+ // CreateInstance can be flaky; retry 3 times before marking as failing.
+ testutil.Retry(t, 3, 5*time.Second, func(r *testutil.R) {
if err := iAdminClient.CreateInstance(ctx, conf); err != nil {
t.Fatalf("CreateInstance: %v", err)
}
+ })
defer iAdminClient.DeleteInstance(ctx, instanceToCreate)
@@ -1743,7 +1747,7 @@ func TestIntegration_AdminUpdateInstanceLabels(t *testing.T) {
}
// Create an instance admin client
- timeout := 5 * time.Minute
+ timeout := 7 * time.Minute
ctx, _ := context.WithTimeout(context.Background(), timeout)
iAdminClient, err := testEnv.NewInstanceAdminClient()
if err != nil {
@@ -1759,9 +1763,12 @@ func TestIntegration_AdminUpdateInstanceLabels(t *testing.T) {
InstanceType: DEVELOPMENT,
Zone: instanceToCreateZone,
}
+
+ testutil.Retry(t, 3, 5*time.Second, func(R *testutil.R) {
if err := iAdminClient.CreateInstance(ctx, conf); err != nil {
t.Fatalf("CreateInstance: %v", err)
}
+ })
defer iAdminClient.DeleteInstance(ctx, instanceToCreate)
// Check the created test instances
