Skip to content

Commit 931134b

Browse files
authored
Add source_collection to indexMetaDatabase object and ignore newly added fields (#58)
## Problem `source_collection` is a newly added field in `indexMetaDatabase` object of describeIndex response body. But without adding it to the response body of describe index call, it breaks. ## Solution Added the field as well as added support to ignore newly added fields. ## Type of Change - [X] Bug fix (non-breaking change which fixes an issue) - [X] 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) - [ ] None of the above: (explain here) ## Test Plan Ran integration tests and added unit test for the same
1 parent 14224b6 commit 931134b

File tree

14 files changed

+104
-38
lines changed

14 files changed

+104
-38
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
[comment]: <> (When bumping [pc:VERSION_LATEST_RELEASE] create a new entry below)
44
### Unreleased version
5+
### v0.7.4
6+
- Add source_collection and support to ignore newly added fields to the response body for describeIndex's indexMetaDatabase object
7+
58
### v0.7.3
69
- Add assert with retry mechanism
710
- Add deprecation warning for queries parameter

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ Maven:
1515
<dependency>
1616
<groupId>io.pinecone</groupId>
1717
<artifactId>pinecone-client</artifactId>
18-
<version>0.7.3</version>
18+
<version>0.7.4</version>
1919
</dependency>
2020
```
2121

2222
[comment]: <> (^ [pc:VERSION_LATEST_RELEASE])
2323

2424
Gradle:
2525
```
26-
implementation "io.pinecone:pinecone-client:0.7.3"
26+
implementation "io.pinecone:pinecone-client:0.7.4"
2727
```
2828

2929
[comment]: <> (^ [pc:VERSION_LATEST_RELEASE])
3030

31-
Alternatively, you can use our standalone uberjar [pinecone-client-0.7.3-all.jar](https://repo1.maven.org/maven2/io/pinecone/pinecone-client/0.7.3/pinecone-client-0.7.3-all.jar), which bundles the pinecone client and all dependencies together inside a single jar. You can include this on your classpath like any 3rd party JAR without having to obtain the *pinecone-client* dependencies separately.
31+
Alternatively, you can use our standalone uberjar [pinecone-client-0.7.4-all.jar](https://repo1.maven.org/maven2/io/pinecone/pinecone-client/0.7.4/pinecone-client-0.7.4-all.jar), which bundles the pinecone client and all dependencies together inside a single jar. You can include this on your classpath like any 3rd party JAR without having to obtain the *pinecone-client* dependencies separately.
3232

3333
[comment]: <> (^ [pc:VERSION_LATEST_RELEASE])
3434

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pineconeClientVersion = 0.7.3
1+
pineconeClientVersion = 0.7.4

src/integration/java/io/pinecone/helpers/RetryAssert.java renamed to src/integration/java/io/pinecone/helpers/AssertRetry.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
package io.pinecone.helpers;
22

3+
import java.io.IOException;
34
import java.util.concurrent.ExecutionException;
45

5-
public class RetryAssert {
6+
public class AssertRetry {
67
private static final int maxRetry = 4;
78
private static int delay = 1500;
89

@@ -14,7 +15,7 @@ public static void assertWithRetry(AssertionRunnable assertionRunnable) throws I
1415
try {
1516
assertionRunnable.run();
1617
success = true;
17-
} catch (AssertionError | ExecutionException e) {
18+
} catch (AssertionError | ExecutionException | IOException e) {
1819
retryCount++;
1920
delay*=2;
2021
Thread.sleep(delay);
@@ -24,6 +25,6 @@ public static void assertWithRetry(AssertionRunnable assertionRunnable) throws I
2425

2526
@FunctionalInterface
2627
public interface AssertionRunnable {
27-
void run() throws AssertionError, ExecutionException, InterruptedException;
28+
void run() throws AssertionError, ExecutionException, InterruptedException, IOException;
2829
}
2930
}

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import java.io.IOException;
88
import java.util.List;
99

10+
import static io.pinecone.helpers.AssertRetry.assertWithRetry;
11+
1012
public class IndexManager {
1113
private static PineconeClientConfig config;
1214

@@ -67,15 +69,12 @@ private static String createNewIndex(int dimension, PineconeIndexOperationClient
6769

6870
public static IndexMeta isIndexReady(String indexName, PineconeIndexOperationClient indexOperationClient)
6971
throws IOException, InterruptedException {
70-
IndexMeta indexMeta;
71-
while (true) {
72-
indexMeta = indexOperationClient.describeIndex(indexName);
73-
if (indexMeta.getStatus().getState().equalsIgnoreCase("ready")) {
74-
break;
75-
}
76-
Thread.sleep(1000);
77-
}
72+
final IndexMeta[] indexMeta = new IndexMeta[1];
73+
assertWithRetry(() -> {
74+
indexMeta[0] = indexOperationClient.describeIndex(indexName);
75+
assert (indexMeta[0].getStatus().getState().equalsIgnoreCase("ready"));
76+
});
7877

79-
return indexMeta;
78+
return indexMeta[0];
8079
}
8180
}

src/integration/java/io/pinecone/integration/controlPlane/ConfigureIndexTest.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public void configureIndexWithInvalidIndexName() {
4343
try {
4444
isIndexReady(indexName, indexOperationClient);
4545
indexOperationClient.configureIndex("non-existent-index", configureIndexRequest);
46-
} catch (PineconeNotFoundException exception) {
47-
assert (exception.getLocalizedMessage().contains("404: Not Found"));
46+
} catch (PineconeNotFoundException notFoundException) {
47+
assert (notFoundException.getLocalizedMessage().toLowerCase().contains("not found"));
4848
} catch (IOException | InterruptedException exception) {
4949
logger.error(exception.toString());
5050
}
@@ -57,10 +57,8 @@ public void configureIndexExceedingQuota() {
5757
try {
5858
isIndexReady(indexName, indexOperationClient);
5959
indexOperationClient.configureIndex(indexName, configureIndexRequest);
60-
} catch (PineconeBadRequestException exception) {
61-
assert (exception.getLocalizedMessage().contains("The index exceeds the project quota"));
62-
assert (exception.getLocalizedMessage().contains("Upgrade your account or change" +
63-
" the project settings to increase the quota."));
60+
} catch (PineconeBadRequestException badRequestException) {
61+
assert (badRequestException.getLocalizedMessage().contains("Capacity Reached. Increase your quota or upgrade to create more indexes."));
6462
} catch (Exception exception) {
6563
logger.error(exception.toString());
6664
}
@@ -110,8 +108,8 @@ public void changingBasePodType() {
110108

111109
isIndexReady(indexName, indexOperationClient);
112110
indexOperationClient.configureIndex(indexName, configureIndexRequest);
113-
} catch (PineconeBadRequestException pineconeBadRequestException) {
114-
assertEquals(pineconeBadRequestException.getMessage(), "updating base pod type is not supported");
111+
} catch (PineconeBadRequestException badRequestException) {
112+
assertEquals(badRequestException.getMessage(), "Bad request: Cannot change pod type.");
115113
} catch (Exception exception) {
116114
logger.error(exception.getLocalizedMessage());
117115
}
@@ -166,7 +164,7 @@ public void sizeDown() throws IOException, InterruptedException {
166164
Thread.sleep(3500);
167165
} catch (Exception exception) {
168166
assertEquals(exception.getClass(), PineconeBadRequestException.class);
169-
assertEquals(exception.getMessage(), "scaling down pod type is not supported");
167+
assert(exception.getMessage().contains("Bad request: Cannot scale down an index, only up."));
170168
} finally {
171169
// Delete this index since it'll be unused for other tests
172170
indexOperationClient.deleteIndex(indexName);

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
import java.util.List;
1919

2020
import static io.pinecone.helpers.IndexManager.createIndexIfNotExistsDataPlane;
21-
import static io.pinecone.helpers.RetryAssert.assertWithRetry;
22-
import static org.hamcrest.MatcherAssert.assertThat;
23-
import static org.hamcrest.Matchers.equalTo;
24-
import static org.hamcrest.Matchers.notNullValue;
21+
import static io.pinecone.helpers.AssertRetry.assertWithRetry;
2522

2623
public class PineconeClientLiveIntegTest {
2724

@@ -155,8 +152,7 @@ public void sanity() throws InterruptedException {
155152

156153
assertWithRetry(() -> {
157154
QueryResponse queryResponse = blockingStub.query(queryByIdRequest);
158-
assertThat(queryResponse, notNullValue());
159-
assertThat(queryResponse.getMatchesCount(), equalTo(1));
155+
Assertions.assertEquals(queryResponse.getMatchesCount(),1);
160156
assert (queryResponse.getMatches(0).getValuesList().containsAll(updateValueList));
161157
});
162158

src/integration/java/io/pinecone/integration/dataplane/UpsertAndDescribeIndexStatsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import static io.pinecone.helpers.BuildUpsertRequest.*;
88
import static io.pinecone.helpers.IndexManager.createIndexIfNotExistsDataPlane;
9-
import static io.pinecone.helpers.RetryAssert.assertWithRetry;
9+
import static io.pinecone.helpers.AssertRetry.assertWithRetry;
1010
import static org.junit.jupiter.api.Assertions.assertEquals;
1111

1212
import java.io.IOException;

src/main/java/io/pinecone/PineconeClientConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private String maskedApiKey() {
139139
}
140140

141141
public String getUserAgent() {
142-
String userAgentLanguage = "lang=java; pineconeClientVersion = v0.7.3";
142+
String userAgentLanguage = "lang=java; pineconeClientVersion = v0.7.4";
143143
return (this.getUsageContext() != null) ?
144144
userAgentLanguage + "; usageContext=" + this.getUsageContext() : userAgentLanguage;
145145
}

src/main/java/io/pinecone/model/CreateIndexRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CreateIndexRequest {
1212

1313
private String metric = "cosine";
1414

15-
private Integer pods = 1;
15+
private Integer pods;
1616

1717
private Integer replicas = 1;
1818

0 commit comments

Comments
 (0)