Skip to content

Commit

Permalink
[storage] fix: use a different bucket for requester_pays_test
Browse files Browse the repository at this point in the history
fixes #3654
  • Loading branch information
Takashi Matsuo committed Apr 30, 2020
1 parent 0213191 commit 543bf60
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 16 additions & 0 deletions storage/cloud-client/README_TEST.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 8 additions & 1 deletion storage/cloud-client/requester_pays_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]


Expand Down

0 comments on commit 543bf60

Please sign in to comment.