-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-11309. Increase CONTAINER_STATE Column Length in UNHEALTHY_CONTAINERS to Avoid Truncation #7071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDDS-11309. Increase CONTAINER_STATE Column Length in UNHEALTHY_CONTAINERS to Avoid Truncation #7071
Changes from all commits
db0ef4a
61dba70
da0bb06
6ee44c0
5a0207d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,9 +20,12 @@ | |
|
|
||
| import static org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.THREE; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.hadoop.ozone.recon.schema.ContainerSchemaDefinition.UnHealthyContainerStates.ALL_REPLICAS_UNHEALTHY; | ||
| import static org.hadoop.ozone.recon.schema.ContainerSchemaDefinition.UnHealthyContainerStates.ALL_REPLICAS_BAD; | ||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertNull; | ||
| import static org.junit.jupiter.api.Assertions.fail; | ||
| import static org.junit.jupiter.api.Assertions.assertFalse; | ||
| import static org.mockito.Mockito.any; | ||
| import static org.mockito.Mockito.anyInt; | ||
| import static org.mockito.Mockito.mock; | ||
|
|
@@ -199,7 +202,7 @@ public void testRun() throws Exception { | |
|
|
||
| List<UnhealthyContainers> unhealthyContainers = | ||
| containerHealthSchemaManager.getUnhealthyContainers( | ||
| ALL_REPLICAS_UNHEALTHY, 0, Integer.MAX_VALUE); | ||
| ALL_REPLICAS_BAD, 0, Integer.MAX_VALUE); | ||
| assertEquals(1, unhealthyContainers.size()); | ||
| assertEquals(2L, | ||
| unhealthyContainers.get(0).getContainerId().longValue()); | ||
|
|
@@ -384,6 +387,91 @@ public void testDeletedContainer() throws Exception { | |
| .isGreaterThan(currentTime); | ||
| } | ||
|
|
||
| @Test | ||
| public void testAllContainerStateInsertions() { | ||
| UnhealthyContainersDao unHealthyContainersTableHandle = | ||
| getDao(UnhealthyContainersDao.class); | ||
|
|
||
| ContainerHealthSchemaManager containerHealthSchemaManager = | ||
| new ContainerHealthSchemaManager( | ||
| getSchemaDefinition(ContainerSchemaDefinition.class), | ||
| unHealthyContainersTableHandle); | ||
|
|
||
| // Iterate through each state in the UnHealthyContainerStates enum | ||
| for (ContainerSchemaDefinition.UnHealthyContainerStates state : | ||
| ContainerSchemaDefinition.UnHealthyContainerStates.values()) { | ||
|
|
||
| // Create a dummy UnhealthyContainer record with the current state | ||
| UnhealthyContainers unhealthyContainer = new UnhealthyContainers(); | ||
| unhealthyContainer.setContainerId(state.ordinal() + 1L); | ||
|
|
||
| // Set replica counts based on the state | ||
| switch (state) { | ||
| case MISSING: | ||
| case EMPTY_MISSING: | ||
| unhealthyContainer.setExpectedReplicaCount(3); | ||
| unhealthyContainer.setActualReplicaCount(0); | ||
| unhealthyContainer.setReplicaDelta(3); | ||
| break; | ||
|
|
||
| case UNDER_REPLICATED: | ||
| unhealthyContainer.setExpectedReplicaCount(3); | ||
| unhealthyContainer.setActualReplicaCount(1); | ||
| unhealthyContainer.setReplicaDelta(2); | ||
| break; | ||
|
|
||
| case OVER_REPLICATED: | ||
| unhealthyContainer.setExpectedReplicaCount(3); | ||
| unhealthyContainer.setActualReplicaCount(4); | ||
| unhealthyContainer.setReplicaDelta(-1); | ||
| break; | ||
|
|
||
| case MIS_REPLICATED: | ||
| case NEGATIVE_SIZE: | ||
| unhealthyContainer.setExpectedReplicaCount(3); | ||
| unhealthyContainer.setActualReplicaCount(3); | ||
| unhealthyContainer.setReplicaDelta(0); | ||
| break; | ||
|
|
||
| case ALL_REPLICAS_BAD: | ||
| unhealthyContainer.setExpectedReplicaCount(3); | ||
| unhealthyContainer.setActualReplicaCount(0); | ||
| unhealthyContainer.setReplicaDelta(3); | ||
| break; | ||
|
|
||
| default: | ||
| fail("Unhandled state: " + state.name() + ". Please add this state to the switch case."); | ||
| } | ||
|
|
||
| unhealthyContainer.setContainerState(state.name()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though it will not impact test case purpose, but for each
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pls fix this comment, as it creates confusion. |
||
| unhealthyContainer.setInStateSince(System.currentTimeMillis()); | ||
|
|
||
| // Try inserting the record and catch any exception that occurs | ||
| Exception exception = null; | ||
| try { | ||
| containerHealthSchemaManager.insertUnhealthyContainerRecords( | ||
| Collections.singletonList(unhealthyContainer)); | ||
| } catch (Exception e) { | ||
| exception = e; | ||
| } | ||
|
|
||
| // Assert no exception should be thrown for each state | ||
| assertNull(exception, | ||
| "Exception was thrown during insertion for state " + state.name() + | ||
| ": " + exception); | ||
|
|
||
| // Optionally, verify the record was inserted correctly | ||
| List<UnhealthyContainers> insertedRecords = | ||
| unHealthyContainersTableHandle.fetchByContainerId( | ||
| state.ordinal() + 1L); | ||
| assertFalse(insertedRecords.isEmpty(), | ||
| "Record was not inserted for state " + state.name() + "."); | ||
| assertEquals(insertedRecords.get(0).getContainerState(), state.name(), | ||
| "The inserted container state does not match for state " + | ||
| state.name() + "."); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testNegativeSizeContainers() throws Exception { | ||
| // Setup mock objects and test environment | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.