Пример #1
0
    def testComposite(self):
        external_key = namespaced_stored_object.NamespaceKey(
            update_test_suites.TEST_SUITES_2_CACHE_KEY,
            datastore_hooks.EXTERNAL)
        stored_object.Set(external_key, ['TEST_PARTIAL_TEST_SUITE:COMPOSITE'])
        testing_common.AddTests(
            ['master'], ['bot'], {
                'TEST_PARTIAL_TEST_SUITE': {
                    'COMPOSITE': {
                        'measurement': {
                            'test_case': {},
                        },
                    },
                },
            })
        test = utils.TestKey('master/bot/TEST_PARTIAL_TEST_SUITE/COMPOSITE/' +
                             'measurement/test_case').get()
        test.has_rows = True
        test.put()

        self.Post('/update_test_suite_descriptors')
        self.ExecuteDeferredTasks('default')
        expected = {
            'measurements': ['measurement'],
            'bots': ['master:bot'],
            'cases': ['test_case'],
            'caseTags': {},
        }
        actual = update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
            'TEST_PARTIAL_TEST_SUITE:COMPOSITE')
        self.assertEqual(expected, actual)
Пример #2
0
  def testUnparsed(self):
    external_key = namespaced_stored_object.NamespaceKey(
        update_test_suites.TEST_SUITES_2_CACHE_KEY, datastore_hooks.EXTERNAL)
    stored_object.Set(external_key, ['unparsed'])
    testing_common.AddTests(
        ['master'],
        ['bot'],
        {
            'unparsed': {
                'a': {
                    'b': {
                        'c': {},
                    },
                },
            },
        })
    test = utils.TestKey('master/bot/unparsed/a/b/c').get()
    test.has_rows = True
    test.put()

    self.Post('/update_test_suite_descriptors')
    with self.assertRaises(ValueError):
      self.ExecuteDeferredTasks('default')
    actual = update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
        'unparsed')
    self.assertEqual(None, actual)
    def testInternal(self):
        internal_key = namespaced_stored_object.NamespaceKey(
            update_test_suites.TEST_SUITES_2_CACHE_KEY,
            datastore_hooks.INTERNAL)
        stored_object.Set(internal_key, ['internal'])
        testing_common.AddTests(['master'], ['bot'], {
            'internal': {
                'measurement': {
                    'test_case': {},
                },
            },
        })
        test = utils.TestKey('master/bot/internal/measurement/test_case').get()
        test.has_rows = True
        test.put()

        self.Post('/update_test_suite_descriptors?internal_only=true')
        self.ExecuteDeferredTasks('default')
        expected = {
            'measurements': ['measurement'],
            'bots': ['master:bot'],
            'cases': ['test_case'],
        }
        self.SetCurrentUser('*****@*****.**')
        actual = update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
            'internal')
        self.assertEqual(expected, actual)
    def testCaseTags(self):
        external_key = namespaced_stored_object.NamespaceKey(
            update_test_suites.TEST_SUITES_2_CACHE_KEY,
            datastore_hooks.EXTERNAL)
        stored_object.Set(external_key, ['suite'])
        testing_common.AddTests(['master'], ['a', 'b'], {
            'suite': {
                'measurement': {
                    'x': {},
                    'y': {},
                    'z': {},
                },
            },
        })
        for bot in 'ab':
            for case in 'xyz':
                test = utils.TestKey('master/%s/suite/measurement/%s' %
                                     (bot, case)).get()
                test.has_rows = True
                test.put()
        histogram.SparseDiagnostic(test=utils.TestKey('master/a/suite'),
                                   name=reserved_infos.TAG_MAP.name,
                                   end_revision=sys.maxint,
                                   data=histogram_module.TagMap({
                                       'tagsToStoryNames': {
                                           'j': ['x']
                                       }
                                   }).AsDict()).put()
        histogram.SparseDiagnostic(test=utils.TestKey('master/b/suite'),
                                   name=reserved_infos.TAG_MAP.name,
                                   end_revision=sys.maxint,
                                   data=histogram_module.TagMap({
                                       'tagsToStoryNames': {
                                           'j': ['y'],
                                           'k': ['y']
                                       }
                                   }).AsDict()).put()

        self.Post('/update_test_suite_descriptors')

        self.ExecuteDeferredTasks('default')

        expected = {
            'measurements': ['measurement'],
            'bots': ['master:a', 'master:b'],
            'cases': ['x', 'y', 'z'],
            'caseTags': {
                'j': ['x', 'y'],
                'k': ['y']
            },
        }
        actual = update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
            'suite')
        self.assertEqual(expected, actual)
    def testInternal(self):
        internal_key = namespaced_stored_object.NamespaceKey(
            update_test_suites.TEST_SUITES_2_CACHE_KEY,
            datastore_hooks.INTERNAL)
        stored_object.Set(internal_key, ['internal'])
        testing_common.AddTests(['master'], ['bot'], {
            'internal': {
                'measurement': {
                    'test_case': {},
                },
            },
        })
        test = utils.TestKey('master/bot/internal/measurement/test_case').get()
        test.unescaped_story_name = 'test_case'
        test.has_rows = True
        test.internal_only = True
        test.put()

        self.Post('/update_test_suite_descriptors?internal_only=true')

        # deferred.Defer() packages up the function call and arguments, not changes
        # to global state like SetPrivilegedRequest, so set privileged=False as the
        # taskqueue does, and test that UpdateDescriptor sets it back to True so
        # that it gets the internal TestMetadata.
        class FakeRequest(object):
            def __init__(self):
                self.registry = {'privileged': False}

        webapp2._local.request = FakeRequest()
        self.ExecuteDeferredTasks('default')

        expected = {
            'measurements': ['measurement'],
            'bots': ['bot'],
            'cases': ['test_case'],
            'caseTags': {},
        }
        self.SetCurrentUser('*****@*****.**')
        actual = update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
            'master', 'internal')
        self.assertEqual(expected, actual)
Пример #6
0
def GetSystemHealthDescriptors():
    return update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
        'system_health.memory_mobile')
Пример #7
0
 def UnprivilegedPost(self, *args):
     return update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
         args[0])
Пример #8
0
 def Post(self):
     master = self.request.get('master')
     suite = self.request.get('test_suite')
     return update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
         master, suite)
Пример #9
0
 def Post(self):
     return update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
         self.request.get('test_suite'))
Пример #10
0
 def AuthorizedPost(self, *args):
     return update_test_suite_descriptors.FetchCachedTestSuiteDescriptor(
         args[0])