Skip to content

Commit 1026506

Browse files
authored
acc: run bundle/run/app-with-job locally (databricks#5820)
## Summary Convert `acceptance/bundle/run/app-with-job` to run against the local testserver in addition to cloud. The test drives the full app lifecycle (deploy → `bundle run` → `apps stop` → re-run), which the fake Apps API did not model faithfully. Make the testserver app status mirror cloud: - `AppsUpsert`: a `no_compute` app (how `bundle deploy` always creates apps) now reports `app_status` `UNAVAILABLE` until started, instead of `RUNNING`. - `AppsStart`: starting the compute also brings the application up (`RUNNING`). - `AppsStop`: stopping the compute takes the application down (`UNAVAILABLE`) and returns the cloud "Start the app compute to deploy the app." message. Regenerate the goldens of sibling local apps tests, whose informational `App is in RUNNING state` bundle-run log now correctly reads `App is in UNAVAILABLE state` for a not-yet-started `no_compute` app. ## Why This PR is part of the conversion to local tests.
1 parent eab4e00 commit 1026506

9 files changed

Lines changed: 35 additions & 16 deletions

File tree

acceptance/apps/deploy/bundle-no-args-with-flags/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Deploying resources...
66
Updating deployment state...
77
Deployment complete!
88
✓ Getting the status of the app myapp
9-
✓ App is in RUNNING state
9+
✓ App is in UNAVAILABLE state
1010
✓ App compute is in STOPPED state
1111
✓ Starting the app myapp
1212
✓ App is starting...

acceptance/apps/deploy/bundle-no-args/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Deploying resources...
66
Updating deployment state...
77
Deployment complete!
88
✓ Getting the status of the app myapp
9-
✓ App is in RUNNING state
9+
✓ App is in UNAVAILABLE state
1010
✓ App compute is in STOPPED state
1111
✓ Starting the app myapp
1212
✓ App is starting...

acceptance/bundle/apps/git_source/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Deployment complete!
2424

2525
>>> [CLI] bundle run my_app
2626
✓ Getting the status of the app [APP_NAME]
27-
✓ App is in RUNNING state
27+
✓ App is in UNAVAILABLE state
2828
✓ App compute is in STOPPED state
2929
✓ Starting the app [APP_NAME]
3030
✓ App is starting...

acceptance/bundle/generate/app_not_yet_deployed/output.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
>>> [CLI] apps create my-app --no-compute --no-wait
33
{
44
"app_status": {
5-
"message": "Application is running.",
6-
"state": "RUNNING"
5+
"message": "App status is unavailable.",
6+
"state": "UNAVAILABLE"
77
},
88
"compute_size": "MEDIUM",
99
"compute_status": {

acceptance/bundle/resources/apps/immutable/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Deployment complete!
77

88
>>> [CLI] bundle run my_app
99
✓ Getting the status of the app my-immutable-app
10-
✓ App is in RUNNING state
10+
✓ App is in UNAVAILABLE state
1111
✓ App compute is in STOPPED state
1212
✓ Starting the app my-immutable-app
1313
✓ App is starting...

acceptance/bundle/resources/apps/resource-refs/output.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Deployment complete!
77

88
>>> [CLI] bundle run data_app
99
✓ Getting the status of the app data-app
10-
✓ App is in RUNNING state
10+
✓ App is in UNAVAILABLE state
1111
✓ App compute is in STOPPED state
1212
✓ Starting the app data-app
1313
✓ App is starting...

acceptance/bundle/run/app-with-job/out.test.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/bundle/run/app-with-job/test.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Local = false
1+
Local = true
22

33
#
44
# On June 18 2025 it was taking:

libs/testserver/apps.go

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import (
1111
"github.com/databricks/databricks-sdk-go/service/iam"
1212
)
1313

14+
const (
15+
appStatusRunningMessage = "App has status: App is running"
16+
appStatusUnavailableMessage = "App status is unavailable."
17+
)
18+
1419
func (s *FakeWorkspace) AppsCreateUpdate(req Request, name string) Response {
1520
var updateReq apps.AsyncUpdateAppRequest
1621
if err := json.Unmarshal(req.Body, &updateReq); err != nil {
@@ -154,6 +159,11 @@ func (s *FakeWorkspace) AppsStart(_ Request, name string) Response {
154159
State: apps.ComputeStateActive,
155160
Message: "App compute is active.",
156161
}
162+
// Starting the compute brings the application up.
163+
app.AppStatus = &apps.ApplicationStatus{
164+
State: "RUNNING",
165+
Message: appStatusRunningMessage,
166+
}
157167
s.Apps[name] = app
158168

159169
return Response{Body: app}
@@ -169,7 +179,12 @@ func (s *FakeWorkspace) AppsStop(_ Request, name string) Response {
169179

170180
app.ComputeStatus = &apps.ComputeStatus{
171181
State: apps.ComputeStateStopped,
172-
Message: "App compute is stopped.",
182+
Message: "Start the app compute to deploy the app.",
183+
}
184+
// Stopping the compute takes the application down.
185+
app.AppStatus = &apps.ApplicationStatus{
186+
State: "UNAVAILABLE",
187+
Message: appStatusUnavailableMessage,
173188
}
174189
s.Apps[name] = app
175190

@@ -215,18 +230,22 @@ func (s *FakeWorkspace) AppsUpsert(req Request, name string) Response {
215230
}
216231
}
217232

218-
app.AppStatus = &apps.ApplicationStatus{
219-
State: "RUNNING",
220-
Message: "Application is running.",
221-
}
222-
223-
// Respect no_compute query param: if true, start the app in STOPPED state.
233+
// A no_compute app is created without running compute, so on cloud it
234+
// reports an UNAVAILABLE application status until it is started.
224235
if req.URL.Query().Get("no_compute") == "true" {
236+
app.AppStatus = &apps.ApplicationStatus{
237+
State: "UNAVAILABLE",
238+
Message: appStatusUnavailableMessage,
239+
}
225240
app.ComputeStatus = &apps.ComputeStatus{
226241
State: apps.ComputeStateStopped,
227242
Message: "App compute is stopped.",
228243
}
229244
} else {
245+
app.AppStatus = &apps.ApplicationStatus{
246+
State: "RUNNING",
247+
Message: "Application is running.",
248+
}
230249
app.ComputeStatus = &apps.ComputeStatus{
231250
State: "ACTIVE",
232251
Message: "App compute is active.",

0 commit comments

Comments
 (0)