Honor MAX_PEERS env variable in randomized test

This commit is contained in:
Antonio Scandurra 2022-11-01 10:24:26 +01:00
parent c6e52dbef7
commit ef72c75fab

View File

@ -5784,7 +5784,6 @@ async fn test_random_collaboration(
let max_peers = env::var("MAX_PEERS") let max_peers = env::var("MAX_PEERS")
.map(|i| i.parse().expect("invalid `MAX_PEERS` variable")) .map(|i| i.parse().expect("invalid `MAX_PEERS` variable"))
.unwrap_or(5); .unwrap_or(5);
assert!(max_peers <= 5);
let max_operations = env::var("OPERATIONS") let max_operations = env::var("OPERATIONS")
.map(|i| i.parse().expect("invalid `OPERATIONS` variable")) .map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
@ -5806,24 +5805,16 @@ async fn test_random_collaboration(
.await .await
.unwrap() .unwrap()
.user_id; .user_id;
let mut available_guests = vec![
"guest-1".to_string(),
"guest-2".to_string(),
"guest-3".to_string(),
"guest-4".to_string(),
];
for (ix, username) in Some(&"host".to_string()) let mut available_guests = Vec::new();
.into_iter() for ix in 0..max_peers {
.chain(&available_guests) let username = format!("guest-{}", ix + 1);
.enumerate()
{
let user_id = db let user_id = db
.create_user( .create_user(
&format!("{username}@example.com"), &format!("{username}@example.com"),
false, false,
NewUserParams { NewUserParams {
github_login: username.into(), github_login: username.clone(),
github_user_id: (ix + 1) as i32, github_user_id: (ix + 1) as i32,
invite_count: 0, invite_count: 0,
}, },
@ -5843,6 +5834,7 @@ async fn test_random_collaboration(
.respond_to_contact_request(room_creator_user_id, user_id, true) .respond_to_contact_request(room_creator_user_id, user_id, true)
.await .await
.unwrap(); .unwrap();
available_guests.push(username);
} }
let _room_creator = server.create_client(cx, "room-creator").await; let _room_creator = server.create_client(cx, "room-creator").await;