Fix spurious signer tests failures (#3312)
* Increasing sleep time for signer tests * Attempt re-connections instead of delaying tests execution
This commit is contained in:
parent
877cfe9b53
commit
915766c7bf
@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::str::{self, Lines};
|
use std::str::{self, Lines};
|
||||||
@ -42,8 +43,28 @@ pub fn read_block(lines: &mut Lines, all: bool) -> String {
|
|||||||
block
|
block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn connect(address: &SocketAddr) -> TcpStream {
|
||||||
|
let mut retries = 0;
|
||||||
|
let mut last_error = None;
|
||||||
|
while retries < 10 {
|
||||||
|
retries += 1;
|
||||||
|
|
||||||
|
let res = TcpStream::connect(address);
|
||||||
|
match res {
|
||||||
|
Ok(stream) => {
|
||||||
|
return stream;
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
last_error = Some(e);
|
||||||
|
thread::sleep(Duration::from_millis(retries * 10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
panic!("Unable to connect to the server. Last error: {:?}", last_error);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn request(address: &SocketAddr, request: &str) -> Response {
|
pub fn request(address: &SocketAddr, request: &str) -> Response {
|
||||||
let mut req = TcpStream::connect(address).unwrap();
|
let mut req = connect(address);
|
||||||
req.set_read_timeout(Some(Duration::from_secs(1))).unwrap();
|
req.set_read_timeout(Some(Duration::from_secs(1))).unwrap();
|
||||||
req.write_all(request.as_bytes()).unwrap();
|
req.write_all(request.as_bytes()).unwrap();
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::{self, Duration};
|
use std::time;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use devtools::{http_client, RandomTempPath};
|
use devtools::{http_client, RandomTempPath};
|
||||||
use rpc::ConfirmationsQueue;
|
use rpc::ConfirmationsQueue;
|
||||||
@ -50,7 +50,6 @@ pub fn serve() -> (Server, usize, GuardedAuthCodes) {
|
|||||||
let builder = ServerBuilder::new(queue, path.to_path_buf());
|
let builder = ServerBuilder::new(queue, path.to_path_buf());
|
||||||
let port = 35000 + rand::random::<usize>() % 10000;
|
let port = 35000 + rand::random::<usize>() % 10000;
|
||||||
let res = builder.start(format!("127.0.0.1:{}", port).parse().unwrap()).unwrap();
|
let res = builder.start(format!("127.0.0.1:{}", port).parse().unwrap()).unwrap();
|
||||||
thread::sleep(Duration::from_millis(25));
|
|
||||||
|
|
||||||
(res, port, GuardedAuthCodes {
|
(res, port, GuardedAuthCodes {
|
||||||
authcodes: AuthCodes::from_file(&path).unwrap(),
|
authcodes: AuthCodes::from_file(&path).unwrap(),
|
||||||
|
Loading…
Reference in New Issue
Block a user