瀏覽代碼

fix(test): wait for spawned tasks' result

Yujia Qiao 4 年之前
父節點
當前提交
e836071c3a
共有 1 個文件被更改,包括 11 次插入4 次删除
  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