Index: dashboard/dashboard/pinpoint/handlers/new.py |
diff --git a/dashboard/dashboard/pinpoint/handlers/new.py b/dashboard/dashboard/pinpoint/handlers/new.py |
index 6f7f71c8d4ac4391351aad5ce5f7ca8ca86b4e86..fd3a9bc836ea6c9b2da2e1f1c9e2c9e1b3d31b80 100644 |
--- a/dashboard/dashboard/pinpoint/handlers/new.py |
+++ b/dashboard/dashboard/pinpoint/handlers/new.py |
@@ -8,14 +8,10 @@ import webapp2 |
from dashboard.api import api_auth |
from dashboard.pinpoint.models import change |
from dashboard.pinpoint.models import job as job_module |
+from dashboard.pinpoint.models import test_config as test_config_module |
-_ERROR_METRIC_NO_TEST_SUITE = "Specified a metric but there's no test_suite "\ |
- "to run." |
-_ERROR_BUG_ID = 'Bug ID must be integer value.' |
- |
-class ParameterValidationError(Exception): |
- pass |
+_ERROR_BUG_ID = 'Bug ID must be an integer.' |
class New(webapp2.RequestHandler): |
@@ -24,7 +20,7 @@ class New(webapp2.RequestHandler): |
def post(self): |
try: |
self._CreateJob() |
- except (api_auth.ApiAuthException, ParameterValidationError) as e: |
+ except (api_auth.ApiAuthException, KeyError, TypeError, ValueError) as e: |
self._WriteErrorMessage(e.message) |
def _WriteErrorMessage(self, message): |
@@ -34,11 +30,10 @@ class New(webapp2.RequestHandler): |
def _CreateJob(self): |
"""Start a new Pinpoint job.""" |
configuration = self.request.get('configuration') |
- test_suite = self.request.get('test_suite') |
- test = self.request.get('test') |
- metric = self.request.get('metric') |
+ target = self.request.get('target') |
+ test_config = self.request.get('test_config') |
perezju
2017/08/07 12:06:12
Seems like this is not needed? (Value is thrown aw
dtu
2017/08/15 17:06:40
Done. Previously I was going to put all the test c
|
auto_explore = self.request.get('auto_explore') == '1' |
- bug_id = self._ValidateBugId(self.request.get('bug_id')) |
+ bug_id = self.request.get('bug_id') |
change_1 = { |
'base_commit': { |
@@ -54,18 +49,16 @@ class New(webapp2.RequestHandler): |
} |
} |
- # Validate parameters. |
- self._ValidateMetric(test_suite, metric) |
- |
- # Convert parameters to canonical internal representation. |
+ # Validate parameters and convert them to canonical internal representation. |
+ test_config = test_config_module.TestConfig(target, self.request) |
+ bug_id = self._ValidateBugId(bug_id) |
changes = self._ValidateChanges(change_1, change_2) |
# Create job. |
job = job_module.Job.New( |
configuration=configuration, |
- test_suite=test_suite, |
- test=test, |
- metric=metric, |
+ target=target, |
+ test_config=test_config, |
auto_explore=auto_explore, |
bug_id=bug_id) |
@@ -80,6 +73,8 @@ class New(webapp2.RequestHandler): |
job.Start() |
job.put() |
+ # TODO: Figure out if these should be underscores or lowerCamelCase. |
+ # TODO: They should match the input parameters. |
self.response.out.write(json.dumps({ |
'jobId': job_id, |
'jobUrl': job.url |
@@ -92,17 +87,7 @@ class New(webapp2.RequestHandler): |
try: |
return int(bug_id) |
except ValueError: |
- raise ParameterValidationError(_ERROR_BUG_ID) |
+ raise ValueError(_ERROR_BUG_ID) |
def _ValidateChanges(self, change_1, change_2): |
- try: |
- changes = (change.Change.FromDict(change_1), |
- change.Change.FromDict(change_2)) |
- except (KeyError, ValueError) as e: |
- raise ParameterValidationError(str(e)) |
- |
- return changes |
- |
- def _ValidateMetric(self, test_suite, metric): |
- if metric and not test_suite: |
- raise ParameterValidationError(_ERROR_METRIC_NO_TEST_SUITE) |
+ return (change.Change.FromDict(change_1), change.Change.FromDict(change_2)) |