### Question:
ClientRMService extends AbstractService implements
    ClientRMProtocol { @Override public GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request) throws YarnRemoteException { GetClusterNodesResponse response = recordFactory.newRecordInstance(GetClusterNodesResponse.class); Collection<RMNode> nodes = this.rmContext.getRMNodes().values(); List<NodeReport> nodeReports = new ArrayList<NodeReport>(nodes.size()); for (RMNode nodeInfo : nodes) { nodeReports.add(createNodeReports(nodeInfo)); } response.setNodeReports(nodeReports); return response; } ClientRMService(RMContext rmContext, YarnScheduler scheduler,
      RMAppManager rmAppManager, ApplicationACLsManager applicationACLsManager,
      RMDelegationTokenSecretManager rmDTSecretManager); @Override void init(Configuration conf); @Override void start(); @Private InetSocketAddress getBindAddress(); @Override GetNewApplicationResponse getNewApplication(
      GetNewApplicationRequest request); @Override GetApplicationReportResponse getApplicationReport(
      GetApplicationReportRequest request); @Override SubmitApplicationResponse submitApplication(
      SubmitApplicationRequest request); @SuppressWarnings("unchecked") @Override KillApplicationResponse forceKillApplication(
      KillApplicationRequest request); @Override GetClusterMetricsResponse getClusterMetrics(
      GetClusterMetricsRequest request); @Override GetAllApplicationsResponse getAllApplications(
      GetAllApplicationsRequest request); @Override GetClusterNodesResponse getClusterNodes(GetClusterNodesRequest request); @Override GetQueueInfoResponse getQueueInfo(GetQueueInfoRequest request); @Override GetQueueUserAclsInfoResponse getQueueUserAcls(
      GetQueueUserAclsInfoRequest request); @Override GetDelegationTokenResponse getDelegationToken(
      GetDelegationTokenRequest request); @Override void stop();  }### Answer:
@Test public void testGetClusterNodes() throws Exception { MockRM rm = new MockRM() { protected ClientRMService createClientRMService() { return new ClientRMService(this.rmContext, scheduler, this.rmAppManager, this.applicationACLsManager, this.rmDTSecretManager); }; }; rm.start(); MockNM node = rm.registerNode("host:1234", 1024); node.nodeHeartbeat(true); Configuration conf = new Configuration(); YarnRPC rpc = YarnRPC.create(conf); InetSocketAddress rmAddress = rm.getClientRMService().getBindAddress(); LOG.info("Connecting to ResourceManager at " + rmAddress); ClientRMProtocol client = (ClientRMProtocol) rpc .getProxy(ClientRMProtocol.class, rmAddress, conf); GetClusterNodesRequest request = Records.newRecord(GetClusterNodesRequest.class); List<NodeReport> nodeReports = client.getClusterNodes(request).getNodeReports(); Assert.assertEquals(1, nodeReports.size()); Assert.assertTrue("Node is expected to be healthy!", nodeReports.get(0) .getNodeHealthStatus().getIsNodeHealthy()); node.nodeHeartbeat(false); nodeReports = client.getClusterNodes(request).getNodeReports(); Assert.assertEquals(1, nodeReports.size()); Assert.assertFalse("Node is expected to be unhealthy!", nodeReports.get(0) .getNodeHealthStatus().getIsNodeHealthy()); }