Skip to content
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-11868. Enable OM Ratis in TestQuotaRepairTask #7593

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading