From 543bf60ea3200b77417c51d923da6c73d1cfdf54 Mon Sep 17 00:00:00 2001 From: Takashi Matsuo Date: Thu, 30 Apr 2020 19:03:31 +0000 Subject: [PATCH] [storage] fix: use a different bucket for requester_pays_test fixes #3654 --- storage/cloud-client/README_TEST.md | 16 ++++++++++++++++ storage/cloud-client/requester_pays_test.py | 9 ++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 storage/cloud-client/README_TEST.md diff --git a/storage/cloud-client/README_TEST.md b/storage/cloud-client/README_TEST.md new file mode 100644 index 000000000000..447da9888a38 --- /dev/null +++ b/storage/cloud-client/README_TEST.md @@ -0,0 +1,16 @@ + +For requester_pays_test.py, we need to use a different Storage bucket. + +The test looks for an environment variable +`REQUESTER_PAYS_TEST_BUCKET` first and then fallback to +`${CLOUD_STORAGE_BUCKET} + '-requester-pays-test'`. + +On the test project, we created a bucket named +`python-docs-samples-tests-requester-pays-test`. + + +Also, the service account for the test needs to have `Billing Project +Manager` role in order to make changes on buckets with requester pays +enabled. + +We added that role to the test service account. diff --git a/storage/cloud-client/requester_pays_test.py b/storage/cloud-client/requester_pays_test.py index 70a4b2002954..fddba708a86c 100644 --- a/storage/cloud-client/requester_pays_test.py +++ b/storage/cloud-client/requester_pays_test.py @@ -23,7 +23,14 @@ import storage_download_file_requester_pays import storage_get_requester_pays_status -BUCKET = os.environ["CLOUD_STORAGE_BUCKET"] + +# We should not use the same bucket as other tests are using. +# First look at REQUESTER_PAYS_TEST_BUCKET and fall back to +# ${CLOUD_STORAGE_BUCKET} + '-requester-pays-test'. +BUCKET = os.environ.get( + "REQUESTER_PAYS_TEST_BUCKET", + "{}-requester-pays-test".format(os.environ["CLOUD_STORAGE_BUCKET"]) +) PROJECT = os.environ["GCLOUD_PROJECT"]