コード例 #1
0
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
コード例 #2
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()
コード例 #3
0
ファイル: Iterator.py プロジェクト: CmWork/STAKCommands
 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.')
コード例 #4
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)
コード例 #5
0
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
コード例 #6
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.')
コード例 #7
0
ファイル: Iterator.py プロジェクト: CmWork/STAKCommands
 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)
コード例 #8
0
ファイル: IteratorUtils.py プロジェクト: CmWork/STAKCommands
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
コード例 #9
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.')
コード例 #10
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(), [])
コード例 #11
0
ファイル: IteratorUtils.py プロジェクト: CmWork/STAKCommands
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
コード例 #12
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
コード例 #13
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.')
コード例 #14
0
ファイル: Iterator.py プロジェクト: CmWork/STAKCommands
 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)
コード例 #15
0
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 ""
コード例 #16
0
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
コード例 #17
0
ファイル: Iterator.py プロジェクト: CmWork/STAKCommands
 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.')
コード例 #18
0
def end_iterator(force_stop=False):
    logger.info('End iteration.')
    itr_result_obj = iterator_utils.get_leaf_iterator()
    if itr_result_obj is None:
        logger.error('There is no iterator running to end iterator.')
        return
    iterator = Iterator(0, itr_result_obj)
    data = iterator.complete(force_stop)
    parentIterator = iterator_utils.get_leaf_iterator_no_throw()
    if parentIterator is None:
        logger.info('Adding iteration result to Test.')
        data[pc.STATUS][pc.APPLY_VERDICT] = True
        test_result = TestResult()
        test_result.add_provider_data(data)
    else:
        logger.info('Adding iteration result to parent iterator.')
        logger.debug_result_object_info(itr_result_obj)
        parent_itr = Iterator(0, parentIterator)
        parent_itr.add_child_iterator_data(data)
    logger.debug('End iteration completed')
コード例 #19
0
ファイル: Iterator.py プロジェクト: CmWork/STAKCommands
 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
コード例 #20
0
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
コード例 #21
0
ファイル: ProviderUtils.py プロジェクト: CmWork/STAKCommands
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
コード例 #22
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
コード例 #23
0
def create_test():
    logger.info('Create methodology test.')
    test_result = TestResult()
    test_result.create_test()
    logger.debug('Create test completed.')
コード例 #24
0
ファイル: Iterator.py プロジェクト: CmWork/STAKCommands
 def add_child_iterator_data(self, data):
     logger.info('Add child iterator data.')
     json_data = json.dumps(data, separators=(',', ':'), sort_keys=False)
     self.set_stc_object(self.stc_property_child_iterator_data, json_data)
     logger.debug('Add child iterator data completed.')
コード例 #25
0
ファイル: Iterator.py プロジェクト: CmWork/STAKCommands
 def get_last_iteration_data(self):
     logger.debug('Get last iteration data.')
     idata = self.get_from_stc_collection_property_as_dict(self.stc_property_completed_data)
     if not idata:
         return None
     return idata[-1]
コード例 #26
0
def start_test():
    logger.info('Start test')
    test_result = TestResult()
    test_result.start_test()
    logger.debug('Start test completed')
