parent
734dc198ca
commit
7bd389de61
|
@ -489,6 +489,7 @@ public class UpdateTests extends ElasticsearchIntegrationTest {
|
||||||
.setSource("field1", 0, "content", "bar")
|
.setSource("field1", 0, "content", "bar")
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
|
|
||||||
|
long ttl = 10000;
|
||||||
client().prepareIndex()
|
client().prepareIndex()
|
||||||
.setIndex("test")
|
.setIndex("test")
|
||||||
.setType("subtype1")
|
.setType("subtype1")
|
||||||
|
@ -496,28 +497,27 @@ public class UpdateTests extends ElasticsearchIntegrationTest {
|
||||||
.setParent("parentId1")
|
.setParent("parentId1")
|
||||||
.setRouting("routing1")
|
.setRouting("routing1")
|
||||||
.setTimestamp(String.valueOf(timestamp))
|
.setTimestamp(String.valueOf(timestamp))
|
||||||
.setTTL(111211211)
|
.setTTL(ttl)
|
||||||
.setSource("field1", 1, "content", "foo")
|
.setSource("field1", 1, "content", "foo")
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
long postIndexTs = System.currentTimeMillis();
|
|
||||||
|
|
||||||
// Update the first object and note context variables values
|
// Update the first object and note context variables values
|
||||||
Map<String, Object> scriptParams = new HashMap<>();
|
Map<String, Object> scriptParams = new HashMap<>();
|
||||||
scriptParams.put("delim", "_");
|
scriptParams.put("delim", "_");
|
||||||
UpdateResponse updateResponse = client().prepareUpdate("test", "subtype1", "id1")
|
UpdateResponse updateResponse = client().prepareUpdate("test", "subtype1", "id1")
|
||||||
.setRouting("routing1")
|
.setRouting("routing1")
|
||||||
.setScript(
|
.setScript("assert ctx._index == \"test\" : \"index should be \\\"test\\\"\"\n" +
|
||||||
"assert ctx._index == \"test\" : \"index should be \\\"test\\\"\"\n" +
|
"assert ctx._type == \"subtype1\" : \"type should be \\\"subtype1\\\"\"\n" +
|
||||||
"assert ctx._type == \"subtype1\" : \"type should be \\\"subtype1\\\"\"\n" +
|
"assert ctx._id == \"id1\" : \"id should be \\\"id1\\\"\"\n" +
|
||||||
"assert ctx._id == \"id1\" : \"id should be \\\"id1\\\"\"\n" +
|
"assert ctx._version == 1 : \"version should be 1\"\n" +
|
||||||
"assert ctx._version == 1 : \"version should be 1\"\n" +
|
"assert ctx._parent == \"parentId1\" : \"parent should be \\\"parentId1\\\"\"\n" +
|
||||||
"assert ctx._parent == \"parentId1\" : \"parent should be \\\"parentId1\\\"\"\n" +
|
"assert ctx._routing == \"routing1\" : \"routing should be \\\"routing1\\\"\"\n" +
|
||||||
"assert ctx._routing == \"routing1\" : \"routing should be \\\"routing1\\\"\"\n" +
|
"assert ctx._timestamp == " + timestamp + " : \"timestamp should be " + timestamp + "\"\n" +
|
||||||
"assert ctx._timestamp == " + timestamp + " : \"timestamp should be " + timestamp + "\"\n" +
|
// ttl has a 3-second leeway, because it's always counting down
|
||||||
"def now = new Date().getTime()\n" +
|
"assert ctx._ttl <= " + ttl + " : \"ttl should be <= " + ttl + " but was \" + ctx._ttl\n" +
|
||||||
"assert (111211211 - ctx._ttl) <= (now - " + postIndexTs + ") : \"ttl is not within acceptable range\"\n" +
|
"assert ctx._ttl >= " + (ttl-3000) + " : \"ttl should be <= " + (ttl-3000) + " but was \" + ctx._ttl\n" +
|
||||||
"ctx._source.content = ctx._source.content + delim + ctx._source.content;\n" +
|
"ctx._source.content = ctx._source.content + delim + ctx._source.content;\n" +
|
||||||
"ctx._source.field1 += 1;\n",
|
"ctx._source.field1 += 1;\n",
|
||||||
ScriptService.ScriptType.INLINE)
|
ScriptService.ScriptType.INLINE)
|
||||||
.setScriptParams(scriptParams)
|
.setScriptParams(scriptParams)
|
||||||
.execute().actionGet();
|
.execute().actionGet();
|
||||||
|
|
Loading…
Reference in New Issue