| OLD | NEW | 
|---|
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be | 
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. | 
| 4 | 4 | 
| 5 import os |  | 
| 6 |  | 
| 7 from recipe_engine import recipe_api | 5 from recipe_engine import recipe_api | 
| 8 | 6 | 
| 9 class GomaApi(recipe_api.RecipeApi): | 7 class GomaApi(recipe_api.RecipeApi): | 
| 10   """GomaApi contains helper functions for using goma.""" | 8   """GomaApi contains helper functions for using goma.""" | 
| 11 | 9 | 
| 12   def __init__(self, **kwargs): | 10   def __init__(self, **kwargs): | 
| 13     super(GomaApi, self).__init__(**kwargs) | 11     super(GomaApi, self).__init__(**kwargs) | 
| 14     self._goma_dir = None | 12     self._goma_dir = None | 
| 15     self._goma_started = False | 13     self._goma_started = False | 
| 16 | 14 | 
| 17     self._goma_ctl_env_init() |  | 
| 18 |  | 
| 19   def _goma_ctl_env_init(self): |  | 
| 20     self._goma_ctl_env = {} | 15     self._goma_ctl_env = {} | 
| 21 | 16 | 
| 22     # Inherit some env vars used in goma_utils.SendGomaTsMon. |  | 
| 23     for key in ['BUILDBOT_BUILDERNAME', |  | 
| 24                 'BUILDBOT_MASTERNAME', |  | 
| 25                 'BUILDBOT_SLAVENAME', |  | 
| 26                 'BUILDBOT_CLOBBER', |  | 
| 27                 'TEST_TMPDIR', |  | 
| 28                 'TMPDIR', |  | 
| 29                 'TMP', |  | 
| 30     ]: |  | 
| 31       if key in os.environ: # pragma: no cover |  | 
| 32         self._goma_ctl_env[key] = os.environ[key] |  | 
| 33 |  | 
| 34   @property | 17   @property | 
| 35   def service_account_json_path(self): | 18   def service_account_json_path(self): | 
| 36     if self.m.platform.is_win: | 19     if self.m.platform.is_win: | 
| 37       return 'C:\\creds\\service_accounts\\service-account-goma-client.json' | 20       return 'C:\\creds\\service_accounts\\service-account-goma-client.json' | 
| 38     return '/creds/service_accounts/service-account-goma-client.json' | 21     return '/creds/service_accounts/service-account-goma-client.json' | 
| 39 | 22 | 
| 40   def ensure_goma(self, canary=False): | 23   def ensure_goma(self, canary=False): | 
| 41     with self.m.step.nest('ensure_goma'): | 24     with self.m.step.nest('ensure_goma'): | 
| 42       with self.m.step.context({'infra_step': True}): | 25       with self.m.step.context({'infra_step': True}): | 
| 43         try: | 26         try: | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 79 | 62 | 
| 80     if self.build_data_dir: | 63     if self.build_data_dir: | 
| 81       self._goma_ctl_env['GOMA_DUMP_STATS_FILE'] = ( | 64       self._goma_ctl_env['GOMA_DUMP_STATS_FILE'] = ( | 
| 82           self.m.path.join(self.build_data_dir, 'goma_stats_proto')) | 65           self.m.path.join(self.build_data_dir, 'goma_stats_proto')) | 
| 83       self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'] = ( | 66       self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'] = ( | 
| 84           self.m.path.join(self.build_data_dir, 'crash_report_id_file')) | 67           self.m.path.join(self.build_data_dir, 'crash_report_id_file')) | 
| 85 | 68 | 
| 86     self._goma_ctl_env['GOMA_SERVICE_ACCOUNT_JSON_FILE'] = ( | 69     self._goma_ctl_env['GOMA_SERVICE_ACCOUNT_JSON_FILE'] = ( | 
| 87         self.service_account_json_path) | 70         self.service_account_json_path) | 
| 88 | 71 | 
| 89     # GLOG_log_dir should not be set. |  | 
| 90     assert env is None or 'GLOG_log_dir' not in env |  | 
| 91 |  | 
| 92     goma_ctl_start_env = self._goma_ctl_env.copy() | 72     goma_ctl_start_env = self._goma_ctl_env.copy() | 
| 93 | 73 | 
| 94     if env is not None: | 74     if env is not None: | 
| 95       goma_ctl_start_env.update(env) | 75       goma_ctl_start_env.update(env) | 
| 96 | 76 | 
| 97     try: | 77     try: | 
| 98       self.m.python( | 78       self.m.python( | 
| 99           name='start_goma', | 79           name='start_goma', | 
| 100           script=self.goma_ctl, | 80           script=self.goma_ctl, | 
| 101           args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs) | 81           args=['restart'], env=goma_ctl_start_env, infra_step=True, **kwargs) | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 125     assert self._goma_started | 105     assert self._goma_started | 
| 126     self.m.python( | 106     self.m.python( | 
| 127         name='stop_goma', | 107         name='stop_goma', | 
| 128         script=self.goma_ctl, | 108         script=self.goma_ctl, | 
| 129         args=['stop'], env=self._goma_ctl_env, **kwargs) | 109         args=['stop'], env=self._goma_ctl_env, **kwargs) | 
| 130 | 110 | 
| 131     self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command, | 111     self.upload_logs(ninja_log_outdir, ninja_log_compiler, ninja_log_command, | 
| 132                      ninja_log_exit_status) | 112                      ninja_log_exit_status) | 
| 133 | 113 | 
| 134     self._goma_started = False | 114     self._goma_started = False | 
| 135     self._goma_ctl_env_init() | 115     self._goma_ctl_env = {} | 
| 136 |  | 
| 137 | 116 | 
| 138   def upload_logs(self, ninja_log_outdir=None, ninja_log_compiler=None, | 117   def upload_logs(self, ninja_log_outdir=None, ninja_log_compiler=None, | 
| 139                   ninja_log_command=None, ninja_log_exit_status=None, | 118                   ninja_log_command=None, ninja_log_exit_status=None, | 
| 140                   name=None): | 119                   name=None): | 
| 141     args = [ | 120     args = [ | 
| 142         '--upload-compiler-proxy-info' | 121         '--upload-compiler-proxy-info' | 
| 143     ] | 122     ] | 
| 144 | 123 | 
| 145     if ninja_log_outdir: | 124     if ninja_log_outdir: | 
| 146       assert ninja_log_compiler is not None | 125       assert ninja_log_compiler is not None | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 159           '--goma-stats-file', self._goma_ctl_env['GOMA_DUMP_STATS_FILE'], | 138           '--goma-stats-file', self._goma_ctl_env['GOMA_DUMP_STATS_FILE'], | 
| 160           '--goma-crash-report-id-file', | 139           '--goma-crash-report-id-file', | 
| 161           self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'], | 140           self._goma_ctl_env['GOMACTL_CRASH_REPORT_ID_FILE'], | 
| 162           '--build-data-dir', self.build_data_dir, | 141           '--build-data-dir', self.build_data_dir, | 
| 163       ]) | 142       ]) | 
| 164 | 143 | 
| 165     self.m.python( | 144     self.m.python( | 
| 166       name=name or 'upload_log', | 145       name=name or 'upload_log', | 
| 167       script=self.package_repo_resource( | 146       script=self.package_repo_resource( | 
| 168           'scripts', 'slave', 'upload_goma_logs.py'), | 147           'scripts', 'slave', 'upload_goma_logs.py'), | 
| 169       args=args, | 148       args=args | 
| 170       env=self._goma_ctl_env |  | 
| 171     ) | 149     ) | 
| OLD | NEW | 
|---|