chesnokoff commented on code in PR #12521:
URL: https://github.com/apache/ignite/pull/12521#discussion_r2580924660
##########
modules/control-utility/src/test/java/org/apache/ignite/util/RollingUpgradeCommandTest.java:
##########
@@ -177,4 +190,109 @@ public void testForceEnable() {
assertTrue(crd.context().rollingUpgrade().enabled());
}
+
+ /** */
+ @Test
+ public void testStatusWhenDisabled() {
+ int res = execute(ROLLING_UPGRADE, STATUS);
+
+ assertEquals(EXIT_CODE_OK, res);
+
+ RollingUpgradeTaskResult taskRes =
(RollingUpgradeTaskResult)lastOperationResult;
+
+ assertNull(taskRes.errorMessage());
+ assertNull(taskRes.currentVersion());
+ assertNull(taskRes.targetVersion());
+
+ assertNull(taskRes.nodes());
+
+ RollingUpgradeStatusCommand statusCmd = new
RollingUpgradeStatusCommand();
+
+ List<String> lines = new ArrayList<>();
+
+ statusCmd.printResult(null, taskRes, lines::add);
+
+ List<String> expectedLines = new ArrayList<>();
+
+ expectedLines.add("Rolling upgrade status: disabled");
+
+ assertEquals(expectedLines, lines);
+ }
+
+ /** */
+ @Test
+ public void testStatusWhenEnabled() throws Exception {
+ IgniteProductVersion curVer =
IgniteProductVersion.fromString(crd.localNode().attribute(ATTR_BUILD_VER));
+
+ String targetVerStr = curVer.major() + "." + (curVer.minor() + 1) +
"." + curVer.maintenance();
+ IgniteProductVersion targetVer =
IgniteProductVersion.fromString(targetVerStr);
+
+ execute(ROLLING_UPGRADE, ENABLE, targetVerStr);
+
+ Consumer<IgniteConfiguration> cfgC = cfg -> {
+ TcpDiscoverySpi discoSpi = new TcpDiscoverySpi() {
+ @Override public void setNodeAttributes(Map<String, Object>
attrs, IgniteProductVersion ver) {
+ super.setNodeAttributes(attrs, ver);
+ attrs.put(ATTR_BUILD_VER, targetVerStr);
+ }
+ };
+
+
discoSpi.setIpFinder(((TcpDiscoverySpi)cfg.getDiscoverySpi()).getIpFinder());
+ cfg.setDiscoverySpi(discoSpi);
+ };
+
+ try (IgniteEx ignored = startGrid(SERVER_NODE_CNT + 1, cfgC)) {
+ int res = execute(ROLLING_UPGRADE, STATUS);
+
+ assertEquals(EXIT_CODE_OK, res);
+ }
+
+ RollingUpgradeTaskResult taskRes =
(RollingUpgradeTaskResult)lastOperationResult;
+
+ assertNull(taskRes.errorMessage());
+ assertEquals(curVer, taskRes.currentVersion());
+ assertEquals(targetVer, taskRes.targetVersion());
+
+ List<RollingUpgradeStatusNode> nodes = taskRes.nodes();
+
+ assertNotNull(nodes);
+ assertEquals(SERVER_NODE_CNT + 2, nodes.size());
+
+ List<RollingUpgradeStatusNode> oldNodes = nodes.stream().filter(node
-> node.version().equals(curVer)).collect(toList());
+
+ List<RollingUpgradeStatusNode> newNodes = nodes.stream().filter(node
-> node.version().equals(targetVer)).collect(toList());
+
+ assertEquals(SERVER_NODE_CNT + 1, oldNodes.size());
+ assertEquals(1, newNodes.size());
+
+ RollingUpgradeStatusCommand statusCmd = new
RollingUpgradeStatusCommand();
+
+ List<String> lines = new ArrayList<>();
+
+ statusCmd.printResult(null, taskRes, lines::add);
+
+ List<String> expectedLines = new ArrayList<>();
+
+ expectedLines.add("Rolling upgrade status: enabled");
+ expectedLines.add("Current version: " + curVer);
+ expectedLines.add("Target version: " + targetVer);
+
+ expectedLines.add("Version " + curVer + ":");
+ oldNodes.forEach(node -> expectedLines.add(" [id=" + node.uuid() +
+ ", consistentId=" + node.consistentId() +
+ ", addrs=" + node.addresses() +
+ ", order=" + node.order() +
+ ", isClient=" + node.client() +
+ "]"));
+
+ expectedLines.add("Version " + targetVer + ":");
+ newNodes.forEach(node -> expectedLines.add(" [id=" + node.uuid() +
+ ", consistentId=" + node.consistentId() +
+ ", addrs=" + node.addresses() +
+ ", order=" + node.order() +
+ ", isClient=" + node.client() +
+ "]"));
+
+ assertEquals(expectedLines, lines);
Review Comment:
Output:
```
Rolling upgrade status: enabled
Current version: 2.18.0#19700101-sha1:00000000
Target version: 2.19.0#19700101-sha1:00000000
Version 2.18.0#19700101-sha1:00000000:
[id=a7b889b5-458a-4ab1-a1b2-fdd994400000,
consistentId=gridCommandHandlerTest0, addrs=[127.0.0.1], order=1,
isClient=false]
[id=b9a42989-63b4-4a89-8938-fb871fd00001,
consistentId=gridCommandHandlerTest1, addrs=[127.0.0.1], order=2,
isClient=false]
[id=12bee2c2-65ec-4d27-8d7a-653e8d34b548, consistentId=client,
addrs=[127.0.0.1], order=3, isClient=true]
Version 2.19.0#19700101-sha1:00000000:
[id=756b9adb-957b-4b48-a1e3-d8342ef00003,
consistentId=gridCommandHandlerTest3, addrs=[127.0.0.1], order=6,
isClient=false]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]