Skip to content

Commit 404d0be

Browse files
committed
feat: re-add wait_for in metrics checks
1 parent dfb3e5e commit 404d0be

File tree

1 file changed

+58
-38
lines changed

1 file changed

+58
-38
lines changed

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 58 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,16 +1500,19 @@ fn simple_neon_integration() {
15001500
// query for prometheus metrics
15011501
#[cfg(feature = "monitoring_prom")]
15021502
{
1503-
let prom_http_origin = format!("http://{}", prom_bind);
1504-
let client = reqwest::blocking::Client::new();
1505-
let res = client
1506-
.get(&prom_http_origin)
1507-
.send()
1508-
.unwrap()
1509-
.text()
1510-
.unwrap();
1511-
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
1512-
assert!(res.contains(&expected_result));
1503+
wait_for(10, || {
1504+
let prom_http_origin = format!("http://{}", prom_bind);
1505+
let client = reqwest::blocking::Client::new();
1506+
let res = client
1507+
.get(&prom_http_origin)
1508+
.send()
1509+
.unwrap()
1510+
.text()
1511+
.unwrap();
1512+
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
1513+
Ok(res.contains(&expected_result))
1514+
})
1515+
.expect("Prometheus metrics did not update");
15131516
}
15141517

15151518
info!("Nakamoto miner started...");
@@ -1621,16 +1624,27 @@ fn simple_neon_integration() {
16211624
// make sure prometheus returns an updated number of processed blocks
16221625
#[cfg(feature = "monitoring_prom")]
16231626
{
1624-
let prom_http_origin = format!("http://{}", prom_bind);
1625-
let client = reqwest::blocking::Client::new();
1626-
let res = client
1627-
.get(&prom_http_origin)
1628-
.send()
1629-
.unwrap()
1630-
.text()
1631-
.unwrap();
1632-
let expected_result = format!("stacks_node_stacks_tip_height {}", tip.stacks_block_height);
1633-
assert!(res.contains(&expected_result));
1627+
wait_for(10, || {
1628+
let prom_http_origin = format!("http://{}", prom_bind);
1629+
let client = reqwest::blocking::Client::new();
1630+
let res = client
1631+
.get(&prom_http_origin)
1632+
.send()
1633+
.unwrap()
1634+
.text()
1635+
.unwrap();
1636+
let expected_result_1 = format!(
1637+
"stacks_node_stx_blocks_processed_total {}",
1638+
tip.stacks_block_height
1639+
);
1640+
1641+
let expected_result_2 = format!(
1642+
"stacks_node_stacks_tip_height {}",
1643+
tip.stacks_block_height - 1
1644+
);
1645+
Ok(res.contains(&expected_result_1) && res.contains(&expected_result_2))
1646+
})
1647+
.expect("Prometheus metrics did not update");
16341648
}
16351649

16361650
check_nakamoto_empty_block_heuristics();
@@ -6360,15 +6374,18 @@ fn signer_chainstate() {
63606374
.unwrap()
63616375
.stacks_block_height;
63626376
let prom_http_origin = format!("http://{}", prom_bind);
6363-
let client = reqwest::blocking::Client::new();
6364-
let res = client
6365-
.get(&prom_http_origin)
6366-
.send()
6367-
.unwrap()
6368-
.text()
6369-
.unwrap();
6370-
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
6371-
assert!(res.contains(&expected_result));
6377+
wait_for(10, || {
6378+
let client = reqwest::blocking::Client::new();
6379+
let res = client
6380+
.get(&prom_http_origin)
6381+
.send()
6382+
.unwrap()
6383+
.text()
6384+
.unwrap();
6385+
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
6386+
Ok(res.contains(&expected_result))
6387+
})
6388+
.expect("Failed waiting for prometheus metrics to update")
63726389
}
63736390

63746391
info!("Nakamoto miner started...");
@@ -6972,15 +6989,18 @@ fn continue_tenure_extend() {
69726989
#[cfg(feature = "monitoring_prom")]
69736990
{
69746991
let prom_http_origin = format!("http://{}", prom_bind);
6975-
let client = reqwest::blocking::Client::new();
6976-
let res = client
6977-
.get(&prom_http_origin)
6978-
.send()
6979-
.unwrap()
6980-
.text()
6981-
.unwrap();
6982-
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
6983-
assert!(res.contains(&expected_result));
6992+
wait_for(10, || {
6993+
let client = reqwest::blocking::Client::new();
6994+
let res = client
6995+
.get(&prom_http_origin)
6996+
.send()
6997+
.unwrap()
6998+
.text()
6999+
.unwrap();
7000+
let expected_result = format!("stacks_node_stacks_tip_height {block_height_pre_3_0}");
7001+
Ok(res.contains(&expected_result))
7002+
})
7003+
.expect("Prometheus metrics did not update");
69847004
}
69857005

69867006
info!("Nakamoto miner started...");

0 commit comments

Comments
 (0)