OpenSearch/rest-api-spec/test
Honza Kral 434b70ba91 Siggest api broken in current release 2013-07-23 20:10:59 +02:00
..
bulk Bulk tests 2013-07-20 21:12:39 +02:00
cluster.put_settings Basic tests for get/set cluster settings 2013-07-18 16:46:41 +02:00
cluster.reroute super basic test for cluster.reroute 2013-07-18 16:36:20 +02:00
create text ids 2013-07-11 02:32:35 +02:00
delete Delete ignores parent param 2013-07-23 20:10:48 +02:00
delete_by_query Delete by query tests 2013-07-22 00:40:20 +02:00
exists Added tests for exists, get_source and mget 2013-07-01 16:03:37 +02:00
get Unicode in parent/routing 2013-07-14 15:44:57 +02:00
get_source skip clause for get_source tests 2013-07-11 13:50:59 +02:00
index unicode in index name, dot in type name 2013-07-14 15:43:07 +02:00
indices.analyze fixing old format of indices.analyze tests 2013-07-11 13:52:03 +02:00
indices.delete_alias formattings issues 2013-07-23 19:20:40 +02:00
indices.delete_mapping Delete mapping tests 2013-07-15 15:01:48 +02:00
indices.exists Tests for indices.exists 2013-07-15 15:04:56 +02:00
indices.get_mapping tests for get_mapping 2013-07-15 14:53:32 +02:00
indices.put_alias formattings issues 2013-07-23 19:20:40 +02:00
indices.put_mapping Add basic tests for put mapping 2013-07-15 14:43:27 +02:00
indices.put_settings Indices settings tests 2013-07-22 00:49:53 +02:00
indices.put_template Template APIs tests 2013-07-20 21:12:27 +02:00
info lucene_version is only in es sine 0.90.1 2013-07-11 13:51:36 +02:00
mget fixed parent/routing mget tests - missing fields parameter 2013-07-15 10:31:28 +02:00
msearch msearch tests 2013-07-22 00:40:12 +02:00
ping Renamed "ok" and "not_ok" to "is_true" and "is_false" 2013-07-01 15:58:23 +02:00
scroll Basic scroll tests 2013-07-16 16:43:47 +02:00
search Added test for searching over type and all indices 2013-07-18 16:23:22 +02:00
suggest Siggest api broken in current release 2013-07-23 20:10:59 +02:00
update Update text ids 2013-07-12 18:26:18 +02:00
README.asciidoc formattings issues 2013-07-23 19:20:40 +02:00

README.asciidoc

Test Suite:
===========

The tests in each YAML file should be run in order as a single set of dependent tests.
Before each file, the test cluster should be "reset" (eg deleting indices etc),
the `response` var and the `stash` should be cleared (see below).

Dot notation:
-------------
Dot notation is used for (1) method calls and (2) hierarchical data structures.  For
instance, a method call like `cluster.health` would do the equivalent of:

    client.cluster.health(...params...)

A test against `_tokens.1.token` would examine the `token` key, in the second element
of the `tokens` array, inside the `response` var (see below):

    $val = $response->{tokens}[1]{token}  # Perl syntax roolz!

If one of the levels (eg `tokens`) does not exist, it should return an undefined value.
If no field name is given (ie the empty string) then return the current
$val -- used for testing the whole response body.

Use \. to specify paths that actually contain '.' in the key name, for example
in the `indices.get_settings` API.

Skipping tests:
---------------
If tests should be skipped on particular versions of Elasticsearch, the
first entry in the list of tests should be called `skip`, and contain
the range of versions to be skipped, and the reason why the tests are
skipped.  For instance:

....
    "Parent":
     - skip:
          version:     "0 - 0.90.2"
          reason:      Delete ignores the parent param

     - do:
       ... test definitions ...
....

All tests in the file should be skipped if: `min <= current <= max`.

The `version` range should always have an upper bound. Versions should
either have each version part compared numerically, or should be converted
to a string with sufficient digits to allow string comparison, eg

    0.90.2 -> 000-090-002

Snapshot versions and versions of the form `1.0.0.Beta1` can be treated
as the rounded down version, eg `1.0.0`.

Required operators:
-------------------

=== `do`

The `do` operator calls a method on the client. For instance:

....
    - do:
        cluster.health:
            level: shards
....

The response from the `do` operator should be stored in the `response` var, which
is reset (1) at the beginning of a file or (2) on the next `do`.

If the arguments to `do` include `catch`, then we are expecting an error, which should
be caught and tested.  For instance:

....
    - do:
        catch:        missing
        get:
            index:    test
            type:    test
            id:        1
....

The argument to `catch` can be any of:

[horizontal]
`missing`::     a 404 response from ES
`conflict`::    a 409 response from ES
`request`::     a generic error response from ES
`param`::       a client-side error indicating an unknown parameter has been passed
                to the method
`/foo bar/`::   the text of the error message matches this regular expression

If `catch` is specified, then the `response` var must be cleared, and the test
should fail if no error is thrown.

=== `set`

For some tests, it is necessary to extract a value from the previous `response`, in
order to reuse it in a subsequent `do` and other tests.  For instance, when
testing indexing a document without a specified ID:

....
    - do:
        index:
            index: test
            type:  test
    - set:  { _id: id }   # stash the value of `response._id` as `id`
    - do:
        get:
            index: test
            type:  test
            id:    $id    # replace `$id` with the stashed value
    - match: { _id: $id } # the returned `response._id` matches the stashed `id`
....

The stash should be reset at the beginning of each test file.

=== `is_true`

The specified key exists and has a true value (ie not `0`, `false`, `undefined`, `null`
or the empty string), eg:

....
    - is_true:  fields._parent  # the _parent key exists in the fields hash and is "true"
....

=== `is_false`

The specified key doesn't exist or has a false value (ie `0`, `false`, `undefined`,
`null` or the empty string), eg:

....
    - is_false:  fields._source  # the _source key doesn't exist in the fields hash or is "false"
....

=== `match`

Used to compare two variables (could be scalars, arrays or hashes).  The two variables
should be identical, eg:

....
    - match: { _source: { foo: bar }}
....

=== `lt` and `gt`

Compares two numeric values, eg:

....
    - lt: { fields._ttl: 10000 }  # the `_ttl` value is less than 10,000
....

=== `length`

This depends on the datatype of the value being examined, eg:

....
    - length: { _id: 22    }   # the `_id` string is 22 chars long
    - length: { _tokens: 3 }   # the `_tokens` array has 3 elements
    - length: { _source: 5 }   # the `_source` hash has 5 keys
....