Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 16 additions & 94 deletions .github/workflows/producer_hive_dataproc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,10 @@ jobs:
run: |
scenarios=$(./scripts/get_valid_test_scenarios.sh "producer/hive_dataproc/scenarios/" ${{ inputs.component_release }} ${{ inputs.ol_release }} )
[[ "$scenarios" == "" ]] || echo "scenarios=$scenarios" >> $GITHUB_OUTPUT
echo "openlineage_cluster_suffix=$(echo '${{ inputs.ol_release }}' | sed 's/\.//g')" >> $GITHUB_OUTPUT
echo "component_cluster_suffix=$(echo '${{ inputs.component_release }}' | sed 's/\.//g')" >> $GITHUB_OUTPUT
case "${{ inputs.component_release }}" in
"3.1.3")
echo "hive_short=3" >> $GITHUB_OUTPUT
echo "dataproc_version=2.1-debian11" >> $GITHUB_OUTPUT
;;
*)
echo "hive version ${{ inputs.component_release }} not supported"
exit 1
;;
esac

echo "cluster_name=hive-dataproc-producer-test-$(echo '${{ inputs.component_release }}' | sed 's/\.//g')-$(echo '${{ inputs.ol_release }}' | sed 's/\.//g')-${{ github.run_id }}" >> "$GITHUB_OUTPUT"
# the cluster settings per Hive release are in producer/hive_dataproc/runner/cluster.json
jq -e --arg v '${{ inputs.component_release }}' 'has($v)' producer/hive_dataproc/runner/cluster.json > /dev/null \
|| { echo "hive version ${{ inputs.component_release }} not supported"; exit 1; }

- name: GCP authorization
id: gcp-auth
Expand Down Expand Up @@ -77,15 +68,6 @@ jobs:
gcs-path: "gs://open-lineage-e2e/jars"
credentials: ${{ steps.gcp-auth.outputs.credentials_file_path }}

- name: Upload initialization actions to GCS
id: upload-initialization-actions
if: ${{ steps.init.outputs.scenarios }}
uses: ./.github/actions/upload_artifacts
with:
local-file-path: producer/hive_dataproc/runner/get_hive_openlineage_jars.sh
gcs-path: "gs://open-lineage-e2e/scripts"
credentials: ${{ steps.gcp-auth.outputs.credentials_file_path }}

- name: Set up Python 3.11
if: ${{ steps.init.outputs.scenarios }}
uses: actions/setup-python@v5
Expand All @@ -106,32 +88,15 @@ jobs:
if: ${{ steps.init.outputs.scenarios }}
uses: ./.github/actions/dataproc_cluster
with:
cluster-name: "hive-dataproc-producer-test-${{steps.init.outputs.component_cluster_suffix}}-${{ steps.init.outputs.openlineage_cluster_suffix }}-${{ github.run_id }}"
cluster-name: ${{ steps.init.outputs.cluster_name }}
project-id: gcp-open-lineage-testing
region: us-west1
# the GCS transport: runner/create_cluster.sh's default, a fixed snapshot (released 1.40.0-1.55.0 break Hive)
create-command: |
metadata=''
# Temporary: released transports-gcs 1.40.0-1.55.0 break Hive on Dataproc (half-relocated Woodstox stops
# HiveServer2, the bundled Conscrypt native library aborts the Tez AM). This snapshot has both fixed; go back
# to uploading the matching transport (get-ol-artifacts' gcs output) once a release has the fix (1.56.0?).
metadata+='GCS_TRANSPORT_JAR=gs://open-lineage-e2e/jars/transports-gcs-1.56.0-SNAPSHOT-conscrypt-fix.jar'
metadata+=',OPENLINEAGE_HIVE_URL=${{ steps.upload-hive-integration.outputs.uploaded-file }}'

