@Test public void testUnassignedShardAndEmptyNodesInRoutingTable() throws Exception { internalCluster().startNode(); createIndex("a"); ensureSearchable("a"); ClusterState current = clusterService().state(); GatewayAllocator allocator = internalCluster().getInstance(GatewayAllocator.class); AllocationDeciders allocationDeciders = new AllocationDeciders(Settings.EMPTY, new AllocationDecider[0]); RoutingNodes routingNodes = new RoutingNodes( ClusterState.builder(current) .routingTable( RoutingTable.builder(current.routingTable()) .remove("a") .addAsRecovery(current.metaData().index("a"))) .nodes(DiscoveryNodes.EMPTY_NODES) .build()); ClusterInfo clusterInfo = new ClusterInfo(ImmutableMap.<String, DiskUsage>of(), ImmutableMap.<String, Long>of()); RoutingAllocation routingAllocation = new RoutingAllocation(allocationDeciders, routingNodes, current.nodes(), clusterInfo); allocator.allocateUnassigned(routingAllocation); }