During the development and review process of the disk health indicator we noticed that it was hard to understand. Since we learnt a lot from the first round of development we want to go through the code one more time and restructure it.
server/src/test/java/org/elasticsearch/health/node/DiskHealthIndicatorServiceTests.java
DiskHealthIndicatorService.getNodeIdsReportingStatus(diskInfoByNode, status),
                equalTo(statusToNodeIdMap.get(status) == null ? Set.of() : statusToNodeIdMap.get(status))
            );
        }
    }
    public void testGetRolesOnNodes() {
        Set<DiscoveryNodeRole> roles = new HashSet<>(
            randomSubsetOf(randomIntBetween(1, DiscoveryNodeRole.roles().size()), DiscoveryNodeRole.roles())
        );
        Set<DiscoveryNode> discoveryNodes = createNodes(roles);
        ClusterService clusterService = createClusterService(false, discoveryNodes);
        Set<DiscoveryNodeRole> result = DiskHealthIndicatorService.getRolesOnNodes(
            discoveryNodes.stream().map(DiscoveryNode::getId).collect(Collectors.toSet()),
            clusterService.state()
        );
        assertThat(result, equalTo(roles));
    }
    public void testGetNodesWithDataRole() {
        Set<DiscoveryNode> nonDataNodes = createNodes(new HashSet<>(randomNonEmptySubsetOf(NON_DATA_ROLES)));
        Set<DiscoveryNode> pureDataNodes = createNodes(new HashSet<>(randomNonEmptySubsetOf(DATA_ROLES)));
        Set<DiscoveryNode> mixedNodes = createNodes(
            Stream.concat(randomNonEmptySubsetOf(NON_DATA_ROLES).stream(), randomNonEmptySubsetOf(DATA_ROLES).stream())
                .collect(Collectors.toSet())
        );
        Set<DiscoveryNode> allNodes = Stream.concat(Stream.concat(nonDataNodes.stream(), pureDataNodes.stream()), mixedNodes.stream())
            .collect(Collectors.toSet());
        ClusterService clusterService = createClusterService(false, allNodes);
        assertThat(
            DiskHealthIndicatorService.getNodesWithDataRole(
                allNodes.stream().map(DiscoveryNode::getId).collect(Collectors.toSet()),