This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 0038dd6610 HDDS-8479. XceiverClient not closed properly in tests
(#4611)
0038dd6610 is described below
commit 0038dd661016cbbdff504e42985896134aa73795
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Mon Apr 24 10:02:24 2023 +0200
HDDS-8479. XceiverClient not closed properly in tests (#4611)
---
.../rpc/TestContainerReplicationEndToEnd.java | 13 ++++-
.../rpc/TestContainerStateMachineFailures.java | 68 ++++++++++++----------
.../client/rpc/TestDeleteWithSlowFollower.java | 29 ++++-----
3 files changed, 62 insertions(+), 48 deletions(-)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerReplicationEndToEnd.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerReplicationEndToEnd.java
index 0192255a82..96f5ac586c 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerReplicationEndToEnd.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerReplicationEndToEnd.java
@@ -135,6 +135,9 @@ public class TestContainerReplicationEndToEnd {
@AfterClass
public static void shutdown() {
IOUtils.closeQuietly(client);
+ if (xceiverClientManager != null) {
+ xceiverClientManager.close();
+ }
if (cluster != null) {
cluster.shutdown();
}
@@ -184,8 +187,6 @@ public class TestContainerReplicationEndToEnd {
Thread.sleep(2 * containerReportInterval);
DatanodeDetails oldReplicaNode = pipeline.getFirstNode();
// now move the container to the closed on the datanode.
- XceiverClientSpi xceiverClient =
- xceiverClientManager.acquireClient(pipeline);
ContainerProtos.ContainerCommandRequestProto.Builder request =
ContainerProtos.ContainerCommandRequestProto.newBuilder();
request.setDatanodeUuid(pipeline.getFirstNode().getUuidString());
@@ -193,7 +194,13 @@ public class TestContainerReplicationEndToEnd {
request.setContainerID(containerID);
request.setCloseContainer(
ContainerProtos.CloseContainerRequestProto.getDefaultInstance());
- xceiverClient.sendCommand(request.build());
+ XceiverClientSpi xceiverClient =
+ xceiverClientManager.acquireClient(pipeline);
+ try {
+ xceiverClient.sendCommand(request.build());
+ } finally {
+ xceiverClientManager.releaseClient(xceiverClient, false);
+ }
// wait for container to move to closed state in SCM
Thread.sleep(2 * containerReportInterval);
Assert.assertTrue(
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerStateMachineFailures.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerStateMachineFailures.java
index 6c4ca58213..03350bd4ba 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerStateMachineFailures.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestContainerStateMachineFailures.java
@@ -643,42 +643,46 @@ public class TestContainerStateMachineFailures {
}
};
- List<Thread> threadList = new ArrayList<>();
+ try {
+ List<Thread> threadList = new ArrayList<>();
- for (int i = 0; i < 100; i++) {
- count++;
- Thread r = new Thread(r2);
- r.start();
- threadList.add(r);
- }
+ for (int i = 0; i < 100; i++) {
+ count++;
+ Thread r = new Thread(r2);
+ r.start();
+ threadList.add(r);
+ }
- Thread closeContainerThread = new Thread(r1);
- closeContainerThread.start();
- threadList.add(closeContainerThread);
- latch.await(600, TimeUnit.SECONDS);
- for (int i = 0; i < 101; i++) {
- threadList.get(i).join();
- }
+ Thread closeContainerThread = new Thread(r1);
+ closeContainerThread.start();
+ threadList.add(closeContainerThread);
+ latch.await(600, TimeUnit.SECONDS);
+ for (int i = 0; i < 101; i++) {
+ threadList.get(i).join();
+ }
- if (failCount.get() > 0) {
- fail("testWriteStateMachineDataIdempotencyWithClosedContainer failed");
- }
- Assert.assertTrue(
- TestHelper.getDatanodeService(omKeyLocationInfo, cluster)
- .getDatanodeStateMachine()
- .getContainer().getContainerSet().getContainer(containerID)
- .getContainerState()
- == ContainerProtos.ContainerDataProto.State.CLOSED);
- Assert.assertTrue(stateMachine.isStateMachineHealthy());
- try {
- stateMachine.takeSnapshot();
- } catch (IOException ioe) {
- Assert.fail("Exception should not be thrown");
- }
- FileInfo latestSnapshot = storage.findLatestSnapshot().getFile();
- Assert.assertFalse(snapshot.getPath().equals(latestSnapshot.getPath()));
+ if (failCount.get() > 0) {
+ fail("testWriteStateMachineDataIdempotencyWithClosedContainer failed");
+ }
+ Assert.assertTrue(
+ TestHelper.getDatanodeService(omKeyLocationInfo, cluster)
+ .getDatanodeStateMachine()
+ .getContainer().getContainerSet().getContainer(containerID)
+ .getContainerState()
+ == ContainerProtos.ContainerDataProto.State.CLOSED);
+ Assert.assertTrue(stateMachine.isStateMachineHealthy());
+ try {
+ stateMachine.takeSnapshot();
+ } catch (IOException ioe) {
+ Assert.fail("Exception should not be thrown");
+ }
+ FileInfo latestSnapshot = storage.findLatestSnapshot().getFile();
+ Assert.assertFalse(snapshot.getPath().equals(latestSnapshot.getPath()));
- r2.run();
+ r2.run();
+ } finally {
+ xceiverClientManager.releaseClient(xceiverClient, false);
+ }
}
@Test
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestDeleteWithSlowFollower.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestDeleteWithSlowFollower.java
index b7232d756d..ac4e11dd83 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestDeleteWithSlowFollower.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/client/rpc/TestDeleteWithSlowFollower.java
@@ -180,6 +180,9 @@ public class TestDeleteWithSlowFollower {
@AfterClass
public static void shutdown() {
IOUtils.closeQuietly(client);
+ if (xceiverClientManager != null) {
+ xceiverClientManager.close();
+ }
if (cluster != null) {
cluster.shutdown();
}
@@ -242,8 +245,6 @@ public class TestDeleteWithSlowFollower {
key.close();
// now move the container to the closed on the datanode.
- XceiverClientSpi xceiverClient =
- xceiverClientManager.acquireClient(pipeline);
ContainerProtos.ContainerCommandRequestProto.Builder request =
ContainerProtos.ContainerCommandRequestProto.newBuilder();
request.setDatanodeUuid(pipeline.getFirstNode().getUuidString());
@@ -251,22 +252,24 @@ public class TestDeleteWithSlowFollower {
request.setContainerID(containerID);
request.setCloseContainer(
ContainerProtos.CloseContainerRequestProto.getDefaultInstance());
- xceiverClient.sendCommand(request.build());
+ XceiverClientSpi xceiverClient =
+ xceiverClientManager.acquireClient(pipeline);
+ try {
+ xceiverClient.sendCommand(request.build());
+ } finally {
+ xceiverClientManager.releaseClient(xceiverClient, false);
+ }
ContainerStateMachine stateMachine =
(ContainerStateMachine) RatisTestHelper
.getStateMachine(leader, pipeline);
- OmKeyArgs keyArgs = new OmKeyArgs.Builder().setVolumeName(volumeName).
- setBucketName(bucketName)
- .setReplicationConfig(
- RatisReplicationConfig
- .getInstance(THREE))
- .setKeyName(keyName)
- .build();
+ OmKeyArgs keyArgs = new OmKeyArgs.Builder()
+ .setVolumeName(volumeName).setBucketName(bucketName)
+ .setReplicationConfig(RatisReplicationConfig.getInstance(THREE))
+ .setKeyName(keyName).build();
OmKeyInfo info = cluster.getOzoneManager().lookupKey(keyArgs);
- BlockID blockID =
- info.getKeyLocationVersions().get(0).getLocationList().get(0)
- .getBlockID();
+ BlockID blockID = info.getKeyLocationVersions().get(0)
+ .getLocationList().get(0).getBlockID();
OzoneContainer ozoneContainer;
final DatanodeStateMachine dnStateMachine =
leader.getDatanodeStateMachine();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]