Skip to content

Commit

Permalink
Bug 1279213 - Make Treeherder use the new client server_url parameter
Browse files Browse the repository at this point in the history
And use `SITE_URL` rather than requiring the separate environment
variables just for requests to Treeherder's own API. (Thereby reducing
the number of environment variables I have to toggle back and forth for
the Heroku migration).
  • Loading branch information
Ed Morley committed Jun 23, 2016
1 parent b4119b0 commit a1c84ec
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 37 deletions.
9 changes: 3 additions & 6 deletions tests/client/test_treeherder_client.py
Expand Up @@ -396,8 +396,7 @@ def test_post_job_collection(self):
tjc.add(tjc.get_job(job))

client = TreeherderClient(
protocol='http',
host='host',
server_url='http://host',
client_id='client-abc',
secret='secret123',
)
Expand All @@ -423,8 +422,7 @@ def test_send_result_collection(self):
trc.add(trc.get_resultset(resultset))

client = TreeherderClient(
protocol='http',
host='host',
server_url='http://host',
client_id='client-abc',
secret='secret123',
)
Expand All @@ -450,8 +448,7 @@ def test_send_artifact_collection(self):
tac.add(tac.get_artifact(artifact))

client = TreeherderClient(
protocol='http',
host='host',
server_url='http://host',
client_id='client-abc',
secret='secret123',
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Expand Up @@ -7,7 +7,7 @@

def post_collection(project, th_collection):

client = TreeherderClient(protocol='http', host='localhost')
client = TreeherderClient(server_url='http://localhost')
return client.post_collection(project, th_collection)


Expand Down
4 changes: 2 additions & 2 deletions tests/webapp/api/test_artifact_api.py
Expand Up @@ -84,7 +84,7 @@ def test_artifact_create_text_log_summary(webapp, test_project, eleven_jobs_stor
})
tac.add(ta)

cli = client.TreeherderClient(protocol='http', host='localhost')
cli = client.TreeherderClient(server_url='http://localhost')
cli.post_collection(test_project, tac)

with ArtifactsModel(test_project) as artifacts_model:
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_artifact_create_text_log_summary_and_bug_suggestions(
'job_guid': job['job_guid']
}))

cli = client.TreeherderClient(protocol='http', host='localhost')
cli = client.TreeherderClient(server_url='http://localhost')
cli.post_collection(test_project, tac)

with ArtifactsModel(test_project) as artifacts_model:
Expand Down
3 changes: 0 additions & 3 deletions treeherder/config/settings.py
Expand Up @@ -16,9 +16,6 @@
ENABLE_DEBUG_TOOLBAR = env.bool("ENABLE_DEBUG_TOOLBAR", False)
DEBUG_TOOLBAR_PATCH_SETTINGS = False # disable django debug toolbar automatic configuration

TREEHERDER_REQUEST_PROTOCOL = env("TREEHERDER_REQUEST_PROTOCOL", default="http")
TREEHERDER_REQUEST_HOST = env("TREEHERDER_REQUEST_HOST", default="local.treeherder.mozilla.org")

# Default to retaining data for ~4 months.
DATA_CYCLE_DAYS = env.int("DATA_CYCLE_DAYS", default=120)

Expand Down
3 changes: 1 addition & 2 deletions treeherder/etl/th_publisher.py
Expand Up @@ -16,8 +16,7 @@ def post_treeherder_collections(th_collections, chunk_size=1):
credentials = Credentials.objects.get(client_id=settings.ETL_CLIENT_ID)

cli = TreeherderClient(
protocol=settings.TREEHERDER_REQUEST_PROTOCOL,
host=settings.TREEHERDER_REQUEST_HOST,
server_url=settings.SITE_URL,
client_id=credentials.client_id,
secret=str(credentials.secret),
)
Expand Down
3 changes: 1 addition & 2 deletions treeherder/log_parser/utils.py
Expand Up @@ -85,8 +85,7 @@ def _retry(e):

credentials = Credentials.objects.get(client_id=settings.ETL_CLIENT_ID)
client = TreeherderClient(
protocol=settings.TREEHERDER_REQUEST_PROTOCOL,
host=settings.TREEHERDER_REQUEST_HOST,
server_url=settings.SITE_URL,
client_id=credentials.client_id,
secret=str(credentials.secret),
)
Expand Down
@@ -1,5 +1,4 @@
from optparse import make_option
from urlparse import urlparse

from django.core.management.base import BaseCommand

Expand Down Expand Up @@ -29,9 +28,7 @@ class Command(BaseCommand):
)

def handle(self, *args, **options):
server_params = urlparse(options['server'])
c = TreeherderClient(protocol=server_params.scheme,
host=server_params.netloc)
c = TreeherderClient(server_url=options['server'])

# options / option collection hashes
for (uuid, props) in c.get_option_collection_hash().iteritems():
Expand Down
6 changes: 1 addition & 5 deletions treeherder/perf/management/commands/import_perf_data.py
@@ -1,6 +1,5 @@
import datetime
from optparse import make_option
from urlparse import urlparse

import concurrent.futures
from django.core.management.base import (BaseCommand,
Expand Down Expand Up @@ -152,12 +151,9 @@ def handle(self, *args, **options):
raise CommandError("Need to (only) specify project/branch")
project = args[0]

server_params = urlparse(options['server'])

time_interval = options['time_interval']

pc = PerfherderClient(protocol=server_params.scheme,
host=server_params.netloc)
pc = PerfherderClient(server_url=options['server'])
signatures = pc.get_performance_signatures(
project,
interval=time_interval)
Expand Down
14 changes: 2 additions & 12 deletions treeherder/perf/management/commands/test_analyze_perf.py
@@ -1,5 +1,4 @@
from optparse import make_option
from urlparse import urlparse

from django.conf import settings
from django.core.management.base import (BaseCommand,
Expand All @@ -22,7 +21,7 @@ class Command(BaseCommand):
make_option('--server',
action='store',
dest='server',
default=None,
default=settings.SITE_URL,
help='Server to get data from, default to local instance'),
make_option('--time-interval',
action='store',
Expand All @@ -48,20 +47,11 @@ def _get_series_description(option_collection_hash, series_properties):
testname] + test_options])

def handle(self, *args, **options):
if options['server']:
server_params = urlparse(options['server'])
server_protocol = server_params.scheme
server_host = server_params.netloc
else:
server_protocol = settings.TREEHERDER_REQUEST_PROTOCOL
server_host = settings.TREEHERDER_REQUEST_HOST

if not options['project']:
raise CommandError("Must specify at least one project with "
"--project")

pc = PerfherderClient(protocol=server_protocol,
host=server_host)
pc = PerfherderClient(server_url=options['server'])

option_collection_hash = pc.get_option_collection_hash()

Expand Down

0 comments on commit a1c84ec

Please sign in to comment.