mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-06 11:42:14 +00:00
Revert "Revert "Once again, use native Ginkgo test runner instead of cmd/e2e.""
This reverts commit 67da1ac0c8
.
This commit is contained in:
@@ -18,54 +18,18 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||
GINKGO_PARALLEL=${GINKGO_PARALLEL:-n} # set to 'y' to run tests in parallel
|
||||
KUBE_ROOT=$(readlink -f $(dirname "${BASH_SOURCE}")/..)
|
||||
|
||||
source "${KUBE_ROOT}/cluster/common.sh"
|
||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||
|
||||
# --- Find local test binaries.
|
||||
|
||||
# Detect the OS name/arch so that we can find our binary
|
||||
case "$(uname -s)" in
|
||||
Darwin)
|
||||
host_os=darwin
|
||||
;;
|
||||
Linux)
|
||||
host_os=linux
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported host OS. Must be Linux or Mac OS X." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$(uname -m)" in
|
||||
x86_64*)
|
||||
host_arch=amd64
|
||||
;;
|
||||
i?86_64*)
|
||||
host_arch=amd64
|
||||
;;
|
||||
amd64*)
|
||||
host_arch=amd64
|
||||
;;
|
||||
arm*)
|
||||
host_arch=arm
|
||||
;;
|
||||
i?86*)
|
||||
host_arch=x86
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported host arch. Must be x86_64, 386 or arm." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Gather up the list of likely places and use ls to find the latest one.
|
||||
locations=(
|
||||
"${KUBE_ROOT}/_output/dockerized/bin/${host_os}/${host_arch}/e2e"
|
||||
"${KUBE_ROOT}/_output/local/bin/${host_os}/${host_arch}/e2e"
|
||||
"${KUBE_ROOT}/platforms/${host_os}/${host_arch}/e2e"
|
||||
)
|
||||
e2e=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 )
|
||||
# Ginkgo will build the e2e tests, so we need to make sure that the environment
|
||||
# is set up correctly (including Godeps, etc).
|
||||
kube::golang::setup_env
|
||||
# Find the ginkgo binary build as part of the release.
|
||||
ginkgo=$(kube::util::find-binary "ginkgo")
|
||||
e2e_test=$(kube::util::find-binary "e2e.test")
|
||||
|
||||
# --- Setup some env vars.
|
||||
|
||||
@@ -89,8 +53,8 @@ if [[ -z "${AUTH_CONFIG:-}" ]]; then
|
||||
|
||||
if [[ "${KUBERNETES_PROVIDER}" == "conformance_test" ]]; then
|
||||
auth_config=(
|
||||
"--auth_config=${KUBERNETES_CONFORMANCE_TEST_AUTH_CONFIG:-}"
|
||||
"--cert_dir=${KUBERNETES_CONFORMANCE_TEST_CERT_DIR:-}"
|
||||
"--auth-config=${KUBERNETES_CONFORMANCE_TEST_AUTH_CONFIG:-}"
|
||||
"--cert-dir=${KUBERNETES_CONFORMANCE_TEST_CERT_DIR:-}"
|
||||
)
|
||||
else
|
||||
auth_config=(
|
||||
@@ -108,21 +72,26 @@ else
|
||||
echo "Conformance Test. No cloud-provider-specific preparation."
|
||||
KUBERNETES_PROVIDER=""
|
||||
auth_config=(
|
||||
"--auth_config=${AUTH_CONFIG:-}"
|
||||
"--cert_dir=${CERT_DIR:-}"
|
||||
"--auth-config=${AUTH_CONFIG:-}"
|
||||
"--cert-dir=${CERT_DIR:-}"
|
||||
)
|
||||
fi
|
||||
|
||||
# Use the kubectl binary from the same directory as the e2e binary.
|
||||
ginkgo_args=()
|
||||
if [[ ${GINKGO_PARALLEL} =~ ^[yY]$ ]]; then
|
||||
ginkgo_args+=("-p")
|
||||
fi
|
||||
|
||||
# The --host setting is used only when providing --auth_config
|
||||
# If --kubeconfig is used, the host to use is retrieved from the .kubeconfig
|
||||
# file and the one provided with --host is ignored.
|
||||
export PATH=$(dirname "${e2e}"):"${PATH}"
|
||||
"${e2e}" "${auth_config[@]:+${auth_config[@]}}" \
|
||||
"${ginkgo}" "${ginkgo_args[@]:+${ginkgo_args[@]}}" "${e2e_test}" -- \
|
||||
"${auth_config[@]:+${auth_config[@]}}" \
|
||||
--host="https://${KUBE_MASTER_IP-}" \
|
||||
--provider="${KUBERNETES_PROVIDER}" \
|
||||
--gce_project="${PROJECT:-}" \
|
||||
--gce_zone="${ZONE:-}" \
|
||||
--kube_master="${KUBE_MASTER:-}" \
|
||||
${E2E_REPORT_DIR+"--report_dir=${E2E_REPORT_DIR}"} \
|
||||
--gce-project="${PROJECT:-}" \
|
||||
--gce-zone="${ZONE:-}" \
|
||||
--kube-master="${KUBE_MASTER:-}" \
|
||||
--repo-root="${KUBE_VERSION_ROOT}" \
|
||||
${E2E_REPORT_DIR+"--report-dir=${E2E_REPORT_DIR}"} \
|
||||
"${@:-}"
|
||||
|
@@ -44,13 +44,13 @@ readonly KUBE_CLIENT_BINARIES_WIN=("${KUBE_CLIENT_BINARIES[@]/%/.exe}")
|
||||
|
||||
# The set of test targets that we are building for all platforms
|
||||
readonly KUBE_TEST_TARGETS=(
|
||||
cmd/e2e
|
||||
cmd/integration
|
||||
cmd/gendocs
|
||||
cmd/genman
|
||||
cmd/genbashcomp
|
||||
examples/k8petstore/web-server
|
||||
github.com/onsi/ginkgo/ginkgo
|
||||
test/e2e/e2e.test
|
||||
)
|
||||
readonly KUBE_TEST_BINARIES=("${KUBE_TEST_TARGETS[@]##*/}")
|
||||
readonly KUBE_TEST_BINARIES_WIN=("${KUBE_TEST_BINARIES[@]/%/.exe}")
|
||||
@@ -289,14 +289,33 @@ kube::golang::fallback_if_stdlib_not_installable() {
|
||||
use_go_build=true
|
||||
}
|
||||
|
||||
# Try and replicate the native binary placement of go install without
|
||||
# calling go install.
|
||||
kube::golang::output_filename_for_binary() {
|
||||
local binary=$1
|
||||
local platform=$2
|
||||
local output_path="${KUBE_GOPATH}/bin"
|
||||
if [[ $platform != $host_platform ]]; then
|
||||
output_path="${output_path}/${platform//\//_}"
|
||||
fi
|
||||
local bin=$(basename "${binary}")
|
||||
if [[ ${GOOS} == "windows" ]]; then
|
||||
bin="${bin}.exe"
|
||||
fi
|
||||
echo "${output_path}/${bin}"
|
||||
}
|
||||
|
||||
kube::golang::build_binaries_for_platform() {
|
||||
local platform=$1
|
||||
local use_go_build=${2-}
|
||||
|
||||
local -a statics=()
|
||||
local -a nonstatics=()
|
||||
local -a tests=()
|
||||
for binary in "${binaries[@]}"; do
|
||||
if kube::golang::is_statically_linked_library "${binary}"; then
|
||||
if [[ "${binary}" =~ ".test"$ ]]; then
|
||||
tests+=($binary)
|
||||
elif kube::golang::is_statically_linked_library "${binary}"; then
|
||||
statics+=($binary)
|
||||
else
|
||||
nonstatics+=($binary)
|
||||
@@ -307,27 +326,17 @@ kube::golang::build_binaries_for_platform() {
|
||||
fi
|
||||
|
||||
if [[ -n ${use_go_build:-} ]]; then
|
||||
# Try and replicate the native binary placement of go install without
|
||||
# calling go install. This means we have to iterate each binary.
|
||||
local output_path="${KUBE_GOPATH}/bin"
|
||||
if [[ $platform != $host_platform ]]; then
|
||||
output_path="${output_path}/${platform//\//_}"
|
||||
fi
|
||||
|
||||
kube::log::progress " "
|
||||
for binary in "${binaries[@]}"; do
|
||||
local bin=$(basename "${binary}")
|
||||
if [[ ${GOOS} == "windows" ]]; then
|
||||
bin="${bin}.exe"
|
||||
fi
|
||||
|
||||
local outfile=$(kube::golang::output_filename_for_binary "${binary}" \
|
||||
"${platform}")
|
||||
if kube::golang::is_statically_linked_library "${binary}"; then
|
||||
CGO_ENABLED=0 go build -o "${output_path}/${bin}" \
|
||||
CGO_ENABLED=0 go build -o "${outfile}" \
|
||||
"${goflags[@]:+${goflags[@]}}" \
|
||||
-ldflags "${version_ldflags}" \
|
||||
"${binary}"
|
||||
else
|
||||
go build -o "${output_path}/${bin}" \
|
||||
go build -o "${outfile}" \
|
||||
"${goflags[@]:+${goflags[@]}}" \
|
||||
-ldflags "${version_ldflags}" \
|
||||
"${binary}"
|
||||
@@ -349,6 +358,14 @@ kube::golang::build_binaries_for_platform() {
|
||||
fi
|
||||
fi
|
||||
|
||||
for test in "${tests[@]:+${tests[@]}}"; do
|
||||
local outfile=$(kube::golang::output_filename_for_binary "${test}" \
|
||||
"${platform}")
|
||||
go test -c -o "${outfile}" \
|
||||
"${goflags[@]:+${goflags[@]}}" \
|
||||
-ldflags "${version_ldflags}" \
|
||||
"$(dirname ${test})"
|
||||
done
|
||||
}
|
||||
|
||||
# Return approximate physical memory in gigabytes.
|
||||
|
@@ -35,6 +35,7 @@ kube::test::find_dirs() {
|
||||
-o -wholename '*/third_party/*' \
|
||||
-o -wholename '*/Godeps/*' \
|
||||
-o -wholename '*/contrib/podex/*' \
|
||||
-o -wholename '*/test/e2e/*' \
|
||||
-o -wholename '*/test/integration/*' \
|
||||
\) -prune \
|
||||
\) -name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./||' | sort -u
|
||||
|
Reference in New Issue
Block a user