You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/04/22 19:47:55 UTC

[GitHub] [beam] damccorm commented on a diff in pull request #17449: [BEAM-14358] add retry to connect to testcontainer

damccorm commented on code in PR #17449:
URL: https://github.com/apache/beam/pull/17449#discussion_r856525412


##########
sdks/go/test/integration/io/xlang/jdbc/jdbc_test.go:
##########
@@ -68,9 +70,23 @@ func setupTestContainer(t *testing.T, ctx context.Context, dbname, username, pas
 		},
 		Started: true,
 	}
-	container, err := testcontainers.GenericContainer(ctx, req)
-	if err != nil {
-		t.Fatalf("failed to start container: %s", err)
+
+	strategy := retry.LimitCount(maxRetryCount,
+		retry.Exponential{
+			Initial: time.Second,
+			Factor:  2,
+		},
+	)
+	var container testcontainers.Container
+	var err error
+	for r := retry.Start(strategy, nil); r.Next(); {
+		container, err = testcontainers.GenericContainer(ctx, req)
+		if err == nil {
+			break
+		}
+		if r.Count() == maxRetryCount {
+			t.Fatalf("failed to start container: %v", err)

Review Comment:
   ```suggestion
   			t.Fatalf("failed to start container with %v retries: %v", maxRetryCount, err)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org