summaryrefslogtreecommitdiff
path: root/rest-api-spec/test/update
diff options
context:
space:
mode:
Diffstat (limited to 'rest-api-spec/test/update')
-rw-r--r--rest-api-spec/test/update/10_doc.yaml40
-rw-r--r--rest-api-spec/test/update/15_script.yaml79
-rw-r--r--rest-api-spec/test/update/20_doc_upsert.yaml41
-rw-r--r--rest-api-spec/test/update/22_doc_as_upsert.yaml41
-rw-r--r--rest-api-spec/test/update/25_script_upsert.yaml41
-rw-r--r--rest-api-spec/test/update/30_internal_version.yaml47
-rw-r--r--rest-api-spec/test/update/35_external_version.yaml40
-rw-r--r--rest-api-spec/test/update/40_routing.yaml56
-rw-r--r--rest-api-spec/test/update/50_parent.yaml79
-rw-r--r--rest-api-spec/test/update/55_parent_with_routing.yaml63
-rw-r--r--rest-api-spec/test/update/60_refresh.yaml50
-rw-r--r--rest-api-spec/test/update/70_timestamp.yaml77
-rw-r--r--rest-api-spec/test/update/75_ttl.yaml96
-rw-r--r--rest-api-spec/test/update/80_fields.yaml20
-rw-r--r--rest-api-spec/test/update/85_fields_meta.yaml51
-rw-r--r--rest-api-spec/test/update/90_missing.yaml42
-rw-r--r--rest-api-spec/test/update/TODO.txt7
17 files changed, 870 insertions, 0 deletions
diff --git a/rest-api-spec/test/update/10_doc.yaml b/rest-api-spec/test/update/10_doc.yaml
new file mode 100644
index 0000000..b4581ed
--- /dev/null
+++ b/rest-api-spec/test/update/10_doc.yaml
@@ -0,0 +1,40 @@
+---
+"Partial document":
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ foo: bar
+ count: 1
+ nested: { one: 1, two: 2 }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc:
+ foo: baz
+ nested:
+ one: 3
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: "1" }
+ - match: { _version: 2 }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _source.foo: baz }
+ - match: { _source.count: 1 }
+ - match: { _source.nested.one: 3 }
+ - match: { _source.nested.two: 2 }
+
diff --git a/rest-api-spec/test/update/15_script.yaml b/rest-api-spec/test/update/15_script.yaml
new file mode 100644
index 0000000..c8cfc5f
--- /dev/null
+++ b/rest-api-spec/test/update/15_script.yaml
@@ -0,0 +1,79 @@
+---
+"Script":
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ foo: bar
+ count: 1
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ script: "1"
+ body:
+ lang: mvel
+ script: "ctx._source.foo = bar"
+ params: { bar: 'xxx' }
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: "1" }
+ - match: { _version: 2 }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _source.foo: xxx }
+ - match: { _source.count: 1 }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ lang: mvel
+ script: "ctx._source.foo = 'yyy'"
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: "1" }
+ - match: { _version: 3 }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _source.foo: yyy }
+ - match: { _source.count: 1 }
+
+ - do:
+ catch: /script_lang not supported \[doesnotexist\]/
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ script: "1"
+ lang: "doesnotexist"
+ params: { bar: 'xxx' }
+
+ - do:
+ catch: /script_lang not supported \[doesnotexist\]/
+ update:
+ index: test_1
+ type: test
+ id: 1
+ lang: doesnotexist
+ script: "1"
+
diff --git a/rest-api-spec/test/update/20_doc_upsert.yaml b/rest-api-spec/test/update/20_doc_upsert.yaml
new file mode 100644
index 0000000..f34e030
--- /dev/null
+++ b/rest-api-spec/test/update/20_doc_upsert.yaml
@@ -0,0 +1,41 @@
+---
+"Doc upsert":
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: bar, count: 1 }
+ upsert: { foo: baz }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _source.foo: baz }
+ - is_false: _source.count
+
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: bar, count: 1 }
+ upsert: { foo: baz }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _source.foo: bar }
+ - match: { _source.count: 1 }
+
+
diff --git a/rest-api-spec/test/update/22_doc_as_upsert.yaml b/rest-api-spec/test/update/22_doc_as_upsert.yaml
new file mode 100644
index 0000000..af25730
--- /dev/null
+++ b/rest-api-spec/test/update/22_doc_as_upsert.yaml
@@ -0,0 +1,41 @@
+---
+"Doc as upsert":
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: bar, count: 1 }
+ doc_as_upsert: 1
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _source.foo: bar }
+ - match: { _source.count: 1 }
+
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { count: 2 }
+ doc_as_upsert: 1
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _source.foo: bar }
+ - match: { _source.count: 2 }
+
+
diff --git a/rest-api-spec/test/update/25_script_upsert.yaml b/rest-api-spec/test/update/25_script_upsert.yaml
new file mode 100644
index 0000000..64226b7
--- /dev/null
+++ b/rest-api-spec/test/update/25_script_upsert.yaml
@@ -0,0 +1,41 @@
+---
+"Script upsert":
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ script: "ctx._source.foo = bar"
+ params: { bar: 'xxx' }
+ upsert: { foo: baz }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _source.foo: baz }
+
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ script: "ctx._source.foo = bar"
+ params: { bar: 'xxx' }
+ upsert: { foo: baz }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _source.foo: xxx }
+
+
diff --git a/rest-api-spec/test/update/30_internal_version.yaml b/rest-api-spec/test/update/30_internal_version.yaml
new file mode 100644
index 0000000..c9f3706
--- /dev/null
+++ b/rest-api-spec/test/update/30_internal_version.yaml
@@ -0,0 +1,47 @@
+---
+"Internal version":
+
+ - do:
+ catch: conflict
+ update:
+ index: test_1
+ type: test
+ id: 1
+ version: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - match: { _version: 1}
+
+ - do:
+ catch: conflict
+ update:
+ index: test_1
+ type: test
+ id: 1
+ version: 2
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ version: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - match: { _version: 2}
diff --git a/rest-api-spec/test/update/35_external_version.yaml b/rest-api-spec/test/update/35_external_version.yaml
new file mode 100644
index 0000000..a3ca3a9
--- /dev/null
+++ b/rest-api-spec/test/update/35_external_version.yaml
@@ -0,0 +1,40 @@
+---
+"External version":
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ version: 2
+ version_type: external
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - match: { _version: 2 }
+
+ - do:
+ catch: conflict
+ update:
+ index: test_1
+ type: test
+ id: 1
+ version: 2
+ version_type: external
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ version: 3
+ version_type: external
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - match: { _version: 3 }
diff --git a/rest-api-spec/test/update/40_routing.yaml b/rest-api-spec/test/update/40_routing.yaml
new file mode 100644
index 0000000..52cd938
--- /dev/null
+++ b/rest-api-spec/test/update/40_routing.yaml
@@ -0,0 +1,56 @@
+---
+"Routing":
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ settings:
+ index:
+ number_of_replicas: 0
+
+ - do:
+ cluster.health:
+ wait_for_status: green
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ routing: 5
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ routing: 5
+ fields: _routing
+
+ - match: { fields._routing: "5"}
+
+ - do:
+ catch: missing
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ routing: 5
+ fields: foo
+ body:
+ doc: { foo: baz }
+
+ - match: { get.fields.foo: [baz] }
+
diff --git a/rest-api-spec/test/update/50_parent.yaml b/rest-api-spec/test/update/50_parent.yaml
new file mode 100644
index 0000000..3d15ea9
--- /dev/null
+++ b/rest-api-spec/test/update/50_parent.yaml
@@ -0,0 +1,79 @@
+---
+setup:
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ mappings:
+ test:
+ _parent: { type: "foo" }
+ - do:
+ cluster.health:
+ wait_for_status: yellow
+
+---
+"Parent":
+
+ - do:
+ catch: /RoutingMissingException/
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ fields: [_parent, _routing]
+
+ - match: { fields._parent: "5"}
+ - match: { fields._routing: "5"}
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ fields: foo
+ body:
+ doc: { foo: baz }
+
+ - match: { get.fields.foo: [baz] }
+
+---
+"Parent omitted":
+
+ - do:
+ index:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ body: { foo: bar }
+
+ - do:
+ catch: request
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+
diff --git a/rest-api-spec/test/update/55_parent_with_routing.yaml b/rest-api-spec/test/update/55_parent_with_routing.yaml
new file mode 100644
index 0000000..cc82802
--- /dev/null
+++ b/rest-api-spec/test/update/55_parent_with_routing.yaml
@@ -0,0 +1,63 @@
+---
+"Parent with routing":
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ mappings:
+ test:
+ _parent: { type: "foo" }
+ settings:
+ number_of_replicas: 0
+
+ - do:
+ cluster.health:
+ wait_for_status: green
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ routing: 4
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ routing: 4
+ parent: 5
+ fields: [_parent, _routing]
+
+ - match: { fields._parent: "5"}
+ - match: { fields._routing: "4"}
+
+ - do:
+ catch: missing
+ update:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ body:
+ doc: { foo: baz }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ routing: 4
+ fields: foo
+ body:
+ doc: { foo: baz }
+
+ - match: { get.fields.foo: [baz] }
+
diff --git a/rest-api-spec/test/update/60_refresh.yaml b/rest-api-spec/test/update/60_refresh.yaml
new file mode 100644
index 0000000..6048292
--- /dev/null
+++ b/rest-api-spec/test/update/60_refresh.yaml
@@ -0,0 +1,50 @@
+---
+"Refresh":
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ settings:
+ index.refresh_interval: -1
+ number_of_replicas: 0
+ - do:
+ cluster.health:
+ wait_for_status: yellow
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ search:
+ index: test_1
+ type: test
+ body:
+ query: { term: { _id: 1 }}
+
+ - match: { hits.total: 0 }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 2
+ refresh: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ search:
+ index: test_1
+ type: test
+ body:
+ query: { term: { _id: 2 }}
+
+ - match: { hits.total: 1 }
diff --git a/rest-api-spec/test/update/70_timestamp.yaml b/rest-api-spec/test/update/70_timestamp.yaml
new file mode 100644
index 0000000..368f750
--- /dev/null
+++ b/rest-api-spec/test/update/70_timestamp.yaml
@@ -0,0 +1,77 @@
+---
+"Timestamp":
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ mappings:
+ test:
+ _timestamp:
+ enabled: 1
+ store: yes
+ - do:
+ cluster.health:
+ wait_for_status: yellow
+
+# blank timestamp
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: _timestamp
+
+ - is_true: fields._timestamp
+
+# milliseconds since epoch
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+ timestamp: 1372011280000
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: _timestamp
+
+ - match: { fields._timestamp: 1372011280000 }
+
+# date format
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+ timestamp: 2013-06-23T18:14:40
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: _timestamp
+
+ - match: { fields._timestamp: 1372011280000 }
+
diff --git a/rest-api-spec/test/update/75_ttl.yaml b/rest-api-spec/test/update/75_ttl.yaml
new file mode 100644
index 0000000..2075c6b
--- /dev/null
+++ b/rest-api-spec/test/update/75_ttl.yaml
@@ -0,0 +1,96 @@
+---
+"TTL":
+
+ - skip:
+ features: gtelte
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ mappings:
+ test:
+ _ttl:
+ enabled: 1
+ store: yes
+ default: 10s
+ - do:
+ cluster.health:
+ wait_for_status: yellow
+
+# blank ttl
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: _ttl
+
+ - lte: { fields._ttl: 10000}
+ - gt: { fields._ttl: 0}
+
+# milliseconds
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+ ttl: 100000
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: _ttl
+
+ - lte: { fields._ttl: 100000}
+ - gt: { fields._ttl: 10000}
+
+# duration
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+ ttl: 20s
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: _ttl
+
+ - lte: { fields._ttl: 20000}
+ - gt: { fields._ttl: 10000}
+
+# with timestamp
+
+ - do:
+ catch: /AlreadyExpiredException/
+ index:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+ ttl: 20s
+ timestamp: 2013-06-23T18:14:40
+
diff --git a/rest-api-spec/test/update/80_fields.yaml b/rest-api-spec/test/update/80_fields.yaml
new file mode 100644
index 0000000..86d6afa
--- /dev/null
+++ b/rest-api-spec/test/update/80_fields.yaml
@@ -0,0 +1,20 @@
+---
+"Fields":
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ fields: foo,bar,_source
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - match: { get._source.foo: bar }
+ - match: { get.fields.foo: [bar] }
+ - is_false: get.fields.bar
+
+# TODO:
+#
+# - Add _routing
diff --git a/rest-api-spec/test/update/85_fields_meta.yaml b/rest-api-spec/test/update/85_fields_meta.yaml
new file mode 100644
index 0000000..97cefa1
--- /dev/null
+++ b/rest-api-spec/test/update/85_fields_meta.yaml
@@ -0,0 +1,51 @@
+---
+"Metadata Fields":
+
+ - skip:
+ version: "0 - 999"
+ reason: "Update doesn't return metadata fields, waiting for #3259"
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ mappings:
+ test:
+ _parent: { type: "foo" }
+ _timestamp:
+ enabled: 1
+ store: yes
+ _ttl:
+ enabled: 1
+ store: yes
+ default: 10s
+
+ - do:
+ cluster.health:
+ wait_for_status: yellow
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ fields: [ _parent, _routing, _timestamp, _ttl ]
+ body:
+ doc: { foo: baz }
+ upsert: { foo: bar }
+
+ - match: { get.fields._parent: "5" }
+ - match: { get.fields._routing: "5" }
+ - is_true: get.fields._timestamp
+ - is_true: get.fields._ttl
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ fields: [ _parent, _routing, _timestamp, _ttl ]
+
+
diff --git a/rest-api-spec/test/update/90_missing.yaml b/rest-api-spec/test/update/90_missing.yaml
new file mode 100644
index 0000000..d51c54c
--- /dev/null
+++ b/rest-api-spec/test/update/90_missing.yaml
@@ -0,0 +1,42 @@
+---
+"Missing document (partial doc)":
+
+ - do:
+ catch: missing
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body: { doc: { foo: bar } }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body: { doc: { foo: bar } }
+ ignore: 404
+
+---
+"Missing document (script)":
+
+
+ - do:
+ catch: missing
+ update:
+ index: test_1
+ type: test
+ id: 1
+ body:
+ script: "ctx._source.foo = bar"
+ params: { bar: 'xxx' }
+
+ - do:
+ update:
+ index: test_1
+ type: test
+ id: 1
+ ignore: 404
+ body:
+ script: "ctx._source.foo = bar"
+ params: { bar: 'xxx' }
diff --git a/rest-api-spec/test/update/TODO.txt b/rest-api-spec/test/update/TODO.txt
new file mode 100644
index 0000000..6eefbfd
--- /dev/null
+++ b/rest-api-spec/test/update/TODO.txt
@@ -0,0 +1,7 @@
+Tests missing for:
+
+# consistency
+# percolate
+# replication
+# retry_on_conflict
+# timeout \ No newline at end of file