mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Add e2e for node expansion with missing staging path
This commit is contained in:
parent
f052ea3ec3
commit
32851bb316
@ -46,6 +46,7 @@ const (
|
|||||||
expansionFailed
|
expansionFailed
|
||||||
expansionFailedOnController
|
expansionFailedOnController
|
||||||
expansionFailedOnNode
|
expansionFailedOnNode
|
||||||
|
expansionFailedMissingStagingPath
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -78,25 +79,35 @@ var _ = utils.SIGDescribe("CSI Mock volume expansion", func() {
|
|||||||
nodeExpansionRequired bool
|
nodeExpansionRequired bool
|
||||||
disableAttach bool
|
disableAttach bool
|
||||||
disableResizingOnDriver bool
|
disableResizingOnDriver bool
|
||||||
|
simulatedCSIDriverError expansionStatus
|
||||||
expectFailure bool
|
expectFailure bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "should expand volume without restarting pod if nodeExpansion=off",
|
name: "should expand volume without restarting pod if nodeExpansion=off",
|
||||||
nodeExpansionRequired: false,
|
nodeExpansionRequired: false,
|
||||||
|
simulatedCSIDriverError: expansionSuccess,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "should expand volume by restarting pod if attach=on, nodeExpansion=on",
|
name: "should expand volume by restarting pod if attach=on, nodeExpansion=on",
|
||||||
nodeExpansionRequired: true,
|
nodeExpansionRequired: true,
|
||||||
|
simulatedCSIDriverError: expansionSuccess,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "should not have staging_path missing in node expand volume pod if attach=on, nodeExpansion=on",
|
||||||
|
nodeExpansionRequired: true,
|
||||||
|
simulatedCSIDriverError: expansionFailedMissingStagingPath,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "should expand volume by restarting pod if attach=off, nodeExpansion=on",
|
name: "should expand volume by restarting pod if attach=off, nodeExpansion=on",
|
||||||
disableAttach: true,
|
disableAttach: true,
|
||||||
nodeExpansionRequired: true,
|
nodeExpansionRequired: true,
|
||||||
|
simulatedCSIDriverError: expansionSuccess,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "should not expand volume if resizingOnDriver=off, resizingOnSC=on",
|
name: "should not expand volume if resizingOnDriver=off, resizingOnSC=on",
|
||||||
disableResizingOnDriver: true,
|
disableResizingOnDriver: true,
|
||||||
expectFailure: true,
|
expectFailure: true,
|
||||||
|
simulatedCSIDriverError: expansionSuccess,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, t := range tests {
|
for _, t := range tests {
|
||||||
@ -113,6 +124,7 @@ var _ = utils.SIGDescribe("CSI Mock volume expansion", func() {
|
|||||||
tp.disableAttach = true
|
tp.disableAttach = true
|
||||||
tp.registerDriver = true
|
tp.registerDriver = true
|
||||||
}
|
}
|
||||||
|
tp.hooks = createExpansionHook(test.simulatedCSIDriverError)
|
||||||
|
|
||||||
m.init(ctx, tp)
|
m.init(ctx, tp)
|
||||||
ginkgo.DeferCleanup(m.cleanup)
|
ginkgo.DeferCleanup(m.cleanup)
|
||||||
@ -172,8 +184,12 @@ var _ = utils.SIGDescribe("CSI Mock volume expansion", func() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ginkgo.By("Deleting the previously created pod")
|
ginkgo.By("Deleting the previously created pod")
|
||||||
|
if test.simulatedCSIDriverError == expansionFailedMissingStagingPath {
|
||||||
|
e2epod.DeletePodOrFail(ctx, m.cs, pod.Namespace, pod.Name)
|
||||||
|
} else {
|
||||||
err = e2epod.DeletePodWithWait(ctx, m.cs, pod)
|
err = e2epod.DeletePodWithWait(ctx, m.cs, pod)
|
||||||
framework.ExpectNoError(err, "while deleting pod for resizing")
|
framework.ExpectNoError(err, "while deleting pod for resizing")
|
||||||
|
}
|
||||||
|
|
||||||
ginkgo.By("Creating a new pod with same volume")
|
ginkgo.By("Creating a new pod with same volume")
|
||||||
pod2, err := m.createPodWithPVC(pvc)
|
pod2, err := m.createPodWithPVC(pvc)
|
||||||
@ -445,6 +461,15 @@ func createExpansionHook(expectedExpansionStatus expansionStatus) *drivers.Hooks
|
|||||||
return &drivers.Hooks{
|
return &drivers.Hooks{
|
||||||
Pre: func(ctx context.Context, method string, request interface{}) (reply interface{}, err error) {
|
Pre: func(ctx context.Context, method string, request interface{}) (reply interface{}, err error) {
|
||||||
switch expectedExpansionStatus {
|
switch expectedExpansionStatus {
|
||||||
|
case expansionFailedMissingStagingPath:
|
||||||
|
expansionRequest, ok := request.(*csipbv1.NodeExpandVolumeRequest)
|
||||||
|
if ok {
|
||||||
|
stagingPath := expansionRequest.StagingTargetPath
|
||||||
|
if stagingPath == "" {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid node expansion request, missing staging path")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
case expansionFailedOnController:
|
case expansionFailedOnController:
|
||||||
expansionRequest, ok := request.(*csipbv1.ControllerExpandVolumeRequest)
|
expansionRequest, ok := request.(*csipbv1.ControllerExpandVolumeRequest)
|
||||||
if ok {
|
if ok {
|
||||||
|
Loading…
Reference in New Issue
Block a user