From 7d0b0fb1460754c9cd9ddc4252e89f99dcf29123 Mon Sep 17 00:00:00 2001 From: Clinton Gormley Date: Wed, 26 Jun 2013 21:18:14 +0100 Subject: [PATCH] Added tests for create --- rest-api-spec/test/create/10_with_id.yaml | 12 +++- rest-api-spec/test/create/15_without_id.yaml | 5 +- rest-api-spec/test/create/20_optype.yaml | 25 -------- .../test/create/30_internal_version.yaml | 18 ++++++ rest-api-spec/test/create/30_version.yaml | 63 ------------------- .../test/create/35_external_version.yaml | 29 +++++++++ rest-api-spec/test/create/40_routing.yaml | 2 +- rest-api-spec/test/create/50_parent.yaml | 53 +--------------- .../test/create/55_parent_with_routing.yaml | 49 +++++++++++++++ rest-api-spec/test/create/60_refresh.yaml | 18 +++--- rest-api-spec/test/create/70_timestamp.yaml | 16 ++++- rest-api-spec/test/create/75_ttl.yaml | 23 +++++-- 12 files changed, 154 insertions(+), 159 deletions(-) delete mode 100644 rest-api-spec/test/create/20_optype.yaml create mode 100644 rest-api-spec/test/create/30_internal_version.yaml delete mode 100644 rest-api-spec/test/create/30_version.yaml create mode 100644 rest-api-spec/test/create/35_external_version.yaml create mode 100644 rest-api-spec/test/create/55_parent_with_routing.yaml diff --git a/rest-api-spec/test/create/10_with_id.yaml b/rest-api-spec/test/create/10_with_id.yaml index 1105f2b6865..52fffb20743 100644 --- a/rest-api-spec/test/create/10_with_id.yaml +++ b/rest-api-spec/test/create/10_with_id.yaml @@ -1,7 +1,7 @@ --- -"Index with ID": +"Create with ID": - do: - index: + create: index: test_1 type: test id: 1 @@ -11,6 +11,7 @@ - match: { _type: test } - match: { _id: 1} - match: { _version: 1} + - do: get: index: test_1 @@ -22,3 +23,10 @@ - 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 index 53d3f2bd618..2a7b425e666 100644 --- a/rest-api-spec/test/create/15_without_id.yaml +++ b/rest-api-spec/test/create/15_without_id.yaml @@ -1,7 +1,7 @@ --- -"Index without ID": +"Create without ID": - do: - index: + create: index: test_1 type: test body: { foo: bar } @@ -11,6 +11,7 @@ - match: { _type: test } - match: { _version: 1 } - set: { _id: id } + - do: get: index: test_1 diff --git a/rest-api-spec/test/create/20_optype.yaml b/rest-api-spec/test/create/20_optype.yaml deleted file mode 100644 index b1eeb4121b8..00000000000 --- a/rest-api-spec/test/create/20_optype.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -"Optype": - - do: - index: - index: test_1 - type: test - id: 1 - op_type: create - body: { foo: bar } - - do: - catch: conflict - index: - index: test_1 - type: test - id: 1 - op_type: create - body: { foo: bar } - - do: - index: - index: test_1 - type: test - id: 1 - op_type: index - body: { foo: bar } - - match: { _version: 2 } 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 00000000000..d64deaaa1bd --- /dev/null +++ b/rest-api-spec/test/create/30_internal_version.yaml @@ -0,0 +1,18 @@ +--- +"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/30_version.yaml b/rest-api-spec/test/create/30_version.yaml deleted file mode 100644 index 0155424b3da..00000000000 --- a/rest-api-spec/test/create/30_version.yaml +++ /dev/null @@ -1,63 +0,0 @@ ---- -"Internal version": - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - match: { _version: 1} - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - - match: { _version: 2} - - do: - catch: conflict - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version: 1 - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version: 2 - - match: { _version: 3 } - ---- -"External version": - - do: - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 5 - - match: { _version: 5} - - do: - catch: conflict - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 5 - - do: - catch: conflict - index: - index: test_1 - type: test - id: 1 - body: { foo: bar } - version_type: external - version: 6 - - match: { _version: 6} 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 00000000000..a18dc857c40 --- /dev/null +++ b/rest-api-spec/test/create/35_external_version.yaml @@ -0,0 +1,29 @@ +--- +"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 index d7caddcdfae..a0ac30b9279 100644 --- a/rest-api-spec/test/create/40_routing.yaml +++ b/rest-api-spec/test/create/40_routing.yaml @@ -1,7 +1,7 @@ --- "Routing": - do: - index: + create: 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 index 51902e52e5d..6a423073e9b 100644 --- a/rest-api-spec/test/create/50_parent.yaml +++ b/rest-api-spec/test/create/50_parent.yaml @@ -12,7 +12,7 @@ wait_for_status: yellow - do: - index: + create: index: test_1 type: test id: 1 @@ -37,54 +37,3 @@ type: test id: 1 - ---- -"Parent with routing": - - do: - indices.create: - index: test_1 - body: - mappings: - test: - _parent: { type: "foo" } - - do: - cluster.health: - wait_for_status: yellow - - - do: - index: - 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: - catch: missing - get: - index: test_1 - type: test - id: 1 - routing: 4 - 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 00000000000..cb31f80985c --- /dev/null +++ b/rest-api-spec/test/create/55_parent_with_routing.yaml @@ -0,0 +1,49 @@ +--- +"Parent with routing": + - do: + indices.create: + index: test_1 + body: + mappings: + test: + _parent: { type: "foo" } + - do: + cluster.health: + wait_for_status: yellow + + - 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 index 74f4b8cc358..6efe95973ef 100644 --- a/rest-api-spec/test/create/60_refresh.yaml +++ b/rest-api-spec/test/create/60_refresh.yaml @@ -11,21 +11,23 @@ wait_for_status: yellow - do: - index: + create: index: test_1 type: test id: 1 body: { foo: bar } - do: - catch: missing - get: + search: index: test_1 type: test - id: 1 + body: + query: { term: { _id: 1 }} + + - match: { hits.total: 0 } - do: - index: + create: index: test_1 type: test id: 2 @@ -33,8 +35,10 @@ body: { foo: bar } - do: - get: + search: index: test_1 type: test - id: 2 + 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 index 90617020686..12fb697c581 100644 --- a/rest-api-spec/test/create/70_timestamp.yaml +++ b/rest-api-spec/test/create/70_timestamp.yaml @@ -15,7 +15,7 @@ # blank timestamp - do: - index: + create: index: test_1 type: test id: 1 @@ -32,7 +32,12 @@ # milliseconds since epoch - do: - index: + delete: + index: test_1 + type: test + id: 1 + - do: + create: index: test_1 type: test id: 1 @@ -50,7 +55,12 @@ # date format - do: - index: + delete: + index: test_1 + type: test + id: 1 + - do: + create: index: test_1 type: test id: 1 diff --git a/rest-api-spec/test/create/75_ttl.yaml b/rest-api-spec/test/create/75_ttl.yaml index c8e9447d778..012a6ba169d 100644 --- a/rest-api-spec/test/create/75_ttl.yaml +++ b/rest-api-spec/test/create/75_ttl.yaml @@ -16,7 +16,7 @@ # blank ttl - do: - index: + create: index: test_1 type: test id: 1 @@ -34,7 +34,12 @@ # milliseconds - do: - index: + delete: + index: test_1 + type: test + id: 1 + - do: + create: index: test_1 type: test id: 1 @@ -52,7 +57,12 @@ # duration - do: - index: + delete: + index: test_1 + type: test + id: 1 + - do: + create: index: test_1 type: test id: 1 @@ -70,9 +80,14 @@ # with timestamp + - do: + delete: + index: test_1 + type: test + id: 1 - do: catch: /AlreadyExpiredException/ - index: + create: index: test_1 type: test id: 1