mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
Repair smoke-test for Windows GCE clusters
This commit is contained in:
parent
79bb357193
commit
9b17de7462
@ -40,7 +40,7 @@
|
|||||||
# Override this to use a different kubectl binary.
|
# Override this to use a different kubectl binary.
|
||||||
kubectl=kubectl
|
kubectl=kubectl
|
||||||
linux_deployment_timeout=60
|
linux_deployment_timeout=60
|
||||||
windows_deployment_timeout=180
|
windows_deployment_timeout=300
|
||||||
output_file=/tmp/k8s-smoke-test.out
|
output_file=/tmp/k8s-smoke-test.out
|
||||||
|
|
||||||
function check_windows_nodes_are_ready {
|
function check_windows_nodes_are_ready {
|
||||||
@ -458,9 +458,9 @@ function test_linux_pod_to_internet {
|
|||||||
echo "TEST: ${FUNCNAME[0]}"
|
echo "TEST: ${FUNCNAME[0]}"
|
||||||
local linux_command_pod
|
local linux_command_pod
|
||||||
linux_command_pod="$(get_linux_command_pod_name)"
|
linux_command_pod="$(get_linux_command_pod_name)"
|
||||||
local internet_ip="8.8.8.8" # Google DNS
|
# A stable (hopefully) HTTP server provided by Cloudflare.
|
||||||
|
local internet_ip="1.1.1.1"
|
||||||
|
|
||||||
# This is expected to return 404 (not found).
|
|
||||||
if ! $kubectl exec "$linux_command_pod" -- curl -m 20 \
|
if ! $kubectl exec "$linux_command_pod" -- curl -m 20 \
|
||||||
"http://$internet_ip" > $output_file; then
|
"http://$internet_ip" > $output_file; then
|
||||||
cleanup_deployments
|
cleanup_deployments
|
||||||
@ -474,7 +474,7 @@ function test_linux_pod_to_k8s_service {
|
|||||||
echo "TEST: ${FUNCNAME[0]}"
|
echo "TEST: ${FUNCNAME[0]}"
|
||||||
local linux_command_pod
|
local linux_command_pod
|
||||||
linux_command_pod="$(get_linux_command_pod_name)"
|
linux_command_pod="$(get_linux_command_pod_name)"
|
||||||
local service="heapster"
|
local service="metrics-server"
|
||||||
local service_ip
|
local service_ip
|
||||||
service_ip=$($kubectl get service --namespace kube-system $service \
|
service_ip=$($kubectl get service --namespace kube-system $service \
|
||||||
-o jsonpath='{.spec.clusterIP}')
|
-o jsonpath='{.spec.clusterIP}')
|
||||||
@ -483,8 +483,8 @@ function test_linux_pod_to_k8s_service {
|
|||||||
-o jsonpath='{.spec.ports[?(@.protocol=="TCP")].port}')
|
-o jsonpath='{.spec.ports[?(@.protocol=="TCP")].port}')
|
||||||
echo "curl-ing $service address from Linux pod: $service_ip:$service_port"
|
echo "curl-ing $service address from Linux pod: $service_ip:$service_port"
|
||||||
|
|
||||||
# curl-ing the heapster service results in an expected 404 response code. The
|
# curl-ing the metrics-server service downloads 14 bytes of unprintable binary
|
||||||
# curl command does not set a failure return code in this case.
|
# data and sets a return code of success (0).
|
||||||
if ! $kubectl exec "$linux_command_pod" -- \
|
if ! $kubectl exec "$linux_command_pod" -- \
|
||||||
curl -m 20 "http://$service_ip:$service_port" &> $output_file; then
|
curl -m 20 "http://$service_ip:$service_port" &> $output_file; then
|
||||||
cleanup_deployments
|
cleanup_deployments
|
||||||
@ -547,26 +547,12 @@ function test_windows_pod_to_internet {
|
|||||||
echo "TEST: ${FUNCNAME[0]}"
|
echo "TEST: ${FUNCNAME[0]}"
|
||||||
local windows_command_pod
|
local windows_command_pod
|
||||||
windows_command_pod="$(get_windows_command_pod_name)"
|
windows_command_pod="$(get_windows_command_pod_name)"
|
||||||
local internet_ip="8.8.8.8"
|
# A stable (hopefully) HTTP server provided by Cloudflare. If this ever stops
|
||||||
|
# working, we can request from 8.8.8.8 (Google DNS) using https instead.
|
||||||
|
local internet_ip="1.1.1.1"
|
||||||
|
|
||||||
# This snippet tests Internet connectivity without depending on DNS by
|
|
||||||
# attempting to curl Google's well-known DNS IP, 8.8.8.8. On success we expect
|
|
||||||
# to get back a 404 status code; on failure the response object will have a
|
|
||||||
# status code of 0 or some other HTTP code.
|
|
||||||
if ! $kubectl exec "$windows_command_pod" -- powershell.exe \
|
if ! $kubectl exec "$windows_command_pod" -- powershell.exe \
|
||||||
"\$response = try { \`
|
"curl -UseBasicParsing http://$internet_ip" > $output_file; then
|
||||||
(curl -UseBasicParsing http://$internet_ip \`
|
|
||||||
-ErrorAction Stop).BaseResponse \`
|
|
||||||
} catch [System.Net.WebException] { \`
|
|
||||||
\$_.Exception.Response \`
|
|
||||||
}; \`
|
|
||||||
\$statusCodeInt = [int]\$response.StatusCode; \`
|
|
||||||
if (\$statusCodeInt -eq 404) { \`
|
|
||||||
exit 0 \`
|
|
||||||
} else { \`
|
|
||||||
Write-Host \"curl $internet_ip got unexpected status code \$statusCodeInt\"
|
|
||||||
exit 1 \`
|
|
||||||
}" > $output_file; then
|
|
||||||
cleanup_deployments
|
cleanup_deployments
|
||||||
echo "Failing output: $(cat $output_file)"
|
echo "Failing output: $(cat $output_file)"
|
||||||
echo "FAILED: ${FUNCNAME[0]}"
|
echo "FAILED: ${FUNCNAME[0]}"
|
||||||
@ -578,7 +564,7 @@ function test_windows_pod_to_k8s_service {
|
|||||||
echo "TEST: ${FUNCNAME[0]}"
|
echo "TEST: ${FUNCNAME[0]}"
|
||||||
local windows_command_pod
|
local windows_command_pod
|
||||||
windows_command_pod="$(get_windows_command_pod_name)"
|
windows_command_pod="$(get_windows_command_pod_name)"
|
||||||
local service="heapster"
|
local service="metrics-server"
|
||||||
local service_ip
|
local service_ip
|
||||||
service_ip=$($kubectl get service --namespace kube-system $service \
|
service_ip=$($kubectl get service --namespace kube-system $service \
|
||||||
-o jsonpath='{.spec.clusterIP}')
|
-o jsonpath='{.spec.clusterIP}')
|
||||||
@ -588,21 +574,25 @@ function test_windows_pod_to_k8s_service {
|
|||||||
local service_address="$service_ip:$service_port"
|
local service_address="$service_ip:$service_port"
|
||||||
|
|
||||||
echo "curl-ing $service address from Windows pod: $service_address"
|
echo "curl-ing $service address from Windows pod: $service_address"
|
||||||
# Performing a web request to the heapster service results in an expected 404
|
# curl-ing the metrics-server service results in a ServerProtocolViolation
|
||||||
# response; this code snippet filters out the expected 404 from other status
|
# ("The server committed a protocol violation. Section=ResponseStatusLine")
|
||||||
# codes that indicate failure.
|
# exception. Since we don't care about what the metrics-server actually gives
|
||||||
|
# back to us, just that we can reach it, we check that we get the expected
|
||||||
|
# exception code and not some other exception code.
|
||||||
|
# TODO: it might be less fragile to check that we don't get the "Unable to
|
||||||
|
# connect to the remote server" exception code (2) instead of specifically
|
||||||
|
# expecting the protocol-violation exception code (11).
|
||||||
if ! $kubectl exec "$windows_command_pod" -- powershell.exe \
|
if ! $kubectl exec "$windows_command_pod" -- powershell.exe \
|
||||||
"\$response = try { \`
|
"\$result = try { \`
|
||||||
(curl -UseBasicParsing http://$service_address \`
|
curl -UseBasicParsing http://$service_address -ErrorAction Stop \`
|
||||||
-ErrorAction Stop).BaseResponse \`
|
|
||||||
} catch [System.Net.WebException] { \`
|
} catch [System.Net.WebException] { \`
|
||||||
\$_.Exception.Response \`
|
\$_ \`
|
||||||
}; \`
|
}; \`
|
||||||
\$statusCodeInt = [int]\$response.StatusCode; \`
|
if ([int]\$result.Exception.Status -eq 11) { \`
|
||||||
if (\$statusCodeInt -eq 404) { \`
|
Write-Host \"curl $service_address got expected exception\"
|
||||||
exit 0 \`
|
exit 0 \`
|
||||||
} else { \`
|
} else { \`
|
||||||
Write-Host \"curl $service_address got unexpected status code \$statusCodeInt\"
|
Write-Host \"curl $service_address got unexpected result/exception: \$result\"
|
||||||
exit 1 \`
|
exit 1 \`
|
||||||
}" > $output_file; then
|
}" > $output_file; then
|
||||||
cleanup_deployments
|
cleanup_deployments
|
||||||
|
Loading…
Reference in New Issue
Block a user