diff --git a/pkg/kv/cosmosdb/main_test.go b/pkg/kv/cosmosdb/main_test.go index 050f74df571..e6edcac47c2 100644 --- a/pkg/kv/cosmosdb/main_test.go +++ b/pkg/kv/cosmosdb/main_test.go @@ -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) @@ -72,14 +72,21 @@ func TestMain(m *testing.M) { } defer cleanupFunc() + const clientTimeout = 30 * time.Second testParams = &kvparams.CosmosDB{ Endpoint: databaseURI, Key: "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", Database: "test-db", - Client: &http.Client{Timeout: 30 * time.Second, Transport: &http.Transport{ - // tests, safe - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec // ignore self-signed cert for local testing using the emulator - }}, + Client: &http.Client{ + Timeout: clientTimeout, + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{ + // ignore self-signed cert for local testing using the emulator + //nolint:gosec + InsecureSkipVerify: true, + }, + }, + }, StrongConsistency: false, } diff --git a/pkg/testutil/cosmosdb.go b/pkg/testutil/cosmosdb.go index e481932e50c..68756c32269 100644 --- a/pkg/testutil/cosmosdb.go +++ b/pkg/testutil/cosmosdb.go @@ -26,7 +26,7 @@ func GetCosmosDBInstance() (string, func(), error) { cosmosdbDockerRunOptions := &dockertest.RunOptions{ Repository: "mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator", - Tag: "latest", + Tag: "vnext-preview", Env: []string{ "AZURE_COSMOS_EMULATOR_PARTITION_COUNT=100", }, @@ -59,6 +59,14 @@ func GetCosmosDBInstance() (string, func(), error) { return "", nil, fmt.Errorf("joining urls: %w", err) } + const clientTimeout = 5 * time.Second + client := http.Client{ + Transport: &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, //nolint:gosec // ignore self-signed cert for local testing using the emulator + }, + Timeout: clientTimeout, + } + 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 @@ -66,9 +74,6 @@ func GetCosmosDBInstance() (string, 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