From 2a16334ee2c72334ec41f3afdd2ac57d13c2e0f9 Mon Sep 17 00:00:00 2001 From: Joe Gallo Date: Mon, 18 Oct 2021 10:04:48 -0400 Subject: [PATCH] Put helpers after tests, rather than before --- .../routing/allocation/DataTierTests.java | 18 +++++------ .../IndexDeprecationChecksTests.java | 30 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/DataTierTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/DataTierTests.java index 0284df0013a9d..d21c10784f6d1 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/DataTierTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/DataTierTests.java @@ -142,6 +142,15 @@ public void testGetPreferredTiersConfiguration() { assertThat(exception.getMessage(), is("invalid data tier [no_tier]")); } + public void testDataNodesWithoutAllDataRoles() { + ClusterState clusterState = clusterStateWithoutAllDataRoles(); + Set nodes = DataTier.dataNodesWithoutAllDataRoles(clusterState); + assertEquals(1, nodes.size()); + DiscoveryNode node = nodes.iterator().next(); + assertEquals("name_3", node.getName()); + assertEquals(org.elasticsearch.core.Set.of(DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE), node.getRoles()); + } + public static ClusterState clusterStateWithoutAllDataRoles() { Set allDataRoles = new HashSet<>(DiscoveryNodeRole.BUILT_IN_ROLES).stream() .filter(role -> ALL_DATA_TIERS.contains(role.roleName())).collect(Collectors.toSet()); @@ -162,15 +171,6 @@ public static ClusterState clusterStateWithoutAllDataRoles() { return ClusterState.builder(ClusterState.EMPTY_STATE).nodes(discoBuilder.build()).build(); } - public void testDataNodesWithoutAllDataRoles() { - ClusterState clusterState = clusterStateWithoutAllDataRoles(); - Set nodes = DataTier.dataNodesWithoutAllDataRoles(clusterState); - assertEquals(1, nodes.size()); - DiscoveryNode node = nodes.iterator().next(); - assertEquals("name_3", node.getName()); - assertEquals(org.elasticsearch.core.Set.of(DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE), node.getRoles()); - } - private static DiscoveryNodes buildDiscoveryNodes() { int numNodes = randomIntBetween(3, 15); DiscoveryNodes.Builder discoBuilder = DiscoveryNodes.builder(); diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java index 070a4f4d303dc..4163c006e0692 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java @@ -698,21 +698,6 @@ public void testFrozenIndex() { )); } - public static ClusterState clusterStateWithoutAllDataRoles() { - DiscoveryNodes.Builder discoBuilder = DiscoveryNodes.builder(); - List nodesList = org.elasticsearch.core.List.of( - new DiscoveryNode("name_0", "node_0", buildNewFakeTransportAddress(), org.elasticsearch.core.Map.of(), - org.elasticsearch.core.Set.of(DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE), Version.CURRENT) - ); - for (DiscoveryNode node : nodesList) { - discoBuilder = discoBuilder.add(node); - } - discoBuilder.localNodeId(randomFrom(nodesList).getId()); - discoBuilder.masterNodeId(randomFrom(nodesList).getId()); - - return ClusterState.builder(ClusterState.EMPTY_STATE).nodes(discoBuilder.build()).build(); - } - public void testEmptyDataTierPreference() { Settings.Builder settings = settings(Version.CURRENT); settings.put(DataTier.TIER_PREFERENCE_SETTING.getKey(), " "); @@ -736,4 +721,19 @@ public void testEmptyDataTierPreference() { )); } } + + public static ClusterState clusterStateWithoutAllDataRoles() { + DiscoveryNodes.Builder discoBuilder = DiscoveryNodes.builder(); + List nodesList = org.elasticsearch.core.List.of( + new DiscoveryNode("name_0", "node_0", buildNewFakeTransportAddress(), org.elasticsearch.core.Map.of(), + org.elasticsearch.core.Set.of(DiscoveryNodeRole.DATA_FROZEN_NODE_ROLE), Version.CURRENT) + ); + for (DiscoveryNode node : nodesList) { + discoBuilder = discoBuilder.add(node); + } + discoBuilder.localNodeId(randomFrom(nodesList).getId()); + discoBuilder.masterNodeId(randomFrom(nodesList).getId()); + + return ClusterState.builder(ClusterState.EMPTY_STATE).nodes(discoBuilder.build()).build(); + } }