Skip to content
This repository has been archived by the owner on Dec 15, 2018. It is now read-only.

Commit

Permalink
Hash test name in URLs for testartifacts
Browse files Browse the repository at this point in the history
Summary:
We use the test name as part of the bucket and URL for test
artifacts. Hash the name before using it.

Fixes T112671

Reviewers: kylec, anupc

Reviewed By: anupc

Subscribers: changesbot, sbezek

Maniphest Tasks: T112671

Differential Revision: https://tails.corp.dropbox.com/D223500
  • Loading branch information
ecnerwala committed Aug 25, 2016
1 parent 7067ff8 commit ee438e1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions changes/models/testresult.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import absolute_import, division

import hashlib
import logging
import random as insecure_random
import re
Expand Down Expand Up @@ -167,7 +168,11 @@ def save(self, test_list):
as_client = ArtifactStoreClient(current_app.config['ARTIFACTS_SERVER'])
for test, testcase in zip(test_list, testcase_list):
if test.artifacts:
bucket_name = '{}_{}'.format(step.id.hex, test.id)
m = hashlib.md5()
m.update(test.id)
bucket_name_base = '{}_{}'.format(step.id.hex, m.hexdigest())

bucket_name = bucket_name_base

num_attempts = 0
max_duplicate_attempts = 5
Expand All @@ -176,8 +181,7 @@ def save(self, test_list):
as_client.create_bucket(bucket_name)
break
except Exception as e:
bucket_name = '{}_{}_dup_{}'.format(step.id.hex, test.id,
"%05x" % insecure_random.getrandbits(4 * 5))
bucket_name = '{}_dup_{}'.format(bucket_name_base, "%05x" % insecure_random.getrandbits(4 * 5))
num_attempts += 1
if num_attempts == max_duplicate_attempts:
raise e
Expand Down

0 comments on commit ee438e1

Please sign in to comment.