@@ -25,8 +25,8 @@ OPENLINEAGE_DIRECTORY=""
2525
2626# Variables with default values
2727PRODUCER_OUTPUT_EVENTS_DIR=output
28- OPENLINEAGE_RELEASE=2-0-2
29- REPORT_PATH=" .. /dbt_producer_report.json"
28+ OPENLINEAGE_RELEASE=1.41.0
29+ REPORT_PATH=" ./dbt_producer_report.json"
3030
3131# If -h or --help is passed, print usage and exit
3232if [[ " $1 " == " -h" || " $1 " == " --help" ]]; then
@@ -51,10 +51,8 @@ if [[ -z "$OPENLINEAGE_DIRECTORY" ]]; then
5151 usage
5252fi
5353
54- OL_SPEC_DIRECTORIES=$OPENLINEAGE_DIRECTORY /spec/,$OPENLINEAGE_DIRECTORY /spec/facets/,$OPENLINEAGE_DIRECTORY /spec/registry/gcp/dataproc/facets,$OPENLINEAGE_DIRECTORY /spec/registry/gcp/lineage/facets
55-
5654# fail if scenarios are not defined in scenario directory
57- [[ $( ls scenarios | wc -l) -gt 0 ]] || { echo >&2 " NO SCENARIOS DEFINED IN scenarios" ; exit 1; }
55+ [[ $( find scenarios | wc -l) -gt 0 ]] || { echo >&2 " NO SCENARIOS DEFINED IN scenarios" ; exit 1; }
5856
5957mkdir -p " $PRODUCER_OUTPUT_EVENTS_DIR "
6058
@@ -73,208 +71,73 @@ echo "==========================================================================
7371#
7472# ###############################################################################
7573
76- echo " Setting up test environment..."
77-
78- # Get script directory for relative paths
79- SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
80- cd " $SCRIPT_DIR "
81-
82- # Check if Python test runner exists
83- if [[ ! -f " test_runner/cli.py" ]]; then
84- echo " Error: Python test runner not found at test_runner/cli.py"
85- exit 1
86- fi
87-
8874# Check if scenario directory exists
8975if [[ ! -d " scenarios" ]]; then
9076 echo " Error: scenarios directory not found"
9177 exit 1
9278fi
9379
80+ # install python dependencies
81+ # python -m pip install --upgrade pip
82+ #
83+ # if [ -f ./runner/requirements.txt ]; then
84+ # pip install -r ./runner/requirements.txt
85+ # fi
86+
9487# ###############################################################################
9588#
9689# RUN dbt PRODUCER TESTS
9790#
9891# ###############################################################################
9992
10093echo " Running dbt producer tests..."
101-
102- # Set up Python environment
103- export PYTHONPATH=" $SCRIPT_DIR /test_runner:$PYTHONPATH "
94+ POSIX_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
95+ BASE_DIR=" $( cygpath -m " $POSIX_DIR " ) "
10496
10597# Run tests for each scenario
106- TOTAL_SCENARIOS=0
107- PASSED_SCENARIOS=0
108- FAILED_SCENARIOS=0
109-
11098echo " Discovering test scenarios..."
11199for scenario_dir in scenarios/* /; do
112100 if [[ -d " $scenario_dir " && -f " ${scenario_dir} config.json" ]]; then
113101 SCENARIO_NAME=$( basename " $scenario_dir " )
114102 echo " Found scenario: $SCENARIO_NAME "
115- TOTAL_SCENARIOS=$(( TOTAL_SCENARIOS + 1 ))
116-
117- echo " ----------------------------------------"
118- echo " Running scenario: $SCENARIO_NAME "
119- echo " ----------------------------------------"
120-
121- # Run the atomic tests for this scenario
122- echo " Step 1: Running atomic tests..."
123- if python3 test_runner/cli.py run-atomic --base-path " ." --verbose; then
124- echo " ✅ Atomic tests passed for $SCENARIO_NAME "
125-
126- # Run OpenLineage event validation if events exist
127- echo " Step 2: Validating OpenLineage events..."
128- EVENTS_FILE=" events/openlineage_events.jsonl"
129- if [[ -f " $EVENTS_FILE " ]]; then
130- echo " 📋 Validating events from: $EVENTS_FILE "
131- echo " 📋 Against spec version: $OPENLINEAGE_RELEASE "
132- if python3 test_runner/cli.py validate-events --events-file " $EVENTS_FILE " --spec-dir " $OPENLINEAGE_DIRECTORY /spec" ; then
133- echo " ✅ Event validation passed for $SCENARIO_NAME (spec: $OPENLINEAGE_RELEASE )"
134- PASSED_SCENARIOS=$(( PASSED_SCENARIOS + 1 ))
135- else
136- echo " ❌ Event validation failed for $SCENARIO_NAME (spec: $OPENLINEAGE_RELEASE )"
137- FAILED_SCENARIOS=$(( FAILED_SCENARIOS + 1 ))
138- fi
139- else
140- echo " ⚠️ No OpenLineage events found at $EVENTS_FILE , skipping validation for $SCENARIO_NAME "
141- PASSED_SCENARIOS=$(( PASSED_SCENARIOS + 1 ))
142- fi
143- else
144- echo " ❌ Atomic tests failed for $SCENARIO_NAME "
145- FAILED_SCENARIOS=$(( FAILED_SCENARIOS + 1 ))
146- fi
147-
148- echo " "
103+
104+ mkdir -p " $PRODUCER_OUTPUT_EVENTS_DIR /$SCENARIO_NAME "
105+ " $scenario_dir " test/run.sh " $BASE_DIR /$PRODUCER_OUTPUT_EVENTS_DIR /$SCENARIO_NAME "
106+
107+ echo " Scenario $SCENARIO_NAME completed"
149108 fi
150109done
151110
152- # ###############################################################################
153- #
154- # GENERATE REPORT
155- #
156- # ###############################################################################
157-
158- echo " =============================================================================="
159- echo " TEST RESULTS "
160- echo " =============================================================================="
161- echo " Total scenarios: $TOTAL_SCENARIOS "
162- echo " Passed scenarios: $PASSED_SCENARIOS "
163- echo " Failed scenarios: $FAILED_SCENARIOS "
164- echo " OpenLineage Spec Version: $OPENLINEAGE_RELEASE "
165- echo " Events File: events/openlineage_events.jsonl"
166- echo " Report File: $REPORT_PATH "
167- echo " =============================================================================="
168- echo " Failed scenarios: $FAILED_SCENARIOS "
169- echo " =============================================================================="
111+ echo " EVENT VALIDATION FOR SPEC VERSION $OPENLINEAGE_RELEASE "
170112
171113# Generate JSON report
172114REPORT_DIR=$( dirname " $REPORT_PATH " )
173115mkdir -p " $REPORT_DIR "
174116
175- cat > " $REPORT_PATH " << EOF
176- {
177- "producer": "dbt",
178- "openlineage_release": "$OPENLINEAGE_RELEASE ",
179- "test_execution_time": "$( date -u +%Y-%m-%dT%H:%M:%SZ) ",
180- "total_scenarios": $TOTAL_SCENARIOS ,
181- "passed_scenarios": $PASSED_SCENARIOS ,
182- "failed_scenarios": $FAILED_SCENARIOS ,
183- "success_rate": $( echo " scale=2; $PASSED_SCENARIOS * 100 / $TOTAL_SCENARIOS " | bc -l 2> /dev/null || echo " 0" ) ,
184- "output_events_directory": "$PRODUCER_OUTPUT_EVENTS_DIR ",
185- "scenarios": []
186- }
187- EOF
117+ SPECS_BASE_DIR=" ./specs"
118+ DEST_DIR=" $SPECS_BASE_DIR /$OPENLINEAGE_RELEASE "
188119
189- echo " Report generated: $REPORT_PATH "
120+ mkdir -p " $DEST_DIR "
190121
191- # ###############################################################################
192- #
193- # CLEANUP AND EXIT
194- #
195- # ###############################################################################
196-
197- echo " Cleaning up temporary files..."
198-
199- # Exit with appropriate code
200- if [[ $FAILED_SCENARIOS -eq 0 ]]; then
201- echo " 🎉 All tests passed!"
202- exit 0
203- else
204- echo " ❌ Some tests failed. Check the output above for details."
205- exit 1
122+ if [ -d " $OPENLINEAGE_DIRECTORY " /spec ]; then
123+ find " $OPENLINEAGE_DIRECTORY " /spec -type f \( -name ' *Facet.json' -o -name ' OpenLineage.json' \) -exec cp -t " $DEST_DIR " {} +
206124fi
207- EOF
208-
209- # Create staging models
210- cat > dbt_project/models/staging/stg_customers.sql << EOF
211- SELECT
212- customer_id,
213- UPPER(name) as customer_name,
214- LOWER(email) as email,
215- signup_date,
216- status
217- FROM {{ ref('customers') }}
218- WHERE status = 'active'
219- EOF
220-
221- cat > dbt_project/models/staging/stg_orders.sql << EOF
222- SELECT
223- order_id,
224- customer_id,
225- product,
226- amount,
227- order_date
228- FROM {{ ref('orders') }}
229- EOF
230-
231- # Create mart model
232- mkdir -p dbt_project/models/marts
233- cat > dbt_project/models/marts/customer_orders.sql << EOF
234- SELECT
235- c.customer_id,
236- c.customer_name,
237- COUNT(o.order_id) as total_orders,
238- SUM(o.amount) as total_spent
239- FROM {{ ref('stg_customers') }} c
240- LEFT JOIN {{ ref('stg_orders') }} o
241- ON c.customer_id = o.customer_id
242- GROUP BY c.customer_id, c.customer_name
243- EOF
244-
245- echo " Running dbt with OpenLineage..."
246- cd dbt_project
247-
248- # Install dependencies and run dbt
249- dbt deps --no-version-check || echo " No packages to install"
250- dbt seed --no-version-check
251- dbt run --no-version-check
252-
253- cd ..
254-
255- echo " dbt execution completed. Checking for generated events..."
256-
257- # Check the events file
258- if [[ -f " events/openlineage_events.jsonl" ]]; then
259- event_count=$( wc -l < " events/openlineage_events.jsonl" )
260- echo " Generated $event_count OpenLineage events"
261- echo " Events saved to: events/openlineage_events.jsonl"
262- else
263- echo " Warning: No OpenLineage events file generated at events/openlineage_events.jsonl"
264- echo " Creating minimal event file for testing..."
265- mkdir -p " events"
266- echo ' {"eventType": "COMPLETE", "eventTime": "2023-01-01T00:00:00Z", "run": {"runId": "test-run-id"}, "job": {"namespace": "dbt://local", "name": "test-job"}, "inputs": [], "outputs": [], "schemaURL": "https://openlineage.io/spec/' $OPENLINEAGE_RELEASE ' /OpenLineage.json#/$defs/RunEvent"}' > " events/openlineage_events.jsonl"
125+ if [ -d " $OPENLINEAGE_DIRECTORY " /integration/common/openlineage ]; then
126+ find " $OPENLINEAGE_DIRECTORY " /integration/common/openlineage -type f -iname ' *facet.json' -exec cp -t " $DEST_DIR " {} +
267127fi
268128
269- echo " EVENT VALIDATION FOR SPEC VERSION $OPENLINEAGE_RELEASE "
129+ if [ -z " $( ls -A " $DEST_DIR " ) " ]; then
130+ echo " Cannot collect OpenLineage specs"
131+ exit 1
132+ fi
270133
271- pip install -r ../../scripts/requirements.txt
134+ # pip install -r ../../scripts/requirements.txt
272135
273136python ../../scripts/validate_ol_events.py \
274- --event_base_dir=" events " \
275- --spec_dirs =" $OL_SPEC_DIRECTORIES " \
137+ --event_base_dir=" $PRODUCER_OUTPUT_EVENTS_DIR " \
138+ --spec_base_dir =" $SPECS_BASE_DIR " \
276139--target=" $REPORT_PATH " \
277- --component=" dbt_producer " \
140+ --component=" scenarios " \
278141--producer_dir=. \
279142--openlineage_version=" $OPENLINEAGE_RELEASE "
280143
0 commit comments