-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve system tests for Cloud Build (#8003)
- Loading branch information
Showing
3 changed files
with
8 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
from tests.providers.google.cloud.utils.gcp_authenticator import GCP_CLOUD_BUILD_KEY, GcpAuthenticator | ||
from tests.utils.logging_command_executor import LoggingCommandExecutor | ||
|
||
GCE_INSTANCE = os.environ.get("GCE_INSTANCE", "testinstance") | ||
GCP_PROJECT_ID = os.environ.get("GCP_PROJECT_ID", "example-project") | ||
GCP_ARCHIVE_URL = os.environ.get("GCP_CLOUD_BUILD_ARCHIVE_URL", "gs://example-bucket/source-code.tar.gz") | ||
GCP_ARCHIVE_URL_PARTS = urlparse(GCP_ARCHIVE_URL) | ||
|
@@ -71,7 +70,7 @@ def create_repository_and_bucket(self): | |
self.execute_cmd(["gcloud", "source", "repos", "create", GCP_REPOSITORY_NAME]) | ||
self.execute_cmd(["git", "init"], cwd=tmp_dir) | ||
self.execute_cmd(["git", "config", "user.email", "[email protected]"], cwd=tmp_dir) | ||
self.execute_cmd(["git", "config", "user.name", "system-test"]) | ||
self.execute_cmd(["git", "config", "user.name", "system-test"], cwd=tmp_dir) | ||
self.execute_cmd( | ||
["git", "config", "credential.https://source.developers.google.com.helper", "gcloud.sh"], | ||
cwd=tmp_dir, | ||
|
@@ -82,7 +81,7 @@ def create_repository_and_bucket(self): | |
GCP_PROJECT_ID, GCP_REPOSITORY_NAME | ||
) | ||
self.execute_cmd(["git", "remote", "add", "origin", repo_url], cwd=tmp_dir) | ||
self.execute_cmd(["git", "push", "origin", "master"], cwd=tmp_dir) | ||
self.execute_cmd(["git", "push", "--force", "origin", "master"], cwd=tmp_dir) | ||
|
||
def delete_repo(self): | ||
"""Delete repository in Google Cloud Source Repository service""" | ||
|
@@ -92,15 +91,15 @@ def delete_repo(self): | |
def delete_bucket(self): | ||
"""Delete bucket in Google Cloud Storage service""" | ||
|
||
self.execute_cmd(["gsutil", "rb", "gs://{}".format(GCP_BUCKET_NAME)]) | ||
self.execute_cmd(["gsutil", "rm", "-r", "gs://{}".format(GCP_BUCKET_NAME)]) | ||
|
||
def delete_docker_images(self): | ||
"""Delete images in Google Cloud Container Registry""" | ||
|
||
repo_image_name = "gcr.io/{}/{}".format(GCP_PROJECT_ID, GCP_REPOSITORY_NAME) | ||
self.execute_cmd(["gcloud", "container", "images", "delete", repo_image_name]) | ||
self.execute_cmd(["gcloud", "container", "images", "delete", "--quiet", repo_image_name]) | ||
bucket_image_name = "gcr.io/{}/{}".format(GCP_PROJECT_ID, GCP_BUCKET_NAME) | ||
self.execute_cmd(["gcloud", "container", "images", "delete", bucket_image_name]) | ||
self.execute_cmd(["gcloud", "container", "images", "delete", "--quiet", bucket_image_name]) | ||
|
||
|
||
if __name__ == "__main__": | ||
|