Exemple #1
0
 def setUp(self):
   super(StartBisectTest, self).setUp()
   stored_object.Set(
       start_try_job._TESTER_DIRECTOR_MAP_KEY,
       {
           'linux_perf_tester': 'linux_perf_bisector',
           'win64_nv_tester': 'linux_perf_bisector',
       })
   app = webapp2.WSGIApplication(
       [('/start_try_job', start_try_job.StartBisectHandler)])
   self.testapp = webtest.TestApp(app)
   namespaced_stored_object.Set(
       start_try_job._BISECT_BOT_MAP_KEY,
       {
           'ChromiumPerf': [
               ('nexus4', 'android_nexus4_perf_bisect'),
               ('nexus7', 'android_nexus7_perf_bisect'),
               ('win8', 'win_8_perf_bisect'),
               ('xp', 'win_xp_perf_bisect'),
               ('android', 'android_nexus7_perf_bisect'),
               ('mac', 'mac_perf_bisect'),
               ('win', 'win_perf_bisect'),
               ('linux', 'linux_perf_bisect'),
               ('', 'linux_perf_bisect'),
           ],
       })
   namespaced_stored_object.Set(
       start_try_job._BUILDER_TYPES_KEY,
       {'ChromiumPerf': 'perf', 'OtherMaster': 'foo'})
   testing_common.SetSheriffDomains(['chromium.org'])
 def setUp(self):
   super(StartBisectTest, self).setUp()
   app = webapp2.WSGIApplication(
       [('/start_try_job', start_try_job.StartBisectHandler)])
   self.testapp = webtest.TestApp(app)
   namespaced_stored_object.Set(
       can_bisect.BISECT_BOT_MAP_KEY,
       {
           'ChromiumPerf': [
               ('nexus4', 'android_nexus4_perf_bisect'),
               ('nexus7', 'android_nexus7_perf_bisect'),
               ('win8', 'win_8_perf_bisect'),
               ('xp', 'win_xp_perf_bisect'),
               ('android', 'android_nexus7_perf_bisect'),
               ('mac', 'mac_perf_bisect'),
               ('win', 'win_perf_bisect'),
               ('linux', 'linux_perf_bisect'),
               ('', 'linux_perf_bisect'),
           ],
       })
   namespaced_stored_object.Set(
       start_try_job._BUILDER_TYPES_KEY,
       {'ChromiumPerf': 'perf', 'OtherMaster': 'foo'})
   namespaced_stored_object.Set(
       start_try_job._BOT_BROWSER_MAP_KEY,
       [
           ['android', 'android-chromium'],
           ['winx64', 'release_x64'],
           ['win_x64', 'release_x64'],
           ['', 'release'],
       ])
   namespaced_stored_object.Set(
       start_try_job._TESTER_DIRECTOR_MAP_KEY,
       {
           'ChromiumPerf': {
               'linux_perf_tester': 'linux_perf_bisector',
               'win64_nv_tester': 'linux_perf_bisector',
           }
       })
   namespaced_stored_object.Set(
       start_try_job._MASTER_BUILDBUCKET_MAP_KEY,
       {
           'ChromiumPerf': 'master.tryserver.chromium.perf'
       })
   testing_common.SetSheriffDomains(['chromium.org'])
   # Add fake Rietveld auth info.
   rietveld_config = rietveld_service.RietveldConfig(
       id='default_rietveld_config',
       client_email='*****@*****.**',
       service_account_key='Fake Account Key',
       server_url='https://test-rietveld.appspot.com')
   rietveld_config.put()
 def testGuessBisectBot_PlatformNotFound_UsesFallback(self):
   namespaced_stored_object.Set(
       can_bisect.BISECT_BOT_MAP_KEY,
       {'OtherMaster': [('foo', 'super_foo_bisect_bot')]})
   self.assertEqual(
       'linux_perf_bisect',
       start_try_job.GuessBisectBot('OtherMaster', 'bar'))
 def testGuessBisectBot_TreatsMasterNameAsPrefix(self):
   namespaced_stored_object.Set(
       can_bisect.BISECT_BOT_MAP_KEY,
       {'OtherMaster': [('foo', 'super_foo_bisect_bot')]})
   self.assertEqual(
       'super_foo_bisect_bot',
       start_try_job.GuessBisectBot('OtherMasterFyi', 'foo'))
