use of org.opensearch.client.WarningsHandler in project OpenSearch by opensearch-project.
the class VersionSensitiveWarningsHandlerTests method testSameVersionCluster.
public void testSameVersionCluster() throws IOException {
Set<Version> nodeVersions = new HashSet<>();
nodeVersions.add(Version.CURRENT);
WarningsHandler handler = expectVersionSpecificWarnings(nodeVersions, (v) -> {
v.current("expectedCurrent1");
});
assertFalse(handler.warningsShouldFailRequest(Arrays.asList("expectedCurrent1")));
assertTrue(handler.warningsShouldFailRequest(Arrays.asList("expectedCurrent1", "unexpected")));
assertFalse(handler.warningsShouldFailRequest(Collections.emptyList()));
}
use of org.opensearch.client.WarningsHandler in project OpenSearch by opensearch-project.
the class VersionSensitiveWarningsHandlerTests method testMixedVersionCluster.
public void testMixedVersionCluster() throws IOException {
Set<Version> nodeVersions = new HashSet<>();
nodeVersions.add(Version.CURRENT);
nodeVersions.add(Version.CURRENT.minimumIndexCompatibilityVersion());
WarningsHandler handler = expectVersionSpecificWarnings(nodeVersions, (v) -> {
v.current("expectedCurrent1");
v.compatible("Expected legacy warning");
});
assertFalse(handler.warningsShouldFailRequest(Arrays.asList("expectedCurrent1")));
assertFalse(handler.warningsShouldFailRequest(Arrays.asList("Expected legacy warning")));
assertFalse(handler.warningsShouldFailRequest(Arrays.asList("expectedCurrent1", "Expected legacy warning")));
assertTrue(handler.warningsShouldFailRequest(Arrays.asList("expectedCurrent1", "Unexpected legacy warning")));
assertTrue(handler.warningsShouldFailRequest(Arrays.asList("Unexpected legacy warning")));
assertFalse(handler.warningsShouldFailRequest(Collections.emptyList()));
}
use of org.opensearch.client.WarningsHandler in project OpenSearch by opensearch-project.
the class OpenSearchRestTestCase method allowTypesRemovalWarnings.
/**
* Creates RequestOptions designed to ignore [types removal] warnings but nothing else
* @deprecated this method is only required while we deprecate types and can be removed in 8.0
*/
@Deprecated
public static RequestOptions allowTypesRemovalWarnings() {
Builder builder = RequestOptions.DEFAULT.toBuilder();
builder.setWarningsHandler(new WarningsHandler() {
@Override
public boolean warningsShouldFailRequest(List<String> warnings) {
for (String warning : warnings) {
if (warning.startsWith("[types removal]") == false) {
// Something other than a types removal message - return true
return true;
}
}
return false;
}
});
return builder.build();
}
Aggregations