Ejemplo n.º 1
0
def stop_test():
    logger.debug('stop_test')
    start_test_if_required()
    test_obj = TestResult()
    if not test_obj.is_test_completed():
        logger.warning('Test did not complete.')
        end_test(True)
Ejemplo n.º 2
0
 def generate_iteration_verdict(self):
     logger.info('Generate iteration verdict.')
     jsonResults = self.get_from_stc_collection_property_as_dict('JsonResults')
     if jsonResults and len(jsonResults) >= 0:
         return self.generate_iteration_result_file(jsonResults)
     else:
         return {}
Ejemplo n.º 3
0
 def set_iterator_result(self):
     logger.debug('Set iterator result object.')
     if self._stc_result_object is None:
         self._stc_result_object = iterator_utils.get_iterator(self._iterator_handle)
         if self._stc_result_object is None:
             self.create_new_iterator()
     logger.debug('Set iterator results object completed.')
Ejemplo n.º 4
0
 def generate_iteration_result_file(self, results):
     logger.info('Generate Iteration result file.')
     iteration = Iteration(self._active_iteration_info.run_time_data,
                           self._stc_result_object,
                           results,
                           self._active_iteration_status.run_time_data,)
     return iteration.generate_report()
Ejemplo n.º 5
0
def get_last_iteration_info_status(iterator_handle):
    logger.info('Get last iteration info for iterator:' + str(iterator_handle))
    result = iterator_utils.get_iterator_result_no_leaf_check(iterator_handle)
    if result is None:
        return None
    iterator = Iterator(iterator_handle, result)
    return iterator.get_last_iteration_data()
def get_data_from_query(db_file_list, query):
    result_data = sql_utils.get_all_data(db_file_list, query)
    rows = result_data[ProviderConst.ROW]
    row_data = []
    for row in rows:
        row_data.append(row[0])
    logger.debug("    row_data in get_data_from_query: " + str(row_data))
    return row_data
Ejemplo n.º 7
0
def end_test(force_stop=False):
    logger.info('end test. Force stop:' + str(force_stop))
    # end all iterators if required.
    start_test_if_required()
    end_all_iterators(force_stop)
    test_result = TestResult()
    test_result.end_test(force_stop)
    logger.debug('end test completed.')
Ejemplo n.º 8
0
def generate_report_file(report_name, data):
    filename = os.path.join(CTestResultSettingExt.GetResultDbBaseDirectory(), report_name)
    logger.info("Saving file:" + filename)
    if not os.path.exists(os.path.dirname(filename)):
        os.makedirs(os.path.dirname(filename))
    f = open(filename, "w")
    f.write(json.dumps(data, separators=(',', ':'), sort_keys=False))
    f.close()
    CFileManager.AddFile(filename, 'RESULT')
    return filename
Ejemplo n.º 9
0
def get_stm_test_result_throw():
    stm_tr = result_obj.get_stm_test_result()
    if stm_tr is None:
        """
        Log error for now and create result object.
        """
        # raise Exception("Unable to find StmTestResult object")
        logger.error('Unable to find StmTestResult object, creating one.')
        stm_tr = result_obj.create_stm_test_result_under_mm()
    return stm_tr
Ejemplo n.º 10
0
def get_active_result_object():
    """Leaf iterator is active result object.
        return StmTestRessult object if none exist.
    """
    logger.debug('Get active result object')
    result = get_leaf_iterator_no_throw()
    if result is None:
        logger.debug('Get active result object, No iterator result so return StmTestResult')
        return get_stm_test_result_throw()
    return result
Ejemplo n.º 11
0
def add_provider_result_to_root(dict_data):
    """Add provider result to test object.
    Try to create one and continue if test does not exist.
    """
    logger.info('Add provider result to root.')
    # make sure test in created and running. If not do that first.
    start_test_if_required()
    test_result = TestResult()
    dict_data = result_utils.insert_report_group_if_not_defined(dict_data)
    test_result.add_provider_data(dict_data)
Ejemplo n.º 12
0
def get_iterator(iterator_handle):
    """Get leaf iterator result object and compare handle. If not same return None
    """
    logger.debug('Get leaf iterator for with handle:' + str(iterator_handle))
    leaf_iterator = get_leaf_iterator_no_throw()
    if leaf_iterator is None:
        return None
    if leaf_iterator.Get('Iterator') != iterator_handle:
        return None
    else:
        return leaf_iterator
