@@ -68,6 +68,67 @@ def test_runtimes_init():
6868 kernelci .runtime .get_runtime (runtime_config )
6969
7070
71+ def test_lava_priority_hierarchy ():
72+ """Test LAVA priority: human=highest, tree=high/medium/low"""
73+ config = kernelci .config .load ('tests/configs/lava-runtimes.yaml' )
74+ runtimes = config ['runtimes' ]
75+ runtime_config = runtimes ['lab-min-12-max-40-new-runtime' ]
76+ lab = kernelci .runtime .get_runtime (runtime_config )
77+
78+ job_config_no_priority = type ('JobConfig' , (), {'priority' : None })()
79+
80+ job_human_high_tree = type ('Job' , (), {
81+ 'node' : {
'data' : {
'tree_priority' :
'high' },
'submitter' :
'[email protected] ' },
82+ 'config' : job_config_no_priority
83+ })()
84+ expected_priority = int (12 + (40 - 12 ) * 80 / 100 )
85+ assert lab ._get_priority (job_human_high_tree ) == expected_priority
86+
87+ job_pipeline_high_tree = type ('Job' , (), {
88+ 'node' : {'data' : {'tree_priority' : 'high' }, 'submitter' : 'service:pipeline' },
89+ 'config' : job_config_no_priority
90+ })()
91+ expected_priority = int (12 + (40 - 12 ) * 60 / 100 )
92+ assert lab ._get_priority (job_pipeline_high_tree ) == expected_priority
93+
94+ job_medium_tree = type ('Job' , (), {
95+ 'node' : {'data' : {'tree_priority' : 'medium' }, 'submitter' : 'service:pipeline' },
96+ 'config' : job_config_no_priority
97+ })()
98+ expected_priority = int (12 + (40 - 12 ) * 40 / 100 )
99+ assert lab ._get_priority (job_medium_tree ) == expected_priority
100+
101+ job_low_tree = type ('Job' , (), {
102+ 'node' : {'data' : {'tree_priority' : 'low' }, 'submitter' : 'service:pipeline' },
103+ 'config' : job_config_no_priority
104+ })()
105+ expected_priority = int (12 + (40 - 12 ) * 20 / 100 )
106+ assert lab ._get_priority (job_low_tree ) == expected_priority
107+
108+ job_default = type ('Job' , (), {
109+ 'node' : {'data' : {}, 'submitter' : 'service:pipeline' },
110+ 'config' : job_config_no_priority
111+ })()
112+ expected_priority = int (12 + (40 - 12 ) * 20 / 100 )
113+ assert lab ._get_priority (job_default ) == expected_priority
114+
115+ # Human submission with user-specified string priority
116+ job_human_set_high = type ('Job' , (), {
117+ 'node' : {
'data' : {
'priority' :
'high' },
'submitter' :
'[email protected] ' },
118+ 'config' : job_config_no_priority
119+ })()
120+ expected_priority = int (12 + (40 - 12 ) * 60 / 100 )
121+ assert lab ._get_priority (job_human_set_high ) == expected_priority
122+
123+ # Human submission with user-specified numeric priority
124+ job_human_set_numeric = type ('Job' , (), {
125+ 'node' : {
'data' : {
'priority' :
50 },
'submitter' :
'[email protected] ' },
126+ 'config' : job_config_no_priority
127+ })()
128+ expected_priority = int (12 + (40 - 12 ) * 50 / 100 )
129+ assert lab ._get_priority (job_human_set_numeric ) == expected_priority
130+
131+
71132def test_lava_priority_scale ():
72133 """Test the logic for determining the priority of LAVA jobs"""
73134 config = kernelci .config .load ('tests/configs/lava-runtimes.yaml' )
0 commit comments