mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
add UTs for devicemountable conditions
This commit is contained in:
parent
81e360d20f
commit
55784f88d4
@ -48,7 +48,7 @@ const (
|
|||||||
|
|
||||||
var _ OperationGenerator = &fakeOperationGenerator{}
|
var _ OperationGenerator = &fakeOperationGenerator{}
|
||||||
|
|
||||||
func TestOperationExecutor_MountVolume_ConcurrentMountForNonAttachablePlugins(t *testing.T) {
|
func TestOperationExecutor_MountVolume_ConcurrentMountForNonAttachableAndNonDevicemountablePlugins(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
ch, quit, oe := setup()
|
ch, quit, oe := setup()
|
||||||
volumesToMount := make([]VolumeToMount, numVolumesToMount)
|
volumesToMount := make([]VolumeToMount, numVolumesToMount)
|
||||||
@ -60,10 +60,11 @@ func TestOperationExecutor_MountVolume_ConcurrentMountForNonAttachablePlugins(t
|
|||||||
podName := "pod-" + strconv.Itoa((i + 1))
|
podName := "pod-" + strconv.Itoa((i + 1))
|
||||||
pod := getTestPodWithSecret(podName, secretName)
|
pod := getTestPodWithSecret(podName, secretName)
|
||||||
volumesToMount[i] = VolumeToMount{
|
volumesToMount[i] = VolumeToMount{
|
||||||
Pod: pod,
|
Pod: pod,
|
||||||
VolumeName: volumeName,
|
VolumeName: volumeName,
|
||||||
PluginIsAttachable: false, // this field determines whether the plugin is attachable
|
PluginIsAttachable: false, // this field determines whether the plugin is attachable
|
||||||
ReportedInUse: true,
|
PluginIsDeviceMountable: false, // this field determines whether the plugin is devicemountable
|
||||||
|
ReportedInUse: true,
|
||||||
}
|
}
|
||||||
oe.MountVolume(0 /* waitForAttachTimeOut */, volumesToMount[i], nil /* actualStateOfWorldMounterUpdater */, false /* isRemount */)
|
oe.MountVolume(0 /* waitForAttachTimeOut */, volumesToMount[i], nil /* actualStateOfWorldMounterUpdater */, false /* isRemount */)
|
||||||
}
|
}
|
||||||
@ -99,6 +100,31 @@ func TestOperationExecutor_MountVolume_ConcurrentMountForAttachablePlugins(t *te
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestOperationExecutor_MountVolume_ConcurrentMountForDeviceMountablePlugins(t *testing.T) {
|
||||||
|
// Arrange
|
||||||
|
ch, quit, oe := setup()
|
||||||
|
volumesToMount := make([]VolumeToMount, numVolumesToAttach)
|
||||||
|
pdName := "pd-volume"
|
||||||
|
volumeName := v1.UniqueVolumeName(pdName)
|
||||||
|
// Act
|
||||||
|
for i := range volumesToMount {
|
||||||
|
podName := "pod-" + strconv.Itoa((i + 1))
|
||||||
|
pod := getTestPodWithGCEPD(podName, pdName)
|
||||||
|
volumesToMount[i] = VolumeToMount{
|
||||||
|
Pod: pod,
|
||||||
|
VolumeName: volumeName,
|
||||||
|
PluginIsDeviceMountable: true, // this field determines whether the plugin is devicemountable
|
||||||
|
ReportedInUse: true,
|
||||||
|
}
|
||||||
|
oe.MountVolume(0 /* waitForAttachTimeout */, volumesToMount[i], nil /* actualStateOfWorldMounterUpdater */, false /* isRemount */)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
if !isOperationRunSerially(ch, quit) {
|
||||||
|
t.Fatalf("Mount operations should not start concurrently for devicemountable volumes")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestOperationExecutor_UnmountVolume_ConcurrentUnmountForAllPlugins(t *testing.T) {
|
func TestOperationExecutor_UnmountVolume_ConcurrentUnmountForAllPlugins(t *testing.T) {
|
||||||
// Arrange
|
// Arrange
|
||||||
ch, quit, oe := setup()
|
ch, quit, oe := setup()
|
||||||
|
Loading…
Reference in New Issue
Block a user