Ejemplo n.º 13
0
def reset_stm_test_result(test_result):
    """ reset root result data and delete all children
    STmTestResult is root result object.
    """
    logger.debug('Reset StmTestResult object')
    iteration_result = test_result.GetObject('StmIteratorResult')
    if iteration_result is not None:
        iteration_result.MarkDelete()
    test_result.Set(Info.get_stc_property_name(), "")
    test_result.Set(Status.get_stc_property_name(), "")
    test_result.SetCollection(get_stc_json_collection_name(), [])
Ejemplo n.º 14
0
def set_iterator_current_value(iterator_handle,
                               iterator_param,
                               value,
                               iteration_id):
    log_string = 'Set iterator values. Iterator handle:' + str(iterator_handle) + ', param:' +\
        str(iterator_param) + ', value:' + str(value) + ', iteration_id:' + str(iteration_id)
    logger.info(log_string)
    start_test_if_required()
    end_inner_iterator_if_required(iterator_handle)
    iterator = Iterator(iterator_handle, None, iterator_param)
    iterator.start_next_iteration(value, iteration_id)
    logger.debug('Set iterator values completed.')
Ejemplo n.º 15
0
def get_stm_test_result():
    """
    Return StmTestResult object if exist else return None.
    """
    logger.debug('get_stm_test_result started.')
    result_parent = meth_man_utils.get_meth_manager()
    active_test = meth_man_utils.get_active_test_case()
    if active_test is not None:
        result_parent = active_test
    test_result = result_parent.GetObject('StmTestResult')
    logger.debug('get_stm_test_result completed.')
    return test_result
Ejemplo n.º 16
0
def add_provider_result(dict_data):
    """Add provider result to active result object.
    It is leaf iterator result object in case of iterative test.
    Do not throw error if result object does not exist.
    Try to create one and continue.
    """
    logger.info('Add provider result.')
    # make sure test in created and running. If not do that first.
    start_test_if_required()
    result = iterator_utils.get_active_result_object()
    logger.debug_result_object_info(result)
    dict_data = result_utils.insert_report_group_if_not_defined(dict_data)
    result_obj.add_provider_data(result, dict_data)
Ejemplo n.º 17
0
 def complete_active_iteration(self, force_stop=False):
     logger.info('completea active iteration.')
     if not self.is_iteration_running():
         logger.error('No active iteration found to complete.')
         return
     logger.log_result_info_status(self._stc_result_object)
     self._active_iteration_info = ActiveIterationInfo()
     self.load_from_stc_object(self._active_iteration_info)
     self._active_iteration_status = ActiveIterationStatus()
     self.load_from_stc_object(self._active_iteration_status)
     if force_stop is True:
         self._active_iteration_status.exec_status = EnumExecStatus.stopped
     else:
         self._active_iteration_status.exec_status = EnumExecStatus.completed
     self._active_iteration_info._end_time = result_utils.get_current_time_string()
     result = self.generate_iteration_verdict()
     if result:
         self._active_iteration_status.verdict = result['verdict']
         self._active_iteration_info.result_file = result['resultFile']
         self._active_iteration_info.set_data_class(self._active_iteration_info,
                                                    EnumDataClass.iteration_result)
         self._active_iteration_info.set_data_format(self._active_iteration_info,
                                                     EnumDataFormat.none)
     else:
         self._active_iteration_status.verdict = EnumVerdict.none
         self._active_iteration_info.set_data_class(self._active_iteration_info,
                                                    EnumDataClass.iteration_result)
         self._active_iteration_info.set_data_format(self._active_iteration_info,
                                                     EnumDataFormat.none)
     self.save_active_iteration_data()
     self.reset_active_iteration_data()
     logger.info('completea active iteration completed.')
Ejemplo n.º 18
0
def end_inner_iterator_if_required(active_iterator_handle):
    itr_result_obj = iterator_utils.get_leaf_iterator()
    root_result = iterator_utils.get_stm_test_result_throw()

    if itr_result_obj is None or \
            itr_result_obj.GetObjectHandle() == root_result.GetObjectHandle() or \
            itr_result_obj.Get(Iterator.get_stc_property_Iterator()) == active_iterator_handle:
        logger.debug('Either new iterator or leaf iterator.')
        return
    # find if new iterator or existing iterator with missing child end iterator
    while itr_result_obj is not None and \
            itr_result_obj.GetObjectHandle() != root_result.GetObjectHandle() and \
            itr_result_obj.Get(Iterator.get_stc_property_Iterator()) != active_iterator_handle:

        itr_result_obj = itr_result_obj.GetParent()
        logger.debug_result_object_info(itr_result_obj)
    if itr_result_obj.GetObjectHandle() == root_result.GetObjectHandle() or \
            itr_result_obj.Get(Iterator.get_stc_property_Iterator()) != active_iterator_handle:
        logger.debug('No existing iterator found with same handle')
        return
    # call end iterator for missing
    leaf_iterator = iterator_utils.get_leaf_iterator()
    while leaf_iterator.Get(Iterator.get_stc_property_Iterator()) != active_iterator_handle:
        logger.error('Missing end iterator for child iterator')
        end_iterator()
        leaf_iterator = iterator_utils.get_leaf_iterator()
