Skip to content

Commit 3731f23

Browse files
committed
deterministic port number
1 parent 805a5d3 commit 3731f23

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/common/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ use serde_json::{json, Value};
4747
use std::collections::{HashMap, HashSet};
4848
use std::env;
4949
use std::path::PathBuf;
50+
use std::sync::atomic::{AtomicU16, Ordering};
5051
use std::sync::{Arc, RwLock};
5152
use std::time::Duration;
5253

@@ -202,9 +203,10 @@ pub(crate) fn random_storage_path() -> PathBuf {
202203
temp_path
203204
}
204205

206+
static PORT_COUNTER: AtomicU16 = AtomicU16::new(5000);
207+
205208
pub(crate) fn random_port() -> u16 {
206-
let mut rng = thread_rng();
207-
rng.gen_range(5000..65535)
209+
PORT_COUNTER.fetch_add(1, Ordering::Relaxed)
208210
}
209211

210212
pub(crate) fn random_listening_addresses() -> Vec<SocketAddress> {

0 commit comments

Comments
 (0)