Skip to content

Commit

Permalink
HDDS-11868. Enable OM Ratis in TestQuotaRepairTask (apache#7593)
Browse files Browse the repository at this point in the history
  • Loading branch information
chungen0126 authored Dec 18, 2024
1 parent 3a0e3b5 commit f5ff2f0
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand All @@ -38,13 +39,13 @@
import org.apache.hadoop.ozone.om.helpers.OmBucketInfo;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.OmVolumeArgs;
import org.apache.hadoop.ozone.om.ratis.OzoneManagerRatisServer;
import org.apache.hadoop.ozone.om.request.OMRequestTestUtils;
import org.apache.hadoop.ozone.om.request.key.TestOMKeyRequest;
import org.apache.hadoop.ozone.om.request.volume.OMQuotaRepairRequest;
import org.apache.hadoop.ozone.om.response.OMClientResponse;
import org.apache.hadoop.ozone.om.response.volume.OMQuotaRepairResponse;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocolPB.OzoneManagerProtocolServerSideTranslatorPB;
import org.apache.hadoop.util.Time;
import org.junit.jupiter.api.Test;

Expand All @@ -57,16 +58,16 @@ public class TestQuotaRepairTask extends TestOMKeyRequest {

@Test
public void testQuotaRepair() throws Exception {
when(ozoneManager.isRatisEnabled()).thenReturn(false);
when(ozoneManager.isRatisEnabled()).thenReturn(true);
OzoneManagerProtocolProtos.OMResponse respMock = mock(OzoneManagerProtocolProtos.OMResponse.class);
when(respMock.getSuccess()).thenReturn(true);
OzoneManagerProtocolServerSideTranslatorPB serverMock = mock(OzoneManagerProtocolServerSideTranslatorPB.class);
OzoneManagerRatisServer ratisServerMock = mock(OzoneManagerRatisServer.class);
AtomicReference<OzoneManagerProtocolProtos.OMRequest> ref = new AtomicReference<>();
doAnswer(invocation -> {
ref.set(invocation.getArgument(1, OzoneManagerProtocolProtos.OMRequest.class));
ref.set(invocation.getArgument(0, OzoneManagerProtocolProtos.OMRequest.class));
return respMock;
}).when(serverMock).submitRequest(any(), any());
when(ozoneManager.getOmServerProtocol()).thenReturn(serverMock);
}).when(ratisServerMock).submitRequest(any(), any(), anyLong());
when(ozoneManager.getOmRatisServer()).thenReturn(ratisServerMock);
OMRequestTestUtils.addVolumeAndBucketToDB(volumeName, bucketName,
omMetadataManager, BucketLayout.OBJECT_STORE);

Expand Down Expand Up @@ -135,16 +136,16 @@ public void testQuotaRepair() throws Exception {

@Test
public void testQuotaRepairForOldVersionVolumeBucket() throws Exception {
when(ozoneManager.isRatisEnabled()).thenReturn(false);
when(ozoneManager.isRatisEnabled()).thenReturn(true);
OzoneManagerProtocolProtos.OMResponse respMock = mock(OzoneManagerProtocolProtos.OMResponse.class);
when(respMock.getSuccess()).thenReturn(true);
OzoneManagerProtocolServerSideTranslatorPB serverMock = mock(OzoneManagerProtocolServerSideTranslatorPB.class);
OzoneManagerRatisServer ratisServerMock = mock(OzoneManagerRatisServer.class);
AtomicReference<OzoneManagerProtocolProtos.OMRequest> ref = new AtomicReference<>();
doAnswer(invocation -> {
ref.set(invocation.getArgument(1, OzoneManagerProtocolProtos.OMRequest.class));
ref.set(invocation.getArgument(0, OzoneManagerProtocolProtos.OMRequest.class));
return respMock;
}).when(serverMock).submitRequest(any(), any());
when(ozoneManager.getOmServerProtocol()).thenReturn(serverMock);
}).when(ratisServerMock).submitRequest(any(), any(), anyLong());
when(ozoneManager.getOmRatisServer()).thenReturn(ratisServerMock);
// add volume with -2 value
OmVolumeArgs omVolumeArgs =
OmVolumeArgs.newBuilder().setCreationTime(Time.now())
Expand Down

0 comments on commit f5ff2f0

Please sign in to comment.