4242# multiple processes try to create VMs concurrently.
4343#
4444# ============================================================================
45+ # SCENARIO REQUIREMENTS
46+ # ============================================================================
47+ #
48+ # Scenarios opt-in to dynamic scheduling by defining dynamic_schedule_requirements().
49+ # Supported fields:
50+ # - min_vcpus: Minimum vCPUs required (default: DEFAULT_VM_VCPUS)
51+ # - min_memory: Minimum memory in MB (default: DEFAULT_VM_MEMORY)
52+ # - min_disksize: Minimum disk size in GB
53+ # - networks: Required networks (empty = network-agnostic, can run on any VM)
54+ # - boot_image: Required boot image
55+ # - fips: Whether FIPS mode is required
56+ # - slow: Set to "true" for long-running tests (e.g., router, conformance)
57+ # Slow tests get priority within their reusability tier to avoid
58+ # becoming the critical path.
59+ #
60+ # ============================================================================
4561
4662set -euo pipefail
4763
@@ -669,11 +685,14 @@ sort_scenarios_for_reuse() {
669685 # 1. Reusability score (ascending): restrictive scenarios first
670686 # - They can't be reused anyway, so get them out of the way
671687 # - Their VMs are destroyed when done
672- # 2. Within same reusability: boot_image descending (optionals before source)
673- # 3. Then vcpus descending (larger VMs first)
688+ # 2. Within same reusability: slow tests first (ascending 0=slow, 1=normal)
689+ # - Long-running tests start early to avoid becoming critical path
690+ # 3. Then boot_image descending (optionals before source)
691+ # 4. Then vcpus descending (larger VMs first)
674692 #
675693 # This ensures:
676694 # - Restrictive scenarios (special networks/boot_images) start first
695+ # - Slow tests start early within their reusability tier
677696 # - Flexible scenarios stay queued longer, maximizing reuse opportunities
678697
679698 for scenario_script in " ${scenarios[@]} " ; do
@@ -682,19 +701,25 @@ sort_scenarios_for_reuse() {
682701 local req_file=" ${SCENARIO_STATUS} /${scenario_name} /requirements"
683702
684703 if [ -f " ${req_file} " ]; then
685- local boot_image networks vcpus reuse_score
704+ local boot_image networks vcpus reuse_score slow_flag slow_sort
686705 boot_image=$( get_req_value " ${req_file} " " boot_image" " default" )
687706 networks=$( get_req_value " ${req_file} " " networks" " default" )
688707 vcpus=$( get_req_value " ${req_file} " " min_vcpus" " ${DEFAULT_VM_VCPUS} " )
708+ slow_flag=$( get_req_value " ${req_file} " " slow" " false" )
689709 reuse_score=$( get_reusability_score " ${boot_image} " " ${networks} " )
690- # Sort key: reuse_score (asc), boot_image (desc), vcpus (desc)
710+ # slow=true -> sort value 0 (first), slow=false -> sort value 1 (after)
711+ slow_sort=1
712+ if [ " ${slow_flag} " = " true" ]; then
713+ slow_sort=0
714+ fi
715+ # Sort key: reuse_score (asc), slow_sort (asc), boot_image (desc), vcpus (desc)
691716 # Use inverse vcpus (100-vcpus) so ascending sort gives descending vcpus
692- printf " %d\t%s\t%02d\t%s\n" " ${reuse_score} " " ${boot_image} " " $(( 100 - vcpus)) " " ${scenario_script} "
717+ printf " %d\t%d\t% s\t%02d\t%s\n" " ${reuse_score} " " ${slow_sort }" " ${boot_image} " " $(( 100 - vcpus)) " " ${scenario_script} "
693718 else
694719 # Unknown requirements - treat as flexible, put last
695- printf " 9\taaa\t99\t%s\n" " ${scenario_script} "
720+ printf " 9\t1\ taaa\t99\t%s\n" " ${scenario_script} "
696721 fi
697- done | sort -t$' \t ' -k1,1n -k2,2r -k3,3n | cut -f4
722+ done | sort -t$' \t ' -k1,1n -k2,2n -k3,3r -k4,4n | cut -f5
698723}
699724
700725# Global sequence counter for queue ordering
0 commit comments