-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add collections operations to
PineconeControlPlaneClient
with integ…
…ration tests (#65) ## Problem The Java SDK is currently missing collections functionality. Now that we've added generated code for the OpenAPI spec, we can hook up collections operations in `PineconeControlPlaneClient`. We'd also like to add integration tests to cover collections. ## Solution - Update `PineconeControlPlaneClient` to include collections operations for create, list, delete, and describe. - Add new integration test files: `CollectionTest` and `CollectionErrorTest`. - Add new helpers to `IndexManager` for creating and connecting to an index by `indexName`, creating a collection and waiting for it to be ready, and polling until an index is ready. - Add new helper to `BuildUpsertRequest` for generating vectors by dimension. Bonuses: - I added some logging configs in `build.gradle` for `test` and the `integrationTest` task. This was primarily to help me debug things in CI and log a bit more info to the console. We can tweak as needed, but I think having something like this will be really helpful as opposed to the generic output. - Set `max-parallel: 1` in the `integration-test` job in the `pr.yml` workflow. Because of the way `findIndexWithDimensionAndType` works we cannot run integration tests in parallel without flakiness. - Fixed an issue in `AssertRetry`. We were incrementing `delay` at the class level which is a static variable, meaning if you re-used the function in one place it would continue increasing the delay for all subsequent calls based on the `backOff`. ## Type of Change - [X] New feature (non-breaking change which adds functionality) ## Test Plan Run integration tests to make sure `CollectionTest` and `CollectionErrorTest` pass as expected. Integration tests should also be passing in CI barring any flakiness.
- Loading branch information
1 parent
051b696
commit 20a38ac
Showing
15 changed files
with
577 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,43 @@ | ||
package io.pinecone.helpers; | ||
|
||
import io.pinecone.exceptions.PineconeException; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.ExecutionException; | ||
|
||
public class AssertRetry { | ||
private static final int maxRetry = 4; | ||
private static int delay = 1500; | ||
private static final int delay = 1500; | ||
|
||
public static void assertWithRetry(AssertionRunnable assertionRunnable) throws InterruptedException { | ||
public static void assertWithRetry(AssertionRunnable assertionRunnable) throws InterruptedException, PineconeException { | ||
assertWithRetry(assertionRunnable, 2); | ||
} | ||
|
||
public static void assertWithRetry(AssertionRunnable assertionRunnable, int backOff) throws InterruptedException { | ||
public static void assertWithRetry(AssertionRunnable assertionRunnable, int backOff) throws AssertionError, InterruptedException { | ||
int retryCount = 0; | ||
int delayCount = delay; | ||
boolean success = false; | ||
String errorMessage = null; | ||
|
||
while (retryCount < maxRetry && !success) { | ||
try { | ||
assertionRunnable.run(); | ||
success = true; | ||
} catch (AssertionError | ExecutionException | IOException e) { | ||
errorMessage = e.getLocalizedMessage(); | ||
retryCount++; | ||
delay*=backOff; | ||
Thread.sleep(delay); | ||
delayCount*=backOff; | ||
Thread.sleep(delayCount); | ||
} | ||
} | ||
|
||
if (!success) { | ||
throw new AssertionError(errorMessage); | ||
} | ||
} | ||
|
||
@FunctionalInterface | ||
public interface AssertionRunnable { | ||
void run() throws AssertionError, ExecutionException, InterruptedException, IOException; | ||
void run() throws AssertionError, ExecutionException, InterruptedException, IOException, PineconeException; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.