Merge remote-tracking branch 'upstream/master' into test-cmd-what

Conflicts:
	test/cmd/legacy-script.sh
This commit is contained in:
Thomas Runyon
2019-01-26 07:40:33 -05:00
1445 changed files with 13229 additions and 480965 deletions

View File

@@ -28,15 +28,15 @@ CMD_FLAG=false
PLUGIN_CMD_FLAG=false
echo "--------------------------------------------------------------------------------"
for tar in $ALL_TARGETS; do
for cmdtar in $CMD_TARGETS; do
if [ $tar = $cmdtar ]; then
if [ $CMD_FLAG = true ]; then
for tar in ${ALL_TARGETS}; do
for cmdtar in ${CMD_TARGETS}; do
if [ ${tar} = ${cmdtar} ]; then
if [ ${CMD_FLAG} = true ]; then
continue 2;
fi
echo -e "${red}${CMD_TARGETS}${reset}"
make -C "${KUBE_ROOT}" $tar PRINT_HELP=y
make -C "${KUBE_ROOT}" ${tar} PRINT_HELP=y
echo "---------------------------------------------------------------------------------"
CMD_FLAG=true
@@ -45,6 +45,6 @@ for tar in $ALL_TARGETS; do
done
echo -e "${red}${tar}${reset}"
make -C "${KUBE_ROOT}" $tar PRINT_HELP=y
make -C "${KUBE_ROOT}" ${tar} PRINT_HELP=y
echo "---------------------------------------------------------------------------------"
done

View File

