Once again, use native Ginkgo test runner instead of cmd/e2e.

This commit deletes cmd/e2e and updates hack/ginkgo-e2e.sh to use the
'ginkgo' command instead. All logic from cmd/e2e/e2e.go and
test/e2e/driver.go have been combined into the new file
test/e2e/e2e_test.go.

The test tarball now includes a built version of the test/e2e test
binary, which includes all tests under test/e2e. This was accomplished
by updating the build scripts to use 'go test -c' when a target name
ended with '.test', and adding a dependency on test/e2e/e2e.test.

This prebuilt test binary is passed to the Ginkgo runner in
hack/ginkgo-e2e.sh. In a future change, we can add support to run
Ginkgo against the source tree if it is available.

This change is generally intended to have no externally visible changes,
aside from the following caveats:
 - The -t/--tests flag has been removed
 - Calling cmd/e2e/e2e directly obviously won't work, but that was never
   intended to be supported anyway
 - If the GINKGO_PARALLEL environment variable is set to y, then ginkgo
   will run test specs in parallel. (Currently defaults to n, since some
   tests are broken in this mode.)

Additionally, several tests which made poor assumptions about cwd or
used testContext before it had been set have been fixed.
This commit is contained in:
Jeff Grafton
2015-05-01 14:18:50 -07:00
parent 1ee33ac481
commit 86b023fdd6
9 changed files with 202 additions and 294 deletions

View File

@@ -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.