xianjingfeng commented on code in PR #938:
URL: https://github.com/apache/incubator-uniffle/pull/938#discussion_r1230953453
##########
integration-test/common/src/test/java/org/apache/uniffle/test/ServletTest.java:
##########
@@ -107,15 +131,48 @@ public void testNodesServlet() throws Exception {
serverList = response.getData();
assertEquals(1, serverList.size());
assertEquals(shuffleServer.getId(), serverList.get(0).get("id"));
+ }
- content = TestUtils.httpGet(NODES_URL + "?status=DECOMMISSIONED");
- response = objectMapper.readValue(content, new
TypeReference<Response<List<HashMap<String, Object>>>>() {});
- serverList = response.getData();
- assertEquals(0, serverList.size());
- content = TestUtils.httpGet(NODES_URL + "?status=ACTIVE");
- response = objectMapper.readValue(content, new
TypeReference<Response<List<HashMap<String, Object>>>>() {});
- serverList = response.getData();
- assertEquals(2, serverList.size());
+ @Test
+ public void testLostNodesServlet() throws IOException {
+ SimpleClusterManager clusterManager = (SimpleClusterManager)
coordinatorServer.getClusterManager();
+ ShuffleServer shuffleServer3 = shuffleServers.get(2);
+ ShuffleServer shuffleServer4 = shuffleServers.get(3);
+ Map<String, ServerNode> servers = clusterManager.getServers();
+
servers.get(shuffleServer3.getId()).setTimestamp(System.currentTimeMillis() -
40000);
+
servers.get(shuffleServer4.getId()).setTimestamp(System.currentTimeMillis() -
40000);
+ clusterManager.nodesCheckTest();
+ List<String> expectShuffleIds =
Arrays.asList(shuffleServer3.getId(),shuffleServer4.getId());
+ List<String> shuffleIds = new ArrayList<>();
+ Response<List<HashMap<String, Object>>> response =
objectMapper.readValue(TestUtils.httpGet(LOSTNODES_URL),
+ new TypeReference<Response<List<HashMap<String, Object>>>>() {});
+ List<HashMap<String, Object>> serverList = response.getData();
+ for (HashMap<String, Object> stringObjectHashMap : serverList) {
+ String shuffleId = (String) stringObjectHashMap.get("id");
+ shuffleIds.add(shuffleId);
+ }
+ assertTrue(CollectionUtils.isEqualCollection(expectShuffleIds,
shuffleIds));
+ }
+
+ @Test
+ public void testUnhealthyNodesServlet() {
+ ShuffleServer shuffleServer3 = shuffleServers.get(2);
+ ShuffleServer shuffleServer4 = shuffleServers.get(3);
+ shuffleServer3.markUnhealthy();
+ shuffleServer4.markUnhealthy();
+ List<String> expectShuffleIds =
Arrays.asList(shuffleServer3.getId(),shuffleServer4.getId());
+ List<String> shuffleIds = new ArrayList<>();
+ Awaitility.await().atMost(30,TimeUnit.SECONDS).until(() -> {
+ Response<List<HashMap<String, Object>>> response =
objectMapper.readValue(TestUtils.httpGet(UNHEALTHYNODES_URL),
+ new TypeReference<Response<List<HashMap<String, Object>>>>() {});
+ List<HashMap<String, Object>> serverList = response.getData();
+ for (HashMap<String, Object> stringObjectHashMap : serverList) {
+ String shuffleId = (String) stringObjectHashMap.get("id");
+ shuffleIds.add(shuffleId);
+ }
+ return serverList.size() == 2;
+ });
+ assertTrue(CollectionUtils.isEqualCollection(expectShuffleIds,shuffleIds));
Review Comment:
```suggestion
assertTrue(CollectionUtils.isEqualCollection(expectShuffleIds,
shuffleIds));
```
--
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]