Add delay for test server availability, could cause connect race (#533)

This commit is contained in:
Nikolay Kim 2025-03-18 05:50:28 +01:00 committed by GitHub
parent 5621ca1898
commit 3b58f5a111
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 8 deletions

View file

@ -59,17 +59,19 @@ where
.workers(1)
.disable_signals()
.run();
tx.send((system, local_addr, server))
.expect("Failed to send Server to TestServer");
ntex_rt::spawn(async move {
ntex_util::time::sleep(ntex_util::time::Millis(75)).await;
tx.send((system, local_addr, server))
.expect("Failed to send Server to TestServer");
});
Ok(())
})
});
let (system, addr, server) = rx.recv().unwrap();
// wait for server
thread::sleep(std::time::Duration::from_millis(50));
TestServer {
addr,
server,

View file

@ -1,5 +1,9 @@
# Changes
## [2.12.3] - 2025-03-xx
* http: Add delay for test server availability, could cause connect race
## [2.12.2] - 2025-03-15
* http: Allow to run publish future to completion in case error

View file

@ -11,7 +11,7 @@ use crate::server::Server;
use crate::service::ServiceFactory;
#[cfg(feature = "ws")]
use crate::ws::{error::WsClientError, WsClient, WsConnection};
use crate::{rt::System, time::Millis, time::Seconds, util::Bytes};
use crate::{rt::System, time::sleep, time::Millis, time::Seconds, util::Bytes};
use super::client::{Client, ClientRequest, ClientResponse, Connector};
use super::error::{HttpError, PayloadError};
@ -244,7 +244,11 @@ where
.workers(1)
.disable_signals()
.run();
tx.send((system, srv, local_addr)).unwrap();
crate::rt::spawn(async move {
sleep(Millis(75)).await;
tx.send((system, srv, local_addr)).unwrap();
});
Ok(())
})
});

View file

@ -697,7 +697,10 @@ where
.set_tag("test", "WEB-SRV")
.run();
tx.send((System::current(), srv, local_addr)).unwrap();
crate::rt::spawn(async move {
sleep(Millis(75)).await;
tx.send((System::current(), srv, local_addr)).unwrap();
});
Ok(())
})
});