Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontedor committed May 16, 2018
1 parent 168a56c commit 5673b2f
Showing 1 changed file with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ public void testCreateShrinkIndexToN() {
ensureGreen();
// now merge source into a 4 shard index
assertAcked(client().admin().indices().prepareResizeIndex("source", "first_shrink")
.setSettings(Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", shardSplits[1]).build()).get());
.setSettings(Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", shardSplits[1])
.putNull("index.blocks.write")
.build()).get());
ensureGreen();
assertHitCount(client().prepareSearch("first_shrink").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), 20);

Expand All @@ -133,9 +135,12 @@ public void testCreateShrinkIndexToN() {
ensureGreen();
// now merge source into a 2 shard index
assertAcked(client().admin().indices().prepareResizeIndex("first_shrink", "second_shrink")
.setSettings(Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", shardSplits[2]).build()).get());
.setSettings(Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", shardSplits[2])
.putNull("index.blocks.write")
.putNull("index.routing.allocation.require._name")
.build()).get());
ensureGreen();
assertHitCount(client().prepareSearch("second_shrink").setSize(100).setQuery(new TermsQueryBuilder("foo", "bar")).get(), 20);
// let it be allocated anywhere and bump replicas
Expand Down Expand Up @@ -270,8 +275,14 @@ public void testCreateShrinkIndex() {

// now merge source into a single shard index
final boolean createWithReplicas = randomBoolean();
assertAcked(client().admin().indices().prepareResizeIndex("source", "target")
.setSettings(Settings.builder().put("index.number_of_replicas", createWithReplicas ? 1 : 0).build()).get());
assertAcked(
client().admin().indices().prepareResizeIndex("source", "target")
.setSettings(
Settings.builder()
.put("index.number_of_replicas", createWithReplicas ? 1 : 0)
.putNull("index.blocks.write")
.putNull("index.routing.allocation.require._name")
.build()).get());
ensureGreen();

// resolve true merge node - this is not always the node we required as all shards may be on another node
Expand Down Expand Up @@ -442,19 +453,20 @@ public void testCreateShrinkWithIndexSort() throws Exception {

// check that index sort cannot be set on the target index
IllegalArgumentException exc = expectThrows(IllegalArgumentException.class,
() -> client().admin().indices().prepareResizeIndex("source", "target")
.setSettings(Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", "2")
.put("index.sort.field", "foo")
.build()).get());
() -> client().admin().indices().prepareResizeIndex("source", "target")
.setSettings(Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", "2")
.put("index.sort.field", "foo")
.build()).get());
assertThat(exc.getMessage(), containsString("can't override index sort when resizing an index"));

// check that the index sort order of `source` is correctly applied to the `target`
assertAcked(client().admin().indices().prepareResizeIndex("source", "target")
.setSettings(Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", "2").build()).get());
.setSettings(Settings.builder()
.put("index.number_of_replicas", 0)
.put("index.number_of_shards", "2")
.putNull("index.blocks.write").build()).get());
ensureGreen();
flushAndRefresh();
GetSettingsResponse settingsResponse =
Expand Down

0 comments on commit 5673b2f

Please sign in to comment.