-
Notifications
You must be signed in to change notification settings - Fork 91
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
acceptance/bundle/local_state_staleness/databricks.yml.tmpl
This file contains hidden or 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,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 |
This file contains hidden or 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 @@ | ||
print("Hello world!") |
This file contains hidden or 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,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 |
This file contains hidden or 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,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" | ||
"$CLI" jobs list -o json | jq -r --arg name "test-job-basic-${UNIQUE_NAME}" '.[] | select(.settings.name == $name) | {name: .settings.name, id: .job_id}' |
This file contains hidden or 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,2 @@ | ||
Cloud = true | ||
Local = true |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cd ..
?