Should allow updating a build-request to 'canceled'.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jan 2018 22:12:23 +0000 (22:12 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jan 2018 22:12:23 +0000 (22:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181819

Reviewed by Ryosuke Niwa.

It's possible syncing script update a build-request to 'canceled' state.

* public/api/build-requests.php: Added 'canceled' as an acceptable update state.
* server-tests/api-build-requests-tests.js: Added a unit test to update a build-request to 'canceled'.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227234 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/api/build-requests.php
Websites/perf.webkit.org/server-tests/api-build-requests-tests.js

index fa62b15..affdd4e 100644 (file)
@@ -1,3 +1,15 @@
+2018-01-18  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Should allow updating a build-request to 'canceled'.
+        https://bugs.webkit.org/show_bug.cgi?id=181819
+
+        Reviewed by Ryosuke Niwa.
+
+        It's possible syncing script update a build-request to 'canceled' state.
+
+        * public/api/build-requests.php: Added 'canceled' as an acceptable update state.
+        * server-tests/api-build-requests-tests.js: Added a unit test to update a build-request to 'canceled'.
+
 2018-01-18  Aakash Jain  <aakash_jain@apple.com>
 
         Add support for builderNameToIDMap in BuildbotSyncer
index a5273fa..5caeee6 100644 (file)
@@ -61,7 +61,7 @@ function update_builds($db, $updates) {
             }
             $db->update_row('build_requests', 'request', array('id' => $id), array('status' => 'failed', 'url' => $url));
         } else {
-            if (!in_array($status, array('pending', 'scheduled', 'running', 'failed', 'completed'))) {
+            if (!in_array($status, array('pending', 'scheduled', 'running', 'failed', 'completed', 'canceled'))) {
                 $db->rollback_transaction();
                 exit_with_error('UnknownBuildRequestStatus', array('buildRequest' => $id, 'status' => $status));
             }
index 1782b30..1fa0146 100644 (file)
@@ -542,4 +542,48 @@ describe('/api/build-requests', function () {
             assert.strictEqual(buildRequests[7].order(), 3);
         });
     });
+
+    it('should not return "UnknownBuildRequestStatus" when updating a canceled build request', () => {
+        const updates = {'700': {status: 'canceled', url: 'http://build.webkit.org/someBuilder/builds'}};
+        return MockData.addMockData(TestServer.database()).then(() => {
+            return TestServer.remoteAPI().postJSONWithStatus('/api/build-requests/build-webkit', {
+                'slaveName': 'sync-slave',
+                'slavePassword': 'password',
+                'buildRequestUpdates': updates
+            }).then((response) => {
+                assert.equal(response['status'], 'OK');
+
+                assert.equal(response['buildRequests'].length, 4);
+                assert.deepEqual(response['buildRequests'][0].id, 700);
+                assert.deepEqual(response['buildRequests'][0].order, 0);
+                assert.deepEqual(response['buildRequests'][0].platform, '65');
+                assert.deepEqual(response['buildRequests'][0].commitSet, 401);
+                assert.deepEqual(response['buildRequests'][0].status, 'canceled');
+                assert.deepEqual(response['buildRequests'][0].test, '200');
+
+                assert.deepEqual(response['buildRequests'][1].id, 701);
+                assert.deepEqual(response['buildRequests'][1].order, 1);
+                assert.deepEqual(response['buildRequests'][1].platform, '65');
+                assert.deepEqual(response['buildRequests'][1].commitSet, 402);
+                assert.deepEqual(response['buildRequests'][1].status, 'pending');
+                assert.deepEqual(response['buildRequests'][1].test, '200');
+
+                assert.deepEqual(response['buildRequests'][2].id, 702);
+                assert.deepEqual(response['buildRequests'][2].order, 2);
+                assert.deepEqual(response['buildRequests'][2].platform, '65');
+                assert.deepEqual(response['buildRequests'][2].commitSet, 401);
+                assert.deepEqual(response['buildRequests'][2].status, 'pending');
+                assert.deepEqual(response['buildRequests'][2].test, '200');
+
+                assert.deepEqual(response['buildRequests'][3].id, 703);
+                assert.deepEqual(response['buildRequests'][3].order, 3);
+                assert.deepEqual(response['buildRequests'][3].platform, '65');
+                assert.deepEqual(response['buildRequests'][3].commitSet, 402);
+                assert.deepEqual(response['buildRequests'][3].status, 'pending');
+                assert.deepEqual(response['buildRequests'][3].test, '200');
+            }, () => {
+                assert(false, 'Should not be reached');
+            });
+        });
+    });
 });