8000 Convert TestLocalStateStaleness to an acceptance test by anton-107 · Pull Request #3010 · databricks/cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Convert TestLocalStateStaleness to an acceptance test #3010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 13, 2025
Merged
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
18 changes: 18 additions & 0 deletions acceptance/bundle/local_state_staleness/databricks.yml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
bundle:
name: local-state-staleness-test

workspace:
root_path: "~/.bundle/local-state-staleness-test-$UNIQUE_NAME"

resources:
jobs:
test_job:
name: test-job-basic-$UNIQUE_NAME
tasks:
- task_key: my_notebook_task
new_cluster:
num_workers: 1
spark_version: $DEFAULT_SPARK_VERSION
node_type_id: $NODE_TYPE_ID
spark_python_task:
python_file: ./hello_world.py
1 change: 1 addition & 0 deletions acceptance/bundle/local_state_staleness/hello_world.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("Hello world!")
42 changes: 42 additions & 0 deletions acceptance/bundle/local_state_staleness/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

=== Step 1: Deploy bundle A
>>> [CLI] bundle deploy --force-lock --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/local-state-staleness-test-[UNIQUE_NAME]/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Step 2: Deploy bundle B
>>> [CLI] bundle deploy --force-lock --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/local-state-staleness-test-[UNIQUE_NAME]/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Step 3: Deploy bundle A again (should use remote state)
>>> [CLI] bundle deploy --force-lock --auto-approve
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/local-state-staleness-test-[UNIQUE_NAME]/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Step 4: Verify only one job exists
{
"name": "test-job-basic-[UNIQUE_NAME]",
"id": [NUMID]
}

=== Cleanup - destroy bundle A (bundle B does not have an active deployment)

>>> [CLI] bundle destroy --auto-approve
The following resources will be deleted:
delete job test_job

All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/local-state-staleness-test-[UNIQUE_NAME]

Deleting files...
Destroy complete!

>>> rm -rf [TEST_TMP_DIR]/bundle_a

>>> rm -rf [TEST_TMP_DIR]/bundle_b
44 changes: 44 additions & 0 deletions acceptance/bundle/local_state_staleness/script
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# The approach for this test is as follows:
# 1) First deploy of bundle instance A
# 2) First deploy of bundle instance B
# 3) Second deploy of bundle instance A
# Because of deploy (2), the locally cached state of bundle instance A should be stale.
# Then for deploy (3), it must use the remote state over the stale local state.

envsubst < databricks.yml.tmpl > databricks.yml

# Create two separate bundle directories to simulate two bundle instances
BUNDLE_A_DIR="$TEST_TMP_DIR/bundle_a"
BUNDLE_B_DIR="$TEST_TMP_DIR/bundle_b"

mkdir -p "$BUNDLE_A_DIR" "$BUNDLE_B_DIR"

# Copy bundle files to both directories
cp databricks.yml hello_world.py "$BUNDLE_A_DIR/"
cp databricks.yml hello_world.py "$BUNDLE_B_DIR/"

cleanup() {
title "Cleanup - destroy bundle A (bundle B does not have an active deployment)\n"
cd "$BUNDLE_A_DIR" || exit
trace "$CLI" bundle destroy --auto-approve

trace rm -rf "$BUNDLE_A_DIR"
trace rm -rf "$BUNDLE_B_DIR"
}
trap cleanup EXIT

title "Step 1: Deploy bundle A"
cd "$BUNDLE_A_DIR"
trace "$CLI" bundle deploy --force-lock --auto-approve

title "Step 2: Deploy bundle B"
cd "$BUNDLE_B_DIR"
trace "$CLI" bundle deploy --force-lock --auto-approve

title "Step 3: Deploy bundle A again (should use remote state)"
cd "$BUNDLE_A_DIR"
trace "$CLI" bundle deploy --force-lock --auto-approve

title "Step 4: Verify only one job exists\n"
cd "$BUNDLE_A_DIR"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cd ..?

"$CLI" jobs list -o json | jq -r --arg name "test-job-basic-${UNIQUE_NAME}" '.[] | select(.settings.name == $name) | {name: .settings.name, id: .job_id}'
2 changes: 2 additions & 0 deletions acceptance/bundle/local_state_staleness/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Cloud = true
Local = true
64 changes: 0 additions & 64 deletions integration/bundle/local_state_staleness_test.go

This file was deleted.

Loading
0