Example #1
0
def cache_test_summaries(project):

    ptm = PerformanceTestModel(project)

    ###
    #New reference data could be found in the cached data
    #summary structures. Update the reference data cached 
    #every time the sumary data is cached.
    ###
    ptm.cache_ref_data()
    ptm.cache_default_project()

    data_iter = ptm.get_all_summary_cache()

    for d in data_iter:
        for data in d:
            key = utils.get_summary_cache_key(
                project,
                data['item_id'],
                data['item_data'],
                )

            rv = cache.set(key, zlib.compress( data['value'] ))
            if not rv:
                msg = "ERROR: Failed to store object in memcache: %s, %s\n" % \
                        ( str(data['item_id']), data['item_data'] )
                sys.stderr.write(msg)

    ptm.disconnect()
Example #2
0
def cache_test_summaries(project):

    ptm = PerformanceTestModel(project)

    ###
    #New reference data could be found in the cached data
    #summary structures. Update the reference data cached
    #every time the sumary data is cached.
    ###
    ptm.cache_ref_data()
    ptm.cache_default_project()

    data_iter = ptm.get_all_summary_cache()

    key_test = []
    for d in data_iter:
        for data in d:
            key = utils.get_summary_cache_key(
                project,
                data['item_id'],
                data['item_data'],
            )
            rv = cache.set(key, zlib.compress(data['value']))
            if not rv:
                msg = "ERROR: Failed to store object in memcache: %s, %s\n" % \
                        ( str(data['item_id']), data['item_data'] )
                sys.stderr.write(msg)

    ptm.disconnect()
Example #3
0
def _get_test_run_summary(project, method, request, dm):

    product_ids = []
    test_ids = []
    platform_ids = []

    #####
    #Calling get_id_list() insures that we have only numbers in the
    #lists, this gaurds against SQL injection
    #####
    if 'product_ids' in request.GET:
        product_ids = utils.get_id_list(request.GET['product_ids'])
    if 'test_ids' in request.GET:
        test_ids = utils.get_id_list(request.GET['test_ids'])
    if 'platform_ids' in request.GET:
        platform_ids = utils.get_id_list(request.GET['platform_ids'])

    time_key = 'days_30'
    time_ranges = utils.get_time_ranges()
    if 'tkey' in request.GET:
        time_key = request.GET['tkey']

    if not product_ids:

        ##Default to id 1
        product_ids = [1]

        ##Set default product_id
        pck = dm.get_project_cache_key('default_product')
        default_product = cache.get(pck)

        ##If we have one use it
        if default_product:
            product_ids = [ int(default_product['id']) ]

    json_data = '{}'

    if product_ids and (not test_ids) and (not platform_ids):

        if len(product_ids) > 1:
            extend_list = { 'data':[], 'columns':[] }
            for id in product_ids:
                key = utils.get_summary_cache_key(project, str(id), time_key)
                compressed_json_data = cache.get(key)

                if compressed_json_data:
                    json_data = zlib.decompress( compressed_json_data )
                    data = json.loads( json_data )
                    extend_list['data'].extend( data['data'] )
                    extend_list['columns'] = data['columns']

            json_data = json.dumps(extend_list)

        else:
            key = utils.get_summary_cache_key(
                project,
                str(product_ids[0]),
                time_key,
                )
            compressed_json_data = cache.get(key)

            if compressed_json_data:
                json_data = zlib.decompress( compressed_json_data )

    else:
        table = dm.get_test_run_summary(time_ranges[time_key]['start'],
                                     time_ranges[time_key]['stop'],
                                     product_ids,
                                     platform_ids,
                                     test_ids)

        json_data = json.dumps( table )

    return json_data