@@ -621,12 +621,25 @@ var _ = ginkgo.Describe("Workload controller interaction with scheduler", ginkgo
621621 wl * kueue.Workload
622622 )
623623
624- ginkgo . BeforeAll ( func () {
624+ startManager := func () {
625625 fwk .StartManager (ctx , cfg , managerAndSchedulerSetup )
626+ }
627+
628+ stopManager := func () {
629+ fwk .StopManager (ctx )
630+ }
631+
632+ restartManager := func () {
633+ stopManager ()
634+ startManager ()
635+ }
636+
637+ ginkgo .BeforeAll (func () {
638+ startManager ()
626639 })
627640
628641 ginkgo .AfterAll (func () {
629- fwk . StopManager ( ctx )
642+ stopManager ( )
630643 })
631644
632645 ginkgo .When ("workload's runtime class is changed" , func () {
@@ -657,7 +670,7 @@ var _ = ginkgo.Describe("Workload controller interaction with scheduler", ginkgo
657670 util .ExpectObjectToBeDeleted (ctx , k8sClient , runtimeClass , true )
658671 })
659672
660- ginkgo .It ("should not temporarily admit an inactive workload" , func () {
673+ ginkgo .It ("should not temporarily admit an inactive workload after changing the runtime class " , func () {
661674 ginkgo .By ("creating an inactive workload" , func () {
662675 wl = utiltestingapi .MakeWorkload ("wl1" , ns .Name ).
663676 Queue (kueue .LocalQueueName (localQueue .Name )).
@@ -685,7 +698,7 @@ var _ = ginkgo.Describe("Workload controller interaction with scheduler", ginkgo
685698 }, util .Timeout , util .Interval ).Should (gomega .Succeed ())
686699 })
687700
688- ginkgo .By ("checking no 'quota reseved ' event appearing for the workload" , func () {
701+ ginkgo .By ("checking no 'quota reserved ' event appearing for the workload" , func () {
689702 gomega .Consistently (func (g gomega.Gomega ) {
690703 found , err := utiltesting .HasMatchingEventAppeared (ctx , k8sClient , func (e * corev1.Event ) bool {
691704 return e .Reason == "QuotaReserved" &&
@@ -700,7 +713,7 @@ var _ = ginkgo.Describe("Workload controller interaction with scheduler", ginkgo
700713 })
701714 })
702715
703- ginkgo .It ("should not temporarily admit a finished workload" , func () {
716+ ginkgo .It ("should not temporarily admit a finished workload after changing the runtime class " , func () {
704717 wl = utiltestingapi .MakeWorkload ("wl1" , ns .Name ).
705718 Queue (kueue .LocalQueueName (localQueue .Name )).
706719 Request (corev1 .ResourceCPU , "1" ).
@@ -757,6 +770,56 @@ var _ = ginkgo.Describe("Workload controller interaction with scheduler", ginkgo
757770 }, util .ConsistentDuration , util .ShortInterval ).Should (gomega .Succeed ())
758771 })
759772 })
773+
774+ ginkgo .It ("should not temporarily admit a finished workload on restart manager" , func () {
775+ wl = utiltestingapi .MakeWorkload ("wl1" , ns .Name ).
776+ Queue (kueue .LocalQueueName (localQueue .Name )).
777+ Request (corev1 .ResourceCPU , "1" ).
778+ RuntimeClass (runtimeClassName ).
779+ Obj ()
780+ util .MustCreate (ctx , k8sClient , wl )
781+
782+ wlKey := client .ObjectKeyFromObject (wl )
783+
784+ ginkgo .By ("creating a workload" , func () {
785+ gomega .Eventually (func (g gomega.Gomega ) {
786+ g .Expect (k8sClient .Get (ctx , wlKey , wl )).To (gomega .Succeed ())
787+ }, util .Timeout , util .Interval ).Should (gomega .Succeed ())
788+ })
789+
790+ ginkgo .By ("waiting for admission" , func () {
791+ util .ExpectWorkloadsToBeAdmitted (ctx , k8sClient , wl )
792+ })
793+
794+ ginkgo .By ("finishing the workload" , func () {
795+ gomega .Eventually (func (g gomega.Gomega ) {
796+ g .Expect (k8sClient .Get (ctx , wlKey , wl )).To (gomega .Succeed ())
797+ g .Expect (workload .Finish (ctx , k8sClient , wl , "ByTest" , "By test" , util .RealClock )).To (gomega .Succeed ())
798+ }, util .Timeout , util .Interval ).Should (gomega .Succeed ())
799+ })
800+
801+ ginkgo .By ("waiting for finish" , func () {
802+ util .ExpectWorkloadToFinish (ctx , k8sClient , wlKey )
803+ })
804+
805+ ginkgo .By ("restarting the manager" , func () {
806+ restartManager ()
807+ })
808+
809+ ginkgo .By ("checking no 'quota reserved' event appearing for the workload" , func () {
810+ gomega .Consistently (func (g gomega.Gomega ) {
811+ count , err := utiltesting .HasMatchingEventAppearedTimes (ctx , k8sClient , func (e * corev1.Event ) bool {
812+ return e .Reason == "QuotaReserved" &&
813+ e .Type == corev1 .EventTypeNormal &&
814+ e .InvolvedObject .Kind == "Workload" &&
815+ e .InvolvedObject .Name == wl .Name &&
816+ e .InvolvedObject .Namespace == wl .Namespace
817+ })
818+ g .Expect (err ).NotTo (gomega .HaveOccurred ())
819+ g .Expect (count ).To (gomega .Equal (1 ))
820+ }, util .ConsistentDuration , util .ShortInterval ).Should (gomega .Succeed ())
821+ })
822+ })
760823 })
761824})
762825
0 commit comments