def get_per_stream_time_from_db(sb_info, db_info_list, title, xcat):
    logger.debug("ndb_info_list TIME: " + str(db_info_list))
    num_stream = len(sb_info)
    time_template["title"]["text"] = title
    time_template["yAxis"]["title"]["text"] = "ms"
    time_template["xAxis"]["categories"] = xcat

    time_template["series"][:] = []
    i = 0
    for sb in sb_info:
        # series_info has to match series_keys
        series_info = ["spline", color_collection[i], sb_info[i], db_info_list[i::num_stream]]
        time_template["series"].append(dict(zip(series_keys, series_info)))
        i = i + 1

    return ""
def get_streamblock_query():
    logger.debug("get_streamblock_query : ")

    sb_handle_list = get_streamblock_handle_list()
    num_str = len(sb_handle_list)
    cnt = 0
    for hnd in sb_handle_list:
        if cnt == 0:
            q_stream = " AND ("
        q_stream = q_stream + "sb.Handle == " + str(hnd)
        cnt = cnt + 1
        if cnt < num_str:
            q_stream = q_stream + " OR "
        elif cnt == num_str:
            q_stream = q_stream + ")"

    return q_stream
Ejemplo n.º 21
0
 def save_active_iteration_data(self):
     """Convert from Active iteration data to Iteration data
     """
     logger.info('Save active iteration data.')
     child_data = self.get_from_stc_as_dict(self.stc_property_child_iterator_data)
     if child_data:
         self._active_iteration_info.set_data_format(self._active_iteration_info,
                                                     EnumDataFormat.group)
         result = self._active_iteration_info.run_time_data
         result[self.get_data_dict_name()] = result_utils.wrap_data_as_single_group(child_data)
     else:
         result = self._active_iteration_info.run_time_data
     result[Status.get_dict_name()] = self._active_iteration_status.run_time_data
     self.append_stc_object_collection(
         self.stc_property_completed_data,
         json.dumps(result, separators=(',', ':'), sort_keys=False))
     logger.debug('Save active iteration data completed.')
Ejemplo n.º 22
0
def complete_iteration():
    logger.info('Complete iteration.')
    itr_result_obj = iterator_utils.get_leaf_iterator()
    if itr_result_obj is None:
        logger.error('There is no iterator running to complete iteration.')
        return
    logger.debug_result_object_info(itr_result_obj)
    iterator = Iterator(0, itr_result_obj)
    iterator.complete_active_iteration()
    logger.debug('Complete iteration completed.')
def get_streamblock_handle_list():
    logger.debug("get_streamblock_handle_list : ")

    sb_handle_list = []
    if not CObjectRefStore.Exists(OBJ_KEY):
        logger.warn("DiffServCfgRampCommand was not called. " + "Using default threshold values.")
    else:
        tmp_dict = CObjectRefStore.Get(OBJ_KEY)
        logger.debug("  tmp_dict: " + str(tmp_dict))
        dict_keys = tmp_dict.keys()
        logger.debug("  dict_keys: " + str(dict_keys))

        # convert keys to handles
        sb_list = tag_utils.get_tagged_objects_from_string_names(dict_keys)
        for sb in sb_list:
            sb_handle_list.append(sb.GetObjectHandle())
        logger.debug("  sb_handle_list: " + str(sb_handle_list))

    return sb_handle_list
Ejemplo n.º 24
0
 def start_next_iteration(self, value, iteration_id):
     logger.info('start next iteration.')
     # make sure no active iteration running.
     if self.is_iteration_running():
         logger.warning('Complete iteration call missing for previous iteration.')
         self.complete_active_iteration()
     self._active_iteration_info = ActiveIterationInfo(value,
                                                       iteration_id,
                                                       self._iterator_param)
     self._active_iteration_info._start_time = result_utils.get_current_time_string()
     self._active_iteration_status = ActiveIterationStatus(EnumExecStatus.running)
     self.commit_active_info_status()
     logger.debug('start next iteration completed.')
     logger.log_result_info_status(self._stc_result_object)
