slfan1989 commented on code in PR #7008:
URL: https://github.com/apache/ozone/pull/7008#discussion_r1857967451
##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/safemode/TestSCMSafeModeManager.java:
##########
@@ -492,6 +509,79 @@ public void testContainerSafeModeRule() throws Exception {
100, 1000 * 5);
}
+ // We simulate common EC types: EC-2-2-1024K, EC-3-2-1024K, EC-6-3-1024K.
+ static Stream<Arguments> processECDataParityCombination() {
+ Stream<Arguments> args = Stream.of(arguments(2, 2),
+ arguments(3, 2), arguments(6, 3));
+ return args;
+ }
+
+ @ParameterizedTest
+ @MethodSource("processECDataParityCombination")
+ public void testContainerSafeModeRuleEC(int data, int parity) throws
Exception {
+ containers = new ArrayList<>();
+
+ // We generate 100 EC Containers.
+ containers.addAll(HddsTestUtils.getECContainerInfo(25 * 4, data, parity));
+
+ // Prepare the data for the container.
+ // We have prepared 25 containers in the CLOSED state and 75 containers in
the OPEN state.
+ // Out of the 25 containers, only 20 containers have a NumberOfKeys
greater than 0.
+ for (ContainerInfo container : containers.subList(0, 25)) {
+ container.setState(HddsProtos.LifeCycleState.CLOSED);
+ container.setNumberOfKeys(10);
+ }
+
+ for (ContainerInfo container : containers.subList(25, 100)) {
+ container.setState(HddsProtos.LifeCycleState.OPEN);
+ container.setNumberOfKeys(10);
+ }
+
+ // Set the last 5 closed containers to be empty
+ for (ContainerInfo container : containers.subList(20, 25)) {
+ container.setNumberOfKeys(0);
+ }
+
+ for (ContainerInfo container : containers) {
+ scmMetadataStore.getContainerTable().put(container.containerID(),
container);
+ }
+
+ // Declare SCMSafeModeManager and confirm entry into Safe Mode.
+ EventQueue eventQueue = new EventQueue();
+ MockNodeManager nodeManager = new MockNodeManager(true, 0);
+ PipelineManager pipelineManager = PipelineManagerImpl.newPipelineManager(
+ config,
+ SCMHAManagerStub.getInstance(true),
+ nodeManager,
+ scmMetadataStore.getPipelineTable(),
+ eventQueue,
+ scmContext,
+ serviceManager,
+ Clock.system(ZoneOffset.UTC));
+
+ ContainerManager containerManager = new ContainerManagerImpl(config,
+ SCMHAManagerStub.getInstance(true), null, pipelineManager,
+ scmMetadataStore.getContainerTable(),
+ new ContainerReplicaPendingOps(Clock.system(ZoneId.systemDefault())));
+
+ scmSafeModeManager = new SCMSafeModeManager(
+ config, containers, containerManager, pipelineManager, queue,
serviceManager, scmContext);
+ assertTrue(scmSafeModeManager.getInSafeMode());
+
+ // Only 20 containers are involved in the calculation,
+ // so when 10 containers complete registration, our threshold is 50%.
+ testECContainerThreshold(containers.subList(0, 10), 0.5, data);
+ assertTrue(scmSafeModeManager.getInSafeMode());
+
+ // When the registration of the remaining containers is completed,
+ // the threshold will reach 100%.
+ testECContainerThreshold(containers.subList(10, 25), 1.0, data);
Review Comment:
It has been changed to 10 to 20.
--
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]