1+ from secrets import token_hex
12from time import sleep
23from typing import Tuple
34
1213
1314@pytest .fixture (name = "trapper_items" )
1415def setup_trapper_items (zapi : ZabbixAPI ):
15- item_key = "pyzabbix.test"
16+ item_key = f "pyzabbix.test{ token_hex ( 4 ) } "
1617
1718 host_id = zapi .host .get (filter = {"host" : [HOST ]})[0 ]["hostid" ]
1819 items = zapi .item .get (hostids = host_id , search = {"key_" : item_key })
@@ -27,6 +28,9 @@ def setup_trapper_items(zapi: ZabbixAPI):
2728 value_type = 3 ,
2829 )["itemids" ][0 ]
2930
31+ # Wait for new item to be fully set
32+ sleep (2 )
33+
3034 yield item_id , item_key
3135
3236 # Cleanup testing item
@@ -46,7 +50,6 @@ def test_sending_metrics(zapi: ZabbixAPI, trapper_items: Tuple[str, str]) -> Non
4650 ZabbixMetric (host = HOST , key = item_key , clock = 1659038666 , ns = 453824511 , value = 7 ),
4751 ZabbixMetric (host = HOST , key = item_key , clock = 1659038677 , ns = 453830345 , value = 8 ),
4852 ]
49- sleep (30 )
5053
5154 sender = ZabbixSender ()
5255 response = sender .send (metrics )
@@ -55,7 +58,9 @@ def test_sending_metrics(zapi: ZabbixAPI, trapper_items: Tuple[str, str]) -> Non
5558 assert response .total == 8
5659 assert response .batch_count == 1
5760
58- sleep (30 )
61+ # Wait for new data to be ingested
62+ sleep (2 )
63+
5964 history = zapi .history .get (
6065 itemids = item_id ,
6166 sortfield = "clock" ,
0 commit comments