adoroszlai commented on code in PR #11620:
URL: https://github.com/apache/ozone/pull/11620#discussion_r4325452508
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneCluster.java:
##########
@@ -114,6 +115,43 @@ public void testStartMultipleDatanodes() throws Exception {
}
}
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void testTransferOMLeadershipPreservesCluster(boolean stopFollower) throws
Exception {
+ MiniOzoneHAClusterImpl haCluster = MiniOzoneCluster.newHABuilder(conf)
+ .setOMServiceId("om-service")
+ .setNumOfOzoneManagers(stopFollower ? 5 : 3)
+ .build();
Review Comment:
This doubles execution time of the test class. I would like to avoid that.
Before:
```
Tests run: 17, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 76.83 s --
in org.apache.hadoop.ozone.TestMiniOzoneCluster
```
After:
```
Tests run: 19, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 145.0 s --
in org.apache.hadoop.ozone.TestMiniOzoneCluster
```
`transferOMLeadershipToAnotherNode` only exists in `MiniOzoneHAClusterImpl`,
i.e. it's test functionality. Is it possible to add assertions about the fixed
behavior in an existing test where it's already used, with less increase of
runtime?
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestMiniOzoneCluster.java:
##########
@@ -114,6 +115,43 @@ public void testStartMultipleDatanodes() throws Exception {
}
}
+ @ParameterizedTest
+ @ValueSource(booleans = {false, true})
+ void testTransferOMLeadershipPreservesCluster(boolean stopFollower) throws
Exception {
+ MiniOzoneHAClusterImpl haCluster = MiniOzoneCluster.newHABuilder(conf)
+ .setOMServiceId("om-service")
+ .setNumOfOzoneManagers(stopFollower ? 5 : 3)
+ .build();
+ cluster = haCluster;
+ cluster.waitForClusterToBeReady();
+ haCluster.waitForLeaderOM();
+ List<OzoneManager> originalOMs = new
ArrayList<>(haCluster.getOzoneManagersList());
+ OzoneManager leader = haCluster.getOMLeader();
+ if (stopFollower) {
+ OzoneManager follower = originalOMs.stream().filter(om -> om !=
leader).findFirst().get();
+ haCluster.stopOzoneManager(follower.getOMNodeId());
+ }
+
+ try {
+ // Repeated transfers must not remove any OM or change its index.
+ for (int i = 0; i < 3; i++) {
+ OzoneManager oldLeader = haCluster.getOMLeader();
+ OzoneManager newLeader =
haCluster.transferOMLeadershipToAnotherNode(oldLeader);
+ assertNotEquals(oldLeader, newLeader);
+ assertTrue(newLeader.isRunning());
+ assertEquals(originalOMs, haCluster.getOzoneManagersList());
+ for (int j = 0; j < originalOMs.size(); j++) {
+ assertEquals(originalOMs.get(j), haCluster.getOzoneManager(j));
+ }
+ }
+
+ haCluster.stop();
Review Comment:
cluster is not stopped in case of failures/errors.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]