Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: add roachtest nightlies coverage scripts #111382

Merged
merged 1 commit into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions build/teamcity/cockroach/coverage/roachtest_nightly_gce.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -exuo pipefail

dir="$(dirname $(dirname $(dirname $(dirname "${0}"))))"

source "$dir/teamcity-support.sh" # For $root
source "$dir/teamcity-bazel-support.sh" # For run_bazel

CLOUD=gce
BAZEL_SUPPORT_EXTRA_DOCKER_ARGS="-e LITERAL_ARTIFACTS_DIR=$root/artifacts -e BUILD_VCS_NUMBER -e CLOUD -e COCKROACH_DEV_LICENSE -e TESTS -e COUNT -e GITHUB_API_TOKEN -e GITHUB_ORG -e GITHUB_REPO -e GOOGLE_EPHEMERAL_CREDENTIALS -e GOOGLE_KMS_KEY_A -e GOOGLE_KMS_KEY_B -e GOOGLE_CREDENTIALS_ASSUME_ROLE -e GOOGLE_SERVICE_ACCOUNT -e SLACK_TOKEN -e TC_BUILDTYPE_ID -e TC_BUILD_BRANCH -e TC_BUILD_ID -e TC_SERVER_URL -e SELECT_PROBABILITY" \
run_bazel build/teamcity/cockroach/coverage/roachtest_nightly_gce_impl.sh
39 changes: 39 additions & 0 deletions build/teamcity/cockroach/coverage/roachtest_nightly_gce_impl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

set -exuo pipefail

dir="$(dirname $(dirname $(dirname $(dirname "${0}"))))"

source "$dir/teamcity-support.sh"

if [[ ! -f ~/.ssh/id_rsa.pub ]]; then
ssh-keygen -q -C "roachtest-nightly-bazel $(date)" -N "" -f ~/.ssh/id_rsa
fi

# We will only spin up AMD64 clusters. Note that the TeamCity runner (this host)
# doesn't need to be AMD64; the roachtest binary is always built for the host
# architecture.
$root/build/teamcity/cockroach/nightlies/roachtest_compile_bits.sh --with-code-coverage amd64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth a comment to emphasize that the hardcoded (target) architecture is not actually preventing TC agent from running arm64, since it's going to be cross-built.


echo "$GOOGLE_EPHEMERAL_CREDENTIALS" > creds.json
gcloud auth activate-service-account --key-file=creds.json
export ROACHPROD_USER=teamcity

# See build/teamcity/util/roachtest_util.sh.
PARALLELISM=16
CPUQUOTA=1024
FILTER="tag:aws tag:default"

build/teamcity-roachtest-invoke.sh \
--metamorphic-encryption-probability=0.5 \
--select-probability="${SELECT_PROBABILITY:-1.0}" \
--cloud="${CLOUD}" \
--count="${COUNT-1}" \
--parallelism="${PARALLELISM}" \
--cpu-quota="${CPUQUOTA}" \
--cluster-id="${TC_BUILD_ID}" \
--artifacts=/artifacts \
--artifacts-literal="${LITERAL_ARTIFACTS_DIR:-}" \
--slack-token="${SLACK_TOKEN:-}" \
--go-cover \
${TESTS:-} ${FILTER}
30 changes: 24 additions & 6 deletions build/teamcity/cockroach/nightlies/roachtest_compile_bits.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
if [ "$#" -eq 0 ]; then
echo "Builds all bits needed for roachtests and stages them in bin/ and lib/."
echo ""
echo "Usage: $0 arch [arch...]"
echo "Usage: $0 [--with-code-coverage] arch [arch...]"
echo " where arch is one of: amd64, arm64, amd64-fips"
exit 1
fi
Expand All @@ -29,12 +29,29 @@ function arch_to_config() {
esac
}

arches=()
crdb_extra_flags=""

for arg in "$@"; do
case "$arg" in
--with-code-coverage)
crdb_extra_flags="--collect_code_coverage --bazel_code_coverage"
;;
*)
# Fail now if the argument is not a valid arch.
arch_to_config $arg >/dev/null || exit 1
arches+=($arg)
;;
esac
done

# Determine host cpu architecture, which we'll need for libgeos, below.
if [[ "$(uname -m)" =~ (arm64|aarch64)$ ]]; then
host_arch=arm64
else
host_arch=amd64
fi

echo "Host architecture: $host_arch"

# Prepare the bin/ and lib/ directories.
Expand All @@ -43,17 +60,18 @@ chmod o+rwx bin
mkdir -p lib
chmod o+rwx lib

for arch in "$@"; do
for arch in "${arches[@]}"; do
config=$(arch_to_config $arch)
echo "Building $config, os=$os, arch=$arch..."
# Build cockroach, workload and geos libs.
bazel build --config $config --config ci -c opt --config force_build_cdeps \
//pkg/cmd/cockroach //pkg/cmd/workload \
//c-deps:libgeos
//pkg/cmd/cockroach $crdb_extra_flags
bazel build --config $config --config ci -c opt --config force_build_cdeps \
//pkg/cmd/workload //c-deps:libgeos
BAZEL_BIN=$(bazel info bazel-bin --config $config --config ci -c opt)

# Build cockroach-short with assertions enabled.
bazel build --config $config --config ci -c opt //pkg/cmd/cockroach-short --crdb_test
bazel build --config $config --config ci -c opt //pkg/cmd/cockroach-short \
--crdb_test $crdb_extra_flags
# Copy the binaries.
cp $BAZEL_BIN/pkg/cmd/cockroach/cockroach_/cockroach bin/cockroach.$os-$arch
cp $BAZEL_BIN/pkg/cmd/workload/workload_/workload bin/workload.$os-$arch
Expand Down