mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	unittests: Fixes unit tests for Windows (part 8)
Currently, there are some unit tests that are failing on Windows due to various reasons: - flexvolume coverts its paths to absolute paths, which means that on Windows the C:\ prefix will be added. This becomes an issue when prober.fs.Walk is called, which will join 2 absolute paths, both containing the C:\ prefix, resulting in an incorrect path.
This commit is contained in:
		@@ -228,6 +228,10 @@ func (prober *flexVolumeProber) updateEventsMap(eventDirAbs string, op volume.Pr
 | 
				
			|||||||
// Each file or directory change triggers two events: one from the watch on itself, another from the watch
 | 
					// Each file or directory change triggers two events: one from the watch on itself, another from the watch
 | 
				
			||||||
// on its parent directory.
 | 
					// on its parent directory.
 | 
				
			||||||
func (prober *flexVolumeProber) addWatchRecursive(filename string) error {
 | 
					func (prober *flexVolumeProber) addWatchRecursive(filename string) error {
 | 
				
			||||||
 | 
						// this may be called with an actual absolute path on Windows (with a C:\ prefix).
 | 
				
			||||||
 | 
						// But the prober.fs.Walk below will execute filepath.Join(fs.root, filenameAbove), which
 | 
				
			||||||
 | 
						// will result in an incorrect path, you can't join C:\path and C:\another\path.
 | 
				
			||||||
 | 
						filename = strings.TrimPrefix(filename, `C:\`)
 | 
				
			||||||
	addWatch := func(path string, info os.FileInfo, err error) error {
 | 
						addWatch := func(path string, info os.FileInfo, err error) error {
 | 
				
			||||||
		if err == nil && info.IsDir() {
 | 
							if err == nil && info.IsDir() {
 | 
				
			||||||
			if err := prober.watcher.AddWatch(path); err != nil {
 | 
								if err := prober.watcher.AddWatch(path); err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -72,11 +72,6 @@ func TestProberExistingDriverBeforeInit(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Probes newly added drivers after prober is running.
 | 
					// Probes newly added drivers after prober is running.
 | 
				
			||||||
func TestProberAddRemoveDriver(t *testing.T) {
 | 
					func TestProberAddRemoveDriver(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")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Arrange
 | 
						// Arrange
 | 
				
			||||||
	_, fs, watcher, prober := initTestEnvironment(t)
 | 
						_, fs, watcher, prober := initTestEnvironment(t)
 | 
				
			||||||
	prober.Probe()
 | 
						prober.Probe()
 | 
				
			||||||
@@ -210,11 +205,6 @@ func TestEmptyPluginDir(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Issue an event to remove plugindir. New directory should still be watched.
 | 
					// Issue an event to remove plugindir. New directory should still be watched.
 | 
				
			||||||
func TestRemovePluginDir(t *testing.T) {
 | 
					func TestRemovePluginDir(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")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Arrange
 | 
						// Arrange
 | 
				
			||||||
	driverPath, fs, watcher, _ := initTestEnvironment(t)
 | 
						driverPath, fs, watcher, _ := initTestEnvironment(t)
 | 
				
			||||||
	err := fs.RemoveAll(pluginDir)
 | 
						err := fs.RemoveAll(pluginDir)
 | 
				
			||||||
@@ -236,11 +226,6 @@ func TestRemovePluginDir(t *testing.T) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
// Issue an event to remove plugindir. New directory should still be watched.
 | 
					// Issue an event to remove plugindir. New directory should still be watched.
 | 
				
			||||||
func TestNestedDriverDir(t *testing.T) {
 | 
					func TestNestedDriverDir(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")
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// Arrange
 | 
						// Arrange
 | 
				
			||||||
	_, fs, watcher, _ := initTestEnvironment(t)
 | 
						_, fs, watcher, _ := initTestEnvironment(t)
 | 
				
			||||||
	// Assert
 | 
						// Assert
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user