mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 12:18:16 +00:00 
			
		
		
		
	tests Windows: Fixes test failures related to COMPUTERNAMEs being truncated
Windows ComputerNames cannot exceed 15 characters. This causes a few tests to fail when the node names exceed that limit. Additionally, the checks should be case insensitive.
This commit is contained in:
		@@ -64,8 +64,11 @@ const (
 | 
			
		||||
		Write-Output $c
 | 
			
		||||
		throw "Contents of /etc/secret/foo.txt are not as expected"
 | 
			
		||||
	}
 | 
			
		||||
	if ($env:NODE_NAME_TEST -ne $env:COMPUTERNAME) {
 | 
			
		||||
		throw "NODE_NAME_TEST env var ($env:NODE_NAME_TEST) does not equal COMPUTERNAME ($env:COMPUTERNAME)"
 | 
			
		||||
	# Windows ComputerNames cannot exceed 15 characters, which means that the $env:COMPUTERNAME
 | 
			
		||||
	# can only be a substring of $env:NODE_NAME_TEST. We compare it with the hostname instead.
 | 
			
		||||
	# The following comparison is case insensitive.
 | 
			
		||||
	if ($env:NODE_NAME_TEST -ine "$(hostname)") {
 | 
			
		||||
		throw "NODE_NAME_TEST env var ($env:NODE_NAME_TEST) does not equal hostname"
 | 
			
		||||
	}
 | 
			
		||||
	Write-Output "SUCCESS"`
 | 
			
		||||
)
 | 
			
		||||
@@ -95,6 +98,8 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
 | 
			
		||||
		ginkgo.By("scheduling a pod with a container that verifies %COMPUTERNAME% matches selected node name")
 | 
			
		||||
		image := imageutils.GetConfig(imageutils.BusyBox)
 | 
			
		||||
		podName := "host-process-test-pod"
 | 
			
		||||
		// We're passing this to powershell.exe -Command. Inside, we must use apostrophes for strings.
 | 
			
		||||
		command := fmt.Sprintf(`& {if ('%s' -ine "$(hostname)") { exit -1 }}`, targetNode.Name)
 | 
			
		||||
		pod := &v1.Pod{
 | 
			
		||||
			ObjectMeta: metav1.ObjectMeta{
 | 
			
		||||
				Name: podName,
 | 
			
		||||
@@ -111,7 +116,7 @@ var _ = SIGDescribe("[Feature:WindowsHostProcessContainers] [MinimumKubeletVersi
 | 
			
		||||
					{
 | 
			
		||||
						Image:   image.GetE2EImage(),
 | 
			
		||||
						Name:    "computer-name-test",
 | 
			
		||||
						Command: []string{"cmd.exe", "/K", "IF", "NOT", "%COMPUTERNAME%", "==", targetNode.Name, "(", "exit", "-1", ")"},
 | 
			
		||||
						Command: []string{"powershell.exe", "-Command", command},
 | 
			
		||||
					},
 | 
			
		||||
				},
 | 
			
		||||
				RestartPolicy: v1.RestartPolicyNever,
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user