Fix flaky test (#21402)
* the async test is flaky on ci * fix unstable test by increasing stats repoting time
This commit is contained in:
@ -43,6 +43,13 @@ impl Drop for QosService {
|
|||||||
|
|
||||||
impl QosService {
|
impl QosService {
|
||||||
pub fn new(cost_model: Arc<RwLock<CostModel>>) -> Self {
|
pub fn new(cost_model: Arc<RwLock<CostModel>>) -> Self {
|
||||||
|
Self::new_with_reporting_duration(cost_model, 1000u64)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_with_reporting_duration(
|
||||||
|
cost_model: Arc<RwLock<CostModel>>,
|
||||||
|
reporting_duration_ms: u64,
|
||||||
|
) -> Self {
|
||||||
let running_flag = Arc::new(AtomicBool::new(true));
|
let running_flag = Arc::new(AtomicBool::new(true));
|
||||||
let metrics = Arc::new(QosServiceMetrics::default());
|
let metrics = Arc::new(QosServiceMetrics::default());
|
||||||
|
|
||||||
@ -52,7 +59,7 @@ impl QosService {
|
|||||||
Builder::new()
|
Builder::new()
|
||||||
.name("solana-qos-service-metrics-repoting".to_string())
|
.name("solana-qos-service-metrics-repoting".to_string())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
Self::reporting_loop(running_flag_clone, metrics_clone);
|
Self::reporting_loop(running_flag_clone, metrics_clone, reporting_duration_ms);
|
||||||
})
|
})
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
@ -133,10 +140,13 @@ impl QosService {
|
|||||||
select_results
|
select_results
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reporting_loop(running_flag: Arc<AtomicBool>, metrics: Arc<QosServiceMetrics>) {
|
fn reporting_loop(
|
||||||
|
running_flag: Arc<AtomicBool>,
|
||||||
|
metrics: Arc<QosServiceMetrics>,
|
||||||
|
reporting_duration_ms: u64,
|
||||||
|
) {
|
||||||
while running_flag.load(Ordering::Relaxed) {
|
while running_flag.load(Ordering::Relaxed) {
|
||||||
// hardcode to report every 1000ms
|
metrics.report(reporting_duration_ms);
|
||||||
metrics.report(1000u64);
|
|
||||||
thread::sleep(Duration::from_millis(100));
|
thread::sleep(Duration::from_millis(100));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -323,8 +333,10 @@ mod tests {
|
|||||||
txs_2.push(transfer_tx.clone());
|
txs_2.push(transfer_tx.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set reporting duration to long enough so the stats wouldn't reset during testing
|
||||||
|
let ten_min = 600_000u64;
|
||||||
let cost_model = Arc::new(RwLock::new(CostModel::default()));
|
let cost_model = Arc::new(RwLock::new(CostModel::default()));
|
||||||
let qos_service = Arc::new(QosService::new(cost_model));
|
let qos_service = Arc::new(QosService::new_with_reporting_duration(cost_model, ten_min));
|
||||||
let qos_service_1 = qos_service.clone();
|
let qos_service_1 = qos_service.clone();
|
||||||
let qos_service_2 = qos_service.clone();
|
let qos_service_2 = qos_service.clone();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user