Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(appengine/standard_python3): print gcloud cmds to improve debugging #8561

Merged
merged 4 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def gcloud_cli(command):

Raises Exception with the stderr output of the last attempt on failure.
"""
full_command = f"gcloud {command} --quiet --format=json"
print("Running command:", full_command)

output = subprocess.run(
f"gcloud {command} --quiet --format=json",
full_command,
capture_output=True,
shell=True,
check=True,
Expand Down Expand Up @@ -74,8 +77,8 @@ def test_upload_and_view(version):

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

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

assert response.status_code == 200
assert b"from google.appengine.api" in response.content
assert response.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def gcloud_cli(command):

Raises Exception with the stderr output of the last attempt on failure.
"""
full_command = f"gcloud {command} --quiet --format=json"
print("Running command:", full_command)

output = subprocess.run(
f"gcloud {command} --quiet --format=json",
full_command,
capture_output=True,
shell=True,
check=True,
Expand Down Expand Up @@ -74,8 +77,8 @@ def test_upload_and_view(version):

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

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

assert response.status_code == 200
assert b"from google.appengine.api" in response.content
assert response.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ def gcloud_cli(command):

Raises Exception with the stderr output of the last attempt on failure.
"""
full_command = f"gcloud {command} --quiet --format=json"
print("Running command:", full_command)

output = subprocess.run(
f"gcloud {command} --quiet --format=json",
full_command,
capture_output=True,
shell=True,
check=True,
Expand Down Expand Up @@ -76,8 +79,8 @@ def test_upload_and_view(version):

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

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

assert response.status_code == 200
assert b"from google.appengine.api" in response.content
assert response.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def gcloud_cli(command):

Raises Exception with the stderr output of the last attempt on failure.
"""
full_command = f"gcloud {command} --quiet --format=json"
print("Running command:", full_command)

output = subprocess.run(
f"gcloud {command} --quiet --format=json",
full_command,
capture_output=True,
shell=True,
check=True,
Expand Down Expand Up @@ -74,8 +77,8 @@ def test_upload_and_view(version):

# Initial value of counter should be 0
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "0"
assert response.status_code == 200

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

# After 20 seconds, counter should be 20
time.sleep(20)
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "20"
assert response.status_code == 200

# After 40 seconds, counter should be 30
time.sleep(20)
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "30"
assert response.status_code == 200

# counter should stay at 30 unless another request to increment it is set
time.sleep(10)
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "30"
assert response.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def gcloud_cli(command):

Raises Exception with the stderr output of the last attempt on failure.
"""
full_command = f"gcloud {command} --quiet --format=json"
print("Running command:", full_command)

output = subprocess.run(
f"gcloud {command} --quiet --format=json",
full_command,
capture_output=True,
shell=True,
check=True,
Expand Down Expand Up @@ -74,8 +77,8 @@ def test_upload_and_view(version):

# Initial value of counter should be 0
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "0"
assert response.status_code == 200

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

# After 20 seconds, counter should be 20
time.sleep(20)
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "20"
assert response.status_code == 200

# After 40 seconds, counter should be 30
time.sleep(20)
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "30"
assert response.status_code == 200

# counter should stay at 30 unless another request to increment it is set
time.sleep(10)
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "30"
assert response.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def gcloud_cli(command):

Raises Exception with the stderr output of the last attempt on failure.
"""
full_command = f"gcloud {command} --quiet --format=json"
print("Running command:", full_command)

output = subprocess.run(
f"gcloud {command} --quiet --format=json",
full_command,
capture_output=True,
shell=True,
check=True,
Expand Down Expand Up @@ -74,8 +77,8 @@ def test_upload_and_view(version):

# Initial value of counter should be 0
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "0"
assert response.status_code == 200

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

# After 20 seconds, counter should be 20
time.sleep(20)
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "20"
assert response.status_code == 200

# After 40 seconds, counter should be 30
time.sleep(20)
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "30"
assert response.status_code == 200

# counter should stay at 30 unless another request to increment it is set
time.sleep(10)
response = requests.get(f"https://{version_hostname}/counter/get")
assert response.status_code == 200
assert response.text == "30"
assert response.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def gcloud_cli(command):

Raises Exception with the stderr output of the last attempt on failure.
"""
full_command = f"gcloud {command} --quiet --format=json"
print("Running command:", full_command)

output = subprocess.run(
f"gcloud {command} --quiet --format=json",
full_command,
capture_output=True,
shell=True,
check=True,
Expand Down Expand Up @@ -74,8 +77,8 @@ def test_send_receive(version):

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

# Send valid mail
response = requests.post(
Expand All @@ -86,8 +89,8 @@ def test_send_receive(version):
},
)

assert response.status_code == 201
assert "Successfully sent mail" in response.text
assert response.status_code == 201

# Give the mail some time to be delivered and logs to post
time.sleep(60)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def gcloud_cli(command):

Raises Exception with the stderr output of the last attempt on failure.
"""
full_command = f"gcloud {command} --quiet --format=json"
print("Running command:", full_command)

output = subprocess.run(
f"gcloud {command} --quiet --format=json",
full_command,
capture_output=True,
shell=True,
check=True,
Expand Down Expand Up @@ -74,8 +77,8 @@ def test_send_receive(version):

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

# Send valid mail
response = requests.post(
Expand All @@ -86,8 +89,8 @@ def test_send_receive(version):
},
)

assert response.status_code == 201
assert "Successfully sent mail" in response.text
assert response.status_code == 201

# Give the mail some time to be delivered and logs to post
time.sleep(60)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ def gcloud_cli(command):

Raises Exception with the stderr output of the last attempt on failure.
"""
full_command = f"gcloud {command} --quiet --format=json"
print("Running command:", full_command)

output = subprocess.run(
f"gcloud {command} --quiet --format=json",
full_command,
capture_output=True,
shell=True,
check=True,
Expand Down Expand Up @@ -74,8 +77,8 @@ def test_send_receive(version):

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

# Send valid mail
response = requests.post(
Expand All @@ -86,8 +89,8 @@ def test_send_receive(version):
},
)

assert response.status_code == 201
assert "Successfully sent mail" in response.text
assert response.status_code == 201

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