From 999087345550e36c8b30d8e100ca0151e3241664 Mon Sep 17 00:00:00 2001 From: Katie McLaughlin Date: Fri, 14 Feb 2025 20:35:03 +1100 Subject: [PATCH] fix(appengine): set project for bundled tests (#13165) --- .../bundled-services/blobstore/django/main_test.py | 5 ++++- .../bundled-services/blobstore/flask/main_test.py | 5 ++++- .../bundled-services/blobstore/wsgi/main_test.py | 5 ++++- .../bundled-services/deferred/django/main_test.py | 5 ++++- .../bundled-services/deferred/flask/main_test.py | 5 ++++- .../bundled-services/deferred/wsgi/main_test.py | 5 ++++- .../bundled-services/mail/django/main_test.py | 5 ++++- .../bundled-services/mail/flask/main_test.py | 5 ++++- .../standard_python3/bundled-services/mail/wsgi/main_test.py | 5 ++++- 9 files changed, 36 insertions(+), 9 deletions(-) diff --git a/appengine/standard_python3/bundled-services/blobstore/django/main_test.py b/appengine/standard_python3/bundled-services/blobstore/django/main_test.py index 0b11876fb76d..ed87982b720d 100644 --- a/appengine/standard_python3/bundled-services/blobstore/django/main_test.py +++ b/appengine/standard_python3/bundled-services/blobstore/django/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os import re import subprocess import uuid @@ -21,6 +22,8 @@ import pytest import requests +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] + @backoff.on_exception(backoff.expo, Exception, max_tries=3) def gcloud_cli(command): @@ -37,7 +40,7 @@ def gcloud_cli(command): Raises Exception with the stderr output of the last attempt on failure. """ - full_command = f"gcloud {command} --quiet --format=json" + full_command = f"gcloud {command} --quiet --format=json --project {project_id}" print("Running command:", full_command) output = subprocess.run( diff --git a/appengine/standard_python3/bundled-services/blobstore/flask/main_test.py b/appengine/standard_python3/bundled-services/blobstore/flask/main_test.py index 6779d6f02cf7..c1e7b665b2e0 100644 --- a/appengine/standard_python3/bundled-services/blobstore/flask/main_test.py +++ b/appengine/standard_python3/bundled-services/blobstore/flask/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os import re import subprocess import uuid @@ -21,6 +22,8 @@ import pytest import requests +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] + @backoff.on_exception(backoff.expo, Exception, max_tries=3) def gcloud_cli(command): @@ -37,7 +40,7 @@ def gcloud_cli(command): Raises Exception with the stderr output of the last attempt on failure. """ - full_command = f"gcloud {command} --quiet --format=json" + full_command = f"gcloud {command} --quiet --format=json --project {project_id}" print("Running command:", full_command) output = subprocess.run( diff --git a/appengine/standard_python3/bundled-services/blobstore/wsgi/main_test.py b/appengine/standard_python3/bundled-services/blobstore/wsgi/main_test.py index 18f57032dcec..75b4c9d4cd04 100644 --- a/appengine/standard_python3/bundled-services/blobstore/wsgi/main_test.py +++ b/appengine/standard_python3/bundled-services/blobstore/wsgi/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os import re import subprocess import uuid @@ -21,6 +22,8 @@ import pytest import requests +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] + @backoff.on_exception(backoff.expo, Exception, max_tries=5) def gcloud_cli(command): @@ -37,7 +40,7 @@ def gcloud_cli(command): Raises Exception with the stderr output of the last attempt on failure. """ - full_command = f"gcloud {command} --quiet --format=json" + full_command = f"gcloud {command} --quiet --format=json --project {project_id}" print("Running command:", full_command) output = subprocess.run( diff --git a/appengine/standard_python3/bundled-services/deferred/django/main_test.py b/appengine/standard_python3/bundled-services/deferred/django/main_test.py index edfb54369f87..5852c0f28688 100644 --- a/appengine/standard_python3/bundled-services/deferred/django/main_test.py +++ b/appengine/standard_python3/bundled-services/deferred/django/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os import subprocess import time import uuid @@ -21,6 +22,8 @@ import pytest import requests +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] + @backoff.on_exception(backoff.expo, Exception, max_tries=3) def gcloud_cli(command): @@ -37,7 +40,7 @@ def gcloud_cli(command): Raises Exception with the stderr output of the last attempt on failure. """ - full_command = f"gcloud {command} --quiet --format=json" + full_command = f"gcloud {command} --quiet --format=json --project {project_id}" print("Running command:", full_command) output = subprocess.run( diff --git a/appengine/standard_python3/bundled-services/deferred/flask/main_test.py b/appengine/standard_python3/bundled-services/deferred/flask/main_test.py index edfb54369f87..5852c0f28688 100644 --- a/appengine/standard_python3/bundled-services/deferred/flask/main_test.py +++ b/appengine/standard_python3/bundled-services/deferred/flask/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os import subprocess import time import uuid @@ -21,6 +22,8 @@ import pytest import requests +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] + @backoff.on_exception(backoff.expo, Exception, max_tries=3) def gcloud_cli(command): @@ -37,7 +40,7 @@ def gcloud_cli(command): Raises Exception with the stderr output of the last attempt on failure. """ - full_command = f"gcloud {command} --quiet --format=json" + full_command = f"gcloud {command} --quiet --format=json --project {project_id}" print("Running command:", full_command) output = subprocess.run( diff --git a/appengine/standard_python3/bundled-services/deferred/wsgi/main_test.py b/appengine/standard_python3/bundled-services/deferred/wsgi/main_test.py index edfb54369f87..5852c0f28688 100644 --- a/appengine/standard_python3/bundled-services/deferred/wsgi/main_test.py +++ b/appengine/standard_python3/bundled-services/deferred/wsgi/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os import subprocess import time import uuid @@ -21,6 +22,8 @@ import pytest import requests +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] + @backoff.on_exception(backoff.expo, Exception, max_tries=3) def gcloud_cli(command): @@ -37,7 +40,7 @@ def gcloud_cli(command): Raises Exception with the stderr output of the last attempt on failure. """ - full_command = f"gcloud {command} --quiet --format=json" + full_command = f"gcloud {command} --quiet --format=json --project {project_id}" print("Running command:", full_command) output = subprocess.run( diff --git a/appengine/standard_python3/bundled-services/mail/django/main_test.py b/appengine/standard_python3/bundled-services/mail/django/main_test.py index 9e3006f607a1..9c62e151d4f6 100644 --- a/appengine/standard_python3/bundled-services/mail/django/main_test.py +++ b/appengine/standard_python3/bundled-services/mail/django/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os import subprocess import time import uuid @@ -21,6 +22,8 @@ import pytest import requests +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] + @backoff.on_exception(backoff.expo, Exception, max_tries=3) def gcloud_cli(command): @@ -37,7 +40,7 @@ def gcloud_cli(command): Raises Exception with the stderr output of the last attempt on failure. """ - full_command = f"gcloud {command} --quiet --format=json" + full_command = f"gcloud {command} --quiet --format=json --project {project_id}" print("Running command:", full_command) output = subprocess.run( diff --git a/appengine/standard_python3/bundled-services/mail/flask/main_test.py b/appengine/standard_python3/bundled-services/mail/flask/main_test.py index b91e552cc82b..4277522f0443 100644 --- a/appengine/standard_python3/bundled-services/mail/flask/main_test.py +++ b/appengine/standard_python3/bundled-services/mail/flask/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os import subprocess import uuid @@ -20,6 +21,8 @@ import pytest import requests +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] + @backoff.on_exception(backoff.expo, Exception, max_tries=3) def gcloud_cli(command): @@ -36,7 +39,7 @@ def gcloud_cli(command): Raises Exception with the stderr output of the last attempt on failure. """ - full_command = f"gcloud {command} --quiet --format=json" + full_command = f"gcloud {command} --quiet --format=json --project {project_id}" print("Running command:", full_command) output = subprocess.run( diff --git a/appengine/standard_python3/bundled-services/mail/wsgi/main_test.py b/appengine/standard_python3/bundled-services/mail/wsgi/main_test.py index b1d171ccb15e..1f12c21ad2d4 100644 --- a/appengine/standard_python3/bundled-services/mail/wsgi/main_test.py +++ b/appengine/standard_python3/bundled-services/mail/wsgi/main_test.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import os import subprocess import time import uuid @@ -21,6 +22,8 @@ import pytest import requests +project_id = os.environ["GOOGLE_CLOUD_PROJECT"] + @backoff.on_exception(backoff.expo, Exception, max_tries=3) def gcloud_cli(command): @@ -37,7 +40,7 @@ def gcloud_cli(command): Raises Exception with the stderr output of the last attempt on failure. """ - full_command = f"gcloud {command} --quiet --format=json" + full_command = f"gcloud {command} --quiet --format=json --project {project_id}" print("Running command:", full_command) output = subprocess.run(