ivandika3 commented on code in PR #7716:
URL: https://github.com/apache/ozone/pull/7716#discussion_r1921852005
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestBlockDataStreamOutput.java:
##########
@@ -105,90 +132,109 @@ public static void init() throws Exception {
.setDataStreamWindowSize(5 * chunkSize)
.applyTo(conf);
- cluster = MiniOzoneCluster.newBuilder(conf)
+ MiniOzoneCluster cluster = MiniOzoneCluster.newBuilder(conf)
.setNumDatanodes(5)
.setDatanodeFactory(UniformDatanodesFactory.newBuilder()
.setCurrentVersion(DN_OLD_VERSION)
.build())
.build();
+
cluster.waitForClusterToBeReady();
- //the easiest way to create an open container is creating a key
- client = OzoneClientFactory.getRpcClient(conf);
- objectStore = client.getObjectStore();
- keyString = UUID.randomUUID().toString();
- volumeName = "testblockdatastreamoutput";
- bucketName = volumeName;
- objectStore.createVolume(volumeName);
- objectStore.getVolume(volumeName).createBucket(bucketName);
+
+ try (OzoneClient client = cluster.newClient()) {
+ ObjectStore objectStore = client.getObjectStore();
+ objectStore.createVolume(volumeName);
+ objectStore.getVolume(volumeName).createBucket(bucketName);
+ }
+
+ return cluster;
}
- static String getKeyName() {
- return UUID.randomUUID().toString();
+ private static Stream<Arguments> clientParameters() {
+ return Stream.of(
+ Arguments.of(true, true),
+ Arguments.of(true, false),
+ Arguments.of(false, true),
+ Arguments.of(false, false)
+ );
}
- @AfterAll
- public static void shutdown() {
- IOUtils.closeQuietly(client);
- if (cluster != null) {
- cluster.shutdown();
- }
+ private static Stream<Arguments> dataLengthParameters() {
+ return Stream.of(
+ Arguments.of(chunkSize / 2),
+ Arguments.of(chunkSize),
+ Arguments.of(chunkSize + 50),
+ Arguments.of(blockSize + 50)
+ );
}
- @Test
- public void testHalfChunkWrite() throws Exception {
- testWrite(chunkSize / 2);
- testWriteWithFailure(chunkSize / 2);
+ static OzoneClientConfig newClientConfig(ConfigurationSource source,
+ boolean flushDelay, boolean
enablePiggybacking) {
+ OzoneClientConfig clientConfig = source.getObject(OzoneClientConfig.class);
+ clientConfig.setChecksumType(ContainerProtos.ChecksumType.NONE);
+ clientConfig.setStreamBufferFlushDelay(flushDelay);
+ clientConfig.setEnablePutblockPiggybacking(enablePiggybacking);
+ return clientConfig;
}
- @Test
- public void testSingleChunkWrite() throws Exception {
- testWrite(chunkSize);
- testWriteWithFailure(chunkSize);
+ static OzoneClient newClient(OzoneConfiguration conf,
+ OzoneClientConfig config) throws IOException {
+ OzoneConfiguration copy = new OzoneConfiguration(conf);
+ copy.setFromObject(config);
+ return OzoneClientFactory.getRpcClient(copy);
+ }
+
+ /**
+ * Create a MiniDFSCluster for testing.
+ * <p>
+ * Ozone is made active by setting OZONE_ENABLED = true
+ *
+ * @throws IOException
+ */
+ @BeforeAll
+ public void init() throws Exception {
+ cluster = createCluster();
}
- @Test
- public void testMultiChunkWrite() throws Exception {
- testWrite(chunkSize + 50);
- testWriteWithFailure(chunkSize + 50);
+ static String getKeyName() {
+ return UUID.randomUUID().toString();
}
- @Test
- @Flaky("HDDS-12027")
- public void testMultiBlockWrite() throws Exception {
- testWrite(blockSize + 50);
- testWriteWithFailure(blockSize + 50);
+ /**
+ * Shutdown MiniDFSCluster.
+ */
+ @AfterAll
+ public void shutdown() {
+ if (cluster != null) {
+ cluster.shutdown();
+ }
}
- static void testWrite(int dataLength) throws Exception {
- XceiverClientMetrics metrics =
- XceiverClientManager.getXceiverClientMetrics();
- long pendingWriteChunkCount =
metrics.getPendingContainerOpCountMetrics(WriteChunk);
- long pendingPutBlockCount =
metrics.getPendingContainerOpCountMetrics(PutBlock);
+ @ParameterizedTest
+ @MethodSource("dataLengthParameters")
+ public void testHalfChunkWrite(int dataLength) throws Exception {
+ OzoneClientConfig config = newClientConfig(cluster.getConf(), false, true);
+ try (OzoneClient client = newClient(cluster.getConf(), config)) {
+ testWrite(client, dataLength);
+ testWriteWithFailure(client, dataLength);
+ }
+ }
Review Comment:
There is a discrepancy between the method name and what it is actually
testing here. The method name is `testHalfChunkWrite`, but
`dataLengthParameters` here have different lengths covering half chunk, full
chunk, multi chunks, multi blocks.
Can use a more generalized name like `testStreamWrite`.
In the future, we can separate the different data length to different
methods since each cases might have specialized assertions only for that case
(e.g. in `BlockOutputStream`: `testWriteMoreThanChunkSize`,
`testWriteExactlyFlushSize`, etc.)
--
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]