forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add bwc tests and restrict range list size to 1
Signed-off-by: Abhilasha Seth <[email protected]>
- Loading branch information
1 parent
52610b8
commit c9c0a08
Showing
11 changed files
with
216 additions
and
85 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
libs/core/src/main/java/org/opensearch/semver/expr/Caret.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,32 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.semver.expr; | ||
|
||
import org.opensearch.Version; | ||
|
||
/** | ||
* Expression to evaluate version compatibility allowing for minor and patch version variability. | ||
*/ | ||
public class Caret implements Expression { | ||
|
||
/** | ||
* Checks if the given version is compatible with the range version allowing for minor and | ||
* patch version variability. | ||
* Allows all versions starting from the rangeVersion upto next major version (exclusive). | ||
* @param rangeVersion the version specified in range | ||
* @param versionToEvaluate the version to evaluate | ||
* @return {@code true} if the versions are compatible {@code false} otherwise | ||
*/ | ||
@Override | ||
public boolean evaluate(final Version rangeVersion, final Version versionToEvaluate) { | ||
Version lower = rangeVersion; | ||
Version upper = Version.fromString((rangeVersion.major + 1) + ".0.0"); | ||
return versionToEvaluate.onOrAfter(lower) && versionToEvaluate.before(upper); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
libs/core/src/test/java/org/opensearch/semver/expr/CaretTests.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,30 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.semver.expr; | ||
|
||
import org.opensearch.Version; | ||
import org.opensearch.test.OpenSearchTestCase; | ||
|
||
public class CaretTests extends OpenSearchTestCase { | ||
|
||
public void testMinorAndPatchVersionVariability() { | ||
Caret caretExpr = new Caret(); | ||
Version rangeVersion = Version.fromString("1.2.3"); | ||
|
||
// Compatible versions | ||
assertTrue(caretExpr.evaluate(rangeVersion, Version.fromString("1.2.3"))); | ||
assertTrue(caretExpr.evaluate(rangeVersion, Version.fromString("1.2.4"))); | ||
assertTrue(caretExpr.evaluate(rangeVersion, Version.fromString("1.3.3"))); | ||
assertTrue(caretExpr.evaluate(rangeVersion, Version.fromString("1.9.9"))); | ||
|
||
// Incompatible versions | ||
assertFalse(caretExpr.evaluate(rangeVersion, Version.fromString("1.2.2"))); | ||
assertFalse(caretExpr.evaluate(rangeVersion, Version.fromString("2.0.0"))); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/PluginInfoIT.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,27 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.upgrades; | ||
|
||
import org.opensearch.client.Request; | ||
import org.opensearch.client.Response; | ||
import org.opensearch.test.rest.yaml.ObjectPath; | ||
|
||
import java.util.Map; | ||
|
||
public class PluginInfoIT extends AbstractFullClusterRestartTestCase { | ||
public void testPluginInfoSerialization() throws Exception { | ||
// Ensure all nodes are able to come up, validate with GET _nodes. | ||
Response response = client().performRequest(new Request("GET", "_nodes")); | ||
ObjectPath objectPath = ObjectPath.createFromResponse(response); | ||
final Map<String, Object> nodeMap = objectPath.evaluate("nodes"); | ||
// Any issue in PluginInfo serialization logic will result into connection failures | ||
// and hence reduced number of nodes. | ||
assertEquals(2, nodeMap.keySet().size()); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
qa/mixed-cluster/src/test/java/org/opensearch/backwards/PluginInfoIT.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,32 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.backwards; | ||
|
||
import org.opensearch.Version; | ||
import org.opensearch.client.Request; | ||
import org.opensearch.client.Response; | ||
import org.opensearch.cluster.metadata.IndexMetadata; | ||
import org.opensearch.common.settings.Settings; | ||
|
||
import org.opensearch.test.rest.OpenSearchRestTestCase; | ||
import org.opensearch.test.rest.yaml.ObjectPath; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class PluginInfoIT extends OpenSearchRestTestCase { | ||
public void testPluginInfoSerialization() throws Exception { | ||
// Ensure all nodes are able to come up | ||
Response response = client().performRequest(new Request("GET", "_nodes")); | ||
ObjectPath objectPath = ObjectPath.createFromResponse(response); | ||
final Map<String, Object> nodeMap = objectPath.evaluate("nodes"); | ||
assertEquals(4, nodeMap.keySet().size()); | ||
} | ||
} |
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
Oops, something went wrong.