[Version] Increment main to 2.0 (#1192)

Increment version on main to 2.0.0.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
Co-authored-by: dblock <dblock@amazon.com>
This commit is contained in:
Nick Knize 2021-09-01 22:35:53 -05:00 committed by GitHub
parent fa8126004c
commit 4b31e1ba04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 98 additions and 156 deletions

View File

@ -379,6 +379,9 @@ public class BwcVersions {
if (currentMajor == 1) {
// add 6.x compatible for OpenSearch 1.0.0
return unmodifiableList(Stream.concat(groupByMajor.get(prevMajor - 1).stream(), result.stream()).collect(Collectors.toList()));
} else if (currentMajor == 2) {
// add 7.x compatible for OpenSearch 2.0.0
return unmodifiableList(Stream.concat(groupByMajor.get(7).stream(), result.stream()).collect(Collectors.toList()));
}
return unmodifiableList(result);
}
@ -386,7 +389,7 @@ public class BwcVersions {
public List<Version> getWireCompatible() {
List<Version> wireCompat = new ArrayList<>();
int currentMajor = currentVersion.getMajor();
int lastMajor = currentMajor == 1 ? 6 : currentMajor - 1;
int lastMajor = currentMajor == 1 ? 6 : currentMajor == 2 ? 7 : currentMajor - 1;
List<Version> lastMajorList = groupByMajor.get(lastMajor);
if (lastMajorList == null) {
throw new IllegalStateException("Expected to find a list of versions for version: " + lastMajor);
@ -402,7 +405,14 @@ public class BwcVersions {
for (Version v : previousMajor) {
wireCompat.add(v);
}
} else if (currentMajor == 2) {
// add all of the 1.x line:
List<Version> previousMajor = groupByMajor.get(1);
for (Version v : previousMajor) {
wireCompat.add(v);
}
}
wireCompat.addAll(groupByMajor.get(currentMajor));
wireCompat.remove(currentVersion);
wireCompat.sort(Version::compareTo);

View File

@ -77,7 +77,7 @@ public final class Version implements Comparable<Version> {
// currently snapshot is not taken into account
int id = major * 10000000 + minor * 100000 + revision * 1000;
// identify if new OpenSearch version 1
this.id = major == 1 ? id ^ MASK : id;
this.id = major == 1 || major == 2 ? id ^ MASK : id;
}
private static int parseSuffixNumber(String substring) {

View File

@ -37,6 +37,10 @@ public class BwcOpenSearchVersionsTests extends GradleUnitTestCase {
static {
sampleVersions.put("1.0.0", asList("5_6_13", "6_6_1", "6_8_15", "7_0_0", "7_9_1", "7_10_0", "7_10_1", "7_10_2", "1_0_0"));
sampleVersions.put("1.1.0", asList("5_6_13", "6_6_1", "6_8_15", "7_0_0", "7_9_1", "7_10_0", "7_10_1", "7_10_2", "1_0_0", "1_1_0"));
sampleVersions.put(
"2.0.0",
asList("5_6_13", "6_6_1", "6_8_15", "7_0_0", "7_9_1", "7_10_0", "7_10_1", "7_10_2", "1_0_0", "1_1_0", "2_0_0")
);
}
public void testWireCompatible() {

View File

@ -52,11 +52,11 @@ public class DistributionDownloadPluginTests extends GradleUnitTestCase {
private static Project packagesProject;
private static Project bwcProject;
private static final Version BWC_MAJOR_VERSION = Version.fromString("4.0.0");
private static final Version BWC_MINOR_VERSION = Version.fromString("3.1.0");
private static final Version BWC_STAGED_VERSION = Version.fromString("3.0.0");
private static final Version BWC_BUGFIX_VERSION = Version.fromString("3.0.1");
private static final Version BWC_MAINTENANCE_VERSION = Version.fromString("2.90.1");
private static final Version BWC_MAJOR_VERSION = Version.fromString("5.0.0");
private static final Version BWC_MINOR_VERSION = Version.fromString("4.1.0");
private static final Version BWC_STAGED_VERSION = Version.fromString("4.0.0");
private static final Version BWC_BUGFIX_VERSION = Version.fromString("4.0.1");
private static final Version BWC_MAINTENANCE_VERSION = Version.fromString("3.90.1");
private static final BwcVersions BWC_MINOR = new BwcVersions(
new TreeSet<>(Arrays.asList(BWC_BUGFIX_VERSION, BWC_MINOR_VERSION, BWC_MAJOR_VERSION)),
BWC_MAJOR_VERSION

View File

@ -65,7 +65,7 @@ public class VersionTests extends GradleUnitTestCase {
public void testCompareWithStringVersions() {
// 1.10.2 is now rebased to OpenSearch version; so this needs to report
assertTrue("OpenSearch 1.10.20 is not interpreted as after Legacy 2.0.0", Version.fromString("1.10.20").after("2.0.0"));
assertTrue("OpenSearch 1.10.20 is not interpreted as after Legacy 3.0.0", Version.fromString("1.10.20").after("3.0.0"));
assertTrue(
"7.0.0-alpha1 should be equal to 7.0.0-alpha1",
Version.fromString("7.0.0-alpha1").equals(Version.fromString("7.0.0-alpha1"))

View File

@ -1,4 +1,4 @@
opensearch = 1.1.0
opensearch = 2.0.0
lucene = 8.9.0
bundled_jdk_vendor = adoptopenjdk

View File

@ -39,20 +39,16 @@ import org.opensearch.client.Response;
import org.opensearch.client.ResponseException;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.common.Booleans;
import org.opensearch.common.Strings;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.rest.action.document.RestBulkAction;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.opensearch.rest.action.search.RestSearchAction.TOTAL_HITS_AS_INT_PARAM;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.either;
import static org.hamcrest.Matchers.equalTo;
/**
* Basic test that indexed documents survive the rolling restart. See
@ -89,25 +85,6 @@ public class IndexingIT extends AbstractRollingTestCase {
}
if (CLUSTER_TYPE == ClusterType.OLD) {
{
Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion();
assertThat("this branch is not needed if we aren't compatible with 6.0",
minimumIndexCompatibilityVersion.onOrBefore(LegacyESVersion.V_6_0_0), equalTo(true));
if (minimumIndexCompatibilityVersion.before(LegacyESVersion.V_7_0_0)) {
XContentBuilder template = jsonBuilder();
template.startObject();
{
template.array("index_patterns", "test_index", "index_with_replicas", "empty_index");
template.startObject("settings");
template.field("number_of_shards", 5);
template.endObject();
}
template.endObject();
Request createTemplate = new Request("PUT", "/_template/prevent-bwc-deprecation-template");
createTemplate.setJsonEntity(Strings.toString(template));
client().performRequest(createTemplate);
}
}
Request createTestIndex = new Request("PUT", "/test_index");
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}");
useIgnoreMultipleMatchingTemplatesWarningsHandler(createTestIndex);

View File

@ -73,7 +73,8 @@ public class Version implements Comparable<Version>, ToXContentFragment {
public static final Version V_1_0_0 = new Version(1000099, org.apache.lucene.util.Version.LUCENE_8_8_2);
public static final Version V_1_0_1 = new Version(1000199, org.apache.lucene.util.Version.LUCENE_8_8_2);
public static final Version V_1_1_0 = new Version(1010099, org.apache.lucene.util.Version.LUCENE_8_9_0);
public static final Version CURRENT = V_1_1_0;
public static final Version V_2_0_0 = new Version(2000099, org.apache.lucene.util.Version.LUCENE_8_9_0);
public static final Version CURRENT = V_2_0_0;
public static Version readVersion(StreamInput in) throws IOException {
return fromId(in.readVInt());
@ -185,7 +186,7 @@ public class Version implements Comparable<Version>, ToXContentFragment {
try {
final int rawMajor = Integer.parseInt(parts[0]);
final int betaOffset = 25; // 0 - 24 is taking by alpha builds
//we reverse the version id calculation based on some assumption as we can't reliably reverse the modulo
final int major = rawMajor * 1000000;
final int minor = Integer.parseInt(parts[1]) * 10000;
@ -205,7 +206,7 @@ public class Version implements Comparable<Version>, ToXContentFragment {
throw new IllegalArgumentException("unable to parse version " + version);
}
}
return fromId((major + minor + revision + build) ^ MASK);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("unable to parse version " + version, e);
@ -306,11 +307,11 @@ public class Version implements Comparable<Version>, ToXContentFragment {
protected Version computeMinCompatVersion() {
if (major == 1) {
return LegacyESVersion.V_6_8_0;
} else if (major == 2) {
return LegacyESVersion.V_7_10_0;
} else if (major == 6) {
// force the minimum compatibility for version 6 to 5.6 since we don't reference version 5 anymore
return Version.fromId(5060099);
} else if (major == 2) {
return LegacyESVersion.V_7_10_0;
} else if (major >= 7) {
// all major versions from 7 onwards are compatible with last minor series of the previous major
Version bwcVersion = null;

View File

@ -118,7 +118,7 @@ public class DiscoveryUpgradeService {
BooleanSupplier isBootstrappedSupplier, JoinHelper joinHelper,
Supplier<Iterable<DiscoveryNode>> peersSupplier,
Consumer<VotingConfiguration> initialConfigurationConsumer) {
assert Version.CURRENT.major == 1 : "remove this service once unsafe upgrades are no longer needed";
assert Version.CURRENT.major == 1 || Version.CURRENT.major == 2 : "remove this service once unsafe upgrades are no longer needed";
this.transportService = transportService;
this.isBootstrappedSupplier = isBootstrappedSupplier;
this.joinHelper = joinHelper;

View File

@ -800,7 +800,7 @@ public class MetadataCreateIndexService {
static int getNumberOfShards(final Settings.Builder indexSettingsBuilder) {
// TODO: this logic can be removed when the current major version is 8
assert Version.CURRENT.major == 1;
assert Version.CURRENT.major == 1 || Version.CURRENT.major == 2;
final int numberOfShards;
final Version indexVersionCreated =
Version.fromId(Integer.parseInt(indexSettingsBuilder.get(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey())));

View File

@ -217,7 +217,8 @@ public class InboundDecoder implements Releasable {
// handshake. This looks odd but it's required to establish the connection correctly we check for real compatibility
// once the connection is established
final Version compatibilityVersion = isHandshake ? currentVersion.minimumCompatibilityVersion() : currentVersion;
if (remoteVersion.isCompatible(compatibilityVersion) == false) {
if ((currentVersion.equals(Version.V_2_0_0) && remoteVersion.equals(Version.fromId(6079999))) == false
&& remoteVersion.isCompatible(compatibilityVersion) == false) {
final Version minCompatibilityVersion = isHandshake ? compatibilityVersion : compatibilityVersion.minimumCompatibilityVersion();
String msg = "Received " + (isHandshake ? "handshake " : "") + "message from unsupported version: [";
return new IllegalStateException(msg + remoteVersion + "] minimal compatible version is: [" + minCompatibilityVersion + "]");

View File

@ -81,7 +81,7 @@ final class TransportHandshaker {
// we also have no payload on the request but the response will contain the actual version of the node we talk
// to as the payload.
Version minCompatVersion = version.minimumCompatibilityVersion();
if(version.onOrAfter(Version.V_1_0_0)) {
if(version.onOrAfter(Version.V_1_0_0) && version.before(Version.V_2_0_0)) {
// the minCompatibleVersion for OpenSearch 1.x is sent as 6.7.99 instead of 6.8.0
// as this helps in (indirectly) identifying the remote node version during handle HandshakeRequest itself
// and then send appropriate version (7.10.2/ OpenSearch 1.x version) in response.
@ -91,6 +91,8 @@ final class TransportHandshaker {
// Sending only BC version to ElasticSearch node provide easy deprecation path for this BC version logic
// in OpenSearch 2.0.0.
minCompatVersion = Version.fromId(6079999);
} else if (version.onOrAfter(Version.V_2_0_0)) {
minCompatVersion = Version.fromId(7099999);
}
handshakeRequestSender.sendRequest(node, channel, requestId, minCompatVersion);
@ -120,7 +122,7 @@ final class TransportHandshaker {
// 1. if remote node is 7.x, then StreamInput version would be 6.8.0
// 2. if remote node is 6.8 then it would be 5.6.0
// 3. if remote node is OpenSearch 1.x then it would be 6.7.99
if(this.version.onOrAfter(Version.V_1_0_0) &&
if((this.version.onOrAfter(Version.V_1_0_0) && this.version.before(Version.V_2_0_0)) &&
(stream.getVersion().equals(LegacyESVersion.V_6_8_0)
|| stream.getVersion().equals(Version.fromId(5060099)))) {
channel.sendResponse(new HandshakeResponse(LegacyESVersion.V_7_10_2));

View File

@ -448,7 +448,7 @@ public class VersionTests extends OpenSearchTestCase {
}
final Version lastMinorFromPreviousMajor =
VersionUtils
.allVersions()
.allReleasedVersions()
.stream()
.filter(v -> v.major == (currentOrNextMajorVersion.major == 1 ? 7 : currentOrNextMajorVersion.major - 1))
.max(Version::compareTo)
@ -464,7 +464,7 @@ public class VersionTests extends OpenSearchTestCase {
Locale.ROOT,
"[%s] should %s be compatible with [%s]",
previousMinorVersion,
isCompatible ? "" : " not",
isCompatible ? "" : "not",
currentOrNextMajorVersion);
assertThat(
message,

View File

@ -57,7 +57,6 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.OptionalInt;
import static org.opensearch.test.VersionUtils.randomVersionBetween;
import static org.hamcrest.CoreMatchers.equalTo;
@ -98,38 +97,6 @@ public class IndicesOptionsTests extends OpenSearchTestCase {
}
}
public void testSerializationPre70() throws Exception {
int iterations = randomIntBetween(5, 20);
List<Version> declaredVersions = Version.getDeclaredVersions(LegacyESVersion.class);
OptionalInt maxV6Id = declaredVersions.stream().filter(v -> v.major == 6).mapToInt(v -> v.id).max();
assertTrue(maxV6Id.isPresent());
final Version maxVersion = Version.fromId(maxV6Id.getAsInt());
for (int i = 0; i < iterations; i++) {
Version version = randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), maxVersion);
IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(),
randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean());
BytesStreamOutput output = new BytesStreamOutput();
output.setVersion(version);
indicesOptions.writeIndicesOptions(output);
StreamInput streamInput = output.bytes().streamInput();
streamInput.setVersion(version);
IndicesOptions indicesOptions2 = IndicesOptions.readIndicesOptions(streamInput);
assertThat(indicesOptions2.ignoreUnavailable(), equalTo(indicesOptions.ignoreUnavailable()));
assertThat(indicesOptions2.allowNoIndices(), equalTo(indicesOptions.allowNoIndices()));
assertThat(indicesOptions2.expandWildcardsOpen(), equalTo(indicesOptions.expandWildcardsOpen()));
assertThat(indicesOptions2.expandWildcardsClosed(), equalTo(indicesOptions.expandWildcardsClosed()));
assertThat(indicesOptions2.forbidClosedIndices(), equalTo(indicesOptions.forbidClosedIndices()));
assertThat(indicesOptions2.allowAliasesToMultipleIndices(), equalTo(indicesOptions.allowAliasesToMultipleIndices()));
assertEquals(indicesOptions2.ignoreAliases(), indicesOptions.ignoreAliases());
assertEquals(indicesOptions2.ignoreThrottled(), indicesOptions.ignoreThrottled());
}
}
public void testFromOptions() {
final boolean ignoreUnavailable = randomBoolean();
final boolean allowNoIndices = randomBoolean();

View File

@ -218,10 +218,10 @@ public class JoinTaskExecutorTests extends OpenSearchTestCase {
String node_5 = UUIDs.base64UUID(); // ES node 7.10.2 in cluster but missing channel version
String node_6 = UUIDs.base64UUID(); // ES node 7.9.0
String node_7 = UUIDs.base64UUID(); // ES node 7.9.0 in cluster but missing channel version
channelVersions.put(node_1, LegacyESVersion.CURRENT);
channelVersions.put(node_2, LegacyESVersion.CURRENT);
channelVersions.put(node_1, Version.CURRENT);
channelVersions.put(node_2, Version.CURRENT);
channelVersions.put(node_4, LegacyESVersion.V_7_10_2);
channelVersions.put(node_6, LegacyESVersion.V_7_9_0);
channelVersions.put(node_6, LegacyESVersion.V_7_10_0);
final TransportService transportService = mock(TransportService.class);
when(transportService.getChannelVersion(any())).thenReturn(channelVersions);
@ -231,8 +231,8 @@ public class JoinTaskExecutorTests extends OpenSearchTestCase {
nodes.add(new DiscoveryNode(node_3, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_2));
nodes.add(new DiscoveryNode(node_4, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_2));
nodes.add(new DiscoveryNode(node_5, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_2));
nodes.add(new DiscoveryNode(node_6, buildNewFakeTransportAddress(), LegacyESVersion.V_7_9_0));
nodes.add(new DiscoveryNode(node_7, buildNewFakeTransportAddress(), LegacyESVersion.V_7_9_0));
nodes.add(new DiscoveryNode(node_6, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_1));
nodes.add(new DiscoveryNode(node_7, buildNewFakeTransportAddress(), LegacyESVersion.V_7_10_0));
final ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).nodes(nodes).build();
final JoinTaskExecutor joinTaskExecutor = new JoinTaskExecutor(Settings.EMPTY, allocationService, logger,
rerouteService, transportService);
@ -247,13 +247,13 @@ public class JoinTaskExecutorTests extends OpenSearchTestCase {
final ClusterStateTaskExecutor.TaskResult taskResult = result.executionResults.values().iterator().next();
assertTrue(taskResult.isSuccess());
DiscoveryNodes resultNodes = result.resultingState.getNodes();
assertEquals(resultNodes.get(node_1).getVersion(), Version.CURRENT);
assertEquals(resultNodes.get(node_2).getVersion(), Version.CURRENT);
assertEquals(resultNodes.get(node_3).getVersion(), Version.CURRENT); // 7.10.2 in old state but sent new join and processed
assertEquals(resultNodes.get(node_4).getVersion(), LegacyESVersion.V_7_10_2);
assertEquals(Version.CURRENT, resultNodes.get(node_1).getVersion());
assertEquals(Version.CURRENT, resultNodes.get(node_2).getVersion());
assertEquals(Version.CURRENT, resultNodes.get(node_3).getVersion()); // 7.10.2 in old state but sent new join and processed
assertEquals(LegacyESVersion.V_7_10_2, resultNodes.get(node_4).getVersion());
assertFalse(resultNodes.nodeExists(node_5)); // 7.10.2 node without active channel will be removed and should rejoin
assertEquals(resultNodes.get(node_6).getVersion(), LegacyESVersion.V_7_9_0);
assertEquals(LegacyESVersion.V_7_10_0, resultNodes.get(node_6).getVersion());
// 7.9.0 node without active channel but shouldn't get removed
assertEquals(resultNodes.get(node_7).getVersion(), LegacyESVersion.V_7_9_0);
assertEquals(LegacyESVersion.V_7_10_0, resultNodes.get(node_7).getVersion());
}
}

View File

@ -97,6 +97,7 @@ import static org.opensearch.cluster.service.MasterServiceTests.discoveryState;
import static org.opensearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK;
import static org.opensearch.test.ClusterServiceUtils.setState;
import static org.opensearch.test.VersionUtils.allVersions;
import static org.opensearch.test.VersionUtils.allOpenSearchVersions;
import static org.opensearch.test.VersionUtils.getPreviousVersion;
import static org.opensearch.test.VersionUtils.randomCompatibleVersion;
import static org.hamcrest.Matchers.allOf;
@ -617,7 +618,7 @@ public class NodeJoinControllerTests extends OpenSearchTestCase {
new HashSet<>(randomSubsetOf(DiscoveryNodeRole.BUILT_IN_ROLES)), badVersion);
final Version goodVersion =
randomFrom(allVersions().stream().filter(v -> v.compareMajor(Version.CURRENT) >= 0).collect(Collectors.toList()));
randomFrom(allOpenSearchVersions().stream().filter(v -> v.compareMajor(Version.CURRENT) >= 0).collect(Collectors.toList()));
final DiscoveryNode goodNode = new DiscoveryNode("goodNode", buildNewFakeTransportAddress(), emptyMap(),
new HashSet<>(randomSubsetOf(DiscoveryNodeRole.BUILT_IN_ROLES)), goodVersion);

View File

@ -180,8 +180,10 @@ public class TransportHandshakerTests extends OpenSearchTestCase {
}
private Version getMinCompatibilityVersionForHandshakeRequest() {
if(Version.CURRENT.onOrAfter(Version.V_1_0_0) && Version.CURRENT.major == 1) {
if (Version.CURRENT.onOrAfter(Version.V_1_0_0) && Version.CURRENT.major == 1) {
return Version.fromId(6079999);
} else if (Version.CURRENT.onOrAfter(Version.V_2_0_0) && Version.CURRENT.major == 2) {
return Version.fromId(7099999);
}
return Version.CURRENT.minimumCompatibilityVersion();
}

View File

@ -66,11 +66,19 @@ public class VersionUtils {
.collect(Collectors.groupingBy(v -> (int)v.major));
// this breaks b/c 5.x is still in version list but master doesn't care about it!
//assert majorVersions.size() == 2;
List<List<Version>> oldVersions = new ArrayList<>(0);
List<List<Version>> previousMajor = new ArrayList<>(0);
if (current.major == 2) {
// add legacy first
oldVersions.addAll(splitByMinor(majorVersions.getOrDefault(6, Collections.emptyList())));
previousMajor.addAll(splitByMinor(majorVersions.getOrDefault(7, Collections.emptyList())));
}
// TODO: remove oldVersions, we should only ever have 2 majors in Version
// rebasing OpenSearch to 1.0.0 means the previous major version was Legacy 7.0.0
int previousMajorID = current.major == 1 ? 7 : current.major - 1;
List<List<Version>> oldVersions = splitByMinor(majorVersions.getOrDefault(previousMajorID - 1, Collections.emptyList()));
// rebasing OpenSearch to 1.0.0 means the previous major version was 7.0.0
List<List<Version>> previousMajor = splitByMinor(majorVersions.get(previousMajorID));
oldVersions.addAll(splitByMinor(majorVersions.getOrDefault(previousMajorID - 1, Collections.emptyList())));
previousMajor.addAll(splitByMinor(majorVersions.getOrDefault(previousMajorID, Collections.emptyList())));
List<List<Version>> currentMajor = splitByMinor(majorVersions.get((int)current.major));
List<Version> unreleasedVersions = new ArrayList<>();
@ -80,7 +88,7 @@ public class VersionUtils {
stableVersions = previousMajor;
// remove current
moveLastToUnreleased(currentMajor, unreleasedVersions);
} else if (current.major != 1) {
} else if (current.major != 1 && current.major != 2) {
// on a stable or release branch, ie N.x
stableVersions = currentMajor;
// remove the next maintenance bugfix
@ -93,7 +101,7 @@ public class VersionUtils {
stableVersions = currentMajor;
}
// remove last minor unless the it's the first OpenSearch version.
// remove last minor unless it's the first OpenSearch version.
// all Legacy ES versions are released, so we don't exclude any.
if (current.equals(Version.V_1_0_0) == false) {
List<Version> lastMinorLine = stableVersions.get(stableVersions.size() - 1);
@ -227,8 +235,7 @@ public class VersionUtils {
public static Version getPreviousMinorVersion() {
for (int i = RELEASED_VERSIONS.size() - 1; i >= 0; i--) {
Version v = RELEASED_VERSIONS.get(i);
if (v.minor < Version.CURRENT.minor
|| (v.major != 1 && v.major < (Version.CURRENT.major != 1 ? Version.CURRENT.major : 8))) {
if (v.minor < Version.CURRENT.minor || v.major < Version.CURRENT.major) {
return v;
}
}

View File

@ -1979,7 +1979,7 @@ public abstract class AbstractSimpleTransportTestCase extends OpenSearchTestCase
public void testHandshakeWithIncompatVersion() {
assumeTrue("only tcp transport has a handshake method", serviceA.getOriginalTransport() instanceof TcpTransport);
Version version = Version.fromString("2.0.0");
Version version = LegacyESVersion.fromString("6.0.0");
try (MockTransportService service = buildService("TS_C", version, Settings.EMPTY)) {
service.start();
service.acceptIncomingRequests();
@ -2013,8 +2013,9 @@ public abstract class AbstractSimpleTransportTestCase extends OpenSearchTestCase
TransportRequestOptions.Type.REG,
TransportRequestOptions.Type.STATE);
try (Transport.Connection connection = serviceA.openConnection(node, builder.build())) {
// OpenSearch 1.0+ in bwc mode should only "upgrade" to Legacy v7.10.2
assertEquals(connection.getVersion(), version.onOrAfter(Version.V_1_0_0) ? LegacyESVersion.V_7_10_2 : version);
// OpenSearch [1.0:2.0) in bwc mode should only "upgrade" to Legacy v7.10.2
assertEquals(connection.getVersion(),
version.onOrAfter(Version.V_1_0_0) && version.before(Version.V_2_0_0) ? LegacyESVersion.V_7_10_2 : version);
}
}
}
@ -2050,9 +2051,7 @@ public abstract class AbstractSimpleTransportTestCase extends OpenSearchTestCase
PlainActionFuture<Transport.Connection> future = PlainActionFuture.newFuture();
serviceA.getOriginalTransport().openConnection(node, connectionProfile, future);
try (Transport.Connection connection = future.actionGet()) {
// OpenSearch sends a handshake version spoofed as Legacy version 7_10_2
// todo change for OpenSearch 2.0.0
assertEquals(LegacyESVersion.V_7_10_2, connection.getVersion());
assertEquals(Version.V_2_0_0, connection.getVersion());
}
}
}
@ -2371,7 +2370,7 @@ public abstract class AbstractSimpleTransportTestCase extends OpenSearchTestCase
assertEquals(1, transportStats.getRxCount());
assertEquals(1, transportStats.getTxCount());
assertEquals(25, transportStats.getRxSize().getBytes());
assertEquals(50, transportStats.getTxSize().getBytes());
assertEquals(51, transportStats.getTxSize().getBytes());
});
serviceC.sendRequest(connection, "internal:action", new TestRequest("hello world"), TransportRequestOptions.EMPTY,
transportResponseHandler);
@ -2381,15 +2380,15 @@ public abstract class AbstractSimpleTransportTestCase extends OpenSearchTestCase
assertEquals(1, transportStats.getRxCount());
assertEquals(2, transportStats.getTxCount());
assertEquals(25, transportStats.getRxSize().getBytes());
assertEquals(106, transportStats.getTxSize().getBytes());
assertEquals(111, transportStats.getTxSize().getBytes());
});
sendResponseLatch.countDown();
responseLatch.await();
stats = serviceC.transport.getStats(); // response has been received
assertEquals(2, stats.getRxCount());
assertEquals(2, stats.getTxCount());
assertEquals(46, stats.getRxSize().getBytes());
assertEquals(106, stats.getTxSize().getBytes());
assertEquals(50, stats.getRxSize().getBytes());
assertEquals(111, stats.getTxSize().getBytes());
} finally {
serviceC.close();
}
@ -2486,7 +2485,7 @@ public abstract class AbstractSimpleTransportTestCase extends OpenSearchTestCase
assertEquals(1, transportStats.getRxCount());
assertEquals(1, transportStats.getTxCount());
assertEquals(25, transportStats.getRxSize().getBytes());
assertEquals(50, transportStats.getTxSize().getBytes());
assertEquals(51, transportStats.getTxSize().getBytes());
});
serviceC.sendRequest(connection, "internal:action", new TestRequest("hello world"), TransportRequestOptions.EMPTY,
transportResponseHandler);
@ -2496,7 +2495,7 @@ public abstract class AbstractSimpleTransportTestCase extends OpenSearchTestCase
assertEquals(1, transportStats.getRxCount());
assertEquals(2, transportStats.getTxCount());
assertEquals(25, transportStats.getRxSize().getBytes());
assertEquals(106, transportStats.getTxSize().getBytes());
assertEquals(111, transportStats.getTxSize().getBytes());
});
sendResponseLatch.countDown();
responseLatch.await();
@ -2508,10 +2507,10 @@ public abstract class AbstractSimpleTransportTestCase extends OpenSearchTestCase
BytesStreamOutput streamOutput = new BytesStreamOutput();
exception.writeTo(streamOutput);
String failedMessage = "Unexpected read bytes size. The transport exception that was received=" + exception;
// 49 bytes are the non-exception message bytes that have been received. It should include the initial
// 53 bytes are the non-exception message bytes that have been received. It should include the initial
// handshake message and the header, version, etc bytes in the exception message.
assertEquals(failedMessage, 49 + streamOutput.bytes().length(), stats.getRxSize().getBytes());
assertEquals(106, stats.getTxSize().getBytes());
assertEquals(failedMessage, 53 + streamOutput.bytes().length(), stats.getRxSize().getBytes());
assertEquals(111, stats.getTxSize().getBytes());
} finally {
serviceC.close();
}

View File

@ -34,45 +34,16 @@ package org.opensearch.upgrades;
import org.opensearch.LegacyESVersion;
import org.opensearch.Version;
import org.opensearch.client.Request;
import org.opensearch.common.Booleans;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.support.XContentMapValues;
import org.opensearch.test.rest.OpenSearchRestTestCase;
import org.junit.Before;
import java.io.IOException;
import java.util.Map;
import static org.opensearch.common.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.equalTo;
public abstract class AbstractFullClusterRestartTestCase extends OpenSearchRestTestCase {
private static final boolean runningAgainstOldCluster = Booleans.parseBoolean(System.getProperty("tests.is_old_cluster"));
@Before
public void init() throws IOException {
assertThat("we don't need this branch if we aren't compatible with 6.0",
Version.CURRENT.minimumIndexCompatibilityVersion().onOrBefore(LegacyESVersion.V_6_0_0), equalTo(true));
if (isRunningAgainstOldCluster() && getOldClusterVersion().before(LegacyESVersion.V_7_0_0)) {
XContentBuilder template = jsonBuilder();
template.startObject();
{
template.field("index_patterns", "*");
template.field("order", "0");
template.startObject("settings");
template.field("number_of_shards", 5);
template.endObject();
}
template.endObject();
Request createTemplate = new Request("PUT", "/_template/template");
createTemplate.setJsonEntity(Strings.toString(template));
client().performRequest(createTemplate);
}
}
public static boolean isRunningAgainstOldCluster() {
return runningAgainstOldCluster;
}

View File

@ -224,13 +224,13 @@ public class VersionUtilsTests extends OpenSearchTestCase {
}
public static class TestVersionBumpIn2x {
public static final Version V_1_6_0 = Version.fromString("1.6.0");
public static final Version V_1_6_1 = Version.fromString("1.6.1");
public static final Version V_1_6_2 = Version.fromString("1.6.2");
public static final Version V_2_0_0 = Version.fromString("2.0.0");
public static final Version V_2_0_1 = Version.fromString("2.0.1");
public static final Version V_2_1_0 = Version.fromString("2.1.0");
public static final Version CURRENT = V_2_1_0;
public static final Version V_2_6_0 = Version.fromString("2.6.0");
public static final Version V_2_6_1 = Version.fromString("2.6.1");
public static final Version V_2_6_2 = Version.fromString("2.6.2");
public static final Version V_3_0_0 = Version.fromString("3.0.0");
public static final Version V_3_0_1 = Version.fromString("3.0.1");
public static final Version V_3_1_0 = Version.fromString("3.1.0");
public static final Version CURRENT = V_3_1_0;
}
public void testResolveReleasedVersionsAtVersionBumpIn2x() {
@ -240,13 +240,13 @@ public class VersionUtilsTests extends OpenSearchTestCase {
List<Version> unreleased = t.v2();
assertThat(released, equalTo(Arrays.asList(
TestVersionBumpIn2x.V_1_6_0,
TestVersionBumpIn2x.V_1_6_1,
TestVersionBumpIn2x.V_2_0_0)));
TestVersionBumpIn2x.V_2_6_0,
TestVersionBumpIn2x.V_2_6_1,
TestVersionBumpIn2x.V_3_0_0)));
assertThat(unreleased, equalTo(Arrays.asList(
TestVersionBumpIn2x.V_1_6_2,
TestVersionBumpIn2x.V_2_0_1,
TestVersionBumpIn2x.V_2_1_0)));
TestVersionBumpIn2x.V_2_6_2,
TestVersionBumpIn2x.V_3_0_1,
TestVersionBumpIn2x.V_3_1_0)));
}
public static class TestNewMinorBranchIn6x {
@ -262,7 +262,7 @@ public class VersionUtilsTests extends OpenSearchTestCase {
public static final Version CURRENT = V_2_2_0;
}
public void testResolveReleasedVersionsAtNewMinorBranchIn6x() {
public void testResolveReleasedVersionsAtNewMinorBranchIn2x() {
Tuple<List<Version>, List<Version>> t = VersionUtils.resolveReleasedVersions(TestNewMinorBranchIn6x.CURRENT,
TestNewMinorBranchIn6x.class);
List<Version> released = t.v1();
@ -271,12 +271,12 @@ public class VersionUtilsTests extends OpenSearchTestCase {
assertThat(released, equalTo(Arrays.asList(
TestNewMinorBranchIn6x.V_1_6_0,
TestNewMinorBranchIn6x.V_1_6_1,
TestNewMinorBranchIn6x.V_1_6_2,
TestNewMinorBranchIn6x.V_2_0_0,
TestNewMinorBranchIn6x.V_2_0_1,
TestNewMinorBranchIn6x.V_2_1_0,
TestNewMinorBranchIn6x.V_2_1_1)));
assertThat(unreleased, equalTo(Arrays.asList(
TestNewMinorBranchIn6x.V_1_6_2,
TestNewMinorBranchIn6x.V_2_1_2,
TestNewMinorBranchIn6x.V_2_2_0)));
}