mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 13:57:38 +00:00
DRA: genTestClaimInfo: add claimUID parameter
This commit is contained in:
@@ -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",
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user