Skip to content

Commit

Permalink
add small retry mechanism for integration test cleanup when deletion …
Browse files Browse the repository at this point in the history
…fails
  • Loading branch information
austin-denoble committed Oct 16, 2024
1 parent 5951a3d commit 13ae2c7
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pinecone/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,19 @@ func (ts *IntegrationTests) TearDownSuite() {
_, err = WaitUntilIndexReady(ts, ctx)
require.NoError(ts.T(), err)
err = ts.client.DeleteIndex(ctx, ts.idxName)

// If the index failed to delete, wait a bit and retry cleaning up
// Somtimes indexes are stuck upgrading, or have pending collections
retry := 4
for err != nil || retry > 0 {
time.Sleep(5 * time.Second)
fmt.Printf("Failed to delete index \"%s\". Retrying... (%d/4)\n", ts.idxName, 5-retry)
err = ts.client.DeleteIndex(ctx, ts.idxName)
retry--
}

if err != nil {
fmt.Printf("Failed to delete index during test cleanup: %v\n", err)
fmt.Printf("Failed to delete index \"%s\" after 4 retries: %v\n", ts.idxName, err)
}

fmt.Printf("\n %s setup suite torn down successfully\n", ts.indexType)
Expand Down

0 comments on commit 13ae2c7

Please sign in to comment.