properties=''
properties+='hive:hive.exec.post.hooks=io.openlineage.hive.hooks.HiveOpenLineageHook'
properties+=',hive:hive.conf.validation=false'
properties+=',hive:hive.server2.logging.operation.level=VERBOSE'
properties+=',hive:hive.root.logger=DEBUG'
properties+=',hive:hive.log.explain.output=true'

python dev/dataproc/dataproc_workflow.py create-cluster \
--project-id "gcp-open-lineage-testing" \
--region "us-west1" \
--cluster-name "hive-dataproc-producer-test-${{steps.init.outputs.component_cluster_suffix}}-${{ steps.init.outputs.openlineage_cluster_suffix }}-${{ github.run_id }}" \
--dataproc-image-version ${{ steps.init.outputs.dataproc_version }} \
--cluster-properties "$properties" \
--metadata "$metadata" \
--initialization-actions "${{ steps.upload-initialization-actions.outputs.uploaded-file }}" \
producer/hive_dataproc/runner/create_cluster.sh \
--hive-release "${{ inputs.component_release }}" \
--cluster-name "${{ steps.init.outputs.cluster_name }}" \
--hive-jar "${{ steps.upload-hive-integration.outputs.uploaded-file }}" \
--credentials-file "${{ steps.gcp-auth.outputs.credentials_file_path }}"

- name: Set producer output event dir
Expand All @@ -143,55 +108,12 @@ jobs:
- name: Run producer jobs and create OL events
if: ${{ steps.init.outputs.scenarios }}
id: run-producer
run: |
set -e
IFS=';' read -ra scenarios <<< "${{ steps.init.outputs.scenarios }}"

properties=''
properties+='hive.extraListeners=io.openlineage.hive.hooks.HiveOpenLineageHook'
properties+=',hive.sql.warehouse.dir=/tmp/warehouse'
properties+=',hive.openlineage.transport.type=gcs'
properties+=',hive.scenario.suffix=${{steps.init.outputs.component_cluster_suffix}}-${{steps.init.outputs.openlineage_cluster_suffix}}'

# one entry per scenario, [{scenario, state, job_id}] as written by the spark runner; a failed query fails
# its scenario in validation instead of stopping the other scenarios
status_file="${{ steps.set-producer-output.outputs.event_dir }}/status.json"
mkdir -p "${{ steps.set-producer-output.outputs.event_dir }}"
echo '[]' > "$status_file"

for scenario in "${scenarios[@]}"
do
echo "Getting script for scenario $scenario"
query_file=$(find "producer/hive_dataproc/scenarios/$scenario/test/" -maxdepth 1 -type f -name "*.sql" | head -n 1)
query=$(cat $query_file)

echo "Running hive job for scenario: $scenario"

properties=''
properties+='hive.openlineage.transport.type=gcs'
properties+=",hive.openlineage.transport.bucketName=open-lineage-e2e"
properties+=",hive.openlineage.transport.fileNamePrefix=events/$scenario/$(date +%s%3N)/"

if python dev/dataproc/dataproc_workflow.py run-hive-query \
--project-id gcp-open-lineage-testing \
--region us-west1 \
--cluster-name "hive-dataproc-producer-test-${{steps.init.outputs.component_cluster_suffix}}-${{ steps.init.outputs.openlineage_cluster_suffix }}-${{ github.run_id }}" \
--query "$query" \
--credentials-file "${{ steps.gcp-auth.outputs.credentials_file_path }}" \
--output-directory "${{ steps.set-producer-output.outputs.event_dir }}/$scenario" \
--properties "$properties"
then
state=DONE
echo "Finished running hive job for scenario: $scenario"
else
state=FAILED
echo "::warning::hive job failed for scenario $scenario"
fi
jq --arg scenario "$scenario" --arg state "$state" '. + [{scenario: $scenario, state: $state, job_id: ""}]' \
"$status_file" > "$status_file.tmp" && mv "$status_file.tmp" "$status_file"
done

