Skip to content

Commit

Permalink
Merge pull request #231 from milderhc/test-failure-log
Browse files Browse the repository at this point in the history
Update Redis tests failure logs
  • Loading branch information
johnoliver authored Sep 26, 2024
2 parents 66f9dce + ac87802 commit 6600f4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ private static Stream<Arguments> provideSearchParameters() {
);
}

private final String indexingFailureMessage = "If you are running in a slow machine, data might not be indexed yet. Adjust setup delay if needed";

@ParameterizedTest
@MethodSource("provideSearchParameters")
public void search(RecordCollectionOptions options, String embeddingName) {
Expand All @@ -385,9 +387,9 @@ public void search(RecordCollectionOptions options, String embeddingName) {
// Embeddings similar to the third hotel
List<VectorSearchResult<Hotel>> results = recordCollection.searchAsync(SEARCH_EMBEDDINGS, searchOptions).block();
assertNotNull(results);
assertEquals(VectorSearchOptions.DEFAULT_RESULT_LIMIT, results.size());
assertEquals(VectorSearchOptions.DEFAULT_RESULT_LIMIT, results.size(), indexingFailureMessage);
// The third hotel should be the most similar
assertEquals(hotels.get(2).getId(), results.get(0).getRecord().getId());
assertEquals(hotels.get(2).getId(), results.get(0).getRecord().getId(), indexingFailureMessage);
// Score should be different than zero
assertNotEquals(0.0, results.get(0).getScore());
assertNull(results.get(0).getRecord().getEuclidean());
Expand All @@ -410,9 +412,9 @@ public void searchWithVectors(RecordCollectionOptions options, String embeddingN
// Embeddings similar to the third hotel
List<VectorSearchResult<Hotel>> results = recordCollection.searchAsync(SEARCH_EMBEDDINGS, searchOptions).block();
assertNotNull(results);
assertEquals(VectorSearchOptions.DEFAULT_RESULT_LIMIT, results.size());
assertEquals(VectorSearchOptions.DEFAULT_RESULT_LIMIT, results.size(), indexingFailureMessage);
// The third hotel should be the most similar
assertEquals(hotels.get(2).getId(), results.get(0).getRecord().getId());
assertEquals(hotels.get(2).getId(), results.get(0).getRecord().getId(), indexingFailureMessage);
assertNotNull(results.get(0).getRecord().getEuclidean());
}

Expand All @@ -434,8 +436,8 @@ public void searchWithOffSet(RecordCollectionOptions options, String embeddingNa
// Embeddings similar to the third hotel
List<VectorSearchResult<Hotel>> results = recordCollection.searchAsync(SEARCH_EMBEDDINGS, searchOptions).block();
assertNotNull(results);
assertEquals(4, results.size());
assertEquals(4, results.size(), indexingFailureMessage);
// The first hotel should be the most similar
assertEquals(hotels.get(0).getId(), results.get(0).getRecord().getId());
assertEquals(hotels.get(0).getId(), results.get(0).getRecord().getId(), indexingFailureMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,8 @@ private static Stream<Arguments> provideSearchParameters() {
);
}

private final String indexingFailureMessage = "If you are running in a slow machine, data might not be indexed yet. Adjust setup delay if needed";

@ParameterizedTest
@MethodSource("provideSearchParameters")
public void search(RecordCollectionOptions options, String embeddingName) {
Expand All @@ -385,9 +387,9 @@ public void search(RecordCollectionOptions options, String embeddingName) {
// Embeddings similar to the third hotel
List<VectorSearchResult<Hotel>> results = recordCollection.searchAsync(SEARCH_EMBEDDINGS, searchOptions).block();
assertNotNull(results);
assertEquals(VectorSearchOptions.DEFAULT_RESULT_LIMIT, results.size());
assertEquals(VectorSearchOptions.DEFAULT_RESULT_LIMIT, results.size(), indexingFailureMessage);
// The third hotel should be the most similar
assertEquals(hotels.get(2).getId(), results.get(0).getRecord().getId());
assertEquals(hotels.get(2).getId(), results.get(0).getRecord().getId(), indexingFailureMessage);
// Score should be different than zero
assertNotEquals(0.0, results.get(0).getScore());
assertNull(results.get(0).getRecord().getEuclidean());
Expand All @@ -410,9 +412,9 @@ public void searchWithVectors(RecordCollectionOptions options, String embeddingN
// Embeddings similar to the third hotel
List<VectorSearchResult<Hotel>> results = recordCollection.searchAsync(SEARCH_EMBEDDINGS, searchOptions).block();
assertNotNull(results);
assertEquals(VectorSearchOptions.DEFAULT_RESULT_LIMIT, results.size());
assertEquals(VectorSearchOptions.DEFAULT_RESULT_LIMIT, results.size(), indexingFailureMessage);
// The third hotel should be the most similar
assertEquals(hotels.get(2).getId(), results.get(0).getRecord().getId());
assertEquals(hotels.get(2).getId(), results.get(0).getRecord().getId(), indexingFailureMessage);
assertNotNull(results.get(0).getRecord().getEuclidean());
}

Expand All @@ -434,8 +436,8 @@ public void searchWithOffSet(RecordCollectionOptions options, String embeddingNa
// Embeddings similar to the third hotel
List<VectorSearchResult<Hotel>> results = recordCollection.searchAsync(SEARCH_EMBEDDINGS, searchOptions).block();
assertNotNull(results);
assertEquals(4, results.size());
assertEquals(4, results.size(), indexingFailureMessage);
// The first hotel should be the most similar
assertEquals(hotels.get(0).getId(), results.get(0).getRecord().getId());
assertEquals(hotels.get(0).getId(), results.get(0).getRecord().getId(), indexingFailureMessage);
}
}

0 comments on commit 6600f4a

Please sign in to comment.