Skip to content

Commit

Permalink
Add more log for testing
Browse files Browse the repository at this point in the history
Signed-off-by: Tianli Feng <ftianli@amazon.com>
  • Loading branch information
Tianli Feng authored and tlfeng committed Aug 4, 2023
1 parent 675acdb commit b0a49a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ public void testScrollCreatedOnReplica() throws Exception {
final IndexShard replicaShard = getIndexShard(replica, INDEX_NAME);
final SegmentInfos segmentInfos = replicaShard.getLatestSegmentInfosAndCheckpoint().v1().get();
final Collection<String> snapshottedSegments = segmentInfos.files(false);
logger.info("snapshotted segments: " + snapshottedSegments);
// opens a scrolled query before a flush is called.
// this is for testing scroll segment consistency between refresh and flush
SearchResponse searchResponse = client(replica).prepareSearch()
Expand All @@ -982,8 +983,10 @@ public void testScrollCreatedOnReplica() throws Exception {
.setScroll(TimeValue.timeValueDays(1))
.get();

logger.info("before flush");
// force call flush
flush(INDEX_NAME);
logger.info("after flush");

for (int i = 3; i < 50; i++) {
client().prepareDelete(INDEX_NAME, String.valueOf(i)).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get();
Expand Down Expand Up @@ -1014,14 +1017,17 @@ public void testScrollCreatedOnReplica() throws Exception {
scrollHits += searchResponse.getHits().getHits().length;
searchResponse = client(replica).prepareSearchScroll(searchResponse.getScrollId()).setScroll(TimeValue.timeValueDays(1)).get();
assertAllSuccessful(searchResponse);
logger.info("scrollHits: " + scrollHits + ". scroll id: " + searchResponse.getScrollId());
} while (searchResponse.getHits().getHits().length > 0);

List<String> currentFiles = List.of(replicaShard.store().directory().listAll());
logger.info("currentFiles: " + currentFiles);
assertTrue("Files should be preserved", currentFiles.containsAll(snapshottedSegments));

client(replica).prepareClearScroll().addScrollId(searchResponse.getScrollId()).get();

currentFiles = List.of(replicaShard.store().directory().listAll());
logger.info("currentFiles after clearing scroll: " + currentFiles);
assertFalse("Files should be cleaned up post scroll clear request", currentFiles.containsAll(snapshottedSegments));
assertEquals(100, scrollHits);
}
Expand Down
1 change: 1 addition & 0 deletions server/src/main/java/org/opensearch/index/store/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ public void close() {
public void deleteFile(String msg, String name) throws IOException {
deletesLogger.trace("{}: delete file {}", msg, name);
super.deleteFile(name);
deletesLogger.info("{}: delete file {}", msg, name);
}

@Override
Expand Down

0 comments on commit b0a49a6

Please sign in to comment.