|
9 | 9 |
|
10 | 10 | package org.elasticsearch.ingest.geoip; |
11 | 11 |
|
12 | | -import org.elasticsearch.ElasticsearchException; |
13 | 12 | import org.elasticsearch.action.ActionListener; |
14 | 13 | import org.elasticsearch.action.ActionRequest; |
15 | 14 | import org.elasticsearch.action.ActionResponse; |
|
25 | 24 | import org.elasticsearch.action.index.TransportIndexAction; |
26 | 25 | import org.elasticsearch.action.support.broadcast.BroadcastResponse; |
27 | 26 | import org.elasticsearch.cluster.ClusterState; |
28 | | -import org.elasticsearch.cluster.block.ClusterBlockException; |
29 | 27 | import org.elasticsearch.cluster.block.ClusterBlocks; |
30 | 28 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
31 | 29 | import org.elasticsearch.cluster.service.ClusterService; |
32 | | -import org.elasticsearch.common.ReferenceDocs; |
33 | 30 | import org.elasticsearch.common.settings.ClusterSettings; |
34 | 31 | import org.elasticsearch.common.settings.Settings; |
35 | 32 | import org.elasticsearch.index.reindex.BulkByScrollResponse; |
@@ -583,37 +580,28 @@ void processDatabase(Map<String, Object> databaseInfo) { |
583 | 580 | assertFalse(it.hasNext()); |
584 | 581 | } |
585 | 582 |
|
586 | | - public void testUpdateDatabasesWriteBlock() { |
| 583 | + public void testUpdateDatabasesWriteBlock() throws IOException { |
| 584 | + /* |
| 585 | + * Here we make sure that we bail out before making an httpClient request if there is write block on the .geoip_databases index |
| 586 | + */ |
587 | 587 | ClusterState state = createClusterState(new PersistentTasksCustomMetadata(1L, Map.of())); |
588 | 588 | var geoIpIndex = state.getMetadata().getIndicesLookup().get(GeoIpDownloader.DATABASES_INDEX).getWriteIndex().getName(); |
589 | 589 | state = ClusterState.builder(state) |
590 | 590 | .blocks(new ClusterBlocks.Builder().addIndexBlock(geoIpIndex, IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK)) |
591 | 591 | .build(); |
592 | 592 | when(clusterService.state()).thenReturn(state); |
593 | | - var e = expectThrows(ClusterBlockException.class, () -> geoIpDownloader.updateDatabases()); |
594 | | - assertThat( |
595 | | - e.getMessage(), |
596 | | - equalTo( |
597 | | - "index [" |
598 | | - + geoIpIndex |
599 | | - + "] blocked by: [TOO_MANY_REQUESTS/12/disk usage exceeded flood-stage watermark, " |
600 | | - + "index has read-only-allow-delete block; for more information, see " |
601 | | - + ReferenceDocs.FLOOD_STAGE_WATERMARK |
602 | | - + "];" |
603 | | - ) |
604 | | - ); |
| 593 | + geoIpDownloader.updateDatabases(); |
605 | 594 | verifyNoInteractions(httpClient); |
606 | 595 | } |
607 | 596 |
|
608 | | - public void testUpdateDatabasesIndexNotReady() { |
| 597 | + public void testUpdateDatabasesIndexNotReady() throws IOException { |
| 598 | + /* |
| 599 | + * Here we make sure that we bail out before making an httpClient request if there are unallocated shards on the .geoip_databases |
| 600 | + * index |
| 601 | + */ |
609 | 602 | ClusterState state = createClusterState(new PersistentTasksCustomMetadata(1L, Map.of()), true); |
610 | | - var geoIpIndex = state.getMetadata().getIndicesLookup().get(GeoIpDownloader.DATABASES_INDEX).getWriteIndex().getName(); |
611 | | - state = ClusterState.builder(state) |
612 | | - .blocks(new ClusterBlocks.Builder().addIndexBlock(geoIpIndex, IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK)) |
613 | | - .build(); |
614 | 603 | when(clusterService.state()).thenReturn(state); |
615 | | - var e = expectThrows(ElasticsearchException.class, () -> geoIpDownloader.updateDatabases()); |
616 | | - assertThat(e.getMessage(), equalTo("not all primary shards of [.geoip_databases] index are active")); |
| 604 | + geoIpDownloader.updateDatabases(); |
617 | 605 | verifyNoInteractions(httpClient); |
618 | 606 | } |
619 | 607 |
|
|
0 commit comments