Skip to content

Commit 7387c94

Browse files
dinagravesleahecoleglasnt
authored
Using check_call to expose underlying error messages (GoogleCloudPlatform#7140)
* Using check_call to expose underlying error messages * Check call Co-authored-by: Leah E. Cole <6719667+leahecole@users.noreply.github.com> Co-authored-by: Katie McLaughlin <glasnt@google.com>
1 parent 5eb4cfb commit 7387c94

File tree

11 files changed

+85
-119
lines changed

11 files changed

+85
-119
lines changed

memorystore/redis/cloud_run_deployment/e2e_test.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,15 @@ def redis_host():
5959
def container_image():
6060
# Build container image for Cloud Run deployment
6161
image_name = f"gcr.io/{PROJECT}/test-visit-count-{SUFFIX}"
62-
subprocess.run(
62+
subprocess.check_call(
6363
[
6464
"cp",
6565
"cloud_run_deployment/Dockerfile",
6666
".",
67-
], check=True
67+
]
6868
)
69-
subprocess.run(
69+
70+
subprocess.check_call(
7071
[
7172
"gcloud",
7273
"builds",
@@ -75,14 +76,15 @@ def container_image():
7576
image_name,
7677
"--project",
7778
PROJECT,
78-
], check=True
79+
]
7980
)
81+
8082
yield image_name
8183

82-
subprocess.run(["rm", "Dockerfile"], check=True)
84+
subprocess.check_call(["rm", "Dockerfile"])
8385

8486
# Delete container image
85-
subprocess.run(
87+
subprocess.check_call(
8688
[
8789
"gcloud",
8890
"container",
@@ -92,15 +94,15 @@ def container_image():
9294
"--quiet",
9395
"--project",
9496
PROJECT,
95-
], check=True
97+
]
9698
)
9799

98100

99101
@pytest.fixture
100102
def deployed_service(container_image, redis_host):
101103
# Deploy image to Cloud Run
102104
service_name = f"test-visit-count-{SUFFIX}"
103-
subprocess.run(
105+
subprocess.check_call(
104106
[
105107
"gcloud",
106108
"run",
@@ -117,12 +119,12 @@ def deployed_service(container_image, redis_host):
117119
f"REDISHOST={redis_host},REDISPORT=6379",
118120
"--project",
119121
PROJECT,
120-
], check=True
122+
]
121123
)
122124
yield service_name
123125

124126
# Delete Cloud Run service
125-
subprocess.run(
127+
subprocess.check_call(
126128
[
127129
"gcloud",
128130
"run",
@@ -134,7 +136,7 @@ def deployed_service(container_image, redis_host):
134136
"--quiet",
135137
"--project",
136138
PROJECT,
137-
], check=True
139+
]
138140
)
139141

140142

run/django/test/e2e_test.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def deployed_service() -> str:
8484
if SAMPLE_VERSION:
8585
substitutions.append(f",_VERSION={SAMPLE_VERSION}")
8686

87-
subprocess.run(
87+
subprocess.check_call(
8888
[
8989
"gcloud",
9090
"builds",
@@ -95,8 +95,7 @@ def deployed_service() -> str:
9595
"./test/e2e_test_setup.yaml",
9696
"--substitutions",
9797
]
98-
+ substitutions,
99-
check=True,
98+
+ substitutions
10099
)
101100

102101
yield SERVICE
@@ -117,7 +116,7 @@ def deployed_service() -> str:
117116
if SAMPLE_VERSION:
118117
substitutions.append(f"_SAMPLE_VERSION={SAMPLE_VERSION}")
119118

120-
subprocess.run(
119+
subprocess.check_call(
121120
[
122121
"gcloud",
123122
"builds",
@@ -128,8 +127,7 @@ def deployed_service() -> str:
128127
"./test/e2e_test_cleanup.yaml",
129128
"--substitutions",
130129
]
131-
+ substitutions,
132-
check=True,
130+
+ substitutions
133131
)
134132

135133

run/filesystem/e2e_test.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def deployed_service():
3636
connector = os.environ['CONNECTOR']
3737
ip_address = os.environ['IP_ADDRESS']
3838

39-
subprocess.run(
39+
subprocess.check_call(
4040
[
4141
'gcloud',
4242
'builds',
@@ -46,13 +46,12 @@ def deployed_service():
4646
'--project',
4747
PROJECT,
4848
f'--substitutions=_SERVICE_NAME={service_name},_FILESTORE_IP_ADDRESS={ip_address},_CONNECTOR={connector}'
49-
],
50-
check=True,
49+
]
5150
)
5251

5352
yield service_name
5453

55-
subprocess.run(
54+
subprocess.check_call(
5655
[
5756
'gcloud',
5857
'run',
@@ -64,8 +63,7 @@ def deployed_service():
6463
'--quiet',
6564
'--project',
6665
PROJECT,
67-
],
68-
check=True,
66+
]
6967
)
7068

7169

run/hello-broken/e2e_test.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@pytest.fixture
3333
def container_image():
3434
# Build container image for Cloud Run deployment
35-
subprocess.run(
35+
subprocess.check_call(
3636
[
3737
"gcloud",
3838
"builds",
@@ -42,14 +42,13 @@ def container_image():
4242
"--project",
4343
PROJECT,
4444
"--quiet",
45-
],
46-
check=True,
45+
]
4746
)
4847

4948
yield IMAGE_NAME
5049

5150
# Delete container image
52-
subprocess.run(
51+
subprocess.check_call(
5352
[
5453
"gcloud",
5554
"container",
@@ -59,16 +58,15 @@ def container_image():
5958
"--quiet",
6059
"--project",
6160
PROJECT,
62-
],
63-
check=True,
61+
]
6462
)
6563

6664

6765
@pytest.fixture
6866
def deployed_service(container_image):
6967
# Deploy image to Cloud Run
7068
service_name = f"hello-{SUFFIX}"
71-
subprocess.run(
69+
subprocess.check_call(
7270
[
7371
"gcloud",
7472
"run",
@@ -81,13 +79,12 @@ def deployed_service(container_image):
8179
"--region=us-central1",
8280
"--platform=managed",
8381
"--no-allow-unauthenticated",
84-
],
85-
check=True,
82+
]
8683
)
8784

8885
yield service_name
8986

90-
subprocess.run(
87+
subprocess.check_call(
9188
[
9289
"gcloud",
9390
"run",
@@ -99,8 +96,7 @@ def deployed_service(container_image):
9996
"--quiet",
10097
"--project",
10198
PROJECT,
102-
],
103-
check=True,
99+
]
104100
)
105101

106102

run/helloworld/e2e_test.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
@pytest.fixture
3333
def container_image():
3434
# Build container image for Cloud Run deployment
35-
subprocess.run(
35+
subprocess.check_call(
3636
[
3737
"gcloud",
3838
"builds",
@@ -42,14 +42,13 @@ def container_image():
4242
"--project",
4343
PROJECT,
4444
"--quiet",
45-
],
46-
check=True,
45+
]
4746
)
4847

4948
yield IMAGE_NAME
5049

5150
# Delete container image
52-
subprocess.run(
51+
subprocess.check_call(
5352
[
5453
"gcloud",
5554
"container",
@@ -59,16 +58,15 @@ def container_image():
5958
"--quiet",
6059
"--project",
6160
PROJECT,
62-
],
63-
check=True,
61+
]
6462
)
6563

6664

6765
@pytest.fixture
6866
def deployed_service(container_image):
6967
# Deploy image to Cloud Run
7068
service_name = f"helloworld-{SUFFIX}"
71-
subprocess.run(
69+
subprocess.check_call(
7270
[
7371
"gcloud",
7472
"run",
@@ -82,13 +80,12 @@ def deployed_service(container_image):
8280
"--platform=managed",
8381
"--no-allow-unauthenticated",
8482
"--set-env-vars=NAME=Test",
85-
],
86-
check=True,
83+
]
8784
)
8885

8986
yield service_name
9087

91-
subprocess.run(
88+
subprocess.check_call(
9289
[
9390
"gcloud",
9491
"run",
@@ -100,8 +97,7 @@ def deployed_service(container_image):
10097
"--quiet",
10198
"--project",
10299
PROJECT,
103-
],
104-
check=True,
100+
]
105101
)
106102

107103

run/idp-sql/test/e2e_test.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def deployed_service() -> str:
106106
if SAMPLE_VERSION:
107107
substitutions.append(f"_SAMPLE_VERSION={SAMPLE_VERSION}")
108108

109-
subprocess.run(
109+
subprocess.check_call(
110110
[
111111
"gcloud",
112112
"builds",
@@ -117,8 +117,7 @@ def deployed_service() -> str:
117117
"./test/e2e_test_setup.yaml",
118118
"--substitutions",
119119
]
120-
+ substitutions,
121-
check=True,
120+
+ substitutions
122121
)
123122

124123
service_url = (
@@ -159,7 +158,7 @@ def deployed_service() -> str:
159158
if SAMPLE_VERSION:
160159
substitutions.append(f"_SAMPLE_VERSION={SAMPLE_VERSION}")
161160

162-
subprocess.run(
161+
subprocess.check_call(
163162
[
164163
"gcloud",
165164
"builds",
@@ -170,8 +169,7 @@ def deployed_service() -> str:
170169
"./test/e2e_test_cleanup.yaml",
171170
"--substitutions",
172171
]
173-
+ substitutions,
174-
check=True,
172+
+ substitutions
175173
)
176174

177175

0 commit comments

Comments
 (0)