echo "Finished running all scenarios"
run: |
producer/hive_dataproc/runner/run_scenarios.sh \
--cluster-name "${{ steps.init.outputs.cluster_name }}" \
--scenarios "${{ steps.init.outputs.scenarios }}" \
--events-dir "${{ steps.set-producer-output.outputs.event_dir }}" \
--credentials-file "${{ steps.gcp-auth.outputs.credentials_file_path }}"

- name: Validation
if: ${{ steps.init.outputs.scenarios }}
Expand Down
5 changes: 5 additions & 0 deletions dev/dataproc/dataproc_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,11 @@ async def run_hive_query_command(args):
else:
print("Could not determine bucket or prefix for event files. Skipping download.")

# after the download: a failed query can still have emitted events worth looking at
print(f"Hive job {job_id} ended in state {result['state']}")
if result["state"] != "DONE":
raise SystemExit(f"Hive job {job_id} did not finish successfully (state {result['state']})")


def main():
parser = argparse.ArgumentParser(
Expand Down
1 change: 1 addition & 0 deletions producer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ Producers with a one-command local run, described step by step in their README (
| Producer | Command |
|---|---|
| dbt | `producer/dbt/run_dbt_tests.sh --component-version 1.8.0 --openlineage-version 1.55.0` ([playbook](dbt/README.md#run-locally-as-ci-does)) |
| hive_dataproc | `producer/hive_dataproc/run_hive_dataproc_tests.sh --component-version 3.1.3 --openlineage-version 1.55.0` ([playbook](hive_dataproc/README.md#run-locally-as-ci-does)); needs GCP access |

A new producer starts from `producer/template/run_template_tests.sh` and the sections in `producer/template/README.md`.
101 changes: 98 additions & 3 deletions producer/hive_dataproc/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,101 @@
# Spark Dataproc
# Hive Dataproc

Checks the compatibility of the producer by running the spark jobs on dataproc cluster and then running validation script on the output.
Checks the OpenLineage Hive integration (`openlineage-hive`, a Hive post-execution hook) by running each scenario's
`test/*.sql` as a Hive job on a Dataproc cluster and validating the events the hook writes to GCS.

## Running locally
```
producer/hive_dataproc/
├── scenarios/<scenario>/ config.json, events/ (expected events), test/<query>.sql, scenario.md
├── runner/cluster.json per Hive release: Dataproc image and Hive properties
├── runner/create_cluster.sh creates the cluster with the hook and the GCS transport installed
├── runner/run_scenarios.sh runs the scenarios on a cluster, downloads the events, writes status.json
├── run_hive_dataproc_tests.sh runs everything locally, as CI does
├── versions.json tested Hive and OpenLineage versions
└── dataproc_images.json Dataproc image family per Hive release (the release check watches it for new images)
```

CI (`.github/workflows/producer_hive_dataproc.yml`) runs on pull requests that touch Hive and in the scheduled release
check. It calls the same `runner/` scripts as the local run.

**GCS transport:** released `transports-gcs` 1.40.0–1.55.0 break Hive on Dataproc, so for now the cluster gets a fixed
snapshot (`runner/create_cluster.sh`, `DEFAULT_GCS_TRANSPORT_JAR`) instead of the transport of the OpenLineage release
being tested.

## Run locally, as CI does

Use this to test a new or changed scenario before you commit it. The cluster, the jobs and the validation are the same
as in CI; only the cluster name (yours, with a timestamp) and the credentials differ.

**Prerequisites:** see [`dev/README.md`](../../dev/README.md#prerequisites-for-running-producers-locally): Python 3.11+,
`jq`, `git`, `curl`, the gcloud CLI logged in (`gcloud auth login` and `gcloud auth application-default login`) with
access to `gcp-open-lineage-testing`, or your own project and bucket (`--project`, `--region`, `--bucket`).

**Pick the versions** from `versions.json` (Hive: a key of `runner/cluster.json`; OpenLineage: the latest release, or
the one you're testing). Scenarios only run for the versions in their `config.json`.

**Cost and time:** a cluster (1 master, 2 workers) is created for the run and deleted at the end, also when a step
fails or you press Ctrl-C. Creating it takes about 3 minutes, each scenario about 1 minute.

### One command

From the repository root:

```bash
producer/hive_dataproc/run_hive_dataproc_tests.sh --component-version 3.1.3 --openlineage-version 1.55.0
```

Options (`--help` lists everything):
- `--scenarios 'aggregate_job'` runs only the given scenarios.
- `--hive-jar path/to/openlineage-hive.jar` tests your own build of the integration instead of the release.
- `--keep-cluster` keeps the cluster for more runs; `--cluster-name <name>` then runs on it without creating or deleting
one. Delete it when you're done: `dev/dataproc/delete_cluster.sh --cluster-name <name>`. `dev/dataproc/delete_cluster.sh
--list-mine` lists clusters left behind under your name.
- `--events-dir` and `--report-dir` move the output.

### The same steps by hand

One command per CI step, so you can stop after any of them, look at the output, or re-run just one:

```bash
V=3.1.3 OL=1.55.0 EVENTS=$PWD/hive-dataproc-events-$V-$OL CLUSTER=hive-$USER-test

# "initialize tests": the scenarios valid for the versions
SCENARIOS=$(scripts/get_valid_test_scenarios.sh producer/hive_dataproc/scenarios $V $OL); echo "$SCENARIOS"

# "Install dependencies" (any virtualenv outside the repo; the scripts call `python`)
python3 -m venv ~/.venvs/dataproc && source ~/.venvs/dataproc/bin/activate
pip install -r dev/dataproc/requirements.txt

# "Get OL artifacts" and "Upload openlineage hive integration to GCS"
curl -fsSLO https://repo1.maven.org/maven2/io/openlineage/openlineage-hive/$OL/openlineage-hive-$OL.jar
HIVE_JAR=$(dev/dataproc/gcs_upload.sh openlineage-hive-$OL.jar gs://open-lineage-e2e/jars)

# "Start producer"
producer/hive_dataproc/runner/create_cluster.sh --hive-release $V --cluster-name $CLUSTER --hive-jar "$HIVE_JAR"

# "Run producer jobs and create OL events"
producer/hive_dataproc/runner/run_scenarios.sh --cluster-name $CLUSTER --scenarios "$SCENARIOS" --events-dir "$EVENTS"

# "Validation"
dev/validation/validate_locally.sh --component hive_dataproc --component-version $V --openlineage-version $OL --events-dir "$EVENTS"

# the cluster action's cleanup
dev/dataproc/delete_cluster.sh --cluster-name $CLUSTER
```

### What you get

- `hive-dataproc-events-<V>-<OL>/<scenario>/*.json`: the events the hook wrote (also kept in GCS under
`gs://<bucket>/events/<scenario>/<timestamp>/`).
- `hive-dataproc-events-<V>-<OL>/status.json`: how each scenario's Hive job ended (`DONE`, or e.g. `ERROR` with the
Dataproc job id). A scenario not in `DONE` fails validation with a "producer job" test. To see why, open the job in
the Cloud Console (Dataproc → Jobs) or run `gcloud dataproc jobs describe <job id> --region us-west1`.
- `hive-dataproc-<V>-<OL>-report.json`: the report, with the same name and format as the CI artifact. The script prints
a line per scenario with its status and the tests that didn't pass, and exits 1 if a scenario failed. A test that
doesn't match its expected event lists the differences in its `details`:

```bash
jq '.[].scenarios[] | {name, status, failed: [.tests[] | select(.status == "FAILURE") | {name, details}]}' hive-dataproc-3.1.3-1.55.0-report.json
```

Both outputs are git-ignored when they're in the repository root.
Loading
Loading