-
Notifications
You must be signed in to change notification settings - Fork 79
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
[Chore] Improve test flakes #404
Changes from all commits
d3fcd42
c2cd842
dcc8ce1
2e17ea6
e9fdc2a
f759563
a1aa9c6
9076b70
b632d4b
57b45fe
d23ab4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import re | ||
from pinecone import Pinecone | ||
from datetime import datetime, timedelta | ||
import time | ||
|
||
|
||
def delete_everything(pc): | ||
|
@@ -16,6 +17,30 @@ def delete_everything(pc): | |
for index in pc.list_indexes().names(): | ||
try: | ||
print("Deleting index: " + index) | ||
desc = pc.describe_index(index) | ||
|
||
# Check whether index can be deleted | ||
if desc.deletion_protection == "enabled": | ||
pc.configure_index(index, deletion_protection="disabled") | ||
|
||
# Wait for index to be ready before deleting | ||
ready_to_delete = False | ||
max_wait = 60 | ||
time_waited = 0 | ||
while not ready_to_delete: | ||
desc = pc.describe_index(index) | ||
if desc.status.state == "Ready": | ||
ready_to_delete = True | ||
break | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why both a break and boolean flag? could just loop/break? |
||
else: | ||
print("Index is not ready yet. Waiting for 2 seconds.") | ||
time.sleep(2) | ||
time_waited += 2 | ||
|
||
if time_waited > max_wait: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. small nit: because of logic ordering, you end up sleeping for 2 seconds before failing on the last iteration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is what comes from outsourcing too much typing to github copilot 🤣 |
||
print(f"Timed out waiting for index {index} to be ready") | ||
break | ||
|
||
pc.delete_index(index) | ||
except Exception as e: | ||
print("Failed to delete index: " + index + " " + str(e)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can delete in other states as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would think, wouldn't you? Maybe this is true in some cases, but a lot of flakes seen in the past are about trying to delete while the index is "upgrading". I.e. if you called configure index too recently, your delete request will be rejected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually changed all my integration tests to check both
status.state
andstatus.ready
. There are situations where they are not in sync, and the index is marked as Ready but then the state is something else.I'd maybe recommend checking both just to be thorough, it's helped with some of my flakiness. I think @aulorbe reported this to the db team at some point.