11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
- from conftest import ES_SETTINGS , ES_VERSION
14
+ from conftest import ES_SETTINGS , IS_V8_OR_ABOVE
15
15
from elasticsearch ._async import client
16
16
from testing_support .fixture .event_loop import event_loop as loop
17
17
from testing_support .fixtures import override_application_settings
29
29
# Metrics
30
30
31
31
_base_scoped_metrics = [
32
+ ("Datastore/operation/Elasticsearch/cat.health" , 1 ),
33
+ ("Datastore/operation/Elasticsearch/nodes.info" , 1 ),
34
+ ("Datastore/operation/Elasticsearch/snapshot.status" , 1 ),
32
35
("Datastore/statement/Elasticsearch/_all/cluster.health" , 1 ),
33
36
("Datastore/statement/Elasticsearch/_all/search" , 2 ),
34
37
("Datastore/statement/Elasticsearch/address/index" , 2 ),
39
42
("Datastore/statement/Elasticsearch/other/search" , 2 ),
40
43
]
41
44
45
+ _all_count = 17
42
46
_base_rollup_metrics = [
47
+ ("Datastore/all" , _all_count ),
48
+ ("Datastore/allOther" , _all_count ),
49
+ ("Datastore/Elasticsearch/all" , _all_count ),
50
+ ("Datastore/Elasticsearch/allOther" , _all_count ),
51
+ ("Datastore/operation/Elasticsearch/cat.health" , 1 ),
43
52
("Datastore/operation/Elasticsearch/cluster.health" , 1 ),
44
53
("Datastore/operation/Elasticsearch/index" , 5 ),
45
54
("Datastore/operation/Elasticsearch/indices.refresh" , 1 ),
55
+ ("Datastore/operation/Elasticsearch/nodes.info" , 1 ),
46
56
("Datastore/operation/Elasticsearch/search" , 7 ),
57
+ ("Datastore/operation/Elasticsearch/snapshot.status" , 1 ),
47
58
("Datastore/statement/Elasticsearch/_all/cluster.health" , 1 ),
48
59
("Datastore/statement/Elasticsearch/_all/search" , 2 ),
49
60
("Datastore/statement/Elasticsearch/address/index" , 2 ),
@@ -65,59 +76,6 @@ def is_importable(module_path):
65
76
return False
66
77
67
78
68
- _all_count = 14
69
-
70
- if is_importable ("elasticsearch._async.client.cat" ):
71
- _base_scoped_metrics .append (("Datastore/operation/Elasticsearch/cat.health" , 1 ))
72
- _base_rollup_metrics .append (("Datastore/operation/Elasticsearch/cat.health" , 1 ))
73
- _all_count += 1
74
- else :
75
- _base_scoped_metrics .append (("Datastore/operation/Elasticsearch/cat.health" , None ))
76
- _base_rollup_metrics .append (("Datastore/operation/Elasticsearch/cat.health" , None ))
77
-
78
- if is_importable ("elasticsearch._async.client.nodes" ):
79
- _base_scoped_metrics .append (("Datastore/operation/Elasticsearch/nodes.info" , 1 ))
80
- _base_rollup_metrics .append (("Datastore/operation/Elasticsearch/nodes.info" , 1 ))
81
- _all_count += 1
82
- else :
83
- _base_scoped_metrics .append (("Datastore/operation/Elasticsearch/nodes.info" , None ))
84
- _base_rollup_metrics .append (("Datastore/operation/Elasticsearch/nodes.info" , None ))
85
-
86
- if hasattr (client , "SnapshotClient" ) and hasattr (client .SnapshotClient , "status" ):
87
- _base_scoped_metrics .append (("Datastore/operation/Elasticsearch/snapshot.status" , 1 ))
88
- _base_rollup_metrics .append (("Datastore/operation/Elasticsearch/snapshot.status" , 1 ))
89
- _all_count += 1
90
- else :
91
- _base_scoped_metrics .append (("Datastore/operation/Elasticsearch/snapshot.status" , None ))
92
- _base_rollup_metrics .append (("Datastore/operation/Elasticsearch/snapshot.status" , None ))
93
-
94
- if hasattr (client , "IndicesClient" ) and hasattr (client .IndicesClient , "status" ):
95
- _base_scoped_metrics .append (("Datastore/statement/Elasticsearch/_all/indices.status" , 1 ))
96
- _base_rollup_metrics .extend (
97
- [
98
- ("Datastore/operation/Elasticsearch/indices.status" , 1 ),
99
- ("Datastore/statement/Elasticsearch/_all/indices.status" , 1 ),
100
- ]
101
- )
102
- _all_count += 1
103
- else :
104
- _base_scoped_metrics .append (("Datastore/operation/Elasticsearch/indices.status" , None ))
105
- _base_rollup_metrics .extend (
106
- [
107
- ("Datastore/operation/Elasticsearch/indices.status" , None ),
108
- ("Datastore/statement/Elasticsearch/_all/indices.status" , None ),
109
- ]
110
- )
111
-
112
- _base_rollup_metrics .extend (
113
- [
114
- ("Datastore/all" , _all_count ),
115
- ("Datastore/allOther" , _all_count ),
116
- ("Datastore/Elasticsearch/all" , _all_count ),
117
- ("Datastore/Elasticsearch/allOther" , _all_count ),
118
- ]
119
- )
120
-
121
79
# Instance info
122
80
123
81
_disable_scoped_metrics = list (_base_scoped_metrics )
@@ -203,7 +161,7 @@ async def _exercise_es_v8(es):
203
161
await es .indices .status ()
204
162
205
163
206
- _exercise_es = _exercise_es_v7 if ES_VERSION < ( 8 , 0 , 0 ) else _exercise_es_v8
164
+ _exercise_es = _exercise_es_v8 if IS_V8_OR_ABOVE else _exercise_es_v7
207
165
208
166
209
167
# Test
0 commit comments