Skip to content

Commit f5631f4

Browse files
authored
Add logging to AllocationRoutedStepTests (#63670) (#64191)
(cherry picked from commit 1a72a0d) Signed-off-by: Andrei Dan <[email protected]>
1 parent d4e7d29 commit f5631f4

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ilm/AllocationRoutedStepTests.java

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,27 +75,25 @@ public void testConditionMet() {
7575
Map<String, String> requires = AllocateActionTests.randomMap(1, 5);
7676
Settings.Builder existingSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id)
7777
.put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID());
78-
Settings.Builder expectedSettings = Settings.builder();
7978
Settings.Builder node1Settings = Settings.builder();
8079
Settings.Builder node2Settings = Settings.builder();
8180
includes.forEach((k, v) -> {
8281
existingSettings.put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + k, v);
83-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + k, v);
8482
node1Settings.put(Node.NODE_ATTRIBUTES.getKey() + k, v);
8583
});
8684
excludes.forEach((k, v) -> {
8785
existingSettings.put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + k, v);
88-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + k, v);
8986
});
9087
requires.forEach((k, v) -> {
9188
existingSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
92-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
9389
node1Settings.put(Node.NODE_ATTRIBUTES.getKey() + k, v);
9490
});
9591

9692
IndexRoutingTable.Builder indexRoutingTable = IndexRoutingTable.builder(index)
9793
.addShard(TestShardRouting.newShardRouting(new ShardId(index, 0), "node1", true, ShardRoutingState.STARTED));
9894

95+
logger.info("running test with routing configurations:\n\t includes: [{}]\n\t excludes: [{}]\n\t requires: [{}]",
96+
includes, excludes, requires);
9997
AllocationRoutedStep step = createRandomInstance();
10098
assertAllocateStatus(index, 1, 0, step, existingSettings, node1Settings, node2Settings, indexRoutingTable,
10199
new ClusterStateWaitStep.Result(true, null));
@@ -174,12 +172,10 @@ public void testConditionNotMetDueToRelocation() {
174172
.put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id)
175173
.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_PREFIX + "._id", "node1")
176174
.put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID());
177-
Settings.Builder expectedSettings = Settings.builder();
178175
Settings.Builder node1Settings = Settings.builder();
179176
Settings.Builder node2Settings = Settings.builder();
180177
requires.forEach((k, v) -> {
181178
existingSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
182-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
183179
node1Settings.put(Node.NODE_ATTRIBUTES.getKey() + k, v);
184180
});
185181
boolean primaryOnNode1 = randomBoolean();
@@ -206,28 +202,26 @@ public void testExecuteAllocateNotComplete() throws Exception {
206202
() -> AllocateActionTests.randomMap(1, 5));
207203
Settings.Builder existingSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id)
208204
.put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID());
209-
Settings.Builder expectedSettings = Settings.builder();
210205
Settings.Builder node1Settings = Settings.builder();
211206
Settings.Builder node2Settings = Settings.builder();
212207
includes.forEach((k, v) -> {
213208
existingSettings.put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + k, v);
214-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + k, v);
215209
node1Settings.put(Node.NODE_ATTRIBUTES.getKey() + k, v);
216210
});
217211
excludes.forEach((k, v) -> {
218212
existingSettings.put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + k, v);
219-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + k, v);
220213
});
221214
requires.forEach((k, v) -> {
222215
existingSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
223-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
224216
node1Settings.put(Node.NODE_ATTRIBUTES.getKey() + k, v);
225217
});
226218

227219
IndexRoutingTable.Builder indexRoutingTable = IndexRoutingTable.builder(index)
228220
.addShard(TestShardRouting.newShardRouting(new ShardId(index, 0), "node1", true, ShardRoutingState.STARTED))
229221
.addShard(TestShardRouting.newShardRouting(new ShardId(index, 1), "node2", true, ShardRoutingState.STARTED));
230222

