use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class AbstractSimpleTransportTestCase method testHandshakeWithIncompatVersion.
public void testHandshakeWithIncompatVersion() {
assumeTrue("only tcp transport has a handshake method", serviceA.getOriginalTransport() instanceof TcpTransport);
Version version = LegacyESVersion.fromString("6.0.0");
try (MockTransportService service = buildService("TS_C", version, Settings.EMPTY)) {
service.start();
service.acceptIncomingRequests();
TransportAddress address = service.boundAddress().publishAddress();
DiscoveryNode node = new DiscoveryNode("TS_TPC", "TS_TPC", address, emptyMap(), emptySet(), version0);
ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
builder.addConnections(1, TransportRequestOptions.Type.BULK, TransportRequestOptions.Type.PING, TransportRequestOptions.Type.RECOVERY, TransportRequestOptions.Type.REG, TransportRequestOptions.Type.STATE);
expectThrows(ConnectTransportException.class, () -> serviceA.openConnection(node, builder.build()));
}
}
use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class AbstractSimpleTransportTestCase method testHandshakeUpdatesVersion.
public void testHandshakeUpdatesVersion() throws IOException {
assumeTrue("only tcp transport has a handshake method", serviceA.getOriginalTransport() instanceof TcpTransport);
Version version = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.CURRENT);
try (MockTransportService service = buildService("TS_C", version, Settings.EMPTY)) {
service.start();
service.acceptIncomingRequests();
TransportAddress address = service.boundAddress().publishAddress();
DiscoveryNode node = new DiscoveryNode("TS_TPC", "TS_TPC", address, emptyMap(), emptySet(), LegacyESVersion.fromString("2.0.0"));
ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
builder.addConnections(1, TransportRequestOptions.Type.BULK, TransportRequestOptions.Type.PING, TransportRequestOptions.Type.RECOVERY, TransportRequestOptions.Type.REG, TransportRequestOptions.Type.STATE);
try (Transport.Connection connection = serviceA.openConnection(node, builder.build())) {
// OpenSearch [1.0:3.0) in bwc mode should only "upgrade" to Legacy v7.10.2
assertEquals(connection.getVersion(), version.onOrAfter(Version.V_1_0_0) && version.before(V_3_0_0) ? LegacyESVersion.V_7_10_2 : version);
}
}
}
use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class VersionUtilsTests method testGradleVersionsMatchVersionUtils.
/**
* Tests that {@link Version#minimumCompatibilityVersion()} and {@link VersionUtils#allReleasedVersions()}
* agree with the list of wire and index compatible versions we build in gradle.
*/
public void testGradleVersionsMatchVersionUtils() {
// First check the index compatible versions
VersionsFromProperty indexCompatible = new VersionsFromProperty("tests.gradle_index_compat_versions");
List<Version> released = VersionUtils.allReleasedVersions().stream().filter(v -> v.onOrAfter(Version.CURRENT.minimumIndexCompatibilityVersion())).filter(Version::isRelease).collect(toList());
List<String> releasedIndexCompatible = released.stream().filter(v -> !Version.CURRENT.equals(v)).map(Object::toString).collect(toList());
assertEquals(releasedIndexCompatible, indexCompatible.released);
List<String> unreleasedIndexCompatible = new ArrayList<>(VersionUtils.allUnreleasedVersions().stream().filter(v -> v.equals(Version.CURRENT) == false).filter(v -> v.onOrAfter(Version.CURRENT.minimumIndexCompatibilityVersion())).filter(v -> false == v.isAlpha()).map(Object::toString).collect(toCollection(LinkedHashSet::new)));
assertEquals(unreleasedIndexCompatible, indexCompatible.unreleased);
// Now the wire compatible versions
VersionsFromProperty wireCompatible = new VersionsFromProperty("tests.gradle_wire_compat_versions");
Version minimumCompatibleVersion = Version.CURRENT.minimumCompatibilityVersion();
List<String> releasedWireCompatible = released.stream().filter(v -> !Version.CURRENT.equals(v)).filter(v -> v.onOrAfter(minimumCompatibleVersion)).map(Object::toString).collect(toList());
assertEquals(releasedWireCompatible, wireCompatible.released);
List<String> unreleasedWireCompatible = VersionUtils.allUnreleasedVersions().stream().filter(v -> v.equals(Version.CURRENT) == false).filter(v -> v.onOrAfter(minimumCompatibleVersion)).map(Object::toString).collect(toList());
assertEquals(unreleasedWireCompatible, wireCompatible.unreleased);
}
use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class OpenSearchRestTestCase method minimumNodeVersion.
/**
* Returns the minimum node version among all nodes of the cluster
*/
protected static Version minimumNodeVersion() throws IOException {
final Request request = new Request("GET", "_nodes");
request.addParameter("filter_path", "nodes.*.version");
final Response response = adminClient().performRequest(request);
final Map<String, Object> nodes = ObjectPath.createFromResponse(response).evaluate("nodes");
Version minVersion = null;
for (Map.Entry<String, Object> node : nodes.entrySet()) {
@SuppressWarnings("unchecked") Version nodeVersion = Version.fromString((String) ((Map<String, Object>) node.getValue()).get("version"));
if (minVersion == null || minVersion.after(nodeVersion)) {
minVersion = nodeVersion;
}
}
assertNotNull(minVersion);
return minVersion;
}
use of org.opensearch.Version in project OpenSearch by opensearch-project.
the class OpenSearchRestTestCase method expectSoftDeletesWarning.
protected static void expectSoftDeletesWarning(Request request, String indexName) {
final List<String> esExpectedWarnings = Collections.singletonList("Creating indices with soft-deletes disabled is deprecated and will be removed in future Elasticsearch versions. " + "Please do not specify value for setting [index.soft_deletes.enabled] of index [" + indexName + "].");
final List<String> opensearchExpectedWarnings = Collections.singletonList("Creating indices with soft-deletes disabled is deprecated and will be removed in future OpenSearch versions. " + "Please do not specify value for setting [index.soft_deletes.enabled] of index [" + indexName + "].");
final Builder requestOptions = RequestOptions.DEFAULT.toBuilder();
if (nodeVersions.stream().allMatch(version -> version.onOrAfter(LegacyESVersion.V_7_6_0) && version.before(Version.V_1_0_0))) {
requestOptions.setWarningsHandler(warnings -> warnings.equals(esExpectedWarnings) == false);
request.setOptions(requestOptions);
} else if (nodeVersions.stream().anyMatch(version -> version.onOrAfter(LegacyESVersion.V_7_6_0) && version.before(Version.V_1_0_0))) {
requestOptions.setWarningsHandler(warnings -> warnings.isEmpty() == false && warnings.equals(esExpectedWarnings) == false);
request.setOptions(requestOptions);
}
if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_1_0_0))) {
requestOptions.setWarningsHandler(warnings -> warnings.equals(opensearchExpectedWarnings) == false);
request.setOptions(requestOptions);
} else if (nodeVersions.stream().anyMatch(version -> version.onOrAfter(Version.V_1_0_0))) {
requestOptions.setWarningsHandler(warnings -> warnings.isEmpty() == false && warnings.equals(opensearchExpectedWarnings) == false);
request.setOptions(requestOptions);
}
}
Aggregations