Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: kv test cosmosdb increase timeout while waiting for container #8660

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 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 Expand Up @@ -72,13 +72,17 @@ 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{
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{InsecureSkipVerify: true}, //nolint:gosec // ignore self-signed cert for local testing using the emulator
},
},
StrongConsistency: false,
}

Expand Down
13 changes: 9 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,21 @@ 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
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
Loading