-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #471 from DataRecce/feature/drc-842-extend-smoke-t…
…est-coverage Modify the smoke test
- Loading branch information
Showing
4 changed files
with
64 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
target/ | ||
target-base/ | ||
dbt_packages/ | ||
recce_state.json | ||
recce_summary.md | ||
jaffle_shop.duckdb | ||
.user.yml | ||
package-lock.yml | ||
recce.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,75 @@ | ||
#!/usr/bin/env bash | ||
set -euxo pipefail | ||
set -euo pipefail | ||
|
||
FALLBACK_PR_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/pull/${GITHUB_REF_NAME}" | ||
PR_URL="${PR_URL:-$FALLBACK_PR_URL}" | ||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
cd "$SCRIPT_DIR" | ||
pwd | ||
|
||
# Step 1: prepare env | ||
# Prepare env | ||
git restore models/customers.sql | ||
dbt --version | ||
dbt deps | ||
dbt build --target-path target-base | ||
dbt seed --target-path target-base | ||
dbt run --target-path target-base | ||
dbt docs generate --target-path target-base | ||
|
||
# modify model | ||
echo "where customer_id > 0" >> models/customers.sql | ||
dbt build | ||
dbt run | ||
dbt docs generate | ||
git restore models/customers.sql | ||
|
||
# Step 2: turn off anonymous tracking | ||
mkdir ~/.recce | ||
# Recce Run | ||
mkdir -p ~/.recce | ||
echo "user_id: 00000000000000000000000000000000" > ~/.recce/profile.yml | ||
echo "anonymous_tracking: false" >> ~/.recce/profile.yml | ||
|
||
# Step 3: add helper function | ||
assert_string_value() { | ||
if [ "$1" != "$2" ]; then | ||
echo "Expected $2, but got $1" | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Test | ||
recce run | ||
|
||
# state file generated | ||
if ! [ -e recce_state.json ]; then | ||
echo "recce_state.json not found" | ||
exit 1 | ||
fi | ||
|
||
# row count diff to modified table models | ||
model=$(cat recce_state.json | jq '.runs[0].result | keys | .[0]' | tr -d '"') | ||
run_type=$(cat recce_state.json | jq '.runs[0]'.type | tr -d '"') | ||
assert_string_value $model "customers" | ||
assert_string_value $run_type "row_count_diff" | ||
|
||
# pull request information | ||
pr_url=$(cat recce_state.json | jq .pull_request.url | tr -d '"') | ||
assert_string_value "${pr_url}" "${PR_URL}" | ||
# Recce Summary | ||
recce summary ./recce_state.json | tee recce_summary.md | ||
cat ./recce_summary.md | grep -q customers | ||
|
||
# Recce Server | ||
function check_server_status() { | ||
echo "Waiting for the server to respond..." | ||
if timeout 20 bash -c 'until curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/api/info | grep -q 200; do | ||
echo "Server not ready yet..." | ||
sleep 2 | ||
done'; then | ||
echo "Server is up and running." | ||
EXITCODE=0 | ||
else | ||
echo "Failed to start the server within the time limit." | ||
EXITCODE=1 | ||
fi | ||
|
||
echo "Stopping the server..." | ||
kill $(jobs -p) || true | ||
echo "Server stopped." | ||
|
||
exit $EXITCODE | ||
} | ||
|
||
echo "Starting the server..." | ||
recce server & | ||
check_server_status | ||
|
||
echo "Starting the server (review mode)" | ||
recce server --review recce_state.json & | ||
check_server_status |