Skip to content

Commit

Permalink
Merge branch 'apache:master' into HDDS-9648
Browse files Browse the repository at this point in the history
  • Loading branch information
Tejaskriya authored Dec 22, 2023
2 parents 12e7bb2 + 4cda788 commit 9657605
Show file tree
Hide file tree
Showing 231 changed files with 4,523 additions and 3,622 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import java.util.Collections;
import java.util.UUID;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;

/**
* Test ContainerClientMetrics.
Expand Down Expand Up @@ -108,7 +108,7 @@ public void testAcquireAndRelease() {
private Pipeline createPipeline(PipelineID piplineId, UUID leaderId) {
return Pipeline.newBuilder()
.setId(piplineId)
.setReplicationConfig(Mockito.mock(ReplicationConfig.class))
.setReplicationConfig(mock(ReplicationConfig.class))
.setState(Pipeline.PipelineState.OPEN)
.setNodes(Collections.emptyList())
.setLeaderId(leaderId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@
import org.apache.hadoop.ozone.common.OzoneChecksumException;
import org.apache.ratis.thirdparty.io.grpc.Status;
import org.apache.ratis.thirdparty.io.grpc.StatusException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mockito;
import org.mockito.stubbing.OngoingStubbing;

import java.io.EOFException;
Expand Down Expand Up @@ -92,7 +90,7 @@ public class TestBlockInputStream {
@BeforeEach
@SuppressWarnings("unchecked")
public void setup() throws Exception {
refreshFunction = Mockito.mock(Function.class);
refreshFunction = mock(Function.class);
BlockID blockID = new BlockID(new ContainerBlockID(1, 1));
checksum = new Checksum(ChecksumType.NONE, CHUNK_SIZE);
createChunkList(5);
Expand Down Expand Up @@ -376,7 +374,7 @@ public void testReadNotRetriedOnOtherException(IOException ex)
subject.initialize();

// WHEN
Assertions.assertThrows(ex.getClass(),
assertThrows(ex.getClass(),
() -> subject.read(new byte[len], 0, len));

// THEN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@

import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

/**
* UNIT test for BlockOutputStream.
Expand Down Expand Up @@ -93,8 +95,8 @@ private BlockOutputStream createBlockOutputStream(BufferPool bufferPool)

final Pipeline pipeline = MockPipeline.createRatisPipeline();

final XceiverClientManager xcm = Mockito.mock(XceiverClientManager.class);
Mockito.when(xcm.acquireClient(Mockito.any()))
final XceiverClientManager xcm = mock(XceiverClientManager.class);
when(xcm.acquireClient(any()))
.thenReturn(new MockXceiverClientSpi(pipeline));

OzoneClientConfig config = new OzoneClientConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@

import org.apache.hadoop.ozone.common.ChunkBuffer;
import org.apache.hadoop.security.token.Token;
import org.apache.ozone.test.GenericTestUtils;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.apache.hadoop.hdds.scm.protocolPB.ContainerCommandResponseBuilders.getReadChunkResponse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -160,14 +160,9 @@ public void testPartialChunkRead() throws Exception {
@Test
public void testSeek() throws Exception {
seekAndVerify(0);
EOFException eofException = assertThrows(EOFException.class, () -> seekAndVerify(CHUNK_SIZE + 1));
assertThat(eofException).hasMessage("EOF encountered at pos: " + (CHUNK_SIZE + 1) + " for chunk: " + CHUNK_NAME);

try {
seekAndVerify(CHUNK_SIZE + 1);
fail("Seeking to more than the length of Chunk should fail.");
} catch (EOFException e) {
GenericTestUtils.assertExceptionContains("EOF encountered at pos: "
+ (CHUNK_SIZE + 1) + " for chunk: " + CHUNK_NAME, e);
}
// Seek before read should update the ChunkInputStream#chunkPosition
seekAndVerify(25);
assertEquals(25, chunkStream.getChunkPosition());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
import org.apache.hadoop.hdds.scm.storage.BlockInputStream;
import org.apache.hadoop.hdds.scm.storage.BlockLocationInfo;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;

/**
* Tests for BlockInputStreamFactoryImpl.
*/
Expand All @@ -53,9 +55,9 @@ public void testNonECGivesBlockInputStream() {
BlockExtendedInputStream stream =
factory.create(repConfig, blockInfo, blockInfo.getPipeline(),
blockInfo.getToken(), true, null, null);
Assertions.assertTrue(stream instanceof BlockInputStream);
Assertions.assertEquals(stream.getBlockID(), blockInfo.getBlockID());
Assertions.assertEquals(stream.getLength(), blockInfo.getLength());
assertInstanceOf(BlockInputStream.class, stream);
assertEquals(stream.getBlockID(), blockInfo.getBlockID());
assertEquals(stream.getLength(), blockInfo.getLength());
}

@Test
Expand All @@ -70,9 +72,9 @@ public void testECGivesECBlockInputStream() {
BlockExtendedInputStream stream =
factory.create(repConfig, blockInfo, blockInfo.getPipeline(),
blockInfo.getToken(), true, null, null);
Assertions.assertTrue(stream instanceof ECBlockInputStreamProxy);
Assertions.assertEquals(stream.getBlockID(), blockInfo.getBlockID());
Assertions.assertEquals(stream.getLength(), blockInfo.getLength());
assertInstanceOf(ECBlockInputStreamProxy.class, stream);
assertEquals(stream.getBlockID(), blockInfo.getBlockID());
assertEquals(stream.getLength(), blockInfo.getLength());
}

private BlockLocationInfo createKeyLocationInfo(ReplicationConfig repConf,
Expand Down
Loading

0 comments on commit 9657605

Please sign in to comment.