Changeset 250966 in webkit


Ignore:
Timestamp:
Oct 10, 2019 7:47:10 AM (5 years ago)
Author:
Jonathan Bedard
Message:

results.webkit.org: Start reporting results
https://bugs.webkit.org/show_bug.cgi?id=202639

Reviewed by Dewei Zhu.

  • BuildSlaveSupport/build.webkit.org-config/loadConfig.py:

(loadBuilderConfig): Load API key for results.webkit.org.

  • BuildSlaveSupport/build.webkit.org-config/make_passwords_json.py:

(create_mock_slave_passwords_dict): Add mock for API key.

  • BuildSlaveSupport/build.webkit.org-config/steps.py:

(RunWebKitTests): Start reporting to results.webkit.org.
(RunWebKitTests.init): Do not print the environment to hide the API key.
(RunWebKitTests.start): Add the API key to the environment.
(RunAPITests): Start reporting to results.webkit.org.
(RunAPITests.init): Do not print the environment to hide the API key.
(RunAPITests.start): Add the API key to the environment.
(RunPythonTests): Start reporting to results.webkit.org.
(RunPythonTests.init): Do not print the environment to hide the API key.
(RunPythonTests.start): Add the API key to the environment.

  • Scripts/webkitpy/results/upload.py:

(Upload):
(Upload.upload): Add API_KEY, if it exists, to the request.
(Upload.upload_archive): Ditto.

