kubernetes/pkg/volume/rbd/rbd_unix_test.go
Claudiu Belu d3237b7258 unittests: Fixes unit tests for Windows (part 7)
Currently, there are some unit tests that are failing on Windows due to
various reasons:

- if a powershell command that could return an array (e.g.: Get-Disk) would return an array of
  only one element, powershell will in fact return that object directly, and **not** an array
  containing that element. In a few cases, these commands are used and their output is converted
  to json, after which they're unmarshalled in golang, with the expectation that the unmarshalled
  data to be an array. If it's not an array, we get an error.
- when mounting Block Devices, Windows expects the given source to be a Disk Number, not a path.
- for rbd_windows_test.go, we should start with Disk Number 0, which exists on all hosts.
- if a Disk has multiple volumes, Get-Volume doesn't return the volumes in the same order. This
  can result in various assertions failing.
- the pkg/volume/rbd/rdb_test.TestPlugin test expects that mounter.MountSensitive is called when
  attacher.MountDevice is called. The Windows attacher doesn't currently make that call.
2023-05-08 10:53:39 +00:00

39 lines
1.0 KiB
Go

//go:build !windows
// +build !windows
/*
Copyright 2022 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package rbd
import (
"fmt"
)
func (fake *fakeDiskManager) AttachDisk(b rbdMounter) (string, error) {
fake.mutex.Lock()
defer fake.mutex.Unlock()
devicePath := fmt.Sprintf("/dev/rbd%d", fake.rbdMapIndex)
fake.rbdDevices[devicePath] = true
// Increment rbdMapIndex afterwards, so we can start from rbd0.
fake.rbdMapIndex++
return devicePath, nil
}
func getLoggedSource(devicePath string) (string, error) {
return devicePath, nil
}