def get_active_streamblock_info(db_file_list):
    logger.debug("get_active_streamblock_info : ")

    q_stream = get_streamblock_query()
    query = str("SELECT Name FROM StreamBlock AS Sb " + "WHERE sb.Active == 1") + str(q_stream)
    logger.debug("  query: " + str(query))

    prv_num = 0
    num = 0
    for db_file in db_file_list:
        if not os.path.isfile(db_file):
            raise Exception("Unable to find db file:" + db_file)
        conn = sqlite3.connect(db_file)
        cur = conn.cursor()
        for q in query.split(";"):
            if len(q) > 0:
                cur.execute(q)
        rows = cur.fetchall()
        conn.close()
        num = len(rows)

        if prv_num != 0 and num != prv_num:
            logger.error("Inconsistent numbers of streams in DBs")
        prv_num = num
    return rows
Ejemplo n.º 26
0
 def create_new_iterator(self):
     logger.info('Create new iterator.')
     self._stc_result_object = iterator_utils.create_iterator_result()
     self.set_stc_object(self.stc_property_Iterator, str(self._iterator_handle))
     self._info = IteratorInfo(self._iterator_param)
     self._status = Status(EnumExecStatus.created)
     self.commit_info_status()
     logger.debug('Create new iterator completed.')
     logger.log_result_info_status(self._stc_result_object)
Ejemplo n.º 27
0
def get_db_files(active_db, UseMultipleResultsDatabases):
    logger.debug("get_db_files")
    resultsDbList = []
    dbNamesList = []

    filePath = os.path.dirname(active_db)
    if not os.path.isfile(active_db):
        raise Exception('Results have not been saved recently. No file found.')
    query = "SELECT DbFileName FROM EotResultIterations"
    conn = sqlite3.connect(active_db)
    cur = conn.cursor()
    try:
        cur.execute(query)
        if UseMultipleResultsDatabases:
            # Multiple dbs exist and want all of them
            # Loopmode = Append, UseMultipleResultsDatabases = True
            query = "SELECT DbFileName FROM EotResultIterations"
            cur.execute(query)
            rows = cur.fetchall()
            logger.debug("rows: " + str(rows))
            dbNamesList = re.findall('\'(.*?)\'', str(rows))
        else:
            # Multiple dbs exist but want the current iterations db
            # Loopmode = Append, UseMultipleResultsDatabases = False
            query = "SELECT DbFileName FROM EotResultIterations \
                     WHERE Id = (SELECT MAX(Id) FROM EotResultIterations)"
            cur.execute(query)
            rows = cur.fetchall()
            dbNameList = re.findall('\'(.*?)\'', str(rows))
            dbNamesList.append(dbNameList[0])
    except sqlite3.OperationalError:
        if UseMultipleResultsDatabases:
            # Invalid settings
            # Loopmode = Overwrite, UseMultipleResultsDatabases = True
            raise ValueError("Invalid settings, UseMultipleResultsDatabases \
                             cannot be TRUE if there is only a single results \
                             database. Change SaveResults Loopmode to APPEND")
        else:
            # Single results db
            # Loopmode = Overwrite, UseMultipleResultsDatabases = False
            dbNamesList.append(active_db)

    for dbName in dbNamesList:
        resultDb = os.path.abspath(os.path.join(filePath, dbName))
        resultsDbList.append(resultDb)
    conn.close()
    logger.debug("returning: " + str(resultsDbList))
    return resultsDbList
Ejemplo n.º 28
0
 def complete(self, force_stop):
     logger.info('Complete - End iterator.')
     if self.is_iteration_running():
         logger.warning('Complete iteration call missing before end iterator.')
         self.complete_active_iteration(force_stop)
     self.load_all_iterator_data()
     if force_stop is True:
         self._status.exec_status = EnumExecStatus.stopped
     else:
         self._status.exec_status = EnumExecStatus.completed
     self._status.verdict = EnumVerdict.none
     self._info.set_data_format(self._info, EnumDataFormat.group)
     self._info.set_data_class(self._info, EnumDataClass.iterator_result)
     iteratorData = self._info.run_time_data
     iteratorData[self._status.dict_name] = self._status.run_time_data
     allData = self.get_from_stc_collection_property_as_dict(self.stc_property_completed_data)
     iteratorData[self.get_data_dict_name()] = result_utils.wrap_data_as_single_group(allData)
     self._stc_result_object.MarkDelete()
     logger.debug('Complete - End iterator completed.')
     return iteratorData
Ejemplo n.º 29
0
def reset():
    """Create StmTestResult object if does not exist.
    reset object if exist.
    StmTestResult object should be created under active test.
    If active test does not exist then under methodology manager.
    """
    logger.debug('Reset result objects.')
    result_parent = meth_man_utils.get_meth_manager()
    active_test = meth_man_utils.get_active_test_case()
    if active_test is not None:
        logger.debug('Active test is result parent.')
        result_parent = active_test
    test_result = result_parent.GetObject('StmTestResult')
    if test_result is None:
        ctor = CScriptableCreator()
        test_result = ctor.Create("StmTestResult", result_parent)
    else:
        reset_stm_test_result(test_result)
    logger.debug('Reset result objects done.')
    return test_result
