summaryrefslogtreecommitdiff
path: root/rest-api-spec/test/create
diff options
context:
space:
mode:
Diffstat (limited to 'rest-api-spec/test/create')
-rw-r--r--rest-api-spec/test/create/10_with_id.yaml33
-rw-r--r--rest-api-spec/test/create/15_without_id.yaml25
-rw-r--r--rest-api-spec/test/create/30_internal_version.yaml20
-rw-r--r--rest-api-spec/test/create/35_external_version.yaml33
-rw-r--r--rest-api-spec/test/create/40_routing.yaml41
-rw-r--r--rest-api-spec/test/create/50_parent.yaml43
-rw-r--r--rest-api-spec/test/create/55_parent_with_routing.yaml54
-rw-r--r--rest-api-spec/test/create/60_refresh.yaml46
-rw-r--r--rest-api-spec/test/create/70_timestamp.yaml81
-rw-r--r--rest-api-spec/test/create/75_ttl.yaml104
-rw-r--r--rest-api-spec/test/create/TODO.txt5
11 files changed, 485 insertions, 0 deletions
diff --git a/rest-api-spec/test/create/10_with_id.yaml b/rest-api-spec/test/create/10_with_id.yaml
new file mode 100644
index 0000000..1e58c38
--- /dev/null
+++ b/rest-api-spec/test/create/10_with_id.yaml
@@ -0,0 +1,33 @@
+---
+"Create with ID":
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: "1"}
+ - match: { _version: 1}
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: "1"}
+ - match: { _version: 1}
+ - match: { _source: { foo: bar }}
+
+ - do:
+ catch: conflict
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
diff --git a/rest-api-spec/test/create/15_without_id.yaml b/rest-api-spec/test/create/15_without_id.yaml
new file mode 100644
index 0000000..0342fdb
--- /dev/null
+++ b/rest-api-spec/test/create/15_without_id.yaml
@@ -0,0 +1,25 @@
+---
+"Create without ID":
+ - do:
+ create:
+ index: test_1
+ type: test
+ body: { foo: bar }
+
+ - is_true: _id
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _version: 1 }
+ - set: { _id: id }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: '$id'
+
+ - match: { _index: test_1 }
+ - match: { _type: test }
+ - match: { _id: $id }
+ - match: { _version: 1 }
+ - match: { _source: { foo: bar }}
diff --git a/rest-api-spec/test/create/30_internal_version.yaml b/rest-api-spec/test/create/30_internal_version.yaml
new file mode 100644
index 0000000..fcdb233
--- /dev/null
+++ b/rest-api-spec/test/create/30_internal_version.yaml
@@ -0,0 +1,20 @@
+---
+"Internal version":
+
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+
+ - match: { _version: 1}
+
+ - do:
+ catch: conflict
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+
diff --git a/rest-api-spec/test/create/35_external_version.yaml b/rest-api-spec/test/create/35_external_version.yaml
new file mode 100644
index 0000000..8ee11b0
--- /dev/null
+++ b/rest-api-spec/test/create/35_external_version.yaml
@@ -0,0 +1,33 @@
+---
+"External version":
+
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+ version_type: external
+ version: 5
+
+ - match: { _version: 5}
+
+ - do:
+ catch: conflict
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+ version_type: external
+ version: 5
+
+ - do:
+ catch: conflict
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+ version_type: external
+ version: 6
diff --git a/rest-api-spec/test/create/40_routing.yaml b/rest-api-spec/test/create/40_routing.yaml
new file mode 100644
index 0000000..bc3fb84
--- /dev/null
+++ b/rest-api-spec/test/create/40_routing.yaml
@@ -0,0 +1,41 @@
+---
+"Routing":
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ settings:
+ index:
+ number_of_replicas: 0
+
+ - do:
+ cluster.health:
+ wait_for_status: green
+
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ routing: 5
+ body: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ routing: 5
+ fields: [_routing]
+
+ - match: { _id: "1"}
+ - match: { fields._routing: "5"}
+
+ - do:
+ catch: missing
+ get:
+ index: test_1
+ type: test
+ id: 1
+
diff --git a/rest-api-spec/test/create/50_parent.yaml b/rest-api-spec/test/create/50_parent.yaml
new file mode 100644
index 0000000..dcd24d9
--- /dev/null
+++ b/rest-api-spec/test/create/50_parent.yaml
@@ -0,0 +1,43 @@
+---
+"Parent":
+
+ - do:
+ indices.create:
+ index: test_1
+ body:
+ mappings:
+ test:
+ _parent: { type: "foo" }
+
+ - do:
+ cluster.health:
+ wait_for_status: yellow
+
+ - do:
+ catch: /RoutingMissingException/
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ body: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ fields: [_parent, _routing]
+
+ - match: { _id: "1"}
+ - match: { fields._parent: "5"}
+ - match: { fields._routing: "5"}
+
diff --git a/rest-api-spec/test/create/55_parent_with_routing.yaml b/rest-api-spec/test/create/55_parent_with_routing.yaml
new file mode 100644
index 0000000..ec94718
--- /dev/null
+++ b/rest-api-spec/test/create/55_parent_with_routing.yaml
@@ -0,0 +1,54 @@
+---
+"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:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ routing: 4
+ body: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+ routing: 4
+ fields: [_parent, _routing]
+
+ - match: { _id: "1"}
+ - match: { fields._parent: "5"}
+ - match: { fields._routing: "4"}
+
+ - do:
+ catch: missing
+ get:
+ index: test_1
+ type: test
+ id: 1
+ parent: 5
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ routing: 4
+
diff --git a/rest-api-spec/test/create/60_refresh.yaml b/rest-api-spec/test/create/60_refresh.yaml
new file mode 100644
index 0000000..99bfbc3
--- /dev/null
+++ b/rest-api-spec/test/create/60_refresh.yaml
@@ -0,0 +1,46 @@
+---
+"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:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+
+ - do:
+ search:
+ index: test_1
+ type: test
+ body:
+ query: { term: { _id: 1 }}
+
+ - match: { hits.total: 0 }
+
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 2
+ refresh: 1
+ body: { 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/create/70_timestamp.yaml b/rest-api-spec/test/create/70_timestamp.yaml
new file mode 100644
index 0000000..f48a9fa
--- /dev/null
+++ b/rest-api-spec/test/create/70_timestamp.yaml
@@ -0,0 +1,81 @@
+---
+"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:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: _timestamp
+
+ - is_true: fields._timestamp
+
+# milliseconds since epoch
+
+ - do:
+ delete:
+ index: test_1
+ type: test
+ id: 1
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+ timestamp: 1372011280000
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: _timestamp
+
+ - match: { fields._timestamp: 1372011280000 }
+
+# date format
+
+ - do:
+ delete:
+ index: test_1
+ type: test
+ id: 1
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { 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/create/75_ttl.yaml b/rest-api-spec/test/create/75_ttl.yaml
new file mode 100644
index 0000000..05eb88e
--- /dev/null
+++ b/rest-api-spec/test/create/75_ttl.yaml
@@ -0,0 +1,104 @@
+---
+"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:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { foo: bar }
+
+ - do:
+ get:
+ index: test_1
+ type: test
+ id: 1
+ fields: _ttl
+
+ - lte: { fields._ttl: 10000}
+ - gt: { fields._ttl: 0}
+
+# milliseconds
+
+ - do:
+ delete:
+ index: test_1
+ type: test
+ id: 1
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { 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:
+ delete:
+ index: test_1
+ type: test
+ id: 1
+ - do:
+ create:
+ index: test_1
+ type: test
+ id: 1
+ body: { 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:
+ delete:
+ index: test_1
+ type: test
+ id: 1
+ - do:
+ catch: /AlreadyExpiredException/
+ create:
+ 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/create/TODO.txt b/rest-api-spec/test/create/TODO.txt
new file mode 100644
index 0000000..d8a93ca
--- /dev/null
+++ b/rest-api-spec/test/create/TODO.txt
@@ -0,0 +1,5 @@
+Tests missing for:
+
+# consistency
+# percolate
+# replication