Skip to content

Commit

Permalink
multiple attempts for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetmeleq committed Nov 3, 2023
1 parent cf77315 commit 17c724b
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions test_unstructured_ingest/test-ingest-pinecone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,28 @@ PYTHONPATH=. ./unstructured/ingest/main.py \
--index-name "$PINECONE_INDEX" \
--environment "$PINECONE_ENVIRONMENT"

sleep 15
num_of_vectors_remote=$(curl --request POST \
-s \
--url "https://$PINECONE_INDEX-$PINECONE_PROJECT_ID.svc.$PINECONE_ENVIRONMENT.pinecone.io/describe_index_stats" \
--header "accept: application/json" \
--header "content-type: application/json" \
--header "Api-Key: $PINECONE_API_KEY" | jq -r '.totalVectorCount')
# It can take some time for the index to catch up with the content that was written, this check between 10s sleeps
# to give it that time process the writes. Will timeout after checking for a minute.
num_of_vectors_remote=0
attempt=1
sleep_amount=8
while [ "$num_of_vectors_remote" -eq 0 ] && [ "$attempt" -lt 4 ]; do
echo "attempt $attempt: sleeping $sleep_amount seconds to let index finish catching up after writes"
sleep $sleep_amount

num_of_vectors_remote=$(curl --request POST \
-s \
--url "https://$PINECONE_INDEX-$PINECONE_PROJECT_ID.svc.$PINECONE_ENVIRONMENT.pinecone.io/describe_index_stats" \
--header "accept: application/json" \
--header "content-type: application/json" \
--header "Api-Key: $PINECONE_API_KEY" | jq -r '.totalVectorCount')

echo "vector count in Pinecone: $num_of_vectors_remote"
attempt=$((attempt+1))
done

EXPECTED=3

if [ "$num_of_vectors_remote" -ne $EXPECTED ];then
echo "Number of vectors in Pinecone are $num_of_vectors_remote when the expected number is $EXPECTED. Test failed."
exit 1
Expand Down

0 comments on commit 17c724b

Please sign in to comment.