Skip to content

Commit 9bf455d

Browse files
committed
cosmosdb test client 5s timeout with 7 min retry connect to container
1 parent 4e569da commit 9bf455d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

pkg/kv/cosmosdb/main_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ var (
2626
)
2727

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

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

3636
databaseClient, err := client.NewDatabase(testParams.Database)

pkg/testutil/cosmosdb.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
const (
1515
CosmosDBLocalPort = "8081"
16-
maxWait = 5 * time.Minute // Cosmosdb emulator takes time to start
16+
maxWait = 7 * time.Minute // Cosmosdb emulator takes time to start
1717
)
1818

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

62+
client := http.Client{
63+
Transport: &http.Transport{
64+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec // ignore self-signed cert for local testing using the emulator
65+
},
66+
Timeout: 5 * time.Second,
67+
}
68+
6269
dockerPool.MaxWait = maxWait
6370
log.Printf("Waiting up to %v for emulator to start", dockerPool.MaxWait)
6471
// Note: this hangs for macOS users, and fails. See https://github.com/treeverse/lakeFS/issues/8476
6572
err = dockerPool.Retry(func() error {
6673
// waiting for cosmosdb container to be ready by issuing an HTTP get request with
6774
// exponential backoff retry. The response is not really meaningful for that case
6875
// and so is ignored
69-
client := http.Client{Transport: &http.Transport{
70-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec // ignore self-signed cert for local testing using the emulator
71-
}}
7276
resp, err := client.Get(p)
7377
if err != nil {
7478
return err

0 commit comments

Comments
 (0)