Skip to content

Commit f28ce34

Browse files
authored
Add update, fetch, and query integration tests (#51)
## Problem The sdk currently lacks integration tests for updating, fetching, and querying records. ## Solution Added integration tests for sync and future stubs by: 1. Upserting required + optional parameters vectors 2. Fetch to verify the vectors were upserted 3a. Update the values of the required param vector and query to verify 3b. Update the values and optional params of the required param vector and query to verify 3c: Update the values and optional params of the optional param vector and query to verify Query by filter, id, vectors, and failing tests were also added. ## Type of Change - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [X] None of the above: (explain here) Integration tests ## Test Plan Verified by running integration tests locally.
1 parent 5426722 commit f28ce34

File tree

3 files changed

+438
-3
lines changed

3 files changed

+438
-3
lines changed

src/integration/java/io/pinecone/PineconeClientLiveIntegTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ public void sanity() throws Exception {
120120
fetchRequest = FetchRequest.newBuilder().addIds("v1").setNamespace(namespace).build();
121121
conn.getBlockingStub().fetch(fetchRequest);
122122

123-
// DEPRECATED: batch queries
123+
// DEPRECATED: all methods related to queries in QueryVector
124+
// Use methods related to Vector. Example: addVector, addAllVector, etc.
124125
float[] rawVector = {1.0F, 2.0F, 3.0F};
125126
QueryVector queryVector = QueryVector.newBuilder()
126127
.addAllValues(Floats.asList(rawVector))
@@ -136,6 +137,8 @@ public void sanity() throws Exception {
136137
.build();
137138

138139
QueryRequest batchQueryRequest = QueryRequest.newBuilder()
140+
// DEPRECATED: addQueries() and addAllQueries()
141+
// Please use addVector() or addAllVector() instead
139142
.addQueries(queryVector)
140143
.setNamespace(namespace)
141144
.setTopK(2)

src/integration/java/io/pinecone/helpers/BuildUpsertRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
public class BuildUpsertRequest {
1616
private static final float[][] upsertData = {{1.0F, 2.0F, 3.0F}, {4.0F, 5.0F, 6.0F}, {7.0F, 8.0F, 9.0F}};
1717
public static final String[] metadataFields = new String[]{"genre", "year"};
18+
public static final List<Integer> sparseIndices = Arrays.asList(0, 1, 2);
19+
public static final List<Float> sparseValues = Arrays.asList(0.11f, 0.22f, 0.33f);
1820
public static UpsertRequest buildRequiredUpsertRequest() {
1921
return buildRequiredUpsertRequest(new ArrayList<>(), "");
2022
}
@@ -24,6 +26,7 @@ public static UpsertRequest buildRequiredUpsertRequest(String namespace) {
2426
}
2527

2628
public static UpsertRequest buildRequiredUpsertRequest(List<String> upsertIds, String namespace) {
29+
// Namespace is not mandatory but added for each test, so they are independent
2730
if (upsertIds.isEmpty()) upsertIds = Arrays.asList("v1", "v2", "v3");
2831
if (namespace.isEmpty()) namespace = RandomStringBuilder.build("ns", 8);
2932

@@ -59,8 +62,6 @@ public static UpsertRequest buildOptionalUpsertRequest(List<String> upsertIds, S
5962
if(metadataMap.isEmpty()) metadataMap = createAndGetMetadataMap();
6063

6164
List<Vector> hybridVectors = new ArrayList<>();
62-
List<Integer> sparseIndices = Arrays.asList(0, 1, 2);
63-
List<Float> sparseValues = Arrays.asList(0.11f, 0.22f, 0.33f);
6465

6566
for (int i = 0; i < upsertIds.size(); i++) {
6667
String field1 = metadataFields[i % metadataFields.length];

0 commit comments

Comments
 (0)