From e039c604807c52cbbce56582a0d22073338d1e3f Mon Sep 17 00:00:00 2001 From: Slach Date: Mon, 4 Nov 2024 14:26:28 +0400 Subject: [PATCH] more iterations in tests for connectWithWait, "no port 9000/tcp for container projectX-clickhouse-1" Signed-off-by: Slach --- test/integration/integration_test.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/integration/integration_test.go b/test/integration/integration_test.go index 57b6d8bb..19468afd 100644 --- a/test/integration/integration_test.go +++ b/test/integration/integration_test.go @@ -3102,11 +3102,16 @@ func (env *TestEnvironment) connect(timeOut string) error { time.Sleep(1 * time.Second) } env.ch = &clickhouse.ClickHouse{Config: &config.ClickHouseConfig{}} - for i := 0; i < 3; i++ { + portMaxTry := 3 + for i := 1; i <= portMaxTry; i++ { portOut, portErr := utils.ExecCmdOut(context.Background(), 10*time.Second, "docker", append(env.GetDefaultComposeCommand(), "port", "clickhouse", "9000")...) if portErr != nil { log.Error().Msg(portOut) - log.Fatal().Msgf("%s can't get port for clickhouse: %v", env.ProjectName, portErr) + if i == portMaxTry { + log.Fatal().Msgf("%s can't get port for clickhouse: %v", env.ProjectName, portErr) + } + time.Sleep(500 * time.Millisecond) + continue } hostAndPort := strings.Split(strings.Trim(portOut, " \r\n\t"), ":") if len(hostAndPort) < 1 { @@ -3125,7 +3130,7 @@ func (env *TestEnvironment) connect(timeOut string) error { return nil } - if i == 2 { + if i == portMaxTry { return err } time.Sleep(500 * time.Millisecond)