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