unittests: Fixes hostutil.GetFileType for Windows

GetFileType is meant to return the type of the given file by using os.Stat.
However, os.Stat doesn't work on Windows for Unix Sockets, causing an error to occur:

[2-Socket Test] unexpected error :
CreateFile C:\Users\Administrator\AppData\Local\Temp\test-get-filetype-2776877299\mt.sock:
The file cannot be accessed by the system.

This is a known issue and we're already using a workaround for this in
pkg/kubelet/util/util_windows.go.

This commit fixes this issue for GetFileType on Windows.
This commit is contained in:
Claudiu Belu
2022-12-07 12:25:53 +00:00
parent 12386e2de1
commit b4d1440063
11 changed files with 326 additions and 196 deletions

View File

@@ -119,11 +119,6 @@ func createSocketFile(socketDir string) (string, error) {
}
func TestGetFileType(t *testing.T) {
// Skip tests that fail on Windows, as discussed during the SIG Testing meeting from January 10, 2023
if goruntime.GOOS == "windows" {
t.Skip("Skipping test that fails on Windows")
}
hu := NewHostUtil()
testCase := []struct {