Skip to content

Commit

Permalink
cosmosdb test client 5s timeout with 7 min retry connect to container
Browse files Browse the repository at this point in the history
  • Loading branch information
nopcoder committed Feb 16, 2025
1 parent 4e569da commit 9bf455d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/kv/cosmosdb/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ var (
)

func TestCosmosDB(t *testing.T) {
kvtest.DriverTest(t, func(t testing.TB, ctx context.Context) kv.Store {
if runtime.GOOS == "darwin" {
t.Skipf("this test hangs for macOS users, and fails. skipping - see Issue#8476 for more details")
}
if runtime.GOOS == "darwin" {
t.Skipf("this test hangs for macOS users, and fails. skipping - see Issue#8476 for more details")
}

kvtest.DriverTest(t, func(t testing.TB, ctx context.Context) kv.Store {
t.Helper()

databaseClient, err := client.NewDatabase(testParams.Database)
Expand Down
12 changes: 8 additions & 4 deletions pkg/testutil/cosmosdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

const (
CosmosDBLocalPort = "8081"
maxWait = 5 * time.Minute // Cosmosdb emulator takes time to start
maxWait = 7 * time.Minute // Cosmosdb emulator takes time to start
)

var cosmosdbLocalURI string
Expand Down Expand Up @@ -59,16 +59,20 @@ func GetCosmosDBInstance() (string, func(), error) {
return "", nil, fmt.Errorf("joining urls: %w", err)
}

client := http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec // ignore self-signed cert for local testing using the emulator
},
Timeout: 5 * time.Second,

Check failure on line 66 in pkg/testutil/cosmosdb.go

View workflow job for this annotation

GitHub Actions / Run Linters and Checkers

Magic number: 5, in <assign> detected (mnd)
}

dockerPool.MaxWait = maxWait
log.Printf("Waiting up to %v for emulator to start", dockerPool.MaxWait)
// Note: this hangs for macOS users, and fails. See https://github.com/treeverse/lakeFS/issues/8476
err = dockerPool.Retry(func() error {
// waiting for cosmosdb container to be ready by issuing an HTTP get request with
// exponential backoff retry. The response is not really meaningful for that case
// and so is ignored
client := http.Client{Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec // ignore self-signed cert for local testing using the emulator
}}
resp, err := client.Get(p)
if err != nil {
return err
Expand Down

0 comments on commit 9bf455d

Please sign in to comment.