Skip to content

Commit 5833370

Browse files
acceptance/bundle/dms: cover deployment-history version recording
Local acceptance test (RecordRequests) for deploys with experimental.record_deployment_history enabled, asserting the DMS request sequence in both cases: - create-deployment: GetDeployment returns 404, so the CLI calls CreateDeployment and CreateVersion with version_id=1. - existing-deployment: GetDeployment returns last_version_id=3, so the CLI skips CreateDeployment and calls CreateVersion with version_id=4. The DMS endpoints are stubbed via [[Server]]; the engine is pinned to direct. Co-authored-by: Isaac
1 parent 825f83a commit 5833370

11 files changed

Lines changed: 148 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
bundle:
2+
name: dms-create
3+
4+
experimental:
5+
record_deployment_history: true
6+
7+
resources:
8+
jobs:
9+
foo:
10+
name: foo-job

acceptance/bundle/dms/create-deployment/out.test.toml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/dms-create/default/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> print_requests.py --get //api/2.0/bundle
9+
{
10+
"method": "GET",
11+
"path": "/api/2.0/bundle/deployments/[UUID]"
12+
}
13+
{
14+
"method": "POST",
15+
"path": "/api/2.0/bundle/deployments",
16+
"q": {
17+
"deployment_id": "[UUID]"
18+
},
19+
"body": {
20+
"target_name": "default"
21+
}
22+
}
23+
{
24+
"method": "POST",
25+
"path": "/api/2.0/bundle/deployments/[UUID]/versions",
26+
"q": {
27+
"version_id": "1"
28+
},
29+
"body": {
30+
"cli_version": "[DEV_VERSION]",
31+
"target_name": "default",
32+
"version_type": "VERSION_TYPE_DEPLOY"
33+
}
34+
}
35+
{
36+
"method": "POST",
37+
"path": "/api/2.0/bundle/deployments/[UUID]/versions/1/complete",
38+
"body": {
39+
"completion_reason": "VERSION_COMPLETE_SUCCESS"
40+
}
41+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trace $CLI bundle deploy
2+
trace print_requests.py --get //api/2.0/bundle
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# No deployment exists yet: GetDeployment returns 404, so the CLI calls
2+
# CreateDeployment and then CreateVersion with version_id=1.
3+
[[Server]]
4+
Pattern = "GET /api/2.0/bundle/deployments/{id}"
5+
Response.StatusCode = 404
6+
Response.Body = '''
7+
{"error_code": "NOT_FOUND", "message": "deployment does not exist"}
8+
'''
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
bundle:
2+
name: dms-existing
3+
4+
experimental:
5+
record_deployment_history: true
6+
7+
resources:
8+
jobs:
9+
foo:
10+
name: foo-job

acceptance/bundle/dms/existing-deployment/out.test.toml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
>>> [CLI] bundle deploy
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/dms-existing/default/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
7+
8+
>>> print_requests.py --get //api/2.0/bundle
9+
{
10+
"method": "GET",
11+
"path": "/api/2.0/bundle/deployments/[UUID]"
12+
}
13+
{
14+
"method": "POST",
15+
"path": "/api/2.0/bundle/deployments/[UUID]/versions",
16+
"q": {
17+
"version_id": "4"
18+
},
19+
"body": {
20+
"cli_version": "[DEV_VERSION]",
21+
"target_name": "default",
22+
"version_type": "VERSION_TYPE_DEPLOY"
23+
}
24+
}
25+
{
26+
"method": "POST",
27+
"path": "/api/2.0/bundle/deployments/[UUID]/versions/4/complete",
28+
"body": {
29+
"completion_reason": "VERSION_COMPLETE_SUCCESS"
30+
}
31+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trace $CLI bundle deploy
2+
trace print_requests.py --get //api/2.0/bundle
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# A deployment already exists with last_version_id=3: GetDeployment returns 200,
2+
# so the CLI skips CreateDeployment and calls CreateVersion with version_id=4.
3+
[[Server]]
4+
Pattern = "GET /api/2.0/bundle/deployments/{id}"
5+
Response.Body = '''
6+
{"name": "deployments/test", "target_name": "default", "last_version_id": "3"}
7+
'''

0 commit comments

Comments
 (0)