test: gs: refresh credentials

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2019-02-06 01:46:23 +02:00
parent 99ef6081c1
commit 94a8054d29
2 changed files with 18 additions and 2 deletions
+17 -1
View File
@@ -65,7 +65,23 @@ def _should_test_gcp():
if not os.path.exists(TestDvc.GCP_CREDS_FILE):
return False
if os.getenv("GCP_CREDS"):
creds = os.getenv("GOOGLE_APPLICATION_CREDENTIALS")
if creds and os.getenv("GCP_CREDS"):
if os.path.exists(creds):
os.unlink(creds)
shutil.copyfile(TestDvc.GCP_CREDS_FILE, creds)
try:
check_output(
[
"gcloud",
"auth",
"activate-service-account",
"--key-file",
creds,
]
)
except (CalledProcessError, OSError):
return False
return True
return False
+1 -1
View File
@@ -957,7 +957,7 @@ class TestReproExternalGS(TestReproExternalBase):
return "gsutil cp {} {}".format(i, o)
def write(self, bucket, key, body):
client = gc.Client.from_service_account_json(self.GCP_CREDS_FILE)
client = gc.Client()
bucket = client.bucket(bucket)
bucket.blob(key).upload_from_string(body)