Exemple #5
0
 def testGet_WithNamespacedKey_ShowsPageWithBothVersions(self):
     namespaced_stored_object.Set('foo', 'XXXYYY')
     namespaced_stored_object.SetExternal('foo', 'XXXinternalYYY')
     response = self.testapp.get('/edit_site_config?key=foo')
     self.assertEqual(1, len(response.html('form')))
     self.assertIn('XXXYYY', response.body)
     self.assertIn('XXXinternalYYY', response.body)
 def testGuessBisectBot_FetchesNameFromBisectBotMap(self):
   namespaced_stored_object.Set(
       can_bisect.BISECT_BOT_MAP_KEY,
       {'OtherMaster': [('foo', 'super_foo_bisect_bot')]})
   self.assertEqual(
       'super_foo_bisect_bot',
       start_try_job.GuessBisectBot('OtherMaster', 'foo'))
 def setUp(self):
     super(CanBisectTest, self).setUp()
     app = webapp2.WSGIApplication([('/can_bisect',
                                     can_bisect.CanBisectHandler)])
     self.testapp = webtest.TestApp(app)
     testing_common.SetIsInternalUser('*****@*****.**', True)
     self.SetCurrentUser('*****@*****.**')
     namespaced_stored_object.Set(
         can_bisect.BISECT_BOT_MAP_KEY,
         {'SupportedMaster': ['perf_bot', 'bisect_bot']})
 def testPost_WithKey_UpdatesNamespacedValues(self):
   namespaced_stored_object.Set('foo', 'XXXinternalYYY')
   namespaced_stored_object.SetExternal('foo', 'XXXYYY')
   self.testapp.post('/edit_site_config', {
       'key': 'foo',
       'external_value': '{"x": "y"}',
       'internal_value': '{"x": "yz"}',
       'xsrf_token': xsrf.GenerateToken(users.get_current_user()),
   })
   self.assertEqual({'x': 'yz'}, namespaced_stored_object.Get('foo'))
   self.assertEqual({'x': 'y'}, namespaced_stored_object.GetExternal('foo'))
Exemple #9
0
 def setUp(self):
   super(StartNewBisectForBugTest, self).setUp()
   self.SetCurrentUser('*****@*****.**')
   namespaced_stored_object.Set(
       start_try_job._TESTER_DIRECTOR_MAP_KEY,
       {
           'ChromiumPerf': {
               'linux_perf_tester': 'linux_perf_bisector',
               'win64_nv_tester': 'linux_perf_bisector',
           }
       })
Exemple #10
0
 def setUp(self):
   super(AutoBisectTest, self).setUp()
   app = webapp2.WSGIApplication(
       [('/auto_bisect', auto_bisect.AutoBisectHandler)])
   testing_common.SetIsInternalUser('*****@*****.**', True)
   self.testapp = webtest.TestApp(app)
   self.SetCurrentUser('*****@*****.**')
   namespaced_stored_object.Set(
       start_try_job._TESTER_DIRECTOR_MAP_KEY,
       {
           'ChromiumPerf': {
               'linux_perf_tester': 'linux_perf_bisector',
               'win64_nv_tester': 'linux_perf_bisector',
           }
       })
 def setUp(self):
     super(BisectFYITest, self).setUp()
     app = webapp2.WSGIApplication([('/bisect_fyi',
                                     bisect_fyi.BisectFYIHandler)])
     self.testapp = webtest.TestApp(app)
     stored_object.Set(bisect_fyi._BISECT_FYI_CONFIGS_KEY, TEST_FYI_CONFIGS)
     testing_common.SetIsInternalUser('*****@*****.**', True)
     self.SetCurrentUser('*****@*****.**')
     namespaced_stored_object.Set(
         start_try_job._TESTER_DIRECTOR_MAP_KEY, {
             'ChromiumPerf': {
                 'linux_perf_bisect': 'linux_perf_bisector',
                 'win_x64_perf_bisect': 'win_x64_perf_bisect',
             }
         })
