HDFS-13416. Ozone: TestNodeManager tests fail. Contributed by Bharat Viswanadham.
This commit is contained in:
parent
3779fadc5c
commit
12d80f8cae
@ -241,6 +241,17 @@ public int compareTo(DatanodeDetails that) {
|
|||||||
return this.getUuid().compareTo(that.getUuid());
|
return this.getUuid().compareTo(that.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
return obj instanceof DatanodeDetails &&
|
||||||
|
uuid.equals(((DatanodeDetails) obj).uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return uuid.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns DatanodeDetails.Builder instance.
|
* Returns DatanodeDetails.Builder instance.
|
||||||
*
|
*
|
||||||
|
@ -829,9 +829,10 @@ public List<SCMCommand> sendHeartbeat(
|
|||||||
DatanodeDetailsProto datanodeDetailsProto, SCMNodeReport nodeReport,
|
DatanodeDetailsProto datanodeDetailsProto, SCMNodeReport nodeReport,
|
||||||
ReportState containerReportState) {
|
ReportState containerReportState) {
|
||||||
|
|
||||||
|
Preconditions.checkNotNull(datanodeDetailsProto, "Heartbeat is missing " +
|
||||||
|
"DatanodeDetails.");
|
||||||
DatanodeDetails datanodeDetails = DatanodeDetails
|
DatanodeDetails datanodeDetails = DatanodeDetails
|
||||||
.getFromProtoBuf(datanodeDetailsProto);
|
.getFromProtoBuf(datanodeDetailsProto);
|
||||||
|
|
||||||
// Checking for NULL to make sure that we don't get
|
// Checking for NULL to make sure that we don't get
|
||||||
// an exception from ConcurrentList.
|
// an exception from ConcurrentList.
|
||||||
// This could be a problem in tests, if this function is invoked via
|
// This could be a problem in tests, if this function is invoked via
|
||||||
@ -846,7 +847,6 @@ public List<SCMCommand> sendHeartbeat(
|
|||||||
} else {
|
} else {
|
||||||
LOG.error("Datanode ID in heartbeat is null");
|
LOG.error("Datanode ID in heartbeat is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
return commandQueue.getCommand(datanodeDetails.getUuid());
|
return commandQueue.getCommand(datanodeDetails.getUuid());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,7 +875,7 @@ public Map<UUID, SCMNodeStat> getNodeStats() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SCMNodeMetric getNodeStat(DatanodeDetails datanodeDetails) {
|
public SCMNodeMetric getNodeStat(DatanodeDetails datanodeDetails) {
|
||||||
return new SCMNodeMetric(nodeStats.get(datanodeDetails));
|
return new SCMNodeMetric(nodeStats.get(datanodeDetails.getUuid()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
import org.apache.hadoop.ozone.protocol.commands.SCMCommand;
|
import org.apache.hadoop.ozone.protocol.commands.SCMCommand;
|
||||||
import org.apache.hadoop.test.GenericTestUtils;
|
import org.apache.hadoop.test.GenericTestUtils;
|
||||||
import org.apache.hadoop.test.PathUtils;
|
import org.apache.hadoop.test.PathUtils;
|
||||||
import org.hamcrest.CoreMatchers;
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
@ -71,7 +70,6 @@
|
|||||||
import static org.apache.hadoop.hdds.protocol.proto
|
import static org.apache.hadoop.hdds.protocol.proto
|
||||||
.StorageContainerDatanodeProtocolProtos.SCMCmdType;
|
.StorageContainerDatanodeProtocolProtos.SCMCmdType;
|
||||||
import static org.hamcrest.CoreMatchers.containsString;
|
import static org.hamcrest.CoreMatchers.containsString;
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.core.StringStartsWith.startsWith;
|
import static org.hamcrest.core.StringStartsWith.startsWith;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@ -423,8 +421,8 @@ public void testScmDetectStaleAndDeadNode() throws IOException,
|
|||||||
|
|
||||||
|
|
||||||
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
||||||
List<DatanodeDetails> nodeList = createNodeSet(nodeManager, nodeCount,
|
List<DatanodeDetails> nodeList = createNodeSet(nodeManager, nodeCount);
|
||||||
"Node");
|
|
||||||
|
|
||||||
DatanodeDetails staleNode = TestUtils.getDatanodeDetails(nodeManager);
|
DatanodeDetails staleNode = TestUtils.getDatanodeDetails(nodeManager);
|
||||||
|
|
||||||
@ -484,22 +482,20 @@ public void testScmDetectStaleAndDeadNode() throws IOException,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that we log an error for null in datanode ID.
|
* Check for NPE when datanodeDetails is passed null for sendHeartbeat.
|
||||||
*
|
*
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws InterruptedException
|
* @throws InterruptedException
|
||||||
* @throws TimeoutException
|
* @throws TimeoutException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testScmLogErrorOnNullDatanode() throws IOException,
|
public void testScmCheckForErrorOnNullDatanodeDetails() throws IOException,
|
||||||
InterruptedException, TimeoutException {
|
InterruptedException, TimeoutException {
|
||||||
try (SCMNodeManager nodeManager = createNodeManager(getConf())) {
|
try (SCMNodeManager nodeManager = createNodeManager(getConf())) {
|
||||||
GenericTestUtils.LogCapturer logCapturer =
|
|
||||||
GenericTestUtils.LogCapturer.captureLogs(SCMNodeManager.LOG);
|
|
||||||
nodeManager.sendHeartbeat(null, null, reportState);
|
nodeManager.sendHeartbeat(null, null, reportState);
|
||||||
logCapturer.stopCapturing();
|
} catch (NullPointerException npe) {
|
||||||
assertThat(logCapturer.getOutput(),
|
GenericTestUtils.assertExceptionContains("Heartbeat is missing " +
|
||||||
containsString("Datanode ID in heartbeat is null"));
|
"DatanodeDetails.", npe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,11 +564,11 @@ public void testScmClusterIsInExpectedState1() throws IOException,
|
|||||||
*/
|
*/
|
||||||
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
||||||
DatanodeDetails healthyNode =
|
DatanodeDetails healthyNode =
|
||||||
TestUtils.getDatanodeDetails(nodeManager, "HealthyNode");
|
TestUtils.getDatanodeDetails(nodeManager);
|
||||||
DatanodeDetails staleNode =
|
DatanodeDetails staleNode =
|
||||||
TestUtils.getDatanodeDetails(nodeManager, "StaleNode");
|
TestUtils.getDatanodeDetails(nodeManager);
|
||||||
DatanodeDetails deadNode =
|
DatanodeDetails deadNode =
|
||||||
TestUtils.getDatanodeDetails(nodeManager, "DeadNode");
|
TestUtils.getDatanodeDetails(nodeManager);
|
||||||
nodeManager.sendHeartbeat(
|
nodeManager.sendHeartbeat(
|
||||||
healthyNode.getProtoBufMessage(), null, reportState);
|
healthyNode.getProtoBufMessage(), null, reportState);
|
||||||
nodeManager.sendHeartbeat(
|
nodeManager.sendHeartbeat(
|
||||||
@ -708,15 +704,14 @@ private void heartbeatNodeSet(SCMNodeManager manager,
|
|||||||
* Create a set of Nodes with a given prefix.
|
* Create a set of Nodes with a given prefix.
|
||||||
*
|
*
|
||||||
* @param count - number of nodes.
|
* @param count - number of nodes.
|
||||||
* @param prefix - A prefix string that can be used in verification.
|
|
||||||
* @return List of Nodes.
|
* @return List of Nodes.
|
||||||
*/
|
*/
|
||||||
private List<DatanodeDetails> createNodeSet(SCMNodeManager nodeManager, int
|
private List<DatanodeDetails> createNodeSet(SCMNodeManager nodeManager, int
|
||||||
count, String
|
count) {
|
||||||
prefix) {
|
|
||||||
List<DatanodeDetails> list = new LinkedList<>();
|
List<DatanodeDetails> list = new LinkedList<>();
|
||||||
for (int x = 0; x < count; x++) {
|
for (int x = 0; x < count; x++) {
|
||||||
list.add(TestUtils.getDatanodeDetails(nodeManager, prefix + x));
|
list.add(TestUtils.getDatanodeDetails(nodeManager, UUID.randomUUID()
|
||||||
|
.toString()));
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -758,11 +753,11 @@ public void testScmClusterIsInExpectedState2() throws IOException,
|
|||||||
|
|
||||||
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
||||||
List<DatanodeDetails> healthyNodeList = createNodeSet(nodeManager,
|
List<DatanodeDetails> healthyNodeList = createNodeSet(nodeManager,
|
||||||
healthyCount, "Healthy");
|
healthyCount);
|
||||||
List<DatanodeDetails> staleNodeList = createNodeSet(nodeManager,
|
List<DatanodeDetails> staleNodeList = createNodeSet(nodeManager,
|
||||||
staleCount, "Stale");
|
staleCount);
|
||||||
List<DatanodeDetails> deadNodeList = createNodeSet(nodeManager, deadCount,
|
List<DatanodeDetails> deadNodeList = createNodeSet(nodeManager,
|
||||||
"Dead");
|
deadCount);
|
||||||
|
|
||||||
Runnable healthyNodeTask = () -> {
|
Runnable healthyNodeTask = () -> {
|
||||||
try {
|
try {
|
||||||
@ -810,9 +805,11 @@ public void testScmClusterIsInExpectedState2() throws IOException,
|
|||||||
List<DatanodeDetails> deadList = nodeManager.getNodes(DEAD);
|
List<DatanodeDetails> deadList = nodeManager.getNodes(DEAD);
|
||||||
|
|
||||||
for (DatanodeDetails node : deadList) {
|
for (DatanodeDetails node : deadList) {
|
||||||
assertThat(node.getHostName(), CoreMatchers.startsWith("Dead"));
|
assertTrue(deadNodeList.contains(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Checking stale nodes is tricky since they have to move between
|
// Checking stale nodes is tricky since they have to move between
|
||||||
// healthy and stale to avoid becoming dead nodes. So we search for
|
// healthy and stale to avoid becoming dead nodes. So we search for
|
||||||
// that state for a while, if we don't find that state waitfor will
|
// that state for a while, if we don't find that state waitfor will
|
||||||
@ -849,9 +846,9 @@ public void testScmCanHandleScale() throws IOException,
|
|||||||
|
|
||||||
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
||||||
List<DatanodeDetails> healthyList = createNodeSet(nodeManager,
|
List<DatanodeDetails> healthyList = createNodeSet(nodeManager,
|
||||||
healthyCount, "h");
|
healthyCount);
|
||||||
List<DatanodeDetails> staleList = createNodeSet(nodeManager,
|
List<DatanodeDetails> staleList = createNodeSet(nodeManager,
|
||||||
staleCount, "s");
|
staleCount);
|
||||||
|
|
||||||
Runnable healthyNodeTask = () -> {
|
Runnable healthyNodeTask = () -> {
|
||||||
try {
|
try {
|
||||||
@ -911,7 +908,7 @@ public void testScmLogsHeartbeatFlooding() throws IOException,
|
|||||||
|
|
||||||
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
try (SCMNodeManager nodeManager = createNodeManager(conf)) {
|
||||||
List<DatanodeDetails> healthyList = createNodeSet(nodeManager,
|
List<DatanodeDetails> healthyList = createNodeSet(nodeManager,
|
||||||
healthyCount, "h");
|
healthyCount);
|
||||||
GenericTestUtils.LogCapturer logCapturer =
|
GenericTestUtils.LogCapturer logCapturer =
|
||||||
GenericTestUtils.LogCapturer.captureLogs(SCMNodeManager.LOG);
|
GenericTestUtils.LogCapturer.captureLogs(SCMNodeManager.LOG);
|
||||||
Runnable healthyNodeTask = () -> {
|
Runnable healthyNodeTask = () -> {
|
||||||
@ -1108,7 +1105,7 @@ public void testScmNodeReportUpdate() throws IOException,
|
|||||||
// Compare the result from
|
// Compare the result from
|
||||||
// NodeManager#getNodeStats and NodeManager#getNodeStat
|
// NodeManager#getNodeStats and NodeManager#getNodeStat
|
||||||
SCMNodeStat stat1 = nodeManager.getNodeStats().
|
SCMNodeStat stat1 = nodeManager.getNodeStats().
|
||||||
get(datanodeDetails);
|
get(datanodeDetails.getUuid());
|
||||||
SCMNodeStat stat2 = nodeManager.getNodeStat(datanodeDetails).get();
|
SCMNodeStat stat2 = nodeManager.getNodeStat(datanodeDetails).get();
|
||||||
assertEquals(stat1, stat2);
|
assertEquals(stat1, stat2);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user