File tree Expand file tree Collapse file tree 6 files changed +86
-0
lines changed
Expand file tree Collapse file tree 6 files changed +86
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ VERSION=0.0.0
3+
4+ TB_VERSION_WARNING=1
5+ TB_SKIP_REGRESSION=1
6+
Original file line number Diff line number Diff line change 1+ tinybird-cli >= 5 ,< 6
Original file line number Diff line number Diff line change 1+
2+ #! /usr/bin/env bash
3+ set -euxo pipefail
4+
5+ directory=" datasources/fixtures"
6+ extensions=(" csv" " ndjson" )
7+
8+ absolute_directory=$( realpath " $directory " )
9+
10+ for extension in " ${extensions[@]} " ; do
11+ file_list=$( find " $absolute_directory " -type f -name " *.$extension " )
12+
13+ for file_path in $file_list ; do
14+ file_name=$( basename " $file_path " )
15+ file_name_without_extension=" ${file_name% .* } "
16+
17+ command=" tb datasource append $file_name_without_extension datasources/fixtures/$file_name "
18+ echo $command
19+ $command
20+ done
21+ done
Original file line number Diff line number Diff line change 1+
2+ #! /usr/bin/env bash
3+ set -euxo pipefail
4+
5+ export TB_VERSION_WARNING=0
6+
7+ run_test () {
8+ t=$1
9+ echo " ** Running $t **"
10+ echo " ** $( cat $t ) "
11+ tmpfile=$( mktemp)
12+ retries=0
13+ TOTAL_RETRIES=3
14+
15+ # When appending fixtures, we need to retry in case of the data is not replicated in time
16+ while [ $retries -lt $TOTAL_RETRIES ]; do
17+ # Run the test and store the output in a temporary file
18+ bash $t $2 > $tmpfile
19+ exit_code=$?
20+ if [ " $exit_code " -eq 0 ]; then
21+ # If the test passed, break the loop
22+ if diff -B ${t} .result $tmpfile > /dev/null 2>&1 ; then
23+ break
24+ # If the test failed, increment the retries counter and try again
25+ else
26+ retries=$(( retries+ 1 ))
27+ fi
28+ # If the bash command failed, print an error message and break the loop
29+ else
30+ break
31+ fi
32+ done
33+
34+ if diff -B ${t} .result $tmpfile > /dev/null 2>&1 ; then
35+ echo " ✅ Test $t passed"
36+ rm $tmpfile
37+ return 0
38+ elif [ $retries -eq $TOTAL_RETRIES ]; then
39+ echo " 🚨 ERROR: Test $t failed, diff:" ;
40+ diff -B ${t} .result $tmpfile
41+ rm $tmpfile
42+ return 1
43+ else
44+ echo " 🚨 ERROR: Test $t failed with bash command exit code $? "
45+ cat $tmpfile
46+ rm $tmpfile
47+ return 1
48+ fi
49+ echo " "
50+ }
51+ export -f run_test
52+
53+ fail=0
54+ find ./tests -name " *.test" -print0 | xargs -0 -I {} -P 4 bash -c ' run_test "$@"' _ {} || fail=1
55+
56+ if [ $fail == 1 ]; then
57+ exit -1;
58+ fi
You can’t perform that action at this time.
0 commit comments