Kaynağa Gözat

fix(test): wait for spawned tasks' result

Yujia Qiao 4 yıl önce
ebeveyn
işleme
e836071c3a
1 değiştirilmiş dosya ile 11 ekleme ve 4 silme
  1. 11 4
      tests/integration_test.rs

+ 11 - 4
tests/integration_test.rs

@@ -155,16 +155,23 @@ async fn test(config_path: &'static str, t: Type) -> Result<()> {
 
     // Simulate heavy load
     info!("lots of echo and pingpong");
+
+    let mut v = Vec::new();
+
     for _ in 0..HITTER_NUM / 2 {
-        tokio::spawn(async move {
+        v.push(tokio::spawn(async move {
             echo_hitter(ECHO_SERVER_ADDR_EXPOSED, t).await.unwrap();
-        });
+        }));
 
-        tokio::spawn(async move {
+        v.push(tokio::spawn(async move {
             pingpong_hitter(PINGPONG_SERVER_ADDR_EXPOSED, t)
                 .await
                 .unwrap();
-        });
+        }));
+    }
+
+    for h in v {
+        assert!(tokio::join!(h).0.is_ok());
     }
 
     // Shutdown