@@ -37,20 +37,20 @@ system_spec_name=${SYSTEM_SPEC_NAME:-}
# Parse the flags to pass to ginkgo
ginkgoflags=""
if [[ $parallelism > 1 ]]; then
ginkgoflags="$ginkgoflags -nodes=$parallelism "
if [[ ${parallelism} > 1 ]]; then
ginkgoflags="${ginkgoflags} -nodes=${parallelism} "
fi
if [[ $focus != "" ]]; then
ginkgoflags="$ginkgoflags -focus=\"$focus\" "
if [[ ${focus} != "" ]]; then
ginkgoflags="${ginkgoflags} -focus=\"${focus}\" "
fi
if [[ $skip != "" ]]; then
ginkgoflags="$ginkgoflags -skip=\"$skip\" "
if [[ ${skip} != "" ]]; then
ginkgoflags="${ginkgoflags} -skip=\"${skip}\" "
fi
if [[ $run_until_failure != "" ]]; then
ginkgoflags="$ginkgoflags -untilItFails=$run_until_failure "
if [[ ${run_until_failure} != "" ]]; then
ginkgoflags="${ginkgoflags} -untilItFails=${run_until_failure} "
fi
# Setup the directory to copy test artifacts (logs, junit.xml, etc) from remote host to local host
@@ -60,34 +60,34 @@ if [ ! -d "${artifacts}" ]; then
fi
echo "Test artifacts will be written to ${artifacts}"
if [[ $runtime == "remote" ]] ; then
if [[ ! -z $container_runtime_endpoint ]] ; then
test_args="--container-runtime-endpoint=${container_runtime_endpoint} $test_args"
if [[ ${runtime} == "remote" ]] ; then
if [[ ! -z ${container_runtime_endpoint} ]] ; then
test_args="--container-runtime-endpoint=${container_runtime_endpoint} ${test_args}"
fi
if [[ ! -z $image_service_endpoint ]] ; then
test_args="--image-service-endpoint=$image_service_endpoint $test_args"
if [[ ! -z ${image_service_endpoint} ]] ; then
test_args="--image-service-endpoint=${image_service_endpoint} ${test_args}"
fi
fi
if [ $remote = true ] ; then
if [ ${remote} = true ] ; then
# The following options are only valid in remote run.
images=${IMAGES:-""}
hosts=${HOSTS:-""}
image_project=${IMAGE_PROJECT:-"kubernetes-node-e2e-images"}
metadata=${INSTANCE_METADATA:-""}
list_images=${LIST_IMAGES:-false}
if [[ $list_images == "true" ]]; then
if [[ ${list_images} == "true" ]]; then
gcloud compute images list --project="${image_project}" | grep "e2e-node"
exit 0
fi
gubernator=${GUBERNATOR:-"false"}
image_config_file=${IMAGE_CONFIG_FILE:-""}
if [[ $hosts == "" && $images == "" && $image_config_file == "" ]]; then
if [[ ${hosts} == "" && ${images} == "" && ${image_config_file} == "" ]]; then
image_project=${IMAGE_PROJECT:-"cos-cloud"}
gci_image=$(gcloud compute images list --project $image_project \
gci_image=$(gcloud compute images list --project ${image_project} \
--no-standard-images --filter="name ~ 'cos-beta.*'" --format="table[no-heading](name)")
images=$gci_image
images=${gci_image}
metadata="user-data<${KUBE_ROOT}/test/e2e_node/jenkins/gci-init.yaml,gci-update-strategy=update_disabled"
fi
instance_prefix=${INSTANCE_PREFIX:-"test"}
@@ -97,58 +97,58 @@ if [ $remote = true ] ; then
# Get the compute zone
zone=${ZONE:-"$(gcloud info --format='value(config.properties.compute.zone)')"}
if [[ $zone == "" ]]; then
if [[ ${zone} == "" ]]; then
echo "Could not find gcloud compute/zone when running: \`gcloud info --format='value(config.properties.compute.zone)'\`"
exit 1
fi
# Get the compute project
project=$(gcloud info --format='value(config.project)')
if [[ $project == "" ]]; then
if [[ ${project} == "" ]]; then
echo "Could not find gcloud project when running: \`gcloud info --format='value(config.project)'\`"
exit 1
fi
# Check if any of the images specified already have running instances. If so reuse those instances
# by moving the IMAGE to a HOST
if [[ $images != "" ]]; then
IFS=',' read -ra IM <<< "$images"
if [[ ${images} != "" ]]; then
IFS=',' read -ra IM <<< "${images}"
images=""
for i in "${IM[@]}"; do
if [[ $(gcloud compute instances list "${instance_prefix}-$i" | grep $i) ]]; then
if [[ $hosts != "" ]]; then
hosts="$hosts,"
if [[ $(gcloud compute instances list "${instance_prefix}-${i}" | grep ${i}) ]]; then
if [[ "${hosts}" != "" ]]; then
hosts="${hosts},"
fi
echo "Reusing host ${instance_prefix}-$i"
echo "Reusing host ${instance_prefix}-${i}"
hosts="${hosts}${instance_prefix}-${i}"
else
if [[ $images != "" ]]; then
images="$images,"
if [[ "${images}" != "" ]]; then
images="${images},"
fi
images="$images$i"
images="${images}${i}"
fi
done
fi
# Output the configuration we will try to run
echo "Running tests remotely using"
echo "Project: $project"
echo "Image Project: $image_project"
echo "Compute/Zone: $zone"
echo "Images: $images"
echo "Hosts: $hosts"
echo "Ginkgo Flags: $ginkgoflags"
echo "Instance Metadata: $metadata"
echo "Image Config File: $image_config_file"
echo "Project: ${project}"
echo "Image Project: ${image_project}"
echo "Compute/Zone: ${zone}"
echo "Images: ${images}"
echo "Hosts: ${hosts}"
echo "Ginkgo Flags: ${ginkgoflags}"
echo "Instance Metadata: ${metadata}"
echo "Image Config File: ${image_config_file}"
# Invoke the runner
go run test/e2e_node/runner/remote/run_remote.go --logtostderr --vmodule=*=4 --ssh-env="gce" \
--zone="$zone" --project="$project" --gubernator="$gubernator" \
--hosts="$hosts" --images="$images" --cleanup="$cleanup" \
--results-dir="$artifacts" --ginkgo-flags="$ginkgoflags" \
--image-project="$image_project" --instance-name-prefix="$instance_prefix" \
--delete-instances="$delete_instances" --test_args="$test_args" --instance-metadata="$metadata" \
--image-config-file="$image_config_file" --system-spec-name="$system_spec_name" \
--test-suite="$test_suite" \
--zone="${zone}" --project="${project}" --gubernator="${gubernator}" \
--hosts="${hosts}" --images="${images}" --cleanup="${cleanup}" \
--results-dir="${artifacts}" --ginkgo-flags="${ginkgoflags}" \
--image-project="${image_project}" --instance-name-prefix="${instance_prefix}" \
--delete-instances="${delete_instances}" --test_args="${test_args}" --instance-metadata="${metadata}" \
--image-config-file="${image_config_file}" --system-spec-name="${system_spec_name}" \
--test-suite="${test_suite}" \
2>&1 | tee -i "${artifacts}/build-log.txt"
exit $?
@@ -161,17 +161,17 @@ else
# Do not use any network plugin by default. User could override the flags with
# test_args.
test_args='--kubelet-flags="--network-plugin= --cni-bin-dir=" '$test_args
test_args='--kubelet-flags="--network-plugin= --cni-bin-dir=" '${test_args}
# Runtime flags
test_args='--kubelet-flags="--container-runtime='$runtime'" '$test_args
test_args='--kubelet-flags="--container-runtime='${runtime}'" '${test_args}
# Test using the host the script was run on
# Provided for backwards compatibility
go run test/e2e_node/runner/local/run_local.go \
--system-spec-name="$system_spec_name" --ginkgo-flags="$ginkgoflags" \
--system-spec-name="${system_spec_name}" --ginkgo-flags="${ginkgoflags}" \
--test-flags="--container-runtime=${runtime} \
--alsologtostderr --v 4 --report-dir=${artifacts} --node-name $(hostname) \
$test_args" --build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"
${test_args}" --build-dependencies=true 2>&1 | tee -i "${artifacts}/build-log.txt"
exit $?
fi

View File

@@ -143,13 +143,13 @@ isnum() {
PARALLEL="${PARALLEL:-1}"
while getopts "hp:i:" opt ; do
case $opt in
case ${opt} in
h)
kube::test::usage
exit 0
;;
p)
PARALLEL="$OPTARG"
PARALLEL="${OPTARG}"
if ! isnum "${PARALLEL}" || [[ "${PARALLEL}" -le 0 ]]; then
kube::log::usage "'$0': argument to -p must be numeric and greater than 0"
kube::test::usage
@@ -166,7 +166,7 @@ while getopts "hp:i:" opt ; do
exit 1
;;
:)
kube::log::usage "Option -$OPTARG <value>"
kube::log::usage "Option -${OPTARG} <value>"
kube::test::usage
exit 1
;;
@@ -223,15 +223,15 @@ verifyAndSuggestPackagePath() {
local original_package_path="$3"
local suggestion_package_path="$4"
if ! [ -d "$specified_package_path" ]; then
if ! [ -d "${specified_package_path}" ]; then
# Because k8s sets a localized $GOPATH for testing, seeing the actual
# directory can be confusing. Instead, just show $GOPATH if it exists in the
# $specified_package_path.
local printable_package_path=$(echo "$specified_package_path" | sed "s|$GOPATH|\$GOPATH|")
kube::log::error "specified test path '$printable_package_path' does not exist"
local printable_package_path=$(echo "${specified_package_path}" | sed "s|${GOPATH}|\${GOPATH}|")
kube::log::error "specified test path '${printable_package_path}' does not exist"
if [ -d "$alternative_package_path" ]; then
kube::log::info "try changing \"$original_package_path\" to \"$suggestion_package_path\""
if [ -d "${alternative_package_path}" ]; then
kube::log::info "try changing \"${original_package_path}\" to \"${suggestion_package_path}\""
fi
exit 1
fi
@@ -241,13 +241,13 @@ verifyPathsToPackagesUnderTest() {
local packages_under_test=($@)
for package_path in "${packages_under_test[@]}"; do
local local_package_path="$package_path"
local go_package_path="$GOPATH/src/$package_path"
local local_package_path="${package_path}"
local go_package_path="${GOPATH}/src/${package_path}"
if [[ "${package_path:0:2}" == "./" ]] ; then
verifyAndSuggestPackagePath "$local_package_path" "$go_package_path" "$package_path" "${package_path:2}"
verifyAndSuggestPackagePath "${local_package_path}" "${go_package_path}" "${package_path}" "${package_path:2}"
else
verifyAndSuggestPackagePath "$go_package_path" "$local_package_path" "$package_path" "./$package_path"
verifyAndSuggestPackagePath "${go_package_path}" "${local_package_path}" "${package_path}" "./${package_path}"
fi
done
}
@@ -316,12 +316,12 @@ runTests() {
# vendor/k8s.io/client-go/1.4/rest: causes cover internal errors
# https://github.com/golang/go/issues/16540
cover_ignore_dirs="vendor/k8s.io/code-generator/cmd/generator|vendor/k8s.io/client-go/1.4/rest"
for path in $(echo $cover_ignore_dirs | sed 's/|/ /g'); do
echo -e "skipped\tk8s.io/kubernetes/$path"
for path in $(echo ${cover_ignore_dirs} | sed 's/|/ /g'); do
echo -e "skipped\tk8s.io/kubernetes/${path}"
done
printf "%s\n" "${@}" \
| grep -Ev $cover_ignore_dirs \
| grep -Ev ${cover_ignore_dirs} \
| xargs -I{} -n 1 -P ${KUBE_COVERPROCS} \
bash -c "set -o pipefail; _pkg=\"\$0\"; _pkg_out=\${_pkg//\//_}; \
go test ${goflags[@]:+${goflags[@]}} \
@@ -349,7 +349,7 @@ runTests() {
# Include all coverage reach data in the combined profile, but exclude the
# 'mode' lines, as there should be only one.
for x in `find "${cover_report_dir}" -name "${cover_profile}"`; do
cat $x | grep -h -v "^mode:" || true
cat ${x} | grep -h -v "^mode:" || true
done
} >"${COMBINED_COVER_PROFILE}"
@@ -374,8 +374,8 @@ checkFDs() {
# several unittests panic when httptest cannot open more sockets
# due to the low default files limit on OS X. Warn about low limit.
local fileslimit="$(ulimit -n)"
if [[ $fileslimit -lt 1000 ]]; then
echo "WARNING: ulimit -n (files) should be at least 1000, is $fileslimit, may cause test failure";
if [[ ${fileslimit} -lt 1000 ]]; then
echo "WARNING: ulimit -n (files) should be at least 1000, is ${fileslimit}, may cause test failure";
fi
}
@@ -387,7 +387,7 @@ IFS=';' read -a apiVersions <<< "${KUBE_TEST_API_VERSIONS}"
apiVersionsCount=${#apiVersions[@]}
for (( i=0; i<${apiVersionsCount}; i++ )); do
apiVersion=${apiVersions[i]}
echo "Running tests for APIVersion: $apiVersion"
echo "Running tests for APIVersion: ${apiVersion}"
# KUBE_TEST_API sets the version of each group to be tested.
KUBE_TEST_API="${apiVersion}" runTests "$@"
done

View File

@@ -56,24 +56,22 @@ BASH_TARGETS="
update-generated-device-plugin
update-generated-docs
update-generated-swagger-docs
update-swagger-spec
update-openapi-spec
update-api-reference-docs
update-staging-godeps
update-bazel"
for t in ${BASH_TARGETS}; do
echo -e "${color_yellow}Running $t${color_norm}"
echo -e "${color_yellow}Running ${t}${color_norm}"
if ${SILENT} ; then
if ! bash "${KUBE_ROOT}/hack/$t.sh" 1> /dev/null; then
echo -e "${color_red}Running $t FAILED${color_norm}"
if ! bash "${KUBE_ROOT}/hack/${t}.sh" 1> /dev/null; then
echo -e "${color_red}Running ${t} FAILED${color_norm}"
if ! ${ALL}; then
exit 1
fi
fi
else
if ! bash "${KUBE_ROOT}/hack/$t.sh"; then
echo -e "${color_red}Running $t FAILED${color_norm}"
if ! bash "${KUBE_ROOT}/hack/${t}.sh"; then
echo -e "${color_red}Running ${t} FAILED${color_norm}"
if ! ${ALL}; then
exit 1
fi

View File

@@ -86,7 +86,7 @@ QUICK_CHECKS=$(ls ${QUICK_PATTERNS[@]/#/${KUBE_ROOT}\/hack\/} 2>/dev/null || tru
function is-excluded {
for e in ${EXCLUDED_CHECKS[@]}; do
if [[ $1 -ef "$e" ]]; then
if [[ $1 -ef "${e}" ]]; then
return
fi
done
@@ -95,7 +95,7 @@ function is-excluded {
function is-quick {
for e in ${QUICK_CHECKS[@]}; do
if [[ $1 -ef "$e" ]]; then
if [[ $1 -ef "${e}" ]]; then
return
fi
done
@@ -106,7 +106,7 @@ function is-explicitly-chosen {
local name="${1#verify-}"
name="${name%.*}"
for e in ${WHAT}; do
if [[ $e == "$name" ]]; then
if [[ "${e}" == "${name}" ]]; then
return
fi
done