Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indices stats options #6390

Closed
wants to merge 10 commits into from
4 changes: 0 additions & 4 deletions rest-api-spec/test/indices.stats/10_basic.yaml

This file was deleted.

78 changes: 78 additions & 0 deletions rest-api-spec/test/indices.stats/10_index.yaml
@@ -0,0 +1,78 @@
---
setup:

- do:
index:
index: test1
type: bar
id: 1
body: { "foo": "bar" }

- do:
index:
index: test2
type: baz
id: 1
body: { "foo": "baz" }

---
"Index - blank":
- do:
indices.stats: {}

- match: { _shards.total: 20 }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we assume we have 20 shards in the index?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can. I'm checking the total number of defined shards, not active shards. The test creates two indices with default settings == 20 shards.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we randomize these in java land. If we don't do it now, the day is not far away..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do randomize it....just run the tests and you'll see failures mvn clean test -Dtests.class=*.ElasticsearchRestTests or just run the ElasticsearchRestTests test form your IDE ;)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know - I've pushed a change to make the tests more determinative in this case :)

- is_true: _all
- is_true: indices.test1
- is_true: indices.test2

---
"Index - all":
- do:
indices.stats: { index: _all }

- match: { _shards.total: 20 }
- is_true: _all
- is_true: indices.test1
- is_true: indices.test2


---
"Index - star":
- do:
indices.stats: { index: '*' }

- match: { _shards.total: 20 }
- is_true: _all
- is_true: indices.test1
- is_true: indices.test2

---
"Index - one index":
- do:
indices.stats: { index: 'test1' }

- match: { _shards.total: 10 }
- is_true: _all
- is_true: indices.test1
- is_false: indices.test2

---
"Index - multi-index":
- do:
indices.stats: { index: 'test1,test2' }

- match: { _shards.total: 20 }
- is_true: _all
- is_true: indices.test1
- is_true: indices.test2

---
"Index - pattern":
- do:
indices.stats: { index: '*2' }

- match: { _shards.total: 10 }
- is_true: _all
- is_false: indices.test1
- is_true: indices.test2

110 changes: 110 additions & 0 deletions rest-api-spec/test/indices.stats/11_metric.yaml
@@ -0,0 +1,110 @@
---
setup:

- do:
index:
index: test1
type: bar
id: 1
body: { "foo": "bar" }

- do:
index:
index: test2
type: baz
id: 1
body: { "foo": "baz" }

---
"Metric - blank":
- do:
indices.stats: {}

- is_true: _all.primaries.docs
- is_true: _all.primaries.store
- is_true: _all.primaries.indexing
- is_true: _all.primaries.get
- is_true: _all.primaries.search
- is_true: _all.primaries.merges
- is_true: _all.primaries.refresh
- is_true: _all.primaries.flush
- is_true: _all.primaries.warmer
- is_true: _all.primaries.filter_cache
- is_true: _all.primaries.id_cache
- is_true: _all.primaries.fielddata
- is_true: _all.primaries.percolate
- is_true: _all.primaries.completion
- is_true: _all.primaries.segments
- is_true: _all.primaries.translog
- is_true: _all.primaries.suggest

---
"Metric - _all":
- do:
indices.stats: { metric: _all }

- is_true: _all.primaries.docs
- is_true: _all.primaries.store
- is_true: _all.primaries.indexing
- is_true: _all.primaries.get
- is_true: _all.primaries.search
- is_true: _all.primaries.merges
- is_true: _all.primaries.refresh
- is_true: _all.primaries.flush
- is_true: _all.primaries.warmer
- is_true: _all.primaries.filter_cache
- is_true: _all.primaries.id_cache
- is_true: _all.primaries.fielddata
- is_true: _all.primaries.percolate
- is_true: _all.primaries.completion
- is_true: _all.primaries.segments
- is_true: _all.primaries.translog
- is_true: _all.primaries.suggest

---
"Metric - one":
- do:
indices.stats: { metric: docs }

- is_true: _all.primaries.docs
- is_false: _all.primaries.store
- is_false: _all.primaries.indexing
- is_false: _all.primaries.get
- is_false: _all.primaries.search
- is_false: _all.primaries.merges
- is_false: _all.primaries.refresh
- is_false: _all.primaries.flush
- is_false: _all.primaries.warmer
- is_false: _all.primaries.filter_cache
- is_false: _all.primaries.id_cache
- is_false: _all.primaries.fielddata
- is_false: _all.primaries.percolate
- is_false: _all.primaries.completion
- is_false: _all.primaries.segments
- is_false: _all.primaries.translog
- is_false: _all.primaries.suggest

---
"Metric - multi":
- do:
indices.stats: { metric: [ store, get, merge ] }

- is_false: _all.primaries.docs
- is_true: _all.primaries.store
- is_false: _all.primaries.indexing
- is_true: _all.primaries.get
- is_false: _all.primaries.search
- is_true: _all.primaries.merges
- is_false: _all.primaries.refresh
- is_false: _all.primaries.flush
- is_false: _all.primaries.warmer
- is_false: _all.primaries.filter_cache
- is_false: _all.primaries.id_cache
- is_false: _all.primaries.fielddata
- is_false: _all.primaries.percolate
- is_false: _all.primaries.completion
- is_false: _all.primaries.segments
- is_false: _all.primaries.translog
- is_false: _all.primaries.suggest


69 changes: 69 additions & 0 deletions rest-api-spec/test/indices.stats/12_level.yaml
@@ -0,0 +1,69 @@
---
setup:

- do:
index:
index: test1
type: bar
id: 1
body: { "foo": "bar" }

- do:
index:
index: test2
type: baz
id: 1
body: { "foo": "baz" }

---
"Level - blank":
- do:
indices.stats: {}

- is_true: _all.primaries.docs
- is_true: _all.total.docs
- is_true: indices.test1.primaries.docs
- is_true: indices.test1.total.docs
- is_false: indices.test1.shards
- is_true: indices.test2.primaries.docs
- is_true: indices.test2.total.docs
- is_false: indices.test2.shards

---
"Level - indices":
- do:
indices.stats: { level: indices }

- is_true: _all.primaries.docs
- is_true: _all.total.docs
- is_true: indices.test1.primaries.docs
- is_true: indices.test1.total.docs
- is_false: indices.test1.shards
- is_true: indices.test2.primaries.docs
- is_true: indices.test2.total.docs
- is_false: indices.test2.shards

---
"Level - cluster":
- do:
indices.stats: { level: cluster }

- is_true: _all.primaries.docs
- is_true: _all.total.docs
- is_false: indices


---
"Level - shards":
- do:
indices.stats: { level: shards }

- is_true: _all.primaries.docs
- is_true: _all.total.docs
- is_true: indices.test1.primaries.docs
- is_true: indices.test1.total.docs
- is_true: indices.test1.shards.0.0.docs
- is_true: indices.test2.primaries.docs
- is_true: indices.test2.total.docs
- is_true: indices.test2.shards.0.0.docs