1616import org .elasticsearch .cluster .ClusterChangedEvent ;
1717import org .elasticsearch .cluster .ClusterName ;
1818import org .elasticsearch .cluster .ClusterState ;
19+ import org .elasticsearch .cluster .TestShardRoutingRoleStrategies ;
1920import org .elasticsearch .cluster .metadata .AliasMetadata ;
2021import org .elasticsearch .cluster .metadata .IndexMetadata ;
2122import org .elasticsearch .cluster .metadata .Metadata ;
@@ -279,7 +280,6 @@ public void testManagerSubmitsPutRequest() {
279280 */
280281 public void testManagerDetectsOutdatedMappingsInReindexedIndex () {
281282 final String reindexedIndexName = SYSTEM_INDEX_NAME + SystemIndices .UPGRADED_INDEX_SUFFIX ;
282- final var projectId = randomProjectIdOrDefault ();
283283
284284 // Simulate the post-migration state: the concrete index has the reindexed suffix and an
285285 // outdated managed_index_mappings_version, while the original primary index name and the
@@ -290,21 +290,19 @@ public void testManagerDetectsOutdatedMappingsInReindexedIndex() {
290290 .putAlias (AliasMetadata .builder (SYSTEM_INDEX_NAME ).build ())
291291 .putAlias (AliasMetadata .builder (DESCRIPTOR .getAliasName ()).build ());
292292
293- final Metadata metadata = Metadata .builder ()
294- .generateClusterUuidIfNeeded ()
295- .put (ProjectMetadata .builder (projectId ).put (reindexedIndexMeta ))
296- .build ();
293+ final Metadata metadata = Metadata .builder ().generateClusterUuidIfNeeded ().put (reindexedIndexMeta ).build ();
297294 final DiscoveryNode node = DiscoveryNodeUtils .builder ("1" ).roles (new HashSet <>(DiscoveryNodeRole .roles ())).build ();
298295 final DiscoveryNodes nodes = DiscoveryNodes .builder ().add (node ).masterNodeId (node .getId ()).localNodeId (node .getId ()).build ();
299296 final ClusterState clusterState = ClusterState .builder (CLUSTER_NAME )
300297 .nodes (nodes )
301298 .metadata (metadata )
302- .routingTable (GlobalRoutingTableTestHelper .buildRoutingTable (metadata , RoutingTable .Builder ::addAsNew ))
299+ .routingTable (
300+ RoutingTable .builder (TestShardRoutingRoleStrategies .DEFAULT_ROLE_ONLY ).addAsNew (metadata .index (reindexedIndexName ))
301+ )
303302 .build ();
304- ProjectState projectState = clusterState .projectState (projectId );
305303
306304 assertThat (
307- SystemIndexMappingUpdateService .getUpgradeStatus (projectState , DESCRIPTOR ),
305+ SystemIndexMappingUpdateService .getUpgradeStatus (clusterState , DESCRIPTOR ),
308306 equalTo (UpgradeStatus .NEEDS_MAPPINGS_UPDATE )
309307 );
310308 }
0 commit comments