@@ -297,24 +297,15 @@ func findSRIOVResource(node *v1.Node) (string, int64) {
297
297
return "" , 0
298
298
}
299
299
300
- func deletePodInNamespace (f * framework.Framework , namespace , name string ) {
301
- gp := int64 (0 )
302
- deleteOptions := metav1.DeleteOptions {
303
- GracePeriodSeconds : & gp ,
304
- }
305
- err := f .ClientSet .CoreV1 ().Pods (namespace ).Delete (context .TODO (), name , & deleteOptions )
306
- framework .ExpectNoError (err )
307
- }
308
-
309
- func validatePodAlignment (f * framework.Framework , pod * v1.Pod , hwinfo testEnvHWInfo ) {
300
+ func validatePodAlignment (f * framework.Framework , pod * v1.Pod , envInfo testEnvInfo ) {
310
301
for _ , cnt := range pod .Spec .Containers {
311
302
ginkgo .By (fmt .Sprintf ("validating the container %s on Gu pod %s" , cnt .Name , pod .Name ))
312
303
313
304
logs , err := e2epod .GetPodLogs (f .ClientSet , f .Namespace .Name , pod .Name , cnt .Name )
314
305
framework .ExpectNoError (err , "expected log not found in container [%s] of pod [%s]" , cnt .Name , pod .Name )
315
306
316
307
framework .Logf ("got pod logs: %v" , logs )
317
- numaRes , err := checkNUMAAlignment (f , pod , & cnt , logs , hwinfo )
308
+ numaRes , err := checkNUMAAlignment (f , pod , & cnt , logs , envInfo )
318
309
framework .ExpectNoError (err , "NUMA Alignment check failed for [%s] of pod [%s]: %s" , cnt .Name , pod .Name , numaRes .String ())
319
310
}
320
311
}
@@ -562,7 +553,7 @@ func waitForAllContainerRemoval(podName, podNS string) {
562
553
}, 2 * time .Minute , 1 * time .Second ).Should (gomega .BeTrue ())
563
554
}
564
555
565
- func runTopologyManagerPositiveTest (f * framework.Framework , numPods int , ctnAttrs []tmCtnAttribute , hwinfo testEnvHWInfo ) {
556
+ func runTopologyManagerPositiveTest (f * framework.Framework , numPods int , ctnAttrs []tmCtnAttribute , envInfo testEnvInfo ) {
566
557
var pods []* v1.Pod
567
558
568
559
for podID := 0 ; podID < numPods ; podID ++ {
@@ -575,7 +566,7 @@ func runTopologyManagerPositiveTest(f *framework.Framework, numPods int, ctnAttr
575
566
}
576
567
577
568
for podID := 0 ; podID < numPods ; podID ++ {
578
- validatePodAlignment (f , pods [podID ], hwinfo )
569
+ validatePodAlignment (f , pods [podID ], envInfo )
579
570
}
580
571
581
572
for podID := 0 ; podID < numPods ; podID ++ {
@@ -587,7 +578,7 @@ func runTopologyManagerPositiveTest(f *framework.Framework, numPods int, ctnAttr
587
578
}
588
579
}
589
580
590
- func runTopologyManagerNegativeTest (f * framework.Framework , numPods int , ctnAttrs []tmCtnAttribute , hwinfo testEnvHWInfo ) {
581
+ func runTopologyManagerNegativeTest (f * framework.Framework , numPods int , ctnAttrs []tmCtnAttribute , envInfo testEnvInfo ) {
591
582
podName := "gu-pod"
592
583
framework .Logf ("creating pod %s attrs %v" , podName , ctnAttrs )
593
584
pod := makeTopologyManagerTestPod (podName , numalignCmd , ctnAttrs )
@@ -636,7 +627,16 @@ func getSRIOVDevicePluginConfigMap(cmFile string) *v1.ConfigMap {
636
627
return readConfigMapV1OrDie (cmData )
637
628
}
638
629
639
- func setupSRIOVConfigOrFail (f * framework.Framework , configMap * v1.ConfigMap ) (* v1.Pod , string , int64 ) {
630
+ type sriovData struct {
631
+ configMap * v1.ConfigMap
632
+ serviceAccount * v1.ServiceAccount
633
+ pod * v1.Pod
634
+
635
+ resourceName string
636
+ resourceAmount int64
637
+ }
638
+
639
+ func setupSRIOVConfigOrFail (f * framework.Framework , configMap * v1.ConfigMap ) sriovData {
640
640
var err error
641
641
642
642
ginkgo .By (fmt .Sprintf ("Creating configMap %v/%v" , metav1 .NamespaceSystem , configMap .Name ))
@@ -670,19 +670,34 @@ func setupSRIOVConfigOrFail(f *framework.Framework, configMap *v1.ConfigMap) (*v
670
670
}, 2 * time .Minute , framework .Poll ).Should (gomega .BeTrue ())
671
671
framework .Logf ("Successfully created device plugin pod, detected %d SRIOV device %q" , sriovResourceAmount , sriovResourceName )
672
672
673
- return dpPod , sriovResourceName , sriovResourceAmount
673
+ return sriovData {
674
+ configMap : configMap ,
675
+ serviceAccount : serviceAccount ,
676
+ pod : dpPod ,
677
+ resourceName : sriovResourceName ,
678
+ resourceAmount : sriovResourceAmount ,
679
+ }
674
680
}
675
681
676
- func teardownSRIOVConfigOrFail (f * framework.Framework , dpPod * v1. Pod ) {
677
- framework . Logf ( "deleting the SRIOV device plugin pod %s/%s and waiting for container %s removal" ,
678
- dpPod . Namespace , dpPod . Name , dpPod . Spec . Containers [ 0 ]. Name )
679
- deletePodInNamespace ( f , dpPod . Namespace , dpPod . Name )
680
- waitForContainerRemoval ( dpPod . Spec . Containers [ 0 ]. Name , dpPod . Name , dpPod . Namespace )
681
- }
682
+ func teardownSRIOVConfigOrFail (f * framework.Framework , sd sriovData ) {
683
+ var err error
684
+ gp := int64 ( 0 )
685
+ deleteOptions := metav1. DeleteOptions {
686
+ GracePeriodSeconds : & gp ,
687
+ }
682
688
683
- type testEnvHWInfo struct {
684
- numaNodes int
685
- sriovResourceName string
689
+ ginkgo .By ("Delete SRIOV device plugin pod %s/%s" )
690
+ err = f .ClientSet .CoreV1 ().Pods (sd .pod .Namespace ).Delete (context .TODO (), sd .pod .Name , & deleteOptions )
691
+ framework .ExpectNoError (err )
692
+ waitForContainerRemoval (sd .pod .Spec .Containers [0 ].Name , sd .pod .Name , sd .pod .Namespace )
693
+
694
+ ginkgo .By (fmt .Sprintf ("Deleting configMap %v/%v" , metav1 .NamespaceSystem , sd .configMap .Name ))
695
+ err = f .ClientSet .CoreV1 ().ConfigMaps (metav1 .NamespaceSystem ).Delete (context .TODO (), sd .configMap .Name , & deleteOptions )
696
+ framework .ExpectNoError (err )
697
+
698
+ ginkgo .By (fmt .Sprintf ("Deleting serviceAccount %v/%v" , metav1 .NamespaceSystem , sd .serviceAccount .Name ))
699
+ err = f .ClientSet .CoreV1 ().ServiceAccounts (metav1 .NamespaceSystem ).Delete (context .TODO (), sd .serviceAccount .Name , & deleteOptions )
700
+ framework .ExpectNoError (err )
686
701
}
687
702
688
703
func runTopologyManagerNodeAlignmentSuiteTests (f * framework.Framework , configMap * v1.ConfigMap , reservedSystemCPUs string , numaNodes , coreCount int ) {
@@ -691,144 +706,144 @@ func runTopologyManagerNodeAlignmentSuiteTests(f *framework.Framework, configMap
691
706
threadsPerCore = 2
692
707
}
693
708
694
- dpPod , sriovResourceName , sriovResourceAmount := setupSRIOVConfigOrFail (f , configMap )
695
- hwinfo := testEnvHWInfo {
709
+ sd := setupSRIOVConfigOrFail (f , configMap )
710
+ envInfo := testEnvInfo {
696
711
numaNodes : numaNodes ,
697
- sriovResourceName : sriovResourceName ,
712
+ sriovResourceName : sd . resourceName ,
698
713
}
699
714
700
715
// could have been a loop, we unroll it to explain the testcases
701
716
var ctnAttrs []tmCtnAttribute
702
717
703
718
// simplest case
704
- ginkgo .By (fmt .Sprintf ("Successfully admit one guaranteed pod with 1 core, 1 %s device" , sriovResourceName ))
719
+ ginkgo .By (fmt .Sprintf ("Successfully admit one guaranteed pod with 1 core, 1 %s device" , sd . resourceName ))
705
720
ctnAttrs = []tmCtnAttribute {
706
721
{
707
722
ctnName : "gu-container" ,
708
723
cpuRequest : "1000m" ,
709
724
cpuLimit : "1000m" ,
710
- deviceName : sriovResourceName ,
725
+ deviceName : sd . resourceName ,
711
726
deviceRequest : "1" ,
712
727
deviceLimit : "1" ,
713
728
},
714
729
}
715
- runTopologyManagerPositiveTest (f , 1 , ctnAttrs , hwinfo )
730
+ runTopologyManagerPositiveTest (f , 1 , ctnAttrs , envInfo )
716
731
717
- ginkgo .By (fmt .Sprintf ("Successfully admit one guaranteed pod with 2 cores, 1 %s device" , sriovResourceName ))
732
+ ginkgo .By (fmt .Sprintf ("Successfully admit one guaranteed pod with 2 cores, 1 %s device" , sd . resourceName ))
718
733
ctnAttrs = []tmCtnAttribute {
719
734
{
720
735
ctnName : "gu-container" ,
721
736
cpuRequest : "2000m" ,
722
737
cpuLimit : "2000m" ,
723
- deviceName : sriovResourceName ,
738
+ deviceName : sd . resourceName ,
724
739
deviceRequest : "1" ,
725
740
deviceLimit : "1" ,
726
741
},
727
742
}
728
- runTopologyManagerPositiveTest (f , 1 , ctnAttrs , hwinfo )
743
+ runTopologyManagerPositiveTest (f , 1 , ctnAttrs , envInfo )
729
744
730
745
if reservedSystemCPUs != "" {
731
746
// to avoid false negatives, we have put reserved CPUs in such a way there is at least a NUMA node
732
747
// with 1+ SRIOV devices and not reserved CPUs.
733
748
numCores := threadsPerCore * coreCount
734
749
allCoresReq := fmt .Sprintf ("%dm" , numCores * 1000 )
735
- ginkgo .By (fmt .Sprintf ("Successfully admit an entire socket (%d cores), 1 %s device" , numCores , sriovResourceName ))
750
+ ginkgo .By (fmt .Sprintf ("Successfully admit an entire socket (%d cores), 1 %s device" , numCores , sd . resourceName ))
736
751
ctnAttrs = []tmCtnAttribute {
737
752
{
738
753
ctnName : "gu-container" ,
739
754
cpuRequest : allCoresReq ,
740
755
cpuLimit : allCoresReq ,
741
- deviceName : sriovResourceName ,
756
+ deviceName : sd . resourceName ,
742
757
deviceRequest : "1" ,
743
758
deviceLimit : "1" ,
744
759
},
745
760
}
746
- runTopologyManagerPositiveTest (f , 1 , ctnAttrs , hwinfo )
761
+ runTopologyManagerPositiveTest (f , 1 , ctnAttrs , envInfo )
747
762
}
748
763
749
- if sriovResourceAmount > 1 {
764
+ if sd . resourceAmount > 1 {
750
765
// no matter how busses are connected to NUMA nodes and SRIOV devices are installed, this function
751
766
// preconditions must ensure the following can be fulfilled
752
- ginkgo .By (fmt .Sprintf ("Successfully admit two guaranteed pods, each with 1 core, 1 %s device" , sriovResourceName ))
767
+ ginkgo .By (fmt .Sprintf ("Successfully admit two guaranteed pods, each with 1 core, 1 %s device" , sd . resourceName ))
753
768
ctnAttrs = []tmCtnAttribute {
754
769
{
755
770
ctnName : "gu-container" ,
756
771
cpuRequest : "1000m" ,
757
772
cpuLimit : "1000m" ,
758
- deviceName : sriovResourceName ,
773
+ deviceName : sd . resourceName ,
759
774
deviceRequest : "1" ,
760
775
deviceLimit : "1" ,
761
776
},
762
777
}
763
- runTopologyManagerPositiveTest (f , 2 , ctnAttrs , hwinfo )
778
+ runTopologyManagerPositiveTest (f , 2 , ctnAttrs , envInfo )
764
779
765
- ginkgo .By (fmt .Sprintf ("Successfully admit two guaranteed pods, each with 2 cores, 1 %s device" , sriovResourceName ))
780
+ ginkgo .By (fmt .Sprintf ("Successfully admit two guaranteed pods, each with 2 cores, 1 %s device" , sd . resourceName ))
766
781
ctnAttrs = []tmCtnAttribute {
767
782
{
768
783
ctnName : "gu-container" ,
769
784
cpuRequest : "2000m" ,
770
785
cpuLimit : "2000m" ,
771
- deviceName : sriovResourceName ,
786
+ deviceName : sd . resourceName ,
772
787
deviceRequest : "1" ,
773
788
deviceLimit : "1" ,
774
789
},
775
790
}
776
- runTopologyManagerPositiveTest (f , 2 , ctnAttrs , hwinfo )
791
+ runTopologyManagerPositiveTest (f , 2 , ctnAttrs , envInfo )
777
792
778
793
// testing more complex conditions require knowledge about the system cpu+bus topology
779
794
}
780
795
781
796
// multi-container tests
782
- if sriovResourceAmount >= 4 {
783
- ginkgo .By (fmt .Sprintf ("Successfully admit one guaranteed pods, each with two containers, each with 2 cores, 1 %s device" , sriovResourceName ))
797
+ if sd . resourceAmount >= 4 {
798
+ ginkgo .By (fmt .Sprintf ("Successfully admit one guaranteed pods, each with two containers, each with 2 cores, 1 %s device" , sd . resourceName ))
784
799
ctnAttrs = []tmCtnAttribute {
785
800
{
786
801
ctnName : "gu-container-0" ,
787
802
cpuRequest : "2000m" ,
788
803
cpuLimit : "2000m" ,
789
- deviceName : sriovResourceName ,
804
+ deviceName : sd . resourceName ,
790
805
deviceRequest : "1" ,
791
806
deviceLimit : "1" ,
792
807
},
793
808
{
794
809
ctnName : "gu-container-1" ,
795
810
cpuRequest : "2000m" ,
796
811
cpuLimit : "2000m" ,
797
- deviceName : sriovResourceName ,
812
+ deviceName : sd . resourceName ,
798
813
deviceRequest : "1" ,
799
814
deviceLimit : "1" ,
800
815
},
801
816
}
802
- runTopologyManagerPositiveTest (f , 1 , ctnAttrs , hwinfo )
817
+ runTopologyManagerPositiveTest (f , 1 , ctnAttrs , envInfo )
803
818
804
- ginkgo .By (fmt .Sprintf ("Successfully admit two guaranteed pods, each with two containers, each with 1 core, 1 %s device" , sriovResourceName ))
819
+ ginkgo .By (fmt .Sprintf ("Successfully admit two guaranteed pods, each with two containers, each with 1 core, 1 %s device" , sd . resourceName ))
805
820
ctnAttrs = []tmCtnAttribute {
806
821
{
807
822
ctnName : "gu-container-0" ,
808
823
cpuRequest : "1000m" ,
809
824
cpuLimit : "1000m" ,
810
- deviceName : sriovResourceName ,
825
+ deviceName : sd . resourceName ,
811
826
deviceRequest : "1" ,
812
827
deviceLimit : "1" ,
813
828
},
814
829
{
815
830
ctnName : "gu-container-1" ,
816
831
cpuRequest : "1000m" ,
817
832
cpuLimit : "1000m" ,
818
- deviceName : sriovResourceName ,
833
+ deviceName : sd . resourceName ,
819
834
deviceRequest : "1" ,
820
835
deviceLimit : "1" ,
821
836
},
822
837
}
823
- runTopologyManagerPositiveTest (f , 2 , ctnAttrs , hwinfo )
838
+ runTopologyManagerPositiveTest (f , 2 , ctnAttrs , envInfo )
824
839
825
- ginkgo .By (fmt .Sprintf ("Successfully admit two guaranteed pods, each with two containers, both with with 2 cores, one with 1 %s device" , sriovResourceName ))
840
+ ginkgo .By (fmt .Sprintf ("Successfully admit two guaranteed pods, each with two containers, both with with 2 cores, one with 1 %s device" , sd . resourceName ))
826
841
ctnAttrs = []tmCtnAttribute {
827
842
{
828
843
ctnName : "gu-container-dev" ,
829
844
cpuRequest : "2000m" ,
830
845
cpuLimit : "2000m" ,
831
- deviceName : sriovResourceName ,
846
+ deviceName : sd . resourceName ,
832
847
deviceRequest : "1" ,
833
848
deviceLimit : "1" ,
834
849
},
@@ -838,26 +853,26 @@ func runTopologyManagerNodeAlignmentSuiteTests(f *framework.Framework, configMap
838
853
cpuLimit : "2000m" ,
839
854
},
840
855
}
841
- runTopologyManagerPositiveTest (f , 2 , ctnAttrs , hwinfo )
856
+ runTopologyManagerPositiveTest (f , 2 , ctnAttrs , envInfo )
842
857
}
843
858
844
859
// overflow NUMA node capacity: cores
845
860
numCores := 1 + (threadsPerCore * coreCount )
846
861
excessCoresReq := fmt .Sprintf ("%dm" , numCores * 1000 )
847
- ginkgo .By (fmt .Sprintf ("Trying to admit a guaranteed pods, with %d cores, 1 %s device - and it should be rejected" , numCores , sriovResourceName ))
862
+ ginkgo .By (fmt .Sprintf ("Trying to admit a guaranteed pods, with %d cores, 1 %s device - and it should be rejected" , numCores , sd . resourceName ))
848
863
ctnAttrs = []tmCtnAttribute {
849
864
{
850
865
ctnName : "gu-container" ,
851
866
cpuRequest : excessCoresReq ,
852
867
cpuLimit : excessCoresReq ,
853
- deviceName : sriovResourceName ,
868
+ deviceName : sd . resourceName ,
854
869
deviceRequest : "1" ,
855
870
deviceLimit : "1" ,
856
871
},
857
872
}
858
- runTopologyManagerNegativeTest (f , 1 , ctnAttrs , hwinfo )
873
+ runTopologyManagerNegativeTest (f , 1 , ctnAttrs , envInfo )
859
874
860
- teardownSRIOVConfigOrFail (f , dpPod )
875
+ teardownSRIOVConfigOrFail (f , sd )
861
876
}
862
877
863
878
func runTopologyManagerTests (f * framework.Framework ) {
0 commit comments