mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-10-31 02:08:13 +00:00 
			
		
		
		
	Fix failing kubectl skew tests
This commit is contained in:
		| @@ -68,4 +68,10 @@ if false; then | |||||||
|   echo "Running:" "${kubectl}" "${config[@]:+${config[@]}}" "${@+$@}" >&2 |   echo "Running:" "${kubectl}" "${config[@]:+${config[@]}}" "${@+$@}" >&2 | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  | if [[ "${1:-}" =~ ^(path)$ ]]; then | ||||||
|  |   echo "${kubectl}" | ||||||
|  |   exit 0 | ||||||
|  | fi | ||||||
|  |  | ||||||
| "${kubectl}" "${config[@]:+${config[@]}}" "${@+$@}" | "${kubectl}" "${config[@]:+${config[@]}}" "${@+$@}" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -590,19 +590,29 @@ var _ = framework.KubeDescribe("Kubectl client", func() { | |||||||
|  |  | ||||||
| 			By("overriding icc with values provided by flags") | 			By("overriding icc with values provided by flags") | ||||||
| 			kubectlPath := framework.TestContext.KubectlPath | 			kubectlPath := framework.TestContext.KubectlPath | ||||||
|  | 			// we need the actual kubectl binary, not the script wrapper | ||||||
|  | 			kubectlPathNormalizer := exec.Command("which", kubectlPath) | ||||||
|  | 			if strings.HasSuffix(kubectlPath, "kubectl.sh") { | ||||||
|  | 				kubectlPathNormalizer = exec.Command("sh", "-c", kubectlPath, "path") | ||||||
|  | 			} | ||||||
|  | 			kubectlPathNormalized, err := kubectlPathNormalizer.Output() | ||||||
|  | 			framework.ExpectNoError(err) | ||||||
|  | 			kubectlPath = strings.TrimSpace(string(kubectlPathNormalized)) | ||||||
|  |  | ||||||
| 			inClusterHost := strings.TrimSpace(framework.RunHostCmdOrDie(ns, simplePodName, "printenv KUBERNETES_SERVICE_HOST")) | 			inClusterHost := strings.TrimSpace(framework.RunHostCmdOrDie(ns, simplePodName, "printenv KUBERNETES_SERVICE_HOST")) | ||||||
| 			inClusterPort := strings.TrimSpace(framework.RunHostCmdOrDie(ns, simplePodName, "printenv KUBERNETES_SERVICE_PORT")) | 			inClusterPort := strings.TrimSpace(framework.RunHostCmdOrDie(ns, simplePodName, "printenv KUBERNETES_SERVICE_PORT")) | ||||||
| 			framework.RunKubectlOrDie("cp", kubectlPath, ns+"/"+simplePodName+":/") |  | ||||||
|  | 			framework.Logf("copying %s to the %s pod", kubectlPath, simplePodName) | ||||||
|  | 			framework.RunKubectlOrDie("cp", kubectlPath, ns+"/"+simplePodName+":/tmp/") | ||||||
|  |  | ||||||
| 			By("getting pods with in-cluster configs") | 			By("getting pods with in-cluster configs") | ||||||
| 			execOutput := framework.RunHostCmdOrDie(ns, simplePodName, "/kubectl get pods") | 			execOutput := framework.RunHostCmdOrDie(ns, simplePodName, "/tmp/kubectl get pods") | ||||||
| 			if matched, err := regexp.MatchString("nginx +1/1 +Running", execOutput); err != nil || !matched { | 			if matched, err := regexp.MatchString("nginx +1/1 +Running", execOutput); err != nil || !matched { | ||||||
| 				framework.Failf("Unexpected kubectl exec output: ", execOutput) | 				framework.Failf("Unexpected kubectl exec output: ", execOutput) | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			By("trying to use kubectl with invalid token") | 			By("trying to use kubectl with invalid token") | ||||||
| 			_, err = framework.RunHostCmd(ns, simplePodName, "/kubectl get pods --token=invalid --v=7 2>&1") | 			_, err = framework.RunHostCmd(ns, simplePodName, "/tmp/kubectl get pods --token=invalid --v=7 2>&1") | ||||||
| 			framework.Logf("got err %v", err) | 			framework.Logf("got err %v", err) | ||||||
| 			Expect(err).To(HaveOccurred()) | 			Expect(err).To(HaveOccurred()) | ||||||
| 			Expect(err).To(ContainSubstring("Using in-cluster namespace")) | 			Expect(err).To(ContainSubstring("Using in-cluster namespace")) | ||||||
| @@ -611,14 +621,14 @@ var _ = framework.KubeDescribe("Kubectl client", func() { | |||||||
| 			Expect(err).To(ContainSubstring("Response Status: 401 Unauthorized")) | 			Expect(err).To(ContainSubstring("Response Status: 401 Unauthorized")) | ||||||
|  |  | ||||||
| 			By("trying to use kubectl with invalid server") | 			By("trying to use kubectl with invalid server") | ||||||
| 			_, err = framework.RunHostCmd(ns, simplePodName, "/kubectl get pods --server=invalid --v=6 2>&1") | 			_, err = framework.RunHostCmd(ns, simplePodName, "/tmp/kubectl get pods --server=invalid --v=6 2>&1") | ||||||
| 			framework.Logf("got err %v", err) | 			framework.Logf("got err %v", err) | ||||||
| 			Expect(err).To(HaveOccurred()) | 			Expect(err).To(HaveOccurred()) | ||||||
| 			Expect(err).To(ContainSubstring("Unable to connect to the server")) | 			Expect(err).To(ContainSubstring("Unable to connect to the server")) | ||||||
| 			Expect(err).To(ContainSubstring("GET http://invalid/api")) | 			Expect(err).To(ContainSubstring("GET http://invalid/api")) | ||||||
|  |  | ||||||
| 			By("trying to use kubectl with invalid namespace") | 			By("trying to use kubectl with invalid namespace") | ||||||
| 			output, _ := framework.RunHostCmd(ns, simplePodName, "/kubectl get pods --namespace=invalid --v=6 2>&1") | 			output, _ := framework.RunHostCmd(ns, simplePodName, "/tmp/kubectl get pods --namespace=invalid --v=6 2>&1") | ||||||
| 			Expect(output).To(ContainSubstring("No resources found")) | 			Expect(output).To(ContainSubstring("No resources found")) | ||||||
| 			Expect(output).ToNot(ContainSubstring("Using in-cluster namespace")) | 			Expect(output).ToNot(ContainSubstring("Using in-cluster namespace")) | ||||||
| 			Expect(output).To(ContainSubstring("Using in-cluster configuration")) | 			Expect(output).To(ContainSubstring("Using in-cluster configuration")) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Fabiano Franz
					Fabiano Franz