From 96da66054db345b7ccb6b004838ba6434e5b434c Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Tue, 6 May 2025 13:23:07 +0300 Subject: [PATCH] DRA: genTestClaimInfo: add claimUID parameter --- pkg/kubelet/cm/dra/manager_test.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/kubelet/cm/dra/manager_test.go b/pkg/kubelet/cm/dra/manager_test.go index f65ac87575a..baf1bc4c5f3 100644 --- a/pkg/kubelet/cm/dra/manager_test.go +++ b/pkg/kubelet/cm/dra/manager_test.go @@ -282,7 +282,7 @@ func genTestClaim(name, driver, device, podUID string) *resourceapi.ResourceClai } // genTestClaimInfo generates claim info object -func genTestClaimInfo(podUIDs []string, prepared bool) *ClaimInfo { +func genTestClaimInfo(claimUID types.UID, podUIDs []string, prepared bool) *ClaimInfo { return &ClaimInfo{ ClaimInfoState: state.ClaimInfoState{ ClaimUID: claimUID, @@ -344,7 +344,7 @@ func TestGetResources(t *testing.T) { }, }, pod: genTestPod(), - claimInfo: genTestClaimInfo(nil, false), + claimInfo: genTestClaimInfo(claimUID, nil, false), }, { description: "nil claiminfo", @@ -482,7 +482,7 @@ func TestPrepareResources(t *testing.T) { driverName: driverName, pod: genTestPod(), claim: genTestClaim(claimName, driverName, deviceName, podUID), - claimInfo: genTestClaimInfo([]string{podUID}, true), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, true), expectedClaimInfoState: genClaimInfoState(cdiID), resp: &drapb.NodePrepareResourcesResponse{Claims: map[string]*drapb.NodePrepareResourceResponse{ string(claimUID): { @@ -531,7 +531,7 @@ func TestPrepareResources(t *testing.T) { driverName: driverName, pod: genTestPod(), claim: genTestClaim(claimName, driverName, deviceName, podUID), - claimInfo: genTestClaimInfo([]string{podUID}, true), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, true), expectedClaimInfoState: genClaimInfoState(cdiID), resp: &drapb.NodePrepareResourcesResponse{Claims: map[string]*drapb.NodePrepareResourceResponse{ string(claimUID): { @@ -645,21 +645,21 @@ func TestUnprepareResources(t *testing.T) { description: "unknown driver", pod: genTestPod(), claim: genTestClaim(claimName, "unknown driver", deviceName, podUID), - claimInfo: genTestClaimInfo([]string{podUID}, true), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, true), expectedErrMsg: "plugin name test-driver not found in the list of registered DRA plugins", }, { description: "resource claim referenced by other pod(s)", driverName: driverName, pod: genTestPod(), - claimInfo: genTestClaimInfo([]string{podUID, "another-pod-uid"}, true), + claimInfo: genTestClaimInfo(claimUID, []string{podUID, "another-pod-uid"}, true), wantResourceSkipped: true, }, { description: "should timeout", driverName: driverName, pod: genTestPod(), - claimInfo: genTestClaimInfo([]string{podUID}, true), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, true), wantTimeout: true, expectedUnprepareCalls: 1, expectedErrMsg: "context deadline exceeded", @@ -668,7 +668,7 @@ func TestUnprepareResources(t *testing.T) { description: "should fail when driver returns empty response", driverName: driverName, pod: genTestPod(), - claimInfo: genTestClaimInfo([]string{podUID}, true), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, true), resp: &drapb.NodeUnprepareResourcesResponse{Claims: map[string]*drapb.NodeUnprepareResourceResponse{}}, expectedUnprepareCalls: 1, expectedErrMsg: "NodeUnprepareResources left out 1 claims", @@ -678,7 +678,7 @@ func TestUnprepareResources(t *testing.T) { driverName: driverName, pod: genTestPod(), claim: genTestClaim(claimName, driverName, deviceName, podUID), - claimInfo: genTestClaimInfo([]string{podUID}, false), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, false), expectedUnprepareCalls: 1, }, { @@ -686,14 +686,14 @@ func TestUnprepareResources(t *testing.T) { driverName: driverName, pod: genTestPod(), claim: genTestClaim(claimName, driverName, deviceName, podUID), - claimInfo: genTestClaimInfo([]string{podUID}, true), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, true), expectedUnprepareCalls: 1, }, { description: "should unprepare resource when driver returns nil value", driverName: driverName, pod: genTestPod(), - claimInfo: genTestClaimInfo([]string{podUID}, true), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, true), resp: &drapb.NodeUnprepareResourcesResponse{Claims: map[string]*drapb.NodeUnprepareResourceResponse{string(claimUID): nil}}, expectedUnprepareCalls: 1, }, @@ -800,7 +800,7 @@ func TestGetContainerClaimInfos(t *testing.T) { description: "should get claim info", expectedClaimName: claimName, pod: genTestPod(), - claimInfo: genTestClaimInfo([]string{podUID}, false), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, false), }, { description: "should fail when claim info not found", @@ -836,7 +836,7 @@ func TestGetContainerClaimInfos(t *testing.T) { }, }, }, - claimInfo: genTestClaimInfo([]string{podUID}, false), + claimInfo: genTestClaimInfo(claimUID, []string{podUID}, false), expectedErrMsg: "none of the supported fields are set", }, {