forked from jito-foundation/jito-solana
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-stable.sh
executable file
·238 lines (211 loc) · 8.85 KB
/
test-stable.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/usr/bin/env bash
set -e
cd "$(dirname "$0")/.."
cargo="$(readlink -f "./cargo")"
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
export RUST_BACKTRACE=1
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
;;
test-stable-sbf)
# Clear the C dependency files, if dependency moves these files are not regenerated
test -d target/debug/sbf && find target/debug/sbf -name '*.d' -delete
test -d target/release/sbf && find target/release/sbf -name '*.d' -delete
# rustfilt required for dumping SBF assembly listings
"$cargo" install rustfilt
# solana-keygen required when building C programs
_ "$cargo" build --manifest-path=keygen/Cargo.toml
export PATH="$PWD/target/debug":$PATH
cargo_build_sbf="$(realpath ./cargo-build-sbf)"
cargo_test_sbf="$(realpath ./cargo-test-sbf)"
# 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
# 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
# SBF Rust program unit tests
for sbf_test in programs/sbf/rust/*; do
if pushd "$sbf_test"; then
"$cargo" test
"$cargo_build_sbf" --sbf-sdk ../../../../sdk/sbf --dump
"$cargo_test_sbf" --sbf-sdk ../../../../sdk/sbf
popd
fi
done |& tee cargo.log
# 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
if ((solana_program_count > 14)); 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
"$cargo_build_sbf" -V
# 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
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 \
-- --nocapture &> "${sbf_target_path}"/deploy/instuction_counts.txt
fi
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
# 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
rm -rf target/perf-libs
./fetch-perf-libs.sh
# Force CUDA for solana-core unit tests
export TEST_PERF_LIBS_CUDA=1
# Force CUDA in ci/localnet-sanity.sh
export SOLANA_CUDA=1
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
(
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
)