tests: Checks for Windows permissions as well
Some mounttest related tests are checking the file permissions set on the container files, but the default file permissions on Windows is 775 instead of 644, causing some tests to fail. Keep in mind that file permissions work differently on Windows, and setting file permissions via Kubernetes is not currently supported on Windows.
This commit is contained in:
@@ -5252,3 +5252,24 @@ func WaitForNodeHasTaintOrNot(c clientset.Interface, nodeName string, taint *v1.
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetFileModeRegex returns a file mode related regex which should be matched by the mounttest pods' output.
|
||||
// If the given mask is nil, then the regex will contain the default OS file modes, which are 0644 for Linux and 0775 for Windows.
|
||||
func GetFileModeRegex(filePath string, mask *int32) string {
|
||||
var (
|
||||
linuxMask int32
|
||||
windowsMask int32
|
||||
)
|
||||
if mask == nil {
|
||||
linuxMask = int32(0644)
|
||||
windowsMask = int32(0775)
|
||||
} else {
|
||||
linuxMask = *mask
|
||||
windowsMask = *mask
|
||||
}
|
||||
|
||||
linuxOutput := fmt.Sprintf("mode of file \"%s\": %v", filePath, os.FileMode(linuxMask))
|
||||
windowsOutput := fmt.Sprintf("mode of Windows file \"%v\": %s", filePath, os.FileMode(windowsMask))
|
||||
|
||||
return fmt.Sprintf("(%s|%s)", linuxOutput, windowsOutput)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user