Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#2984 from justinsb/test_in_par…
Browse files Browse the repository at this point in the history
…allel

tests: create script to enable running tests in parallel
  • Loading branch information
google-oss-prow[bot] authored Oct 24, 2024
2 parents 360c790 + 7c8fc37 commit 8d50ea3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
16 changes: 12 additions & 4 deletions dev/tasks/run-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ set -o pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd ${REPO_ROOT}

echo "Downloading envtest assets..."
export KUBEBUILDER_ASSETS=$(go run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest use -p path)
if [[ -z "${KUBEBUILDER_ASSETS:-}" ]]; then
echo "Downloading envtest assets..."
export KUBEBUILDER_ASSETS=$(go run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest use -p path)
fi

if [[ -z "${KCC_USE_DIRECT_RECONCILERS:-}" ]]; then
KCC_USE_DIRECT_RECONCILERS=ComputeForwardingRule,GKEHubFeatureMembership,SecretManagerSecret
Expand Down Expand Up @@ -77,9 +79,15 @@ if [[ -z "${TEST_TIMEOUT:-}" ]]; then
fi
echo "Using TEST_TIMEOUT=${TEST_TIMEOUT}"

# Run e2e tests against real gcp, capturing output
if [[ -z "${PREBUILT_TEST_BINARY:-}" ]]; then
echo "Prebuilding e2e tests"
PREBUILT_TEST_BINARY=.build/tests-e2e
go test -c -o ${PREBUILT_TEST_BINARY} ./tests/e2e
fi

# Run e2e tests
GOLDEN_REQUEST_CHECKS=1 \
GOLDEN_OBJECT_CHECKS=1 \
WRITE_GOLDEN_OUTPUT=1 \
RUN_E2E=1 \
go test ./tests/e2e -timeout ${TEST_TIMEOUT} -v -run $RUN_TESTS
${PREBUILT_TEST_BINARY} -test.timeout ${TEST_TIMEOUT} -test.v -test.run $RUN_TESTS
33 changes: 33 additions & 0 deletions dev/tasks/turbo-e2e
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT="$(git rev-parse --show-toplevel)"
cd ${REPO_ROOT}

dev/tasks/list-tests | xargs -I {} mkdir -p "testlogs/{}"

echo "Downloading envtest assets..."
export KUBEBUILDER_ASSETS=$(go run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest use -p path)

echo "Prebuilding e2e tests"
export PREBUILT_TEST_BINARY=.build/tests-e2e
go test -c -o ${PREBUILT_TEST_BINARY} ./tests/e2e

echo "Running tests"
dev/tasks/list-tests | xargs -P 40 -I {} /bin/bash -c "echo {}; RUN_TESTS={} dev/tasks/run-e2e > testlogs/{}/log 2>&1"

0 comments on commit 8d50ea3

Please sign in to comment.