adoroszlai commented on code in PR #11117:
URL: https://github.com/apache/ozone/pull/11117#discussion_r3861392138
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/read/TestChunkInputStream.java:
##########
@@ -17,44 +17,111 @@
package org.apache.hadoop.ozone.client.rpc.read;
+import static
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.ONE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.apache.commons.io.IOUtils;
+import org.apache.hadoop.hdds.client.RatisReplicationConfig;
+import org.apache.hadoop.hdds.client.ReplicationConfig;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.scm.XceiverClientGrpc;
+import org.apache.hadoop.hdds.scm.XceiverClientShortCircuit;
import org.apache.hadoop.hdds.scm.storage.BlockInputStream;
import org.apache.hadoop.hdds.scm.storage.ChunkInputStream;
+import org.apache.hadoop.hdds.scm.storage.DomainSocketFactory;
+import org.apache.hadoop.hdds.scm.storage.LocalChunkInputStream;
import org.apache.hadoop.ozone.client.OzoneClient;
+import org.apache.hadoop.ozone.client.OzoneClientFactory;
import org.apache.hadoop.ozone.client.io.KeyInputStream;
import org.apache.hadoop.ozone.container.common.impl.ContainerLayoutVersion;
import org.apache.hadoop.ozone.container.keyvalue.ContainerLayoutTestInfo;
import org.apache.hadoop.ozone.om.BucketForTesting;
+import org.apache.ozone.test.GenericTestUtils.LogCapturer;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInstance;
+import org.junit.jupiter.params.Parameter;
+import org.junit.jupiter.params.ParameterizedClass;
+import org.junit.jupiter.params.provider.ValueSource;
/**
* Tests {@link ChunkInputStream}.
*/
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+@ParameterizedClass
+@ValueSource(booleans = {true, false})
class TestChunkInputStream extends InputStreamTests {
+ @Parameter
+ private boolean useShortCircuitRead;
+
+ private LogCapturer localChunkInputStreamLog;
+ private LogCapturer shortCircuitClientLog;
+ private LogCapturer blockInputStreamLog;
+ private LogCapturer grpcClientLog;
+
+ @BeforeEach
+ void startCapturing() {
+ localChunkInputStreamLog =
LogCapturer.captureLogs(LocalChunkInputStream.LOG);
+ shortCircuitClientLog =
LogCapturer.captureLogs(XceiverClientShortCircuit.LOG);
+ blockInputStreamLog = LogCapturer.captureLogs(BlockInputStream.LOG);
+ grpcClientLog = LogCapturer.captureLogs(XceiverClientGrpc.LOG);
+ }
+
+ @AfterEach
+ void stopCapturing() {
+ org.apache.hadoop.hdds.utils.IOUtils.closeQuietly(
+ blockInputStreamLog, grpcClientLog, localChunkInputStreamLog,
shortCircuitClientLog);
+ }
+
+ @Override
+ int getDatanodeCount() {
+ return getRepConfig().getRequiredNodes();
+ }
+
+ @Override
+ ReplicationConfig getRepConfig() {
+ return RatisReplicationConfig.getInstance(ONE);
+ }
+
/**
* Run the tests as a single test method to avoid needing a new mini-cluster
* for each test.
*/
@ContainerLayoutTestInfo.ContainerTest
void testAll(ContainerLayoutVersion layout) throws Exception {
- try (OzoneClient client = getCluster().newClient()) {
- updateConfig(layout);
+ if (useShortCircuitRead) {
+
assumeTrue(DomainSocketFactory.getInstance(getCluster().getConf()).isServiceReady());
+ }
+ updateConfig(layout);
+
+ OzoneConfiguration clientConfig = new
OzoneConfiguration(getCluster().getConf());
+ useShortCircuitRead(clientConfig, useShortCircuitRead);
+ debugShortCircuitRead();
+
+ try (OzoneClient client = OzoneClientFactory.getRpcClient(clientConfig)) {
BucketForTesting bucket = BucketForTesting.newBuilder(client).build();
testChunkReadBuffers(bucket);
testBufferRelease(bucket);
testCloseReleasesBuffers(bucket);
}
+
+ assertEquals(useShortCircuitRead, localChunkInputStreamLog.getOutput()
Review Comment:
We would have to mirror the statements for the two cases, so I prefer
`assertEquals` here.
--
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]