fix: docker entrypoint handle correctly passing a single argument as a string

This commit is contained in:
adrian
2025-09-10 09:15:30 +02:00
committed by Adrian Benavides
parent 580a8822a5
commit b1db641c31
3 changed files with 34 additions and 15 deletions

View File

@@ -27,6 +27,8 @@ services:
RPC_URL: "${RPC_URL}"
SUBSTREAMS_API_TOKEN: "${SUBSTREAMS_API_TOKEN}"
AUTH_API_KEY: "${AUTH_API_KEY}"
# PROTOCOLS to test separated by space and with optional filter
# e.g. "ethereum-balancer-v2=weighted_legacy_creation ethereum-ekubo-v2"
entrypoint: ["/entrypoint.sh", "${PROTOCOLS}"]
volumes:

View File

@@ -2,11 +2,22 @@
set -e
if [ "$#" -lt 1 ]; then
echo "Usage: $0 test1 [test2 ...]"
exit 1
echo "Usage: $0 protocol1[=filter] [protocol2 ...] or \"$0 'protocol1[=filter] protocol2'\""
exit 1
fi
for test in "$@"; do
echo "Running test: /app/substreams/$test"
tycho-protocol-sdk --package-path "/app/substreams/$test" --db-url "$DATABASE_URL"
if [ "$#" -eq 1 ] && [[ "$1" == *" "* ]]; then
IFS=' ' read -r -a args <<< "$1"
else
args=("$@")
fi
for test in "${args[@]}"; do
protocol="${test%%=*}"
filter="${test#*=}"
if [[ "$test" == *"="* ]]; then
tycho-protocol-sdk --package-path "/app/substreams/$protocol" --db-url "$DATABASE_URL" --match-test "$filter"
else
tycho-protocol-sdk --package-path "/app/substreams/$protocol" --db-url "$DATABASE_URL"
fi
done

View File

@@ -78,21 +78,27 @@ impl TestRunner {
.map(|size| size.cols as usize - 35) // Remove length of log prefix
.unwrap_or(80);
info!("Running {} tests ...\n", config.tests.len());
let tests = match &self.match_test {
Some(filter) => config
.tests
.iter()
.filter(|test| test.name.contains(filter))
.collect::<Vec<&IntegrationTest>>(),
None => config
.tests
.iter()
.collect::<Vec<&IntegrationTest>>(),
};
let tests_count = tests.len();
info!("Running {} tests ...\n", tests_count);
info!("{}\n", "-".repeat(terminal_width));
let mut failed_tests: Vec<String> = Vec::new();
let mut count = 1;
for test in &config.tests {
for test in &tests {
info!("TEST {}: {}", count, test.name);
if let Some(match_test) = &self.match_test {
if !test.name.contains(match_test) {
info!("Skipping test (does not match filter: {match_test})\n");
count += 1;
continue;
}
}
match self.run_test(test, &config, config.skip_balance_check) {
Ok(_) => {
@@ -109,7 +115,7 @@ impl TestRunner {
}
info!("Tests finished!");
info!("Passed {}/{}", config.tests.len() - failed_tests.len(), config.tests.len());
info!("Passed {}/{}", tests_count - failed_tests.len(), tests_count);
if !failed_tests.is_empty() {
error!("Failed: {}", failed_tests.join(", "));
}