solana/ci/test-stable.sh

239 lines
8.9 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
set -e
2018-05-27 18:19:07 -07:00
cd "$(dirname "$0")/.."
2018-05-21 23:02:54 -07:00
cargo="$(readlink -f "./cargo")"
2018-12-18 14:25:10 -08:00
source ci/_
annotate() {
${BUILDKITE:-false} && {
buildkite-agent annotate "$@"
}
}
# Run the appropriate test based on entrypoint
testName=$(basename "$0" .sh)
source ci/rust-version.sh stable
2018-06-24 21:24:08 -07:00
export RUST_BACKTRACE=1
2018-09-20 18:51:11 -07:00
export RUSTFLAGS="-D warnings"
source scripts/ulimit-n.sh
#shellcheck source=ci/common/limit-threads.sh
source ci/common/limit-threads.sh
# get channel info
eval "$(ci/channel-info.sh)"
#shellcheck source=ci/common/shared-functions.sh
source ci/common/shared-functions.sh
echo "Executing $testName"
case $testName in
test-stable)
if need_to_upload_test_result; then
_ cargo test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ ci/intercept.sh cargo test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
fi
;;
2022-09-28 14:24:42 -07:00
test-stable-sbf)
# Clear the C dependency files, if dependency moves these files are not regenerated
2022-09-28 14:24:42 -07:00
test -d target/debug/sbf && find target/debug/sbf -name '*.d' -delete
test -d target/release/sbf && find target/release/sbf -name '*.d' -delete
2022-09-28 14:24:42 -07:00
# rustfilt required for dumping SBF assembly listings
"$cargo" install rustfilt
# solana-keygen required when building C programs
_ "$cargo" build --manifest-path=keygen/Cargo.toml
2021-07-30 15:15:06 -07:00
export PATH="$PWD/target/debug":$PATH
2022-09-28 14:24:42 -07:00
cargo_build_sbf="$(realpath ./cargo-build-sbf)"
cargo_test_sbf="$(realpath ./cargo-test-sbf)"
2022-09-28 14:24:42 -07:00
# SBF solana-sdk legacy compile test
"$cargo_build_sbf" --manifest-path sdk/Cargo.toml
# Ensure the minimum supported "rust-version" matches platform tools to fail
# quickly if users try to build with an older platform tools install
cargo_toml=sdk/program/Cargo.toml
source "scripts/read-cargo-variable.sh"
crate_rust_version=$(readCargoVariable rust-version $cargo_toml)
platform_tools_rust_version=$("$cargo_build_sbf" --version | grep rustc)
platform_tools_rust_version=$(echo "$platform_tools_rust_version" | cut -d\ -f2) # Remove "rustc " prefix from a string like "rustc 1.68.0-dev"
platform_tools_rust_version=$(echo "$platform_tools_rust_version" | cut -d- -f1) # Remove "-dev" suffix from a string like "1.68.0-dev"
if [[ $crate_rust_version != "$platform_tools_rust_version" ]]; then
echo "Error: Update 'rust-version' field in '$cargo_toml' from $crate_rust_version to $platform_tools_rust_version"
exit 1
fi
2022-09-28 14:24:42 -07:00
# SBF C program system tests
_ make -C programs/sbf/c tests
if need_to_upload_test_result; then
_ cargo test \
--manifest-path programs/sbf/Cargo.toml \
--no-default-features --features=sbf_c,sbf_rust -- -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ cargo test \
--manifest-path programs/sbf/Cargo.toml \
--no-default-features --features=sbf_c,sbf_rust -- --nocapture
fi
2022-09-28 14:24:42 -07:00
# SBF Rust program unit tests
for sbf_test in programs/sbf/rust/*; do
2022-09-28 14:24:42 -07:00
if pushd "$sbf_test"; then
2021-07-30 15:15:06 -07:00
"$cargo" test
2022-09-28 14:24:42 -07:00
"$cargo_build_sbf" --sbf-sdk ../../../../sdk/sbf --dump
"$cargo_test_sbf" --sbf-sdk ../../../../sdk/sbf
popd
fi
done |& tee cargo.log
2022-09-28 14:24:42 -07:00
# Save the output of cargo building the sbf tests so we can analyze
# the number of redundant rebuilds of dependency crates. The
# expected number of solana-program crate compilations is 4. There
# should be 3 builds of solana-program while 128bit crate is
# built. These compilations are not redundant because the crate is
# built for different target each time. An additional compilation of
# solana-program is performed when simulation crate is built. This
# last compiled solana-program is of different version, normally the
# latest mainbeta release version.
solana_program_count=$(grep -c 'solana-program v' cargo.log)
rm -f cargo.log
Bump rand to 0.8, rand_chacha to 0.3, getrandom to 0.2 (#32871) * sdk: Add concurrent support for rand 0.7 and 0.8 * Update rand, rand_chacha, and getrandom versions * Run command to replace `gen_range` Run `git grep -l gen_range | xargs sed -i'' -e 's/gen_range(\(\S*\), /gen_range(\1../' * sdk: Fix users of older `gen_range` * Replace `hash::new_rand` with `hash::new_with_thread_rng` Run: ``` git grep -l hash::new_rand | xargs sed -i'' -e 's/hash::new_rand([^)]*/hash::new_with_thread_rng(/' ``` * perf: Use `Keypair::new()` instead of `generate` * Use older rand version in zk-token-sdk * program-runtime: Inline random key generation * bloom: Fix clippy warnings in tests * streamer: Scope rng usage correctly * perf: Fix clippy warning * accounts-db: Map to char to generate a random string * Remove `from_secret_key_bytes`, it's just `keypair_from_seed` * ledger: Generate keypairs by hand * ed25519-tests: Use new rand * runtime: Use new rand in all tests * gossip: Clean up clippy and inline keypair generators * core: Inline keypair generation for tests * Push sbf lockfile change * sdk: Sort dependencies correctly * Remove `hash::new_with_thread_rng`, use `Hash::new_unique()` * Use Keypair::new where chacha isn't used * sdk: Fix build by marking rand 0.7 optional * Hardcode secret key length, add static assertion * Unify `getrandom` crate usage to fix linking errors * bloom: Fix tests that require a random hash * Remove some dependencies, try to unify others * Remove unnecessary uses of rand and rand_core * Update lockfiles * Add back some dependencies to reduce rebuilds * Increase max rebuilds from 14 to 15 * frozen-abi: Remove `getrandom` * Bump rebuilds to 17 * Remove getrandom from zk-token-proof
2023-08-21 10:11:21 -07:00
if ((solana_program_count > 17)); then
echo "Regression of build redundancy ${solana_program_count}."
echo "Review dependency features that trigger redundant rebuilds of solana-program."
exit 1
fi
# platform-tools version
2022-09-28 14:24:42 -07:00
"$cargo_build_sbf" -V
2022-09-28 14:24:42 -07:00
# SBF program instruction count assertion
sbf_target_path=programs/sbf/target
if need_to_upload_test_result; then
_ cargo test \
--manifest-path programs/sbf/Cargo.toml \
--no-default-features --features=sbf_c,sbf_rust assert_instruction_count \
-- -Z unstable-options --format json --report-time |& tee results.json
2022-09-28 14:24:42 -07:00
awk '!/{ "type": .* }/' results.json >"${sbf_target_path}"/deploy/instuction_counts.txt
else
_ cargo test \
--manifest-path programs/sbf/Cargo.toml \
--no-default-features --features=sbf_c,sbf_rust assert_instruction_count \
2022-09-28 14:24:42 -07:00
-- --nocapture &> "${sbf_target_path}"/deploy/instuction_counts.txt
fi
2022-09-28 14:24:42 -07:00
sbf_dump_archive="sbf-dumps.tar.bz2"
rm -f "$sbf_dump_archive"
tar cjvf "$sbf_dump_archive" "${sbf_target_path}"/{deploy/*.txt,sbf-solana-solana/release/*.so}
exit 0
;;
test-stable-perf)
if [[ $(uname) = Linux ]]; then
2019-02-27 08:18:29 -08:00
# Enable persistence mode to keep the CUDA kernel driver loaded, avoiding a
# lengthy and unexpected delay the first time CUDA is involved when the driver
# is not yet loaded.
sudo --non-interactive ./net/scripts/enable-nvidia-persistence-mode.sh || true
2019-02-27 08:18:29 -08:00
rm -rf target/perf-libs
2019-02-27 08:18:29 -08:00
./fetch-perf-libs.sh
2019-09-26 13:36:51 -07:00
# Force CUDA for solana-core unit tests
export TEST_PERF_LIBS_CUDA=1
# Force CUDA in ci/localnet-sanity.sh
export SOLANA_CUDA=1
2019-02-27 08:18:29 -08:00
fi
_ cargo build --bins ${V:+--verbose}
if need_to_upload_test_result; then
_ cargo test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ cargo test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture
fi
_ cargo run --manifest-path poh-bench/Cargo.toml ${V:+--verbose} -- --hashes-per-tick 10
;;
test-local-cluster)
_ cargo build --release --bins ${V:+--verbose}
if need_to_upload_test_result; then
_ cargo test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ ci/intercept.sh cargo test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --nocapture --test-threads=1
fi
exit 0
;;
test-local-cluster-flakey)
_ cargo build --release --bins ${V:+--verbose}
if need_to_upload_test_result; then
_ cargo test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ ci/intercept.sh cargo test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --nocapture --test-threads=1
fi
exit 0
;;
test-local-cluster-slow-1)
_ cargo build --release --bins ${V:+--verbose}
if need_to_upload_test_result; then
_ cargo test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ ci/intercept.sh cargo test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --nocapture --test-threads=1
fi
exit 0
;;
test-local-cluster-slow-2)
_ cargo build --release --bins ${V:+--verbose}
if need_to_upload_test_result; then
_ cargo test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json
exit_if_error "${PIPESTATUS[0]}"
else
_ ci/intercept.sh cargo test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --nocapture --test-threads=1
fi
exit 0
;;
test-wasm)
_ node --version
_ npm --version
for dir in sdk/{program,}; do
if [[ -r "$dir"/package.json ]]; then
pushd "$dir"
_ npm install
_ npm test
popd
fi
done
exit 0
;;
test-docs)
if need_to_upload_test_result; then
_ cargo test --jobs "$JOBS" --all --doc --exclude solana-local-cluster ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json
exit "${PIPESTATUS[0]}"
else
_ cargo test --jobs "$JOBS" --all --doc --exclude solana-local-cluster ${V:+--verbose} -- --nocapture
exit 0
fi
;;
*)
echo "Error: Unknown test: $testName"
;;
esac
2018-07-30 12:51:35 -07:00
(
export CARGO_TOOLCHAIN=+"$rust_stable"
export RUST_LOG="solana_metrics=warn,info,$RUST_LOG"
echo --- ci/localnet-sanity.sh
ci/localnet-sanity.sh -x
echo --- ci/run-sanity.sh
ci/run-sanity.sh -x
2018-07-30 12:51:35 -07:00
)