コード例 #27
0
def CreateChart(tagname, b, params):
    plLogger = PLLogger.GetLogger("Methodology")
    plLogger.LogDebug("Running custom CreateChart script...")
    plLogger.LogDebug("    tagname : " + str(tagname))
    db_list = get_dbs(True, False)

    sb_info = get_active_streamblock_info(db_list)
    logger.debug("   number of selected streams: " + str(len(sb_info)))
    q_stream = get_streamblock_query()

    q_maxjitter = (
        str(
            "SELECT ROUND(MaxJitter*1e-3,3) FROM RxEotStreamResults As RxStr "
            + "JOIN StreamBlock AS Sb "
            + "ON RxStr.ParentStreamBlock == Sb.Handle"
        )
        + str(q_stream)
        + str("  WHERE IsExpectedPort = 1")
    )
    q_maxlatency = (
        str(
            "SELECT ROUND(MaxLatency*1e-3,3) FROM RxEotStreamResults As RxStr "
            + "JOIN StreamBlock AS Sb "
            + "ON RxStr.ParentStreamBlock == Sb.Handle"
        )
        + str(q_stream)
        + str("  WHERE IsExpectedPort = 1")
    )
    q_pktloss = (
        str(
            "SELECT TxRes.FrameCount - RxRes.FrameCount "
            + "As 'Packet Loss' From RxEotStreamResults As RxRes "
            + "JOIN TxEotStreamResults As TxRes "
            + "JOIN Streamblock As Sb "
            + "ON RxRes.ParentStreamBlock = TxRes.ParentStreamblock "
            + "AND TxRes.ParentStreamblock = Sb.Handle"
        )
        + str(q_stream)
        + str("  WHERE IsExpectedPort = 1")
    )
    q_ooopkt = (
        str(
            "SELECT OutSeqFrameCount FROM RxEotStreamResults As RxStr "
            + "JOIN StreamBlock AS Sb "
            + "ON RxStr.ParentStreamBlock == Sb.Handle"
        )
        + str(q_stream)
        + str("  WHERE IsExpectedPort = 1")
    )
    q_latepkt = (
        str(
            "SELECT LateFrameCount FROM RxEotStreamResults As RxStr "
            + "JOIN StreamBlock AS Sb "
            + "ON RxStr.ParentStreamBlock == Sb.Handle"
        )
        + str(q_stream)
        + str("  WHERE IsExpectedPort = 1")
    )
    q_duppkt = (
        str(
            "SELECT DuplicateFrameCount FROM RxEotStreamResults As RxStr "
            + "JOIN StreamBlock AS Sb "
            + "ON RxStr.ParentStreamBlock == Sb.Handle"
        )
        + str(q_stream)
        + str("  WHERE IsExpectedPort = 1")
    )

    max_jitter_data = get_data_from_query(db_list, q_maxjitter)
    max_latency_data = get_data_from_query(db_list, q_maxlatency)
    pktloss_data = get_data_from_query(db_list, q_pktloss)
    ooopkt_data = get_data_from_query(db_list, q_ooopkt)
    latepkt_data = get_data_from_query(db_list, q_latepkt)
    duppkt_data = get_data_from_query(db_list, q_duppkt)

    xcat_data = [x + 1 for x in range(len(db_list))]

    # jitter
    get_per_stream_time_from_db(sb_info, max_jitter_data, "Jitter (ms)", xcat_data)
    result_jitter = init_chart_data_dict("GROUP_1", time_template)
    pdg.submit_provider_data(result_jitter)
    # latency
    get_per_stream_time_from_db(sb_info, max_latency_data, "Latency (ms)", xcat_data)
    result_latency = init_chart_data_dict("GROUP_1", time_template)
    pdg.submit_provider_data(result_latency)
    # packet loss
    get_per_stream_packet_from_db(sb_info, pktloss_data, "Packet Loss", xcat_data)
    result_loss = init_chart_data_dict("GROUP_1", packet_template)
    pdg.submit_provider_data(result_loss)
    # ooo packet
    get_per_stream_packet_from_db(sb_info, ooopkt_data, "Out of Order Packet", xcat_data)
    result_ooo = init_chart_data_dict("GROUP_1", packet_template)
    pdg.submit_provider_data(result_ooo)
    # late packet
    get_per_stream_packet_from_db(sb_info, latepkt_data, "Late Packet", xcat_data)
    result_late = init_chart_data_dict("GROUP_1", packet_template)
    pdg.submit_provider_data(result_late)
    # duplicated packet
    get_per_stream_packet_from_db(sb_info, duppkt_data, "Duplicated Packet", xcat_data)
    result_dup = init_chart_data_dict("GROUP_1", packet_template)
    pdg.submit_provider_data(result_dup)

    return ""
コード例 #28
0
def create_stm_test_result_under_mm():
    logger.debug('Create StmTestResult object')
    result_parent = meth_man_utils.get_meth_manager()
    ctor = CScriptableCreator()
    test_result = ctor.Create("StmTestResult", result_parent)
    return test_result