Skip to content

Commit 5910251

Browse files
author
Ace Nassri
authored
feat(appengine/standard_python3): print gcloud cmds to improve debugging (#8561)
* feat: print gcloud cmds to improve debugging * blobstore: put response checks BEFORE status code checks * deferred: put response checks BEFORE status code checks * mail: put response checks BEFORE status code checks
1 parent 6627d1e commit 5910251

File tree

9 files changed

+63
-36
lines changed

9 files changed

+63
-36
lines changed

appengine/standard_python3/bundled-services/blobstore/django/main_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def gcloud_cli(command):
3737
3838
Raises Exception with the stderr output of the last attempt on failure.
3939
"""
40+
full_command = f"gcloud {command} --quiet --format=json"
41+
print("Running command:", full_command)
42+
4043
output = subprocess.run(
41-
f"gcloud {command} --quiet --format=json",
44+
full_command,
4245
capture_output=True,
4346
shell=True,
4447
check=True,
@@ -74,8 +77,8 @@ def test_upload_and_view(version):
7477

7578
# Check that version is serving form in home page
7679
response = requests.get(f"https://{version_hostname}/")
77-
assert response.status_code == 200
7880
assert '<form action="' in response.text
81+
assert response.status_code == 200
7982

8083
matches = re.search(r'action="(.*?)"', response.text)
8184
assert matches is not None
@@ -84,5 +87,5 @@ def test_upload_and_view(version):
8487
with open("./main.py", "rb") as f:
8588
response = requests.post(upload_url, files={"file": f})
8689

87-
assert response.status_code == 200
8890
assert b"from google.appengine.api" in response.content
91+
assert response.status_code == 200

appengine/standard_python3/bundled-services/blobstore/flask/main_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def gcloud_cli(command):
3737
3838
Raises Exception with the stderr output of the last attempt on failure.
3939
"""
40+
full_command = f"gcloud {command} --quiet --format=json"
41+
print("Running command:", full_command)
42+
4043
output = subprocess.run(
41-
f"gcloud {command} --quiet --format=json",
44+
full_command,
4245
capture_output=True,
4346
shell=True,
4447
check=True,
@@ -74,8 +77,8 @@ def test_upload_and_view(version):
7477

7578
# Check that version is serving form in home page
7679
response = requests.get(f"https://{version_hostname}/")
77-
assert response.status_code == 200
7880
assert '<form action="' in response.text
81+
assert response.status_code == 200
7982

8083
matches = re.search(r'action="(.*?)"', response.text)
8184
assert matches is not None
@@ -84,5 +87,5 @@ def test_upload_and_view(version):
8487
with open("./main.py", "rb") as f:
8588
response = requests.post(upload_url, files={"file": f})
8689

87-
assert response.status_code == 200
8890
assert b"from google.appengine.api" in response.content
91+
assert response.status_code == 200

appengine/standard_python3/bundled-services/blobstore/wsgi/main_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,11 @@ def gcloud_cli(command):
3838
3939
Raises Exception with the stderr output of the last attempt on failure.
4040
"""
41+
full_command = f"gcloud {command} --quiet --format=json"
42+
print("Running command:", full_command)
43+
4144
output = subprocess.run(
42-
f"gcloud {command} --quiet --format=json",
45+
full_command,
4346
capture_output=True,
4447
shell=True,
4548
check=True,
@@ -76,8 +79,8 @@ def test_upload_and_view(version):
7679

7780
# Check that version is serving form in home page
7881
response = requests.get(f"https://{version_hostname}/")
79-
assert response.status_code == 200
8082
assert '<form action="' in response.text
83+
assert response.status_code == 200
8184

8285
matches = re.search(r'action="(.*?)"', response.text)
8386
assert matches is not None
@@ -86,5 +89,5 @@ def test_upload_and_view(version):
8689
with open("./main.py", "rb") as f:
8790
response = requests.post(upload_url, files={"file": f})
8891

89-
assert response.status_code == 200
9092
assert b"from google.appengine.api" in response.content
93+
assert response.status_code == 200

appengine/standard_python3/bundled-services/deferred/django/main_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def gcloud_cli(command):
3737
3838
Raises Exception with the stderr output of the last attempt on failure.
3939
"""
40+
full_command = f"gcloud {command} --quiet --format=json"
41+
print("Running command:", full_command)
42+
4043
output = subprocess.run(
41-
f"gcloud {command} --quiet --format=json",
44+
full_command,
4245
capture_output=True,
4346
shell=True,
4447
check=True,
@@ -74,8 +77,8 @@ def test_upload_and_view(version):
7477

7578
# Initial value of counter should be 0
7679
response = requests.get(f"https://{version_hostname}/counter/get")
77-
assert response.status_code == 200
7880
assert response.text == "0"
81+
assert response.status_code == 200
7982

8083
# Request counter be incremented
8184
response = requests.get(f"https://{version_hostname}/counter/increment")
@@ -84,23 +87,23 @@ def test_upload_and_view(version):
8487
# counter should be 10 almost immediately
8588
time.sleep(10)
8689
response = requests.get(f"https://{version_hostname}/counter/get")
87-
assert response.status_code == 200
8890
assert response.text == "10"
91+
assert response.status_code == 200
8992

9093
# After 20 seconds, counter should be 20
9194
time.sleep(20)
9295
response = requests.get(f"https://{version_hostname}/counter/get")
93-
assert response.status_code == 200
9496
assert response.text == "20"
97+
assert response.status_code == 200
9598

9699
# After 40 seconds, counter should be 30
97100
time.sleep(20)
98101
response = requests.get(f"https://{version_hostname}/counter/get")
99-
assert response.status_code == 200
100102
assert response.text == "30"
103+
assert response.status_code == 200
101104

102105
# counter should stay at 30 unless another request to increment it is set
103106
time.sleep(10)
104107
response = requests.get(f"https://{version_hostname}/counter/get")
105-
assert response.status_code == 200
106108
assert response.text == "30"
109+
assert response.status_code == 200

appengine/standard_python3/bundled-services/deferred/flask/main_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def gcloud_cli(command):
3737
3838
Raises Exception with the stderr output of the last attempt on failure.
3939
"""
40+
full_command = f"gcloud {command} --quiet --format=json"
41+
print("Running command:", full_command)
42+
4043
output = subprocess.run(
41-
f"gcloud {command} --quiet --format=json",
44+
full_command,
4245
capture_output=True,
4346
shell=True,
4447
check=True,
@@ -74,8 +77,8 @@ def test_upload_and_view(version):
7477

7578
# Initial value of counter should be 0
7679
response = requests.get(f"https://{version_hostname}/counter/get")
77-
assert response.status_code == 200
7880
assert response.text == "0"
81+
assert response.status_code == 200
7982

8083
# Request counter be incremented
8184
response = requests.get(f"https://{version_hostname}/counter/increment")
@@ -84,23 +87,23 @@ def test_upload_and_view(version):
8487
# counter should be 10 almost immediately. ALMOST immediately
8588
time.sleep(10)
8689
response = requests.get(f"https://{version_hostname}/counter/get")
87-
assert response.status_code == 200
8890
assert response.text == "10"
91+
assert response.status_code == 200
8992

9093
# After 20 seconds, counter should be 20
9194
time.sleep(20)
9295
response = requests.get(f"https://{version_hostname}/counter/get")
93-
assert response.status_code == 200
9496
assert response.text == "20"
97+
assert response.status_code == 200
9598

9699
# After 40 seconds, counter should be 30
97100
time.sleep(20)
98101
response = requests.get(f"https://{version_hostname}/counter/get")
99-
assert response.status_code == 200
100102
assert response.text == "30"
103+
assert response.status_code == 200
101104

102105
# counter should stay at 30 unless another request to increment it is set
103106
time.sleep(10)
104107
response = requests.get(f"https://{version_hostname}/counter/get")
105-
assert response.status_code == 200
106108
assert response.text == "30"
109+
assert response.status_code == 200

appengine/standard_python3/bundled-services/deferred/wsgi/main_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def gcloud_cli(command):
3737
3838
Raises Exception with the stderr output of the last attempt on failure.
3939
"""
40+
full_command = f"gcloud {command} --quiet --format=json"
41+
print("Running command:", full_command)
42+
4043
output = subprocess.run(
41-
f"gcloud {command} --quiet --format=json",
44+
full_command,
4245
capture_output=True,
4346
shell=True,
4447
check=True,
@@ -74,8 +77,8 @@ def test_upload_and_view(version):
7477

7578
# Initial value of counter should be 0
7679
response = requests.get(f"https://{version_hostname}/counter/get")
77-
assert response.status_code == 200
7880
assert response.text == "0"
81+
assert response.status_code == 200
7982

8083
# Request counter be incremented
8184
response = requests.get(f"https://{version_hostname}/counter/increment")
@@ -84,23 +87,23 @@ def test_upload_and_view(version):
8487
# counter should be 10 almost immediately. ALMOST immediately
8588
time.sleep(10)
8689
response = requests.get(f"https://{version_hostname}/counter/get")
87-
assert response.status_code == 200
8890
assert response.text == "10"
91+
assert response.status_code == 200
8992

9093
# After 20 seconds, counter should be 20
9194
time.sleep(20)
9295
response = requests.get(f"https://{version_hostname}/counter/get")
93-
assert response.status_code == 200
9496
assert response.text == "20"
97+
assert response.status_code == 200
9598

9699
# After 40 seconds, counter should be 30
97100
time.sleep(20)
98101
response = requests.get(f"https://{version_hostname}/counter/get")
99-
assert response.status_code == 200
100102
assert response.text == "30"
103+
assert response.status_code == 200
101104

102105
# counter should stay at 30 unless another request to increment it is set
103106
time.sleep(10)
104107
response = requests.get(f"https://{version_hostname}/counter/get")
105-
assert response.status_code == 200
106108
assert response.text == "30"
109+
assert response.status_code == 200

appengine/standard_python3/bundled-services/mail/django/main_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def gcloud_cli(command):
3737
3838
Raises Exception with the stderr output of the last attempt on failure.
3939
"""
40+
full_command = f"gcloud {command} --quiet --format=json"
41+
print("Running command:", full_command)
42+
4043
output = subprocess.run(
41-
f"gcloud {command} --quiet --format=json",
44+
full_command,
4245
capture_output=True,
4346
shell=True,
4447
check=True,
@@ -74,8 +77,8 @@ def test_send_receive(version):
7477

7578
# Check that version is serving form in home page
7679
response = requests.get(f"https://{version_hostname}/")
77-
assert response.status_code == 200
7880
assert '<form action="" method="POST">' in response.text
81+
assert response.status_code == 200
7982

8083
# Send valid mail
8184
response = requests.post(
@@ -86,8 +89,8 @@ def test_send_receive(version):
8689
},
8790
)
8891

89-
assert response.status_code == 201
9092
assert "Successfully sent mail" in response.text
93+
assert response.status_code == 201
9194

9295
# Give the mail some time to be delivered and logs to post
9396
time.sleep(60)

appengine/standard_python3/bundled-services/mail/flask/main_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def gcloud_cli(command):
3737
3838
Raises Exception with the stderr output of the last attempt on failure.
3939
"""
40+
full_command = f"gcloud {command} --quiet --format=json"
41+
print("Running command:", full_command)
42+
4043
output = subprocess.run(
41-
f"gcloud {command} --quiet --format=json",
44+
full_command,
4245
capture_output=True,
4346
shell=True,
4447
check=True,
@@ -74,8 +77,8 @@ def test_send_receive(version):
7477

7578
# Check that version is serving form in home page
7679
response = requests.get(f"https://{version_hostname}/")
77-
assert response.status_code == 200
7880
assert '<form action="" method="POST">' in response.text
81+
assert response.status_code == 200
7982

8083
# Send valid mail
8184
response = requests.post(
@@ -86,8 +89,8 @@ def test_send_receive(version):
8689
},
8790
)
8891

89-
assert response.status_code == 201
9092
assert "Successfully sent mail" in response.text
93+
assert response.status_code == 201
9194

9295
# Give the mail some time to be delivered and logs to post
9396
time.sleep(60)

appengine/standard_python3/bundled-services/mail/wsgi/main_test.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ def gcloud_cli(command):
3737
3838
Raises Exception with the stderr output of the last attempt on failure.
3939
"""
40+
full_command = f"gcloud {command} --quiet --format=json"
41+
print("Running command:", full_command)
42+
4043
output = subprocess.run(
41-
f"gcloud {command} --quiet --format=json",
44+
full_command,
4245
capture_output=True,
4346
shell=True,
4447
check=True,
@@ -74,8 +77,8 @@ def test_send_receive(version):
7477

7578
# Check that version is serving form in home page
7679
response = requests.get(f"https://{version_hostname}/")
77-
assert response.status_code == 200
7880
assert '<form action="" method="POST">' in response.text
81+
assert response.status_code == 200
7982

8083
# Send valid mail
8184
response = requests.post(
@@ -86,8 +89,8 @@ def test_send_receive(version):
8689
},
8790
)
8891

89-
assert response.status_code == 201
9092
assert "Successfully sent mail" in response.text
93+
assert response.status_code == 201
9194

9295
# Give the mail some time to be delivered and logs to post
9396
time.sleep(60)

0 commit comments

Comments
 (0)