Skip to content

Commit b930959

Browse files
Fix tests
1 parent bd1f9a2 commit b930959

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

server/src/test/java/org/elasticsearch/cluster/ClusterStateTests.java

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494

9595
public class ClusterStateTests extends ESTestCase {
9696
private static final Setting<Integer> PROJECT_SETTING = Setting.intSetting("project.setting", 0, Setting.Property.ProjectScope);
97+
private static final Setting<Integer> PROJECT_SETTING2 = Setting.intSetting("project.setting2", 0, Setting.Property.ProjectScope);
9798

9899
public void testSupersedes() {
99100
final DiscoveryNode node1 = DiscoveryNodeUtils.builder("node1").roles(emptySet()).build();
@@ -791,7 +792,14 @@ public void testToXContentWithMultipleProjects() throws IOException {
791792
{
792793
"id": "3LftaL7hgfXAsF60Gm6jcD",
793794
"settings": {
794-
"project.setting": "42"
795+
"project.setting": "42",
796+
"project.setting2": "43"
797+
}
798+
},
799+
{
800+
"id": "tb5W0bx765nDVIwqJPw92G",
801+
"settings": {
802+
"project.setting": "1"
795803
}
796804
}
797805
]
@@ -854,6 +862,7 @@ private static BytesReference sortRoutingTableXContent(String jsonContent) throw
854862

855863
private static ClusterState buildMultiProjectClusterState(DiscoveryNode... nodes) {
856864
ProjectId projectId1 = ProjectId.fromId("3LftaL7hgfXAsF60Gm6jcD");
865+
ProjectId projectId2 = ProjectId.fromId("tb5W0bx765nDVIwqJPw92G");
857866
final Metadata metadata = Metadata.builder()
858867
.clusterUUID("N8nJxElHSP23swO0bPLOcQ")
859868
.clusterUUIDCommitted(true)
@@ -880,7 +889,7 @@ private static ClusterState buildMultiProjectClusterState(DiscoveryNode... nodes
880889
)
881890
)
882891
.put(
883-
ProjectMetadata.builder(ProjectId.fromId("tb5W0bx765nDVIwqJPw92G"))
892+
ProjectMetadata.builder(projectId2)
884893
.put(
885894
IndexMetadata.builder("common-index")
886895
.settings(
@@ -901,11 +910,12 @@ private static ClusterState buildMultiProjectClusterState(DiscoveryNode... nodes
901910
.metadata(metadata)
902911
.nodes(discoveryNodes.build())
903912
.routingTable(GlobalRoutingTableTestHelper.buildRoutingTable(metadata, RoutingTable.Builder::addAsNew))
904-
.putProjectSettings(projectId1, Settings.builder().put(PROJECT_SETTING.getKey(), 42).build())
913+
.putProjectSettings(projectId1, Settings.builder().put(PROJECT_SETTING.getKey(), 42).put(PROJECT_SETTING2.getKey(), 43).build())
914+
.putProjectSettings(projectId2, Settings.builder().put(PROJECT_SETTING.getKey(), 1).build())
905915
.blocks(
906916
ClusterBlocks.builder()
907917
.addGlobalBlock(Metadata.CLUSTER_READ_ONLY_BLOCK)
908-
.addIndexBlock(ProjectId.fromId("tb5W0bx765nDVIwqJPw92G"), "common-index", IndexMetadata.INDEX_METADATA_BLOCK)
918+
.addIndexBlock(projectId2, "common-index", IndexMetadata.INDEX_METADATA_BLOCK)
909919
.addIndexBlock(projectId1, "another-index", IndexMetadata.INDEX_READ_ONLY_BLOCK)
910920
)
911921
.build();
@@ -2202,6 +2212,14 @@ public static int expectedChunkCount(ToXContent.Params params, ClusterState clus
22022212
}
22032213
}
22042214

2215+
// settings
2216+
if (metrics.contains(ClusterState.Metric.PROJECTS_SETTINGS)) {
2217+
Map<ProjectId, Settings> projectsSettings = clusterState.projectsSettings();
2218+
if (projectsSettings.isEmpty() == false) {
2219+
chunkCount += 2 + projectsSettings.size();
2220+
}
2221+
}
2222+
22052223
return Math.toIntExact(chunkCount);
22062224
}
22072225
}

server/src/test/java/org/elasticsearch/cluster/metadata/ProjectMetadataTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,7 @@ public void testToXContentMultiProject() throws IOException {
559559
},
560560
"data_stream_aliases": {}
561561
},
562-
"settings": {
563-
"project.setting.value": "43"
564-
},
565-
"reserved_state": {}
562+
"reserved_state": {}
566563
}
567564
""",
568565
IndexVersion.current(),

0 commit comments

Comments
 (0)