223+
logger.info("running test with routing configurations:\n\t includes: [{}]\n\t excludes: [{}]\n\t requires: [{}]",
224+
includes, excludes, requires);
231225
AllocationRoutedStep step = createRandomInstance();
232226
assertAllocateStatus(index, 2, 0, step, existingSettings, node1Settings, node2Settings, indexRoutingTable,
233227
new ClusterStateWaitStep.Result(false, allShardsActiveAllocationInfo(0, 1)));
@@ -243,21 +237,17 @@ public void testExecuteAllocateNotCompleteOnlyOneCopyAllocated() throws Exceptio
243237
() -> AllocateActionTests.randomMap(1, 5));
244238
Settings.Builder existingSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id)
245239
.put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID());
246-
Settings.Builder expectedSettings = Settings.builder();
247240
Settings.Builder node1Settings = Settings.builder();
248241
Settings.Builder node2Settings = Settings.builder();
249242
includes.forEach((k, v) -> {
250243
existingSettings.put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + k, v);
251-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + k, v);
252244
node1Settings.put(Node.NODE_ATTRIBUTES.getKey() + k, v);
253245
});
254246
excludes.forEach((k, v) -> {
255247
existingSettings.put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + k, v);
256-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + k, v);
257248
});
258249
requires.forEach((k, v) -> {
259250
existingSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
260-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
261251
node1Settings.put(Node.NODE_ATTRIBUTES.getKey() + k, v);
262252
});
263253

@@ -267,7 +257,10 @@ public void testExecuteAllocateNotCompleteOnlyOneCopyAllocated() throws Exceptio
267257
.addShard(TestShardRouting.newShardRouting(new ShardId(index, 0), "node2", primaryOnNode1 == false,
268258
ShardRoutingState.STARTED));
269259

260+
270261
AllocationRoutedStep step = new AllocationRoutedStep(randomStepKey(), randomStepKey());
262+
logger.info("running test with routing configurations:\n\t includes: [{}]\n\t excludes: [{}]\n\t requires: [{}]",
263+
includes, excludes, requires);
271264
assertAllocateStatus(index, 2, 0, step, existingSettings, node1Settings, node2Settings, indexRoutingTable,
272265
new ClusterStateWaitStep.Result(false, allShardsActiveAllocationInfo(0, 1)));
273266
}
@@ -282,21 +275,17 @@ public void testExecuteAllocateUnassigned() throws Exception {
282275
() -> AllocateActionTests.randomMap(1, 5));
283276
Settings.Builder existingSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id)
284277
.put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID());
285-
Settings.Builder expectedSettings = Settings.builder();
286278
Settings.Builder node1Settings = Settings.builder();
287279
Settings.Builder node2Settings = Settings.builder();
288280
includes.forEach((k, v) -> {
289281
existingSettings.put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + k, v);
290-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + k, v);
291282
node1Settings.put(Node.NODE_ATTRIBUTES.getKey() + k, v);
292283
});
293284
excludes.forEach((k, v) -> {
294285
existingSettings.put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + k, v);
295-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_EXCLUDE_GROUP_SETTING.getKey() + k, v);
296286
});
297287
requires.forEach((k, v) -> {
298288
existingSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
299-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
300289
node1Settings.put(Node.NODE_ATTRIBUTES.getKey() + k, v);
301290
});
302291

@@ -305,6 +294,8 @@ public void testExecuteAllocateUnassigned() throws Exception {
305294
.addShard(TestShardRouting.newShardRouting(new ShardId(index, 1), null, null, true, ShardRoutingState.UNASSIGNED,
306295
new UnassignedInfo(randomFrom(Reason.values()), "the shard is intentionally unassigned")));
307296

297+
logger.info("running test with routing configurations:\n\t includes: [{}]\n\t excludes: [{}]\n\t requires: [{}]",
298+
includes, excludes, requires);
308299
AllocationRoutedStep step = createRandomInstance();
309300
assertAllocateStatus(index, 2, 0, step, existingSettings, node1Settings, node2Settings, indexRoutingTable,
310301
new ClusterStateWaitStep.Result(false, waitingForActiveShardsAllocationInfo(0)));
@@ -329,15 +320,10 @@ public void testExecuteAllocateUnassigned() throws Exception {
329320
*/
330321
public void testExecuteReplicasNotAllocatedOnSingleNode() {
331322
Index index = new Index(randomAlphaOfLengthBetween(1, 20), randomAlphaOfLengthBetween(1, 20));
332-
Map<String, String> requires = Collections.singletonMap("_name", "node1");
333323
Settings.Builder existingSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT.id)
334324
.put(IndexMetadata.SETTING_INDEX_UUID, index.getUUID());
335-
Settings.Builder expectedSettings = Settings.builder();
336325
Settings.Builder node1Settings = Settings.builder();
337326
Settings.Builder node2Settings = Settings.builder();
338-
requires.forEach((k, v) -> {
339-
expectedSettings.put(IndexMetadata.INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + k, v);
340-
});
341327

342328
IndexRoutingTable.Builder indexRoutingTable = IndexRoutingTable.builder(index)
343329
.addShard(TestShardRouting.newShardRouting(new ShardId(index, 0), "node1", true, ShardRoutingState.STARTED))

0 commit comments

Comments
 (0)