Location:
trunk/Tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/loadConfig.py

    r250851 r250966  
    5050    else:
    5151        passwords = json.load(open('passwords.json'))
     52    results_server_api_key = passwords.get('results-server-api-key')
     53    if results_server_api_key:
     54        os.environ['RESULTS_SERVER_API_KEY'] = results_server_api_key
     55
    5256    config = json.load(open('config.json'))
    53 
    5457    c['slaves'] = [BuildSlave(slave['name'], passwords[slave['name']], max_builds=1) for slave in config['slaves']]
    5558
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/make_passwords_json.py

    r250851 r250966  
    3232    with open('config.json', 'r') as config_json:
    3333        config_dict = json.load(config_json)
    34     return dict([(slave['name'], '1234') for slave in config_dict['slaves']])
     34    result = dict([(slave['name'], '1234') for slave in config_dict['slaves']])
     35    result['results-server-api-key'] = 'api-key'
     36    return result
    3537
    3638if __name__ == '__main__':
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/steps.py

    r250851 r250966  
    3636S3URL = "https://s3-us-west-2.amazonaws.com/"
    3737WithProperties = properties.WithProperties
     38RESULTS_WEBKIT = 'https://results.webkit.org'
     39RESULTS_SERVER_API_KEY = 'RESULTS_SERVER_API_KEY'
    3840
    3941
     
    417419               "--builder-name", WithProperties("%(buildername)s"),
    418420               "--build-number", WithProperties("%(buildnumber)s"),
     421               "--buildbot-worker", WithProperties("%(slavename)s"),
    419422               "--master-name", "webkit.org",
     423               "--buildbot-master", "build.webkit.org",
     424               "--report", RESULTS_WEBKIT,
    420425               "--test-results-server", "webkit-test-results.webkit.org",
    421426               "--exit-after-n-crashes-or-timeouts", "50",
     
    423428               WithProperties("--%(configuration)s")]
    424429
    425     def start(self):
     430    def __init__(self, *args, **kwargs):
     431        kwargs['logEnviron'] = False
     432        shell.Test.__init__(self, *args, **kwargs)
     433
     434    def start(self):
     435        self.slaveEnvironment[RESULTS_SERVER_API_KEY] = os.getenv(RESULTS_SERVER_API_KEY)
     436
    426437        platform = self.getProperty('platform')
    427438        appendCustomTestingFlags(self, platform, self.getProperty('device_model'))
     
    531542    description = ["api tests running"]
    532543    descriptionDone = ["api-tests"]
    533     command = ["python", "./Tools/Scripts/run-api-tests", "--no-build", WithProperties("--%(configuration)s"), "--verbose"]
     544    command = [
     545        "python",
     546        "./Tools/Scripts/run-api-tests",
     547        "--no-build",
     548        WithProperties("--%(configuration)s"),
     549        "--verbose",
     550        "--buildbot-master", "build.webkit.org",
     551        "--builder-name", WithProperties("%(buildername)s"),
     552        "--build-number", WithProperties("%(buildnumber)s"),
     553        "--buildbot-worker", WithProperties("%(slavename)s"),
     554        "--report", RESULTS_WEBKIT,
     555    ]
    534556    failedTestsFormatString = "%d api test%s failed or timed out"
    535557
    536     def start(self):
     558    def __init__(self, *args, **kwargs):
     559        kwargs['logEnviron'] = False
     560        TestWithFailureCount.__init__(self, *args, **kwargs)
     561
     562    def start(self):
     563        self.slaveEnvironment[RESULTS_SERVER_API_KEY] = os.getenv(RESULTS_SERVER_API_KEY)
    537564        appendCustomTestingFlags(self, self.getProperty('platform'), self.getProperty('device_model'))
    538565        return shell.Test.start(self)
     
    551578    description = ["python-tests running"]
    552579    descriptionDone = ["python-tests"]
    553     command = ["python", "./Tools/Scripts/test-webkitpy", "--verbose", WithProperties("--%(configuration)s")]
     580    command = [
     581        "python",
     582        "./Tools/Scripts/test-webkitpy",
     583        "--verbose",
     584        WithProperties("--%(configuration)s"),
     585        "--buildbot-master", "build.webkit.org",
     586        "--builder-name", WithProperties("%(buildername)s"),
     587        "--build-number", WithProperties("%(buildnumber)s"),
     588        "--buildbot-worker", WithProperties("%(slavename)s"),
     589        "--report", RESULTS_WEBKIT,
     590    ]
    554591    failedTestsFormatString = "%d python test%s failed"
    555592
    556     def start(self):
     593    def __init__(self, *args, **kwargs):
     594        kwargs['logEnviron'] = False
     595        TestWithFailureCount.__init__(self, *args, **kwargs)
     596
     597    def start(self):
     598        self.slaveEnvironment[RESULTS_SERVER_API_KEY] = os.getenv(RESULTS_SERVER_API_KEY)
     599
    557600        platform = self.getProperty('platform')
    558601        # Python tests are flaky on the GTK builders, running them serially
  • trunk/Tools/ChangeLog

    r250946 r250966  
     12019-10-10  Jonathan Bedard  <jbedard@apple.com>
     2
     3        results.webkit.org: Start reporting results
     4        https://bugs.webkit.org/show_bug.cgi?id=202639
     5
     6        Reviewed by Dewei Zhu.
     7
     8        * BuildSlaveSupport/build.webkit.org-config/loadConfig.py:
     9        (loadBuilderConfig): Load API key for results.webkit.org.
     10        * BuildSlaveSupport/build.webkit.org-config/make_passwords_json.py:
     11        (create_mock_slave_passwords_dict): Add mock for API key.
     12        * BuildSlaveSupport/build.webkit.org-config/steps.py:
     13        (RunWebKitTests): Start reporting to results.webkit.org.
     14        (RunWebKitTests.__init__): Do not print the environment to hide the API key.
     15        (RunWebKitTests.start): Add the API key to the environment.
     16        (RunAPITests): Start reporting to results.webkit.org.
     17        (RunAPITests.__init__): Do not print the environment to hide the API key.
     18        (RunAPITests.start): Add the API key to the environment.
     19        (RunPythonTests): Start reporting to results.webkit.org.
     20        (RunPythonTests.__init__): Do not print the environment to hide the API key.
     21        (RunPythonTests.start): Add the API key to the environment.
     22        * Scripts/webkitpy/results/upload.py:
     23        (Upload):
     24        (Upload.upload): Add API_KEY, if it exists, to the request.
     25        (Upload.upload_archive): Ditto.
     26
    1272019-10-09  Russell Epstein  <repstein@apple.com>
    228
  • trunk/Tools/Scripts/webkitpy/results/upload.py

    r250851 r250966  
    2323import webkitpy.thirdparty.autoinstalled.requests
    2424
     25import os
    2526import json
    2627import requests
     
    3233
    3334class Upload(object):
     35    API_KEY = os.getenv('RESULTS_SERVER_API_KEY')
    3436    UPLOAD_ENDPOINT = '/api/upload'
    3537    ARCHIVE_UPLOAD_ENDPOINT = '/api/upload/archive'
     
    170172    def upload(self, hostname, log_line_func=lambda val: sys.stdout.write(val + '\n')):
    171173        try:
    172             response = requests.post('{}{}'.format(hostname, self.UPLOAD_ENDPOINT), data=json.dumps(self, cls=Upload.Encoder))
     174            data = Upload.Encoder().default(self)
     175            if self.API_KEY:
     176                data['api_key'] = self.API_KEY
     177            response = requests.post(
     178                '{}{}'.format(hostname, self.UPLOAD_ENDPOINT),
     179                headers={'Content-type': 'application/json'},
     180                data=json.dumps(data),
     181            )
    173182        except requests.exceptions.ConnectionError:
    174183            log_line_func(' ' * 4 + 'Failed to upload to {}, results server not online'.format(hostname))
     
    180189        if response.status_code != 200:
    181190            log_line_func(' ' * 4 + 'Error uploading to {}'.format(hostname))
    182             log_line_func(' ' * 8 + response.json().get('description'))
     191            try:
     192                log_line_func(' ' * 8 + response.json().get('description'))
     193            except ValueError:
     194                for line in response.text.splitlines():
     195                    log_line_func(' ' * 8 + line)
    183196            return False
    184197
     
    196209            if self.timestamp:
    197210                meta_data['timestamp'] = self.timestamp
     211            if self.API_KEY:
     212                meta_data['api_key'] = self.API_KEY
     213            meta_data['Content-type'] = 'application/octet-stream'
    198214            response = requests.post(
    199215                '{}{}'.format(hostname, self.ARCHIVE_UPLOAD_ENDPOINT),
     
    209225            return False
    210226
    211         if response.status_code != 200:
     227        # FIXME: <rdar://problem/56154412> do not fail test runs because of 403 errors
     228        if response.status_code not in [200, 403]:
    212229            log_line_func(' ' * 4 + 'Error uploading archive to {}'.format(hostname))
    213             log_line_func(' ' * 8 + response.json().get('description'))
     230            try:
     231                log_line_func(' ' * 8 + response.json().get('description'))
     232            except ValueError:
     233                for line in response.text.splitlines():
     234                    log_line_func(' ' * 8 + line)
    214235            return False
    215236
  • trunk/Tools/Scripts/webkitpy/results/upload_unittest.py

    r249652 r250966  
    127127        )
    128128
    129         with mock.patch('requests.post', new=lambda url, data: self.MockResponse()):
     129        with mock.patch('requests.post', new=lambda url, headers={}, data={}: self.MockResponse()):
    130130            self.assertTrue(upload.upload('https://results.webkit.org', log_line_func=lambda _: None))
    131131
    132         with mock.patch('requests.post', new=lambda url, data: self.raise_requests_ConnectionError()):
     132        with mock.patch('requests.post', new=lambda url, headers={}, data={}: self.raise_requests_ConnectionError()):
    133133            lines = []
    134134            self.assertFalse(upload.upload('https://results.webkit.org', log_line_func=lambda line: lines.append(line)))
    135135            self.assertEqual([' ' * 4 + 'Failed to upload to https://results.webkit.org, results server not online'], lines)
    136136
    137         mock_404 = mock.patch('requests.post', new=lambda url, data: self.MockResponse(
     137        mock_404 = mock.patch('requests.post', new=lambda url, headers={}, data={}: self.MockResponse(
    138138            status_code=404,
    139139            text=json.dumps(dict(description='No such address')),
     
    228228        )
    229229
    230         with mock.patch('requests.post', new=lambda url, data, files: self.MockResponse()):
     230        with mock.patch('requests.post', new=lambda url, headers={}, data={}, files={}: self.MockResponse()):
    231231            self.assertTrue(upload.upload_archive('https://results.webkit.org', archive='content', log_line_func=lambda _: None))
    232232
    233         with mock.patch('requests.post', new=lambda url, data, files: self.raise_requests_ConnectionError()):
     233        with mock.patch('requests.post', new=lambda url, headers={}, data={}, files={}: self.raise_requests_ConnectionError()):
    234234            lines = []
    235235            self.assertFalse(upload.upload_archive('https://results.webkit.org', archive='content', log_line_func=lambda line: lines.append(line)))
    236236            self.assertEqual([' ' * 4 + 'Failed to upload test archive to https://results.webkit.org, results server not online'], lines)
    237237
    238         mock_404 = mock.patch('requests.post', new=lambda url, data, files: self.MockResponse(
     238        mock_404 = mock.patch('requests.post', new=lambda url, headers={}, data={}, files={}: self.MockResponse(
    239239            status_code=404,
    240240            text=json.dumps(dict(description='No such address')),
Note: See TracChangeset for help on using the changeset viewer.