Exemple #12
0
def SetCache(test_path, rows):
    """Sets the saved graph revisions data for a test.

  Args:
    test_path: A test path string.
    rows: A list of [revision, value, timestamp] triplets.
  """
    # This first set generally only sets the internal-only cache.
    namespaced_stored_object.Set(_CACHE_KEY % test_path, rows)

    # If this is an internal_only query for externally available data,
    # set the cache for that too.
    if datastore_hooks.IsUnalteredQueryPermitted():
        test = utils.TestKey(test_path).get()
        if test and not test.internal_only:
            namespaced_stored_object.SetExternal(_CACHE_KEY % test_path, rows)
  def post(self):
    """Accepts posted values, makes changes, and shows the form again."""
    key = self.request.get('key')

    if not utils.IsInternalUser():
      self.RenderHtml('edit_site_config.html', {
          'error': 'Only internal users can post to this end-point.'
      })
      return

    if not key:
      self.RenderHtml('edit_site_config.html', {})
      return

    new_value_json = self.request.get('value').strip()
    new_external_value_json = self.request.get('external_value').strip()
    new_internal_value_json = self.request.get('internal_value').strip()

    template_params = {
        'key': key,
        'value': new_value_json,
        'external_value': new_external_value_json,
        'internal_value': new_internal_value_json,
    }

    try:
      new_value = json.loads(new_value_json or 'null')
      new_external_value = json.loads(new_external_value_json or 'null')
      new_internal_value = json.loads(new_internal_value_json or 'null')
    except ValueError:
      template_params['error'] = 'Invalid JSON in at least one field.'
      self.RenderHtml('edit_site_config.html', template_params)
      return

    old_value = stored_object.Get(key)
    old_external_value = namespaced_stored_object.GetExternal(key)
    old_internal_value = namespaced_stored_object.Get(key)

    stored_object.Set(key, new_value)
    namespaced_stored_object.SetExternal(key, new_external_value)
    namespaced_stored_object.Set(key, new_internal_value)

    _SendNotificationEmail(
        key, old_value, old_external_value, old_internal_value,
        new_value, new_external_value, new_internal_value)

    self.RenderHtml('edit_site_config.html', template_params)
Exemple #14
0
  def post(self):
    """Accepts posted values, makes changes, and shows the form again."""
    key = self.request.get('key')

    if not utils.IsInternalUser():
      self.RenderHtml('edit_site_config.html', {
          'error': 'Only internal users can post to this end-point.'
      })
      return

    if not key:
      self.RenderHtml('edit_site_config.html', {})
      return

    value = self.request.get('value').strip()
    external_value = self.request.get('external_value').strip()
    internal_value = self.request.get('internal_value').strip()
    template_params = {
        'key': key,
        'value': value,
        'external_value': external_value,
        'internal_value': internal_value,
    }

    try:
      if value:
        stored_object.Set(key, json.loads(value))
      if external_value:
        namespaced_stored_object.SetExternal(key, json.loads(external_value))
      if internal_value:
        namespaced_stored_object.Set(key, json.loads(internal_value))
    except ValueError:
      template_params['error'] = 'Invalid JSON in at least one field.'

    _SendNotificationEmail(key, template_params)
    self.RenderHtml('edit_site_config.html', template_params)
Exemple #15
0
 def testPost_SendsNotificationEmail(self):
     namespaced_stored_object.SetExternal('foo', {'x': 10, 'y': 2})
     namespaced_stored_object.Set('foo', {'z': 3, 'x': 1})
     self.testapp.post(
         '/edit_site_config', {
             'key': 'foo',
             'external_value': '{"x": 1, "y": 2}',
             'internal_value': '{"x": 1, "z": 3, "y": 2}',
             'xsrf_token': xsrf.GenerateToken(users.get_current_user()),
         })
     messages = self.mail_stub.get_sent_messages()
     self.assertEqual(1, len(messages))
     self.assertEqual('*****@*****.**', messages[0].sender)
     self.assertEqual('*****@*****.**',
                      messages[0].to)
     self.assertEqual('Config "foo" changed by [email protected]',
                      messages[0].subject)
     self.assertIn(
         'Non-namespaced value diff:\n'
         '  null\n'
         '\n'
         'Externally-visible value diff:\n'
         '  {\n'
         '-   "x": 10, \n'
         '?         -\n'
         '\n'
         '+   "x": 1, \n'
         '    "y": 2\n'
         '  }\n'
         '\n'
         'Internal-only value diff:\n'
         '  {\n'
         '    "x": 1, \n'
         '+   "y": 2, \n'
         '    "z": 3\n'
         '  }\n', str(messages[0].body))
 def setUp(self):
   super(CanBisectTest, self).setUp()
   namespaced_stored_object.Set(
       can_bisect.BISECT_BOT_MAP_KEY,
       {'SupportedMaster': ['perf_bot', 'bisect_bot']})
 def testSet_ExternalUser_ExternalVersionSet(self):
     self.SetCurrentUser('*****@*****.**')
     namespaced_stored_object.Set('foo', 12345)
     self.assertIsNone(stored_object.Get('internal_only__foo'))
     self.assertEqual(12345, stored_object.Get('externally_visible__foo'))