1+ //go:build !nobench 
2+ 
13package  sched
24
35import  (
46	"context" 
57	"fmt" 
6- 	"os" 
78	"strings" 
89	"testing" 
910	"time" 
@@ -25,17 +26,6 @@ import (
2526	"sigs.k8s.io/controller-runtime/pkg/envtest" 
2627)
2728
28- // isRunningInGitHubActions checks if the tests are running in GitHub Actions environment 
29- func  isRunningInGitHubActions () bool  {
30- 	if  os .Getenv ("GITHUB_ACTIONS" ) ==  "true"  {
31- 		return  true 
32- 	}
33- 	if  os .Getenv ("CI" ) ==  "true"  {
34- 		return  true 
35- 	}
36- 	return  false 
37- }
38- 
3929// PreemptionTestSuite holds common test setup for preemption tests 
4030type  PreemptionTestSuite  struct  {
4131	ctx             context.Context 
@@ -95,6 +85,9 @@ func (pts *PreemptionTestSuite) SetupSuite() {
9585	Expect (err ).To (Succeed ())
9686	pts .scheduler  =  scheduler 
9787	scheduler .SchedulingQueue .Run (klog .FromContext (ctx ))
88+ 	if  scheduler .APIDispatcher  !=  nil  {
89+ 		scheduler .APIDispatcher .Run (klog .FromContext (ctx ))
90+ 	}
9891
9992	// Start scheduler components 
10093	cc .EventBroadcaster .StartRecordingToSink (ctx .Done ())
@@ -105,6 +98,7 @@ func (pts *PreemptionTestSuite) SetupSuite() {
10598
10699// TearDownSuite cleans up the test environment 
107100func  (pts  * PreemptionTestSuite ) TearDownSuite () {
101+ 	time .Sleep (300  *  time .Millisecond )
108102	if  pts .cancel  !=  nil  {
109103		pts .cancel ()
110104	}
@@ -122,7 +116,7 @@ func (pts *PreemptionTestSuite) TearDownSuite() {
122116// TestPreemption tests comprehensive preemption scenarios 
123117func  TestPreemption (t  * testing.T ) {
124118	suiteConfig , reporterConfig  :=  GinkgoConfiguration ()
125- 	suiteConfig .Timeout  =  1  *  time .Minute 
119+ 	suiteConfig .Timeout  =  2  *  time .Minute 
126120	RegisterFailHandler (Fail )
127121	RunSpecs (t , "Preemption Test Suite" , suiteConfig , reporterConfig )
128122}
@@ -140,16 +134,10 @@ var _ = Describe("GPU Resource Preemption", func() {
140134	})
141135
142136	It ("should preempt lower priority pods for higher priority ones" , func () {
143- 		if  isRunningInGitHubActions () {
144- 			Skip ("Skipping preemption test in GitHub Actions environment" )
145- 		}
146137		testGPUResourcePreemption (suite )
147138	})
148139
149140	It ("should respect eviction protection periods" , func () {
150- 		if  isRunningInGitHubActions () {
151- 			Skip ("Skipping eviction protection test in GitHub Actions environment" )
152- 		}
153141		testGPUResourceEvictProtection (suite )
154142	})
155143})
@@ -193,6 +181,8 @@ func testGPUResourcePreemption(suite *PreemptionTestSuite) {
193181	defer  func () {
194182		_  =  suite .k8sClient .Delete (suite .ctx , criticalPriorityPod )
195183	}()
184+ 	time .Sleep (10  *  time .Millisecond )
185+ 	suite .scheduler .SchedulingQueue .Add (klog .FromContext (suite .ctx ), criticalPriorityPod )
196186	suite .scheduler .ScheduleOne (suite .ctx )
197187
198188	// Preemption should be triggered and victims deleted, wait informer sync 
0 commit comments