@@ -12,6 +12,7 @@ use std::{cmp::min, collections::HashMap, sync::Arc};
12
12
use anyhow:: Result ;
13
13
use async_trait:: async_trait;
14
14
use maplit:: hashmap;
15
+ use rand:: { prelude:: SliceRandom , thread_rng} ;
15
16
use shrub_rs:: models:: {
16
17
commands:: { fn_call, fn_call_with_params, EvgCommand } ,
17
18
params:: ParamValue ,
@@ -512,7 +513,8 @@ impl GenResmokeTaskServiceImpl {
512
513
multiversion_tags : Option < String > ,
513
514
) -> Result < Vec < SubSuite > > {
514
515
let origin_suite = multiversion_name. unwrap_or ( & params. suite_name ) ;
515
- let test_list = self . get_test_list ( params, multiversion_name) ?;
516
+ let mut test_list = self . get_test_list ( params, multiversion_name) ?;
517
+ test_list. shuffle ( & mut thread_rng ( ) ) ;
516
518
let n_suites = min ( test_list. len ( ) , self . config . n_suites ) ;
517
519
let tasks_per_suite = test_list. len ( ) / n_suites;
518
520
@@ -1205,7 +1207,8 @@ mod tests {
1205
1207
#[ test]
1206
1208
fn test_split_task_fallback_should_split_tasks_count ( ) {
1207
1209
let n_suites = 3 ;
1208
- let test_list: Vec < String > = ( 0 ..6 )
1210
+ let n_tests = 6 ;
1211
+ let test_list: Vec < String > = ( 0 ..n_tests)
1209
1212
. into_iter ( )
1210
1213
. map ( |i| format ! ( "test_{}.js" , i) )
1211
1214
. collect ( ) ;
@@ -1225,15 +1228,15 @@ mod tests {
1225
1228
. unwrap ( ) ;
1226
1229
1227
1230
assert_eq ! ( sub_suites. len( ) , n_suites) ;
1228
- let suite_0 = & sub_suites[ 0 ] ;
1229
- assert ! ( suite_0 . test_list. contains ( & "test_0.js" . to_string ( ) ) ) ;
1230
- assert ! ( suite_0 . test_list . contains ( & "test_1.js" . to_string ( ) ) ) ;
1231
- let suite_1 = & sub_suites [ 1 ] ;
1232
- assert ! ( suite_1 . test_list . contains ( & "test_2.js" . to_string ( ) ) ) ;
1233
- assert ! ( suite_1 . test_list . contains ( & "test_3.js" . to_string ( ) ) ) ;
1234
- let suite_2 = & sub_suites [ 2 ] ;
1235
- assert ! ( suite_2 . test_list . contains ( & "test_4.js" . to_string ( ) ) ) ;
1236
- assert ! ( suite_2 . test_list . contains ( & "test_5.js" . to_string ( ) ) ) ;
1231
+ for sub_suite in & sub_suites {
1232
+ assert_eq ! ( sub_suite . test_list. len ( ) , n_tests / n_suites ) ;
1233
+ }
1234
+
1235
+ let all_tests : Vec < String > = sub_suites
1236
+ . iter ( )
1237
+ . flat_map ( |s| s . test_list . clone ( ) )
1238
+ . collect ( ) ;
1239
+ assert_eq ! ( all_tests . len ( ) , n_tests ) ;
1237
1240
}
1238
1241
1239
1242
// tests for get_test_list.
0 commit comments