From 9c2b3d79ad5d61a28a867314816bc18b0e506807 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 26 Aug 2016 12:48:45 -0400 Subject: [PATCH] Fix bulk update tests It was relying on fields extracting fields from the source but it doesn't do that any more. Original commit: elastic/x-pack-elasticsearch@23b534c068fbaa2329003eb6fca47ed966055196 --- .../integration/BulkUpdateTests.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java index 0d4568c7bde..d49cb7950c8 100644 --- a/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java +++ b/elasticsearch/x-pack/security/src/test/java/org/elasticsearch/integration/BulkUpdateTests.java @@ -42,8 +42,8 @@ public class BulkUpdateTests extends SecurityIntegTestCase { public void testThatBulkUpdateDoesNotLoseFields() { assertEquals(DocWriteResponse.Result.CREATED, client().prepareIndex("index1", "type").setSource("{\"test\": \"test\"}").setId("1").get().getResult()); - GetResponse getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").setFields("test").get(); - assertThat(getResponse.getField("test").getValue(), equalTo("test")); + GetResponse getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").get(); + assertEquals("test", getResponse.getSource().get("test")); if (randomBoolean()) { flushAndRefresh(); @@ -52,9 +52,9 @@ public class BulkUpdateTests extends SecurityIntegTestCase { // update with a new field assertEquals(DocWriteResponse.Result.UPDATED, internalCluster().transportClient().prepareUpdate("index1", "type", "1") .setDoc("{\"not test\": \"not test\"}").get().getResult()); - getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").setFields("test", "not test").get(); - assertThat(getResponse.getField("test").getValue(), equalTo("test")); - assertThat(getResponse.getField("not test").getValue(), equalTo("not test")); + getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").get(); + assertEquals("test", getResponse.getSource().get("test")); + assertEquals("not test", getResponse.getSource().get("not test")); // this part is important. Without this, the document may be read from the translog which would bypass the bug where // FLS kicks in because the request can't be found and only returns meta fields @@ -64,11 +64,10 @@ public class BulkUpdateTests extends SecurityIntegTestCase { BulkResponse response = internalCluster().transportClient().prepareBulk().add(client().prepareUpdate("index1", "type", "1") .setDoc("{\"bulk updated\": \"bulk updated\"}")).get(); assertEquals(DocWriteResponse.Result.UPDATED, response.getItems()[0].getResponse().getResult()); - getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1"). - setFields("test", "not test", "bulk updated").get(); - assertThat(getResponse.getField("test").getValue(), equalTo("test")); - assertThat(getResponse.getField("not test").getValue(), equalTo("not test")); - assertThat(getResponse.getField("bulk updated").getValue(), equalTo("bulk updated")); + getResponse = internalCluster().transportClient().prepareGet("index1", "type", "1").get(); + assertEquals("test", getResponse.getSource().get("test")); + assertEquals("not test", getResponse.getSource().get("not test")); + assertEquals("bulk updated", getResponse.getSource().get("bulk updated")); } public void testThatBulkUpdateDoesNotLoseFieldsHttp() throws IOException {