Ejemplo n.º 30
0
def test_get_formatted_drilldown_data_and_more():
    verdict = True
    verdictText = 'Not available'
    displayName = "My display name"
    pass_text = "my pass text"
    applyVerdictToSum = False
    viewName = 'MyTestDrv'
    displays = ['First', 'Second']
    report_group = pc.HIGHEST_PRIORITY_REPORT_GROUP
    drilldowndataObjects = []
    drilldowndata = {}
    drilldowndata[pc.SUMMARIZATION_OBJECT] = 'Port.Name'
    drilldowndata[pc.COLUMN_DISPLAY_NAMES] = displays
    resultviewdata1 = [1, 2]
    resultviewdata2 = [3, 4]
    resultviewdataList = [resultviewdata1, resultviewdata2]
    drilldowndata[pc.ROW] = resultviewdataList
    drilldowndataObjects.append(drilldowndata)

    drilldowndata = {}
    drilldowndata[pc.SUMMARIZATION_OBJECT] = 'Project.Name'
    drilldowndata[pc.COLUMN_DISPLAY_NAMES] = displays
    resultviewdata = [4, 6]
    resultviewdataList = [resultviewdata]
    drilldowndata[pc.ROW] = resultviewdataList
    drilldowndataObjects.append(drilldowndata)

    formatted_data = drv_utils.get_formatted_drilldown_data(drilldowndataObjects)

    provider_data = p.get_table_drv_drilldown_data(viewName,
                                                   verdict,
                                                   verdictText,
                                                   applyVerdictToSum,
                                                   formatted_data,
                                                   report_group,
                                                   displayName,
                                                   pass_text,
                                                   "")
    assert provider_data is not None
    info = provider_data[pc.INFO]
    status = provider_data[pc.STATUS]
    data = provider_data[pc.DATA]
    logger.info(json.dumps(provider_data, separators=(',', ':'), sort_keys=False))
    assert provider_data[pc.CLASS] == EnumDataClass.table_drv_drilldown
    assert provider_data[pc.DATA_FORMAT] == EnumDataFormat.table
    # verify info
    assert info[pc.RESULT_VIEW_NAME] == viewName
    assert info[pc.SUMMARIZATION_OBJECT] == 'Project.Name'
    assert info[pc.REPORT_GROUP] == pc.HIGHEST_PRIORITY_REPORT_GROUP
    assert info[pc.DISPLAY_NAME] == displayName
    # verify status
    assert status[pc.VERDICT] == EnumVerdict.passed
    assert status[pc.VERDICT_TEXT] == pass_text
    assert status[pc.EXEC_STATUS] == EnumExecStatus.completed
    assert status[pc.APPLY_VERDICT] == applyVerdictToSum

    assert len(data[pc.COLUMN_DISPLAY_NAMES]) == 2
    assert data[pc.COLUMN_DISPLAY_NAMES][0] == displays[0]
    assert data[pc.COLUMN_DISPLAY_NAMES][1] == displays[1]
    rows = data[pc.ROW]
    assert len(rows) == 1
    assert len(rows[0]) == 2
    assert rows[0][0] == 4
    assert rows[0][1] == 6
    assert (pc.LINKS in data) is True
    # verify drilldown results
    data = data[pc.LINKS]
    assert len(data) == 1
    data = data[0]
    data[pc.TAG] = 'Port.Name'
    assert (pc.LINK_DATA in data) is True
    data = data[pc.LINK_DATA]
    assert data[pc.CLASS] == EnumDataClass.drill_down_results
    assert data[pc.DATA_FORMAT] == EnumDataFormat.table
    assert data[pc.INFO][pc.SUMMARIZATION_OBJECT] == 'Port.Name'
    data = data[pc.DATA]
    assert len(data[pc.COLUMN_DISPLAY_NAMES]) == 2
    assert data[pc.COLUMN_DISPLAY_NAMES][0] == displays[0]
    assert data[pc.COLUMN_DISPLAY_NAMES][1] == displays[1]
    rows = data[pc.ROW]
    assert len(rows) == 2
    assert len(rows[0]) == 2
    assert rows[0][0] == 1
    assert rows[0][1] == 2
    assert rows[1][0] == 3
    assert rows[1][1] == 4
    assert (pc.LINKS in data) is False