Skip to content

Commit e5efcf3

Browse files
authored
Update tests for Elasticsearch client 7.6.0 (#764)
* Update tests for Elasticsearch client 7.6.0 * Fix it in async_client_tests as well
1 parent 059b2f7 commit e5efcf3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

tests/instrumentation/asyncio/elasticsearch_async_client_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ async def test_search_body(instrument, elasticapm_client, elasticsearch_async):
136136
spans = elasticapm_client.spans_for_transaction(transaction)
137137
assert len(spans) == 1
138138
span = spans[0]
139-
assert span["name"] in ("ES GET /_search", "ES GET /_all/_search")
139+
# Depending on ES_VERSION, could be /_all/_search or /_search, and GET or POST
140+
assert span["name"] in ("ES GET /_search", "ES GET /_all/_search", "ES POST /_search")
140141
assert span["type"] == "db"
141142
assert span["subtype"] == "elasticsearch"
142143
assert span["action"] == "query"

tests/instrumentation/elasticsearch_tests.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,8 @@ def test_search_body(instrument, elasticapm_client, elasticsearch):
329329
spans = elasticapm_client.spans_for_transaction(transaction)
330330
assert len(spans) == 1
331331
span = spans[0]
332-
# Depending on ES_VERSION, could be /_all/_search or /_search
333-
assert span["name"] in ("ES GET /_search", "ES GET /_all/_search")
332+
# Depending on ES_VERSION, could be /_all/_search or /_search, and GET or POST
333+
assert span["name"] in ("ES GET /_search", "ES GET /_all/_search", "ES POST /_search")
334334
assert span["type"] == "db"
335335
assert span["subtype"] == "elasticsearch"
336336
assert span["action"] == "query"
@@ -380,7 +380,9 @@ def test_search_both(instrument, elasticapm_client, elasticsearch):
380380
spans = elasticapm_client.spans_for_transaction(transaction)
381381
assert len(spans) == 1
382382
span = spans[0]
383-
assert span["name"] == "ES GET /tweets/_search"
383+
# Starting in 7.6.0, these turned into POST instead of GET. That detail is
384+
# unimportant for these tests.
385+
assert span["name"] in ("ES GET /tweets/_search", "ES POST /tweets/_search")
384386
assert span["type"] == "db"
385387
assert span["subtype"] == "elasticsearch"
386388
assert span["action"] == "query"
@@ -493,7 +495,9 @@ def test_multiple_indexes(instrument, elasticapm_client, elasticsearch):
493495
spans = elasticapm_client.spans_for_transaction(transaction)
494496
assert len(spans) == 1
495497
span = spans[0]
496-
assert span["name"] == "ES GET /tweets,snaps/_search"
498+
# Starting in 7.6.0, these turned into POST instead of GET. That detail is
499+
# unimportant for these tests.
500+
assert span["name"] in ("ES GET /tweets,snaps/_search", "ES POST /tweets,snaps/_search")
497501
assert span["type"] == "db"
498502
assert span["subtype"] == "elasticsearch"
499503
assert span["action"] == "query"

0 commit comments

Comments
 (0)