@@ -1115,6 +1115,48 @@ var _ = SIGDescribe("POD Resources API", framework.WithSerial(), feature.PodReso
1115
1115
initialConfig .FeatureGates [string (kubefeatures .KubeletPodResourcesGet )]= true
1116
1116
})
1117
1117
1118
+ ginkgo .Context ("with KubeletPodResourcesGet feature gate enabled" ,func () {
1119
+ ginkgo .BeforeEach (func () {
1120
+ e2eskipper .SkipUnlessFeatureGateEnabled ("KubeletPodResourcesGet" )
1121
+ })
1122
+
1123
+ ginkgo .It ("should succeed when calling Get for a valid pod" ,func (ctx context.Context ) {
1124
+ endpoint ,err := util .LocalEndpoint (defaultPodResourcesPath ,podresources .Socket )
1125
+ framework .ExpectNoError (err ,"LocalEndpoint() faild err: %v" ,err )
1126
+
1127
+ cli ,conn ,err := podresources .GetV1Client (endpoint ,defaultPodResourcesTimeout ,defaultPodResourcesMaxSize )
1128
+ framework .ExpectNoError (err ,"GetV1Client() failed err: %v" ,err )
1129
+ defer framework .ExpectNoError (conn .Close ())
1130
+
1131
+ ginkgo .By ("checking Get succeeds when the feature gate is enabled" )
1132
+ pd := podDesc {
1133
+ podName :"fg-enabled-pod" ,
1134
+ cntName :"fg-enabled-cnt" ,
1135
+ cpuRequest :1000 ,
1136
+ }
1137
+ pod := makePodResourcesTestPod (pd )
1138
+ pod = e2epod .NewPodClient (f ).Create (ctx ,pod )
1139
+ defer e2epod .NewPodClient (f ).DeleteSync (ctx ,pod .Name , metav1.DeleteOptions {},f .Timeouts .PodDelete )
1140
+ err = e2epod .WaitForPodCondition (ctx ,f .ClientSet ,pod .Namespace ,pod .Name ,"Ready" ,2 * time .Minute ,testutils .PodRunningReady )
1141
+ framework .ExpectNoError (err )
1142
+
1143
+ res ,err := cli .Get (ctx ,& kubeletpodresourcesv1.GetPodResourcesRequest {
1144
+ PodName :pod .Name ,
1145
+ PodNamespace :pod .Namespace ,
1146
+ })
1147
+
1148
+ framework .Logf ("Get result: %v, err: %v" ,res ,err )
1149
+ framework .ExpectNoError (err ,"Expected Get to succeed with the feature gate enabled" )
1150
+ gomega .Expect (res .PodResources .Name ).To (gomega .Equal (pod .Name ))
1151
+ gomega .Expect (res .PodResources .Containers ).To (gomega .HaveLen (1 ),"expected one container" )
1152
+ container := res .PodResources .Containers [0 ]
1153
+ gomega .Expect (container .Name ).To (gomega .Equal (pd .cntName ),"expected container name match" )
1154
+ gomega .Expect (container .CpuIds ).ToNot (gomega .BeEmpty (),"expected CPU IDs to be reported" )
1155
+ gomega .Expect (container .CpuIds ).To (gomega .HaveLen (pd .CpuRequestExclusive ()),"expected one exclusive CPU" )
1156
+ gomega .Expect (container .Devices ).To (gomega .BeEmpty (),"expected no devices" )
1157
+ })
1158
+ })
1159
+
1118
1160
ginkgo .It ("should return the expected responses" ,func (ctx context.Context ) {
1119
1161
onlineCPUs ,err := getOnlineCPUs ()
1120
1162
framework .ExpectNoError (err ,"getOnlineCPUs() failed err: %v" ,err )