@@ -2250,63 +2250,64 @@ func TestQuotaChangePreemptionSettings(t *testing.T) {
22502250
22512251 parent , err := createManagedQueueWithProps (root , "parent" , false , getResourceConf (), getResourceConf ())
22522252 assert .NilError (t , err , "failed to create basic queue: %v" , err )
2253-
2254- var nilTimer * time.Timer
22552253 testCases := []struct {
22562254 name string
22572255 conf configs.QueueConfig
22582256 expectedDelay uint64
2259- expectedTimer * time.Timer
22602257 }{{"first queue setup without delay" , configs.QueueConfig {
22612258 Resources : configs.Resources {
22622259 Max : getResourceConf (),
22632260 Guaranteed : getResourceConf (),
22642261 },
2265- }, 0 , nilTimer },
2262+ }, 0 },
22662263 {"increase max with delay" , configs.QueueConfig {
22672264 Resources : configs.Resources {
22682265 Max : map [string ]string {"memory" : "100000000" },
22692266 },
22702267 Preemption : configs.Preemption {
22712268 Delay : 500 ,
22722269 },
2273- }, 0 , nilTimer },
2270+ }, 0 },
22742271 {"decrease max with delay" , configs.QueueConfig {
22752272 Resources : configs.Resources {
22762273 Max : map [string ]string {"memory" : "100" },
22772274 },
22782275 Preemption : configs.Preemption {
22792276 Delay : 500 ,
22802277 },
2281- }, 500 , time . AfterFunc ( time . Duration ( 500 ), parent . tryPreemptionToEnforceQuota ) },
2278+ }, 500 },
22822279 {"max remains as is but delay changed" , configs.QueueConfig {
22832280 Resources : configs.Resources {
22842281 Max : map [string ]string {"memory" : "100" },
22852282 },
22862283 Preemption : configs.Preemption {
22872284 Delay : 200 ,
22882285 },
2289- }, 200 , time .AfterFunc (time .Duration (200 ), parent .tryPreemptionToEnforceQuota )},
2286+ }, 200 },
2287+ {"unrelated config change, should not impact earlier set preemption settings" , configs.QueueConfig {
2288+ Resources : configs.Resources {
2289+ Max : map [string ]string {"memory" : "100" },
2290+ Guaranteed : map [string ]string {"memory" : "50" },
2291+ },
2292+ Preemption : configs.Preemption {
2293+ Delay : 200 ,
2294+ },
2295+ }, 200 },
22902296 {"increase max again with delay" , configs.QueueConfig {
22912297 Resources : configs.Resources {
22922298 Max : map [string ]string {"memory" : "101" },
22932299 },
22942300 Preemption : configs.Preemption {
22952301 Delay : 200 ,
22962302 },
2297- }, 0 , nilTimer }}
2303+ }, 0 }}
22982304
22992305 for _ , tc := range testCases {
23002306 t .Run (tc .name , func (t * testing.T ) {
23012307 err = parent .ApplyConf (tc .conf )
23022308 assert .NilError (t , err , "failed to apply conf: %v" , err )
23032309 assert .Assert (t , parent .maxResource != nil )
23042310 assert .Equal (t , parent .quotaChangePreemptionDelay , tc .expectedDelay )
2305- if tc .expectedTimer != nil {
2306- assert .Equal (t , * parent .quotaChangePreemptionTimer , * tc .expectedTimer )
2307- } else {
2308- assert .Assert (t , parent .quotaChangePreemptionTimer == nil )
2309- }
23102311 })
23112312 }
23122313}
@@ -2341,8 +2342,6 @@ func TestNewConfiguredQueue(t *testing.T) {
23412342 assert .Assert (t , resources .Equals (resourceStruct , parent .template .GetMaxResource ()))
23422343 assert .Assert (t , resources .Equals (resourceStruct , parent .template .GetGuaranteedResource ()))
23432344 assert .Equal (t , parent .quotaChangePreemptionDelay , uint64 (0 ))
2344- var expectedTimer * time.Timer
2345- assert .Equal (t , parent .quotaChangePreemptionTimer , expectedTimer )
23462345
23472346 // case 0: managed leaf queue can't use template
23482347 leafConfig := configs.QueueConfig {
@@ -2369,8 +2368,6 @@ func TestNewConfiguredQueue(t *testing.T) {
23692368 assert .NilError (t , err , "Resource creation failed" )
23702369 assert .Assert (t , resources .Equals (childLeaf .guaranteedResource , childLeafGuaranteed ))
23712370 assert .Equal (t , childLeaf .quotaChangePreemptionDelay , uint64 (500 ))
2372- leafExpectedTimer := time .AfterFunc (time .Duration (uint64 (500 )), childLeaf .tryPreemptionToEnforceQuota )
2373- assert .Equal (t , * childLeaf .quotaChangePreemptionTimer , * leafExpectedTimer )
23742371
23752372 // case 1: non-leaf can't use template but it can inherit template from parent
23762373 NonLeafConfig := configs.QueueConfig {
@@ -2388,8 +2385,6 @@ func TestNewConfiguredQueue(t *testing.T) {
23882385 assert .Assert (t , childNonLeaf .guaranteedResource == nil )
23892386 assert .Assert (t , childNonLeaf .maxResource == nil )
23902387 assert .Equal (t , childNonLeaf .quotaChangePreemptionDelay , uint64 (0 ))
2391- var nonLeafExpectedTimer * time.Timer
2392- assert .Equal (t , childNonLeaf .quotaChangePreemptionTimer , nonLeafExpectedTimer )
23932388
23942389 // case 2: do not send queue event when silence flag is set to true
23952390 events .Init ()
@@ -2407,8 +2402,6 @@ func TestNewConfiguredQueue(t *testing.T) {
24072402 noEvents := eventSystem .Store .CountStoredEvents ()
24082403 assert .Equal (t , noEvents , uint64 (0 ), "expected 0 event, got %d" , noEvents )
24092404 assert .Equal (t , rootQ .quotaChangePreemptionDelay , uint64 (0 ))
2410- var rootQTimer * time.Timer
2411- assert .Equal (t , rootQ .quotaChangePreemptionTimer , rootQTimer )
24122405}
24132406
24142407func TestResetRunningState (t * testing.T ) {
0 commit comments