Add the UI for scheduling a A/B testing with a custom root
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Apr 2017 21:38:04 +0000 (21:38 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Apr 2017 21:38:04 +0000 (21:38 +0000)
commitf6611de9db053eb0ca6a85a8b4bd00195b09c390
tree8197967769ca6754cec1352faffaed2820ad058c
parentc0555192eb3d2a1859d011f27d1c55848399cbd2
Add the UI for scheduling a A/B testing with a custom root
https://bugs.webkit.org/show_bug.cgi?id=170622

Reviewed by Anders Carlsson.

This patch adds the support for creating a new analysis task with a custom darwinup roots. A follow up patch
would update the syncing script to schedule such an A/B testing job to a buildbot instance.

* ReadMe.md: Updated instructions for backing up and restoring the database so that it's easier to replace
the file path for the backup.

* init-database.sql: Make task_platform and task_metric optional in each analysis task. Also added a column
to store the root file in commit_set_relationships.

* public/api/build-requests.php:
(main): Include the uploaded files.

* public/api/commits.php:
(main): Added the support for querying the latest commits for a given platform. This is used in a new page
to create a custom analysis task to autofill the latest revisions for a given platform.

* public/api/test-groups.php:
(main): Include the uploaded files.

* public/include/build-requests-fetcher.php:
(BuildRequestsFetcher::__construct): Added a list of uploaded_files and a map from its id.
(BuildRequestsFetcher::uploaded_files): Added.
(BuildRequestsFetcher::fetch_commits_for_set_if_needed): Added the support for including custom roots' id in
each commit set, and inserting its meta data in the list of uplaoded files.

* public/include/commit-log-fetcher.php:
(CommitLogFetcher::fetch_latest_for_platform): Added. Finds the latest commit for a given platform. Ideally,
we should be finding the latest commit for a given platform, but this is very slow so instead find the commit
of the latest build for a given platform.

* public/privileged-api/create-test-group.php:
(main): Added the support for creating an analysis task along with a group.
(commit_sets_from_revision_sets): Added the support for custom roots. Verify the specified uploaded file exists
and include it in commit_set_relationships. Because commits and upload files are stored in a different column
in commit_set_relationships, this function now stores the information for each row of commit_set_relationships
except the commit set ID, which is unknown until the set is created, instead of a commit ID.
(ensure_commit_sets): Made the each entry in a commit set a row instead of a commit ID as done. As this format
is only by v2 UI and detect-changes.js, we don't add the support for specifying custom roots here.

* public/privileged-api/upload-file.php:
(main): Fixed a typo. Also added one more error check.

* public/v3/components/custom-analysis-task-configurator.js: Added. The UI for selecting a test, a platform,
and a set of revisions, as well as custom roots for a custom A/B testing job. The first set of revision with
custom roots is referred as "baseline", and the second configuration is referred as "comparison" in this class.
(CustomAnalysisTaskConfigurator):
(CustomAnalysisTaskConfigurator.prototype.tests): Added.
(CustomAnalysisTaskConfigurator.prototype.platform): Added.
(CustomAnalysisTaskConfigurator.prototype.commitSets): Added. Returns a pair of baseline and comparsion if both
have been configured by the user.
(CustomAnalysisTaskConfigurator.prototype.didConstructShadowTree): Added.
(CustomAnalysisTaskConfigurator.prototype._configureComparison): Added. Called when the user is to configu the
"comparison" configuration.
(CustomAnalysisTaskConfigurator.prototype.render): Added.
(CustomAnalysisTaskConfigurator.prototype._renderTriggerableTests): Added. Renders the list of top-level tests
that can be scheduled by a triggerable.
(CustomAnalysisTaskConfigurator.prototype._renderTriggerablePlatforms): Added. Renders the list of platforms
that can be schedule with the currently selected list of tests by a triggerable. Note that the current UI only
lets the user select a single test but the intent is to allow multiple tests to be selected in the near future.
(CustomAnalysisTaskConfigurator.prototype._buildCheckboxList): Added. Creates a list of radio boxes to select
an item with a callback for each. It automatically sets "selected" class on the selected item. It's used to
render both the list of tests and platforms.
(CustomAnalysisTaskConfigurator.prototype._updateTriggerable): Added. Finds the triggerable for a given list of
tests and platforms. Returns an error when some tests belong to another triggearalbe.
(CustomAnalysisTaskConfigurator.prototype._updateRepositoryGroups): Added. Finds a repository group to use when
the current triggerable has changed. We try to use the repository group of the same name if there is any, and
defaults to the first repository group if there is none. This allows the set of repositories to be specified to
more or less persist across different triggerables. For example, if iOS platforms and Mac platforms use two
distinct triggerables , and both triggerables have two repository groups: one that only specify the OS and the
other that specifies both teh OS and WebKit revision, then this code allows the choice the user had made to
specify either just the OS or the OS and WebKit will be preserved when the user switches from an iOS platform
to a Mac platform.
(CustomAnalysisTaskConfigurator.prototype._updateCommitSetMap): Added. Create a commit set map, the format that
TestGroup.createWithTask accepts given "baseline" and "comparison" commit sets. Pretend "comparison" is not set
if two sets are identical since it makes no sense to schedule an A/B testing job when A and B are identical.
(CustomAnalysisTaskConfigurator.prototype._computeCommitSet): Added. Creates a commit set using the revisions
and the csutom roots the user had specified.
(CustomAnalysisTaskConfigurator.prototype._renderRepositoryPanes): Added. Renders the pane to specify revisions
and custom roots for "baseline" and "comparison".
(CustomAnalysisTaskConfigurator.prototype._renderBaselineRevisionTable): Added.
(CustomAnalysisTaskConfigurator.prototype._renderComparisonRevisionTable): Added.
(CustomAnalysisTaskConfigurator.prototype._optionalRepositoryList): Added.
(CustomAnalysisTaskConfigurator.prototype._buildRevisionTable): Added. Creates a table for specifying revisions
and custom roots along with a list of repository groups to pick. The set of repositories and custom roots are
shown at the all if all repository groups require them. Otherwise, they are grouped at the bottom as optional.
(CustomAnalysisTaskConfigurator.prototype._buildRepositoryGroupList): Added.
(CustomAnalysisTaskConfigurator.prototype._selectRepositoryGroup): Added.
(CustomAnalysisTaskConfigurator.prototype._buildRevisionInput): Added. Creates an input element to specify
a revision for a given repository. Autofills it with the latest commit for the currently selected platform if
the user had not modified the field by the time the revisions are fetched.
(CustomAnalysisTaskConfigurator.htmlTemplate): Added.
(CustomAnalysisTaskConfigurator.cssTemplate): Added.

* public/v3/components/instant-file-uploader.js: Added. A form to upload a custom darwinup root in "baseline"
or "comparison" configurations of CustomAnalysisTaskConfigurator. It's "instant" because it auto-detects when a
file to be uploaded had already been uploaded elsewhere by checking its SHA-256 hash.
(InstantFileUploader):
(InstantFileUploader.prototype.hasFileToUpload): Added.
(InstantFileUploader.prototype.uploadedFiles): Added.
(InstantFileUploader.prototype.addUploadedFile): Added. It's called on the uploader for "comparison"
configuration when the uploader for "baseline" configuration dipsatches "uploadedFile" action to automatically
mirror the newly uploaded custom root to "comparision" configuration.
(InstantFileUploader.prototype.didConstructShadowTree): Added.
(InstantFileUploader.prototype.render): Added.
(InstantFileUploader.prototype._renderUploadedFiles): Added. Renders the list of the uploaded files.
(InstantFileUploader.prototype._renderPreuploadFiles): Added. Renders the list of the files to be uploaded with
a progress bar.
(InstantFileUploader.prototype._updateUploadStatus): Added. Updates the progress bar for uploading the file.
(InstantFileUploader.prototype._formatUploadError): Added.
(InstantFileUploader.prototype._didFileInputChange): Added. Called when the user picks a file to uploaded on
the input element. Fetch the meta data for the uploaded file with the same SHA-256 hash if there is any, and
start uploading the file if there isn't one.
(InstantFileUploader.prototype._removeUploadedFile): Added.
(InstantFileUploader.prototype._didUploadFile): Added. Move a file from the list of files to be uploaded to
the list of uploaded files.
(InstantFileUploader.htmlTemplate): Added.
(InstantFileUploader.cssTemplate): Added.

* public/v3/index.html:

* public/v3/models/analysis-task.js:
(AnalysisTask): Made platform and metric optional as it is now.
(AnalysisTask.findByPlatformAndMetric): Skip analysis tasks without a platform or a metric.
(AnalysisTask.prototype.isCustom): Added. Returns true for a custom analysis task.
(AnalysisTask.fetchRelatedTasks): Skip custom analysis tasks.
(AnalysisTask._constructAnalysisTasksFromRawData): Construct analysis tasks even if they were missing a metric
or a platform instead of silently skipping them.

* public/v3/models/build-request.js:
(BuildRequest.constructBuildRequestsFromData): Construct uploaded file objects returned by /api/build-requests.

* public/v3/models/commit-log.js:
(CommitLog.fetchLatestCommitForPlatform): Added.

* public/v3/models/commit-set.js:
(CommitSet): Added this._customRoots.
(CommitSet.prototype.customRoots): Returns this._customRoots.
(CommitSet.prototype.equals): Returns false when the set of custom roots are not equal.
(CommitSet.areCustomRootsEqual): Added.
(CustomCommitSet):
(CustomCommitSet.prototype.equals): Added.
(CustomCommitSet.prototype.customRoots): Added.
(CustomCommitSet.prototype.addCustomRoot): Added.

* public/v3/models/manifest.js:
(Manifest._didFetchManifest): Store fileUploadSizeLimit in the manifest as UploadedFile.fileUploadSizeLimit.
This allows a file size check in the client size instead of uploading it to the server and receiving an error.

* public/v3/models/metric.js:
(Metric.formatTime): Moved from ChartPaneStatusView to be also used by InstantFileUploader._renderUploadedFiles.

* public/v3/models/test-group.js:
(TestGroup.prototype.createWithTask): Added.
(TestGroup.prototype.createAndRefetchTestGroups):
(TestGroup.prototype._revisionSetsFromCommitSets): Added. Extracted from createAndRefetchTestGroups.
(TestGroup.prototype._fetchTestGroupsForTask): Added. Extracted from createAndRefetchTestGroups.

* public/v3/models/triggerable.js:
(Triggerable.triggerablePlatformsForTests): Added.
(Triggerable.sortByNamePreferringSmallerRepositories): Added.

* public/v3/models/uploaded-file.js:
(UploadedFile.prototype.createdAt): Added.
(UploadedFile.prototype.filename): Added.
(UploadedFile.prototype.author): Added.
(UploadedFile.prototype.size): Added.
(UploadedFile.uploadFile): Added a client-side check for the file size using UploadedFile.fileUploadSizeLimit.
(UploadedFile.fetchUnloadedFileWithIdenticalHash): Ditto. Also fixed a bug that 404 was resulting in a rejected
promise instead of a resolved promise with null.

* public/v3/pages/analysis-category-page.js:
(AnalysisCategoryPage.prototype._reconstructTaskList): Modernized the code. Added the support for platform and
metric being null for some analysis tasks.

* public/v3/pages/analysis-task-page.js:
(AnalysisTaskPage.prototype._didFetchTask): Don't fetch the measurement set or create a chart for custom tasks.
(AnalysisTaskPage.prototype.render): Don't display the charts or the stacking table for custom tasks.
(AnalysisTaskPage.prototype._renderTaskNameAndStatus): Don't try to show the full test name for custom tasks
since it's not associated with exactly one pair.

* public/v3/pages/chart-pane-status-view.js:
(ChartPaneStatusView.prototype._renderBuildRevisionTable):
(ChartPaneStatusView.prototype._formatTime): Moved to Metric.formatTime.

* public/v3/pages/chart-pane.js:
(ChartPane.prototype._analyzeRange): Set inProgress to true to hide CustomAnalysisTaskConfigurator in
CreateAnalysisTaskPage when creating a non-custom analysis task for a specific range.

* public/v3/pages/create-analysis-task-page.js:
(CreateAnalysisTaskPage): This page now shows CustomAnalysisTaskConfigurator by default, and lets a user create
a custom analysis task by picking a test, a platform, and a set of revisions and custom darwinup roots.
(CreateAnalysisTaskPage.prototype.updateFromSerializedState): Show a message when inProgress is set. This is
the old behavior of this page.
(CreateAnalysisTaskPage.prototype.didConstructShadowTree): Added.
(CreateAnalysisTaskPage.prototype._createAnalysisTaskWithGroup): Added.
(CreateAnalysisTaskPage.prototype.render):
(CreateAnalysisTaskPage.prototype._renderMessage): Added. Hides CustomAnalysisTaskConfigurator and the select
element to specify the numebr of iterations when a message is set.
(CreateAnalysisTaskPage.htmlTemplate):
(CreateAnalysisTaskPage.cssTemplate):

* public/v3/pages/page-router.js:
(PageRouter.prototype.route): Always enqueue the page to re-render when the route has changed.

* server-tests/api-build-requests-tests.js: Updated test cases now that the response contains a list of
uploaded files associated with build requests.
*server-tests/api-commits-tests.js: Added a test case for /api/commits/<repository-name>/latest?platform=X.
* server-tests/privileged-api-create-test-group-tests.js: Added test cases for creating a custom analysis task
and a test group with custom roots.
* server-tests/resources/mock-data.js:
(MockData.addMockData): Updated the mock data to satisfy new constraint on analysis-tasks table. Also inserted
more commits, builds, and build_commits rows for testing /api/commits/<repository-name>/latest?platform=X.

* tools/js/remote.js: Include global.FormData from form-data.js.

* unit-tests/analysis-task-tests.js: Added a test for calling findByPlatformAndMetric when there is a custom
analysis task.
(sampleAnalysisTask): Removed the category since /api/analysis-tasks/ no longer generate this property.
(sampleCustomAnalysisTask): Added.
* unit-tests/build-request-tests.js:
(sampleBuildRequestData): Updated the mock response. Added a test case for fetcing custom roots.
* unit-tests/buildbot-syncer-tests.js:
(createSampleBuildRequest): Ditto.
* unit-tests/test-groups-tests.js:
(sampleTestGroup): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215202 268f45cc-cd09-0410-ab3c-d52691b4dbfc
38 files changed:
ChangeLog
Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/ReadMe.md
Websites/perf.webkit.org/init-database.sql
Websites/perf.webkit.org/public/api/build-requests.php
Websites/perf.webkit.org/public/api/commits.php
Websites/perf.webkit.org/public/api/test-groups.php
Websites/perf.webkit.org/public/include/build-requests-fetcher.php
Websites/perf.webkit.org/public/include/commit-log-fetcher.php
Websites/perf.webkit.org/public/privileged-api/create-test-group.php
Websites/perf.webkit.org/public/privileged-api/upload-file.php
Websites/perf.webkit.org/public/v3/index.html
Websites/perf.webkit.org/public/v3/models/analysis-task.js
Websites/perf.webkit.org/public/v3/models/build-request.js
Websites/perf.webkit.org/public/v3/models/commit-log.js
Websites/perf.webkit.org/public/v3/models/commit-set.js
Websites/perf.webkit.org/public/v3/models/manifest.js
Websites/perf.webkit.org/public/v3/models/metric.js
Websites/perf.webkit.org/public/v3/models/test-group.js
Websites/perf.webkit.org/public/v3/models/triggerable.js
Websites/perf.webkit.org/public/v3/models/uploaded-file.js
Websites/perf.webkit.org/public/v3/pages/analysis-category-page.js
Websites/perf.webkit.org/public/v3/pages/analysis-task-page.js
Websites/perf.webkit.org/public/v3/pages/chart-pane-status-view.js
Websites/perf.webkit.org/public/v3/pages/chart-pane.js
Websites/perf.webkit.org/public/v3/pages/create-analysis-task-page.js
Websites/perf.webkit.org/public/v3/pages/page-router.js
Websites/perf.webkit.org/server-tests/api-build-requests-tests.js
Websites/perf.webkit.org/server-tests/api-commits-tests.js
Websites/perf.webkit.org/server-tests/privileged-api-create-test-group-tests.js
Websites/perf.webkit.org/server-tests/resources/mock-data.js
Websites/perf.webkit.org/tools/js/remote.js
Websites/perf.webkit.org/unit-tests/analysis-task-tests.js
Websites/perf.webkit.org/unit-tests/build-request-tests.js
Websites/perf.webkit.org/unit-tests/buildbot-syncer-tests.js
Websites/perf.webkit.org/unit-tests/test-groups-tests.js
public/v3/components/custom-analysis-task-configurator.js [new file with mode: 0644]
public/v3/components/instant-file-uploader.js [new file with mode: 0644]