Skip to content

Commit c244087

Browse files
committed
WIP changes
1 parent 64b7145 commit c244087

File tree

2 files changed

+60
-52
lines changed

2 files changed

+60
-52
lines changed

modules/ingest-geoip/src/test/java/org/elasticsearch/ingest/geoip/EnterpriseGeoIpDownloaderTests.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.elasticsearch.cluster.block.ClusterBlockException;
2828
import org.elasticsearch.cluster.block.ClusterBlocks;
2929
import org.elasticsearch.cluster.metadata.IndexMetadata;
30+
import org.elasticsearch.cluster.metadata.ProjectId;
3031
import org.elasticsearch.cluster.service.ClusterService;
3132
import org.elasticsearch.common.ReferenceDocs;
3233
import org.elasticsearch.common.settings.ClusterSettings;
@@ -76,9 +77,12 @@ public class EnterpriseGeoIpDownloaderTests extends ESTestCase {
7677
private ThreadPool threadPool;
7778
private MockClient client;
7879
private EnterpriseGeoIpDownloader geoIpDownloader;
80+
private ProjectId projectId;
7981

8082
@Before
8183
public void setup() throws IOException {
84+
// TODO: change to random projectId
85+
projectId = ProjectId.DEFAULT;
8286
httpClient = mock(HttpClient.class);
8387
when(httpClient.getBytes(any(), anyString())).thenReturn(
8488
"e4a3411cdd7b21eaf18675da5a7f9f360d33c6882363b2c19c38715834c9e836 GeoIP2-City_20240709.tar.gz".getBytes(StandardCharsets.UTF_8)
@@ -92,7 +96,7 @@ public void setup() throws IOException {
9296
when(clusterService.getClusterSettings()).thenReturn(
9397
new ClusterSettings(Settings.EMPTY, Set.of(GeoIpDownloaderTaskExecutor.POLL_INTERVAL_SETTING))
9498
);
95-
ClusterState state = createClusterState(new PersistentTasksCustomMetadata(1L, Map.of()));
99+
ClusterState state = createClusterState(projectId, new PersistentTasksCustomMetadata(1L, Map.of()));
96100
when(clusterService.state()).thenReturn(state);
97101
client = new MockClient(threadPool);
98102
geoIpDownloader = new EnterpriseGeoIpDownloader(
@@ -440,15 +444,15 @@ void deleteOldChunks(String name, int firstChunk) {
440444
}
441445

442446
public void testUpdateDatabasesWriteBlock() {
443-
ClusterState state = createClusterState(new PersistentTasksCustomMetadata(1L, Map.of()));
447+
ClusterState state = createClusterState(projectId, new PersistentTasksCustomMetadata(1L, Map.of()));
444448
var geoIpIndex = state.getMetadata()
445-
.getProject()
449+
.getProject(projectId)
446450
.getIndicesLookup()
447451
.get(EnterpriseGeoIpDownloader.DATABASES_INDEX)
448452
.getWriteIndex()
449453
.getName();
450454
state = ClusterState.builder(state)
451-
.blocks(new ClusterBlocks.Builder().addIndexBlock(geoIpIndex, IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK))
455+
.blocks(new ClusterBlocks.Builder().addIndexBlock(projectId, geoIpIndex, IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK))
452456
.build();
453457
when(clusterService.state()).thenReturn(state);
454458
var e = expectThrows(ClusterBlockException.class, () -> geoIpDownloader.updateDatabases());
@@ -467,15 +471,15 @@ public void testUpdateDatabasesWriteBlock() {
467471
}
468472

469473
public void testUpdateDatabasesIndexNotReady() throws IOException {
470-
ClusterState state = createClusterState(new PersistentTasksCustomMetadata(1L, Map.of()), true);
474+
ClusterState state = createClusterState(projectId, new PersistentTasksCustomMetadata(1L, Map.of()), true);
471475
var geoIpIndex = state.getMetadata()
472-
.getProject()
476+
.getProject(projectId)
473477
.getIndicesLookup()
474478
.get(EnterpriseGeoIpDownloader.DATABASES_INDEX)
475479
.getWriteIndex()
476480
.getName();
477481
state = ClusterState.builder(state)
478-
.blocks(new ClusterBlocks.Builder().addIndexBlock(geoIpIndex, IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK))
482+
.blocks(new ClusterBlocks.Builder().addIndexBlock(projectId, geoIpIndex, IndexMetadata.INDEX_READ_ONLY_ALLOW_DELETE_BLOCK))
479483
.build();
480484
when(clusterService.state()).thenReturn(state);
481485
geoIpDownloader.updateDatabases();

0 commit comments

Comments
 (0)