-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse syncAfterWrite in other ES tests
- Loading branch information
Showing
5 changed files
with
52 additions
and
35 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
metadata-io/src/test/java/com/linkedin/metadata/ElasticSearchTestUtils.java
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.linkedin.metadata; | ||
|
||
import org.elasticsearch.action.admin.indices.flush.FlushRequest; | ||
import org.elasticsearch.action.admin.indices.flush.FlushResponse; | ||
import org.elasticsearch.action.admin.indices.refresh.RefreshRequest; | ||
import org.elasticsearch.action.admin.indices.refresh.RefreshResponse; | ||
import org.elasticsearch.client.RequestOptions; | ||
import org.elasticsearch.client.RestHighLevelClient; | ||
|
||
public class ElasticSearchTestUtils { | ||
|
||
private ElasticSearchTestUtils() { | ||
} | ||
|
||
public static void syncAfterWrite(RestHighLevelClient searchClient) throws Exception { | ||
// flush changes in ES to disk | ||
FlushResponse fResponse = searchClient.indices().flush(new FlushRequest(), RequestOptions.DEFAULT); | ||
if (fResponse.getFailedShards() > 0) { | ||
throw new RuntimeException("Failed to flush " + fResponse.getFailedShards() + " of " + fResponse.getTotalShards() + " shards"); | ||
} | ||
|
||
// wait for all indices to be refreshed | ||
RefreshResponse rResponse = searchClient.indices().refresh(new RefreshRequest(), RequestOptions.DEFAULT); | ||
if (rResponse.getFailedShards() > 0) { | ||
throw new RuntimeException("Failed to refresh " + rResponse.getFailedShards() + " of " + rResponse.getTotalShards() + " shards"); | ||
} | ||
} | ||
|
||
} |
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
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