Skip to content

Commit 282b9ed

Browse files
authored
Convert TestLocalStateStaleness to an acceptance test (#3010)
## Why <!-- Why are these changes needed? Provide the context that the reviewer might be missing. For example, were there any decisions behind the change that are not reflected in the code itself? --> A change in the series of changes for converting integration tests into acceptance tests. This will allow for easier testing of various backing solutions for bundle deployment
1 parent 2f0a9e3 commit 282b9ed

File tree

6 files changed

+107
-64
lines changed

6 files changed

+107
-64
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
bundle:
2+
name: local-state-staleness-test
3+
4+
workspace:
5+
root_path: "~/.bundle/local-state-staleness-test-$UNIQUE_NAME"
6+
7+
resources:
8+
jobs:
9+
test_job:
10+
name: test-job-basic-$UNIQUE_NAME
11+
tasks:
12+
- task_key: my_notebook_task
13+
new_cluster:
14+
num_workers: 1
15+
spark_version: $DEFAULT_SPARK_VERSION
16+
node_type_id: $NODE_TYPE_ID
17+
spark_python_task:
18+
python_file: ./hello_world.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("Hello world!")
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
=== Step 1: Deploy bundle A
3+
>>> [CLI] bundle deploy --force-lock --auto-approve
4+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/local-state-staleness-test-[UNIQUE_NAME]/files...
5+
Deploying resources...
6+
Updating deployment state...
7+
Deployment complete!
8+
9+
=== Step 2: Deploy bundle B
10+
>>> [CLI] bundle deploy --force-lock --auto-approve
11+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/local-state-staleness-test-[UNIQUE_NAME]/files...
12+
Deploying resources...
13+
Updating deployment state...
14+
Deployment complete!
15+
16+
=== Step 3: Deploy bundle A again (should use remote state)
17+
>>> [CLI] bundle deploy --force-lock --auto-approve
18+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/local-state-staleness-test-[UNIQUE_NAME]/files...
19+
Deploying resources...
20+
Updating deployment state...
21+
Deployment complete!
22+
23+
=== Step 4: Verify only one job exists
24+
{
25+
"name": "test-job-basic-[UNIQUE_NAME]",
26+
"id": [NUMID]
27+
}
28+
29+
=== Cleanup - destroy bundle A (bundle B does not have an active deployment)
30+
31+
>>> [CLI] bundle destroy --auto-approve
32+
The following resources will be deleted:
33+
delete job test_job
34+
35+
All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/local-state-staleness-test-[UNIQUE_NAME]
36+
37+
Deleting files...
38+
Destroy complete!
39+
40+
>>> rm -rf [TEST_TMP_DIR]/bundle_a
41+
42+
>>> rm -rf [TEST_TMP_DIR]/bundle_b
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# The approach for this test is as follows:
2+
# 1) First deploy of bundle instance A
3+
# 2) First deploy of bundle instance B
4+
# 3) Second deploy of bundle instance A
5+
# Because of deploy (2), the locally cached state of bundle instance A should be stale.
6+
# Then for deploy (3), it must use the remote state over the stale local state.
7+
8+
envsubst < databricks.yml.tmpl > databricks.yml
9+
10+
# Create two separate bundle directories to simulate two bundle instances
11+
BUNDLE_A_DIR="$TEST_TMP_DIR/bundle_a"
12+
BUNDLE_B_DIR="$TEST_TMP_DIR/bundle_b"
13+
14+
mkdir -p "$BUNDLE_A_DIR" "$BUNDLE_B_DIR"
15+
16+
# Copy bundle files to both directories
17+
cp databricks.yml hello_world.py "$BUNDLE_A_DIR/"
18+
cp databricks.yml hello_world.py "$BUNDLE_B_DIR/"
19+
20+
cleanup() {
21+
title "Cleanup - destroy bundle A (bundle B does not have an active deployment)\n"
22+
cd "$BUNDLE_A_DIR" || exit
23+
trace "$CLI" bundle destroy --auto-approve
24+
25+
trace rm -rf "$BUNDLE_A_DIR"
26+
trace rm -rf "$BUNDLE_B_DIR"
27+
}
28+
trap cleanup EXIT
29+
30+
title "Step 1: Deploy bundle A"
31+
cd "$BUNDLE_A_DIR"
32+
trace "$CLI" bundle deploy --force-lock --auto-approve
33+
34+
title "Step 2: Deploy bundle B"
35+
cd "$BUNDLE_B_DIR"
36+
trace "$CLI" bundle deploy --force-lock --auto-approve
37+
38+
title "Step 3: Deploy bundle A again (should use remote state)"
39+
cd "$BUNDLE_A_DIR"
40+
trace "$CLI" bundle deploy --force-lock --auto-approve
41+
42+
title "Step 4: Verify only one job exists\n"
43+
cd "$BUNDLE_A_DIR"
44+
"$CLI" jobs list -o json | jq -r --arg name "test-job-basic-${UNIQUE_NAME}" '.[] | select(.settings.name == $name) | {name: .settings.name, id: .job_id}'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cloud = true
2+
Local = true

integration/bundle/local_state_staleness_test.go

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)