Ejemplo n.º 1
0
def check_me_counters(driver, ne_type, counters_expected, rows_of_page,
                      dict_me_add, me_types):
    '''
    This function will check the ME counters, the first edition suspect that only one record each 5 minutes.
    :param ne_type the type of the node
    :param counters_expected: node ME counters that will check with the counters on GUI
    :param dict_me_add: additional information, (check_rounds: how many rounds that will be checked), (
    rows_each_period: how many rows each period, default is 1, this parameter is for extending later.)
    :return: None: the function is for automation testing, critical errors will case program to exit immediately
    '''
    checked_rounds = dict_me_add['check_rounds']
    number_of_rows_be_checked = checked_rounds * dict_me_add['rows_each_period']
    wait_until_rounds_ok(driver, number_of_rows_be_checked, 10,
                         dict_me_add['rows_each_period'])
    list_returns = []
    id_table = (By.XPATH,
                "//div[@class='ebTabs']/div[2]/div/div/div/div/table")

    id_header_trs = (
        By.XPATH,
        "//div[@class='ebTabs']/div[2]/div/div/div/div/table/thead/tr/th")
    ths = find_all_widgets(driver, 20, id_header_trs)
    list_headers = []
    for th in ths:
        list_headers.append(
            th.get_attribute('innerHTML').encode('utf-8').strip())
    # number_of_rows_be_checked = len(counters_expected)
    # if dict_me_add.has_key('check_rounds'):
    # if not 0 == number_of_rows_be_checked % dict_me_add['number_of_lic']:
    #    test.error('Number of checked rows should be integer multiples of number of LICs.')
    for row_index in range(1, number_of_rows_be_checked + 1):
        # check_pm_by_row returns [gui_datettime, lic_name] in List
        time_of_gui = check_me_single_row(driver, id_table, row_index, ne_type,
                                          counters_expected, rows_of_page,
                                          list_headers, me_types)
        list_returns.append(time_of_gui)

    if number_of_rows_be_checked != len(list_returns):
        test.failed(
            'Number of rows have been checked mis-match with the number we expected.'
        )
    else:
        for i in range(len(list_returns)):
            if list_returns[i] is not None and 0 == list_returns[i].minute % 5:
                test.passed('Row ' + str(i) + ' GUI time is correct, is: ' +
                            list_returns[i].strftime('%Y-%m-%d %H:%M'))
            else:
                test.failed('Row ' + str(i) + ' GUI time is correct, is: ' +
                            list_returns[i].strftime('%Y-%m-%d %H:%M'))
            if i + 1 < len(list_returns):
                if 300 == (list_returns[i] - list_returns[i + 1]).seconds:
                    test.passed('Report delta time is 5 minutes.')
                else:
                    test.failed('Report delta time is not 5 minutes.')
Ejemplo n.º 2
0
def check_me_single_row(driver, id_table, index_row, ne_type, dict_counters,
                        rows_of_page, list_headers, me_types):
    test.info('Start to check ME row: ' + str(index_row))

    make_sure_is_correct_page(driver, index_row, rows_of_page)
    try:
        gui_index_row = rows_of_page if 0 == index_row % rows_of_page else index_row % rows_of_page
        id_tr = (By.XPATH, ".//tbody/tr[" + str(gui_index_row) + "]")
        table = find_single_widget(driver, 10, id_table)
        time.sleep(.5)
        tr = find_single_widget(table, 10, id_tr)
        gui_str_time = find_single_widget(
            tr, 10,
            (By.XPATH, ".//td[2]")).get_attribute('innerHTML').encode('utf-8')
        gui_time = datetime.strptime(gui_str_time.strip(), "%Y-%m-%d %H:%M")
        except_counter_id = str(gui_time.minute)

        # id_lic_name = (By.XPATH, ".//td[3]")
        # lic_name = find_single_widget(tr, 5, id_lic_name).get_attribute('innerHTML').encode('utf-8')

        list_row = dict_counters[except_counter_id].split(',')
        list_types = me_types['counter_types'].split(',')
        for i in range(len(list_row)):
            try:
                id_counter = (By.XPATH, ".//td[" + str(i + 3) + "]")
                gui_counter = find_single_widget(
                    tr, 5,
                    id_counter).get_attribute('innerHTML').encode('utf-8')
                # i_gui_counter = int(gui_counter) if 'int' == list_types[i].lower().strip()
                if 'int' == list_types[i].lower().strip():
                    i_gui_counter = int(gui_counter)
                    i_expected = int(list_row[i].strip())
                elif 'float' == list_types[i].lower().strip():
                    i_gui_counter = float(gui_counter)
                    i_expected = float(list_row[i].strip())
                else:
                    test.error('Unknown counter type of me counters.')
            except Exception as e:
                i_gui_counter = None
            if i_expected == i_gui_counter:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + "; " + list_headers[i + 2] + ", GUI is " \
                      + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) + "."

                test.passed(msg)
            else:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + "; " + list_headers[i + 2] + ", GUI is " \
                      + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) + "."

                test.failed(msg)
        return gui_time
    except Exception as e:
        test.error("Test failed, ERROR: " + str(e))
Ejemplo n.º 3
0
def alarm_compare(alarm_expected,alarm_on_gui):
    for name,value in alarm_expected.items():
        if alarm_on_gui.has_key(name):
            if (alarm_on_gui[name] == value):
                test_logger.passed("alarm counter " + name + " accuracy test passed. GUI value is " + str(alarm_on_gui[name]) + ", and the expected value is " + str(value))
            else:
                test_logger.failed("alarm counter " + name + " accuracy test failed. GUI value is " + alarm_on_gui[name] + " ,and the expected value is " + str(value))
        else:
            test_logger.failed("alarm counter " + name + " missing on GUI")

    for name,value in alarm_on_gui.items():
        if not alarm_expected.has_key(name):
            test_logger.failed("extra alarm counter " + name + " on GUI")
Ejemplo n.º 4
0
def make_sure_in_pm_page(driver):
    # btn id: ebBtnSearch
    id_btn_interface = (By.ID, 'ebBtnSearch')
    try:
        find_single_widget(driver, 5, id_btn_interface)
        test.error('Page redirect to the interface management page, critical error!')
    except TimeoutException:
        id_query_btn = (By.ID, "idBtn-search")
        try:
            pm_query_btn = find_single_widget(driver, 10, id_query_btn)
            if pm_query_btn:
                test.passed('Found the query button of PM Management page, check passed.')
        except TimeoutException:
            test.failed('Cannot find the query button of PM Management page.')
Ejemplo n.º 5
0
def wait_until_pm_date_show_up(driver, ne_name, wait_time=720):
    select_given_ne_name(driver, ne_name)
    end_time = datetime.now() + timedelta(seconds=wait_time)
    while datetime.now() < end_time:
        id_query_btn = (By.ID, "idBtn-search")
        find_single_widget(driver, 10, id_query_btn).click()
        id_body_date = (By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
        try:
            find_single_widget(driver, 10, id_body_date)
            test.passed('Successfully found the PM datas.')
            return
        except TimeoutException:
            pass
    test.error('Wait for ' + str(wait_time) + ' seconds but cannot find any PM datas.')
Ejemplo n.º 6
0
def check_pm_by_row(driver, id_table, index_row, ne_type, dict_counters,
                    rows_of_page, list_headers, is_m_lics):
    test.info('Start to check row: ' + str(index_row))

    make_sure_is_correct_page(driver, index_row, rows_of_page)
    try:
        gui_index_row = rows_of_page if 0 == index_row % rows_of_page else index_row % rows_of_page
        id_tr = (By.XPATH, ".//tbody/tr[" + str(gui_index_row) + "]")
        table = find_single_widget(driver, 10, id_table)
        time.sleep(.5)
        tr = find_single_widget(table, 10, id_tr)
        gui_str_time = find_single_widget(
            tr, 10,
            (By.XPATH, ".//td[2]")).get_attribute('innerHTML').encode('utf-8')
        gui_time = datetime.strptime(gui_str_time.strip(), "%Y-%m-%d %H:%M")
        except_counter_id = str(gui_time.minute)

        id_lic_name = (By.XPATH, ".//td[3]")
        lic_name = find_single_widget(
            tr, 5, id_lic_name).get_attribute('innerHTML').encode('utf-8')
        if is_m_lics:
            except_counter_id = str(gui_time.minute) + '-' + lic_name
        list_row = dict_counters[except_counter_id].split(',')
        for i in range(len(list_row)):
            try:
                id_counter = (By.XPATH, ".//td[" + str(i + 4) + "]")
                gui_counter = find_single_widget(
                    tr, 5,
                    id_counter).get_attribute('innerHTML').encode('utf-8')
                i_gui_counter = int(gui_counter)
            except Exception as e:
                i_gui_counter = None
            if int(list_row[i].strip()) == i_gui_counter:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + list_headers[2] + ": " + lic_name + "; " \
                      + list_headers[i + 3] + ", GUI is " + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) \
                      + "."

                test.passed(msg)
            else:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + list_headers[2] + ": " + lic_name + "; " \
                      + list_headers[i + 3] + ", GUI is " + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) \
                      + "."

                test.failed(msg)
        return [gui_time, lic_name]
    except Exception as e:
        test.error("Test failed, ERROR: " + str(e))
Ejemplo n.º 7
0
def wait_until_rounds_ok(driver, rows, rows_of_page, rows_each_period):
    '''
    This function will check the number of rows that we need to check the PM.
    :param driver:
    :param rows:
    :param rows_of_page:
    :param dict_additional:
    :param ne_type:
    :return: None
    '''
    id_tbdoy_trs = (
        By.XPATH,
        "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody/tr")
    # if dict_additional.has_key('check_rows'):
    #    rows = dict_additional['check_rows']

    # if not 0 == rows % dict_additional['number_of_lic']:
    #    test.error('Number of checked rows should be integer multiples of number of LICs.')
    t_start = datetime.now()
    # Note that most of the PM need T2-T1, for Node like SBC, we may wait 5 minutes more since SBC don't need T2-T1
    # t_end = t_start + timedelta(minutes=5 * (rows // dict_additional['number_of_lic'] + 1) + 2)
    t_end = t_start + timedelta(minutes=5 * (rows // rows_each_period + 1) + 2)
    while datetime.now() < t_end:
        # click the query button
        id_query_btn = (By.ID, "idBtn-search")
        find_single_widget(driver, 10, id_query_btn).click()
        time.sleep(.1)
        try:
            i_page = rows / rows_of_page
            tgt_page_number = i_page if 0 == rows % rows_of_page else i_page + 1
            id_tgt_pager = (By.XPATH, ("//div[@class='page']/ul/li[2]/ul/li[" +
                                       str(tgt_page_number) + "]"))
            time.sleep(.1)
            tgt_pager = get_widget_ignore_refrence_error(driver, id_tgt_pager)
            if not tgt_pager.get_attribute('class').find(
                    'ebPagination-entryAnchor_current') > -1:
                tgt_pager.click()
                trs = find_all_widgets(driver, 20, id_tbdoy_trs)
                if rows % rows_of_page <= len(trs):
                    test.passed('All the data that we need are ready now.')
                    return
        except TimeoutException:
            pass
        time.sleep(.5)
    test.failed(
        'It seems that the the data we need has not been collected as expectes, case may fail later steps.'
    )
Ejemplo n.º 8
0
def make_sure_in_pm_page(driver):
    # btn id: ebBtnSearch
    id_btn_interface = (By.ID, 'ebBtnSearch')
    try:
        find_single_widget(driver, 5, id_btn_interface)
        test.error(
            'Page redirect to the interface management page, critical error!')
    except TimeoutException:
        id_query_btn = (By.ID, "idBtn-search")
        try:
            pm_query_btn = find_single_widget(driver, 10, id_query_btn)
            if pm_query_btn:
                test.passed(
                    'Found the query button of PM Management page, check passed.'
                )
        except TimeoutException:
            test.failed('Cannot find the query button of PM Management page.')
Ejemplo n.º 9
0
def wait_until_pm_date_show_up(driver, ne_name, wait_time=720):
    select_given_ne_name(driver, ne_name)
    end_time = datetime.now() + timedelta(seconds=wait_time)
    while datetime.now() < end_time:
        id_query_btn = (By.ID, "idBtn-search")
        find_single_widget(driver, 10, id_query_btn).click()
        id_body_date = (
            By.XPATH,
            "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody")
        try:
            find_single_widget(driver, 10, id_body_date)
            test.passed('Successfully found the counters data.')
            return
        except TimeoutException:
            pass
    test.error('Wait for ' + str(wait_time) +
               ' seconds but cannot find any PM datas.')
Ejemplo n.º 10
0
def compare_data(notif_ne,expected_result):
    for key,value in expected_result.items():
        if notif_ne.has_key(key):
            if type(value) is not types.DictType:
                if notif_ne[key] ==  value:
                    test.passed(key + " accuracy test Passed. The NBI notification value is " + notif_ne[key] + ", and the expected result is " + str(value))
                else:
                    test.failed(key + " accuracy test Failed. The NBI notification value is " + notif_ne[key] + ", and the expected result is " + str(value))
            else:
                expected_result = value
                notif_ne = notif_ne[key]
                compare_data(notif_ne,expected_result)
        else:
            test.failed(key + " accuracy test Failed for " + key + " missing in NBI notification")

    for key_n,value_n in notif_ne.items():
        if expected_result.has_key(key_n) == None:
            test.failed("NBI notification attribute " + key + " accuracy test Failed for extra attribute " + key)
Ejemplo n.º 11
0
def check_pm_by_row(driver, id_table, index_row, ne_type, dict_counters, rows_of_page, list_headers, is_m_lics):
    test.info('Start to check row: ' + str(index_row))

    make_sure_is_correct_page(driver, index_row, rows_of_page)
    try:
        gui_index_row = rows_of_page if 0 == index_row % rows_of_page else index_row % rows_of_page
        id_tr = (By.XPATH, ".//tbody/tr[" + str(gui_index_row) + "]")
        table = find_single_widget(driver, 10, id_table)
        time.sleep(.5)
        tr = find_single_widget(table, 10, id_tr)
        gui_str_time = find_single_widget(tr, 10, (By.XPATH, ".//td[2]")).get_attribute('innerHTML').encode('utf-8')
        gui_time = datetime.strptime(gui_str_time.strip(), "%Y-%m-%d %H:%M")
        except_counter_id = str(gui_time.minute)

        id_lic_name = (By.XPATH, ".//td[3]")
        lic_name = find_single_widget(tr, 5, id_lic_name).get_attribute('innerHTML').encode('utf-8')
        if is_m_lics:
            except_counter_id = str(gui_time.minute) + '-' + lic_name
        list_row = dict_counters[except_counter_id].split(',')
        for i in range(len(list_row)):
            try:
                id_counter = (By.XPATH, ".//td[" + str(i + 4) + "]")
                gui_counter = find_single_widget(tr, 5, id_counter).get_attribute('innerHTML').encode('utf-8')
                i_gui_counter = int(gui_counter)
            except Exception as e:
                i_gui_counter = None
            if int(list_row[i].strip()) == i_gui_counter:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + list_headers[2] + ": " + lic_name + "; " \
                      + list_headers[i + 3] + ", GUI is " + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) \
                      + "."

                test.passed(msg)
            else:
                msg = list_headers[1] + ": " + gui_str_time.strip() + ",\t" + list_headers[2] + ": " + lic_name + "; " \
                      + list_headers[i + 3] + ", GUI is " + str(i_gui_counter) + ",\tExpected is " + str(list_row[i]) \
                      + "."

                test.failed(msg)
        return [gui_time, lic_name]
    except Exception as e:
        test.error("Test failed, ERROR: " + str(e))
Ejemplo n.º 12
0
def wait_until_rounds_ok(driver, rows, rows_of_page, dict_additional):
    '''
    This function will check the number of rows that we need to check the PM.
    :param driver:
    :param rows:
    :param rows_of_page:
    :param dict_additional:
    :param ne_type:
    :return: None
    '''
    id_tbdoy_trs = (By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/tbody/tr")
    if dict_additional.has_key('check_rows'):
        rows = dict_additional['check_rows']

    if not 0 == rows % dict_additional['number_of_lic']:
        test.error('Number of checked rows should be integer multiples of number of LICs.')
    t_start = datetime.now()
    # Note that most of the PM need T2-T1, for Node like SBC, we may wait 5 minutes more since SBC don't need T2-T1
    t_end = t_start + timedelta(minutes=5 * (rows // dict_additional['number_of_lic'] + 1) + 2)
    while datetime.now() < t_end:
        # click the query button
        id_query_btn = (By.ID, "idBtn-search")
        find_single_widget(driver, 10, id_query_btn).click()
        time.sleep(.2)
        try:
            i_page = rows / rows_of_page
            tgt_page_number = i_page if 0 == rows % rows_of_page else i_page + 1
            id_tgt_pager = (By.XPATH, ("//div[@class='page']/ul/li[2]/ul/li[" + str(tgt_page_number) + "]"))
            tgt_pager = find_single_widget(driver, 10, id_tgt_pager)
            if not tgt_pager.get_attribute('class').find('ebPagination-entryAnchor_current') > -1:
                tgt_pager.click()
                trs = find_all_widgets(driver, 20, id_tbdoy_trs)
                if rows % rows_of_page <= len(trs):
                    test.passed('All the data that we need are ready now.')
                    return
        except TimeoutException:
            pass
        time.sleep(.5)
    test.failed('It seems that the the data we need has not been collected as expectes, case may fail later steps.')
Ejemplo n.º 13
0
def check_pm_rows_updated(driver, ne_type, dict_counters, rows_of_page,
                          dict_additional):
    '''
    The main function that check the PM Data accurate, it will first check the data of each row,
    then check the GUI time's minutes is multiple of 5,
    then check the Lics if the node has many LICs.
    :param ne_type: the ne's type
    :param dict_counters: the base counter values in dictionary
    :param rows_of_page: how many rows each page has on the GUI, default is 10
    :param dict_additional: additional information that used for special nodes, (number_of_lic: how many lics of a no
    de), (check_rows: how many rows that will be checked, if this value exist, will only check this number of rows,
    otherwise the number of rows will checked is equal the size of dict_counters)
    :return: None
    '''
    check_rounds = dict_additional['check_rounds']
    number_of_rows_be_checked = check_rounds * dict_additional['number_of_lic']
    wait_until_rounds_ok(driver, number_of_rows_be_checked, 10,
                         dict_additional['number_of_lic'])
    is_m_lics = True if dict_additional['number_of_lic'] > 1 else False
    list_returns = []
    id_table = (By.XPATH,
                "//div[@class='ebTabs']/div[2]/div/div/div/div/table")

    id_header_trs = (
        By.XPATH,
        "//div[@class='ebTabs']/div[2]/div/div/div/div/table/thead/tr/th")
    ths = find_all_widgets(driver, 20, id_header_trs)
    list_headers = []
    for th in ths:
        list_headers.append(
            th.get_attribute('innerHTML').encode('utf-8').strip())
    # if not 0 == number_of_rows_be_checked % dict_additional['number_of_lic']:
    #    test.error('Number of checked rows should be integer multiples of number of LICs.')
    for row_index in range(1, number_of_rows_be_checked + 1):
        # check_pm_by_row returns [gui_datettime, lic_name] in List
        list_returns.append(
            check_pm_by_row(driver, id_table, row_index, ne_type,
                            dict_counters, rows_of_page, list_headers,
                            is_m_lics))
    # check GUI time and lic_name
    lic_from_gui = []
    if number_of_rows_be_checked != len(list_returns):
        test.failed(
            'Number of rows need to be checked mis-match with the number we expected.'
        )
    else:
        number_of_lic = dict_additional['number_of_lic']
        for i in range(0, len(list_returns), number_of_lic):
            for j in range(number_of_lic):
                lic_from_gui.append(list_returns[i + j][1])
                gui_time_and_lic_name = list_returns[i + j]
                if gui_time_and_lic_name[
                        0] is not None and 0 == gui_time_and_lic_name[
                            0].minute % 5:
                    test.passed(
                        'Row ' + str(i + j) + ' GUI time is correct, is: ' +
                        gui_time_and_lic_name[0].strftime('%Y-%m-%d %H:%M'))
                else:
                    test.failed(
                        'Row ' + str(i + j) +
                        ' GUI time is not multiple of 5, is: ' +
                        gui_time_and_lic_name[0].strftime('%Y-%m-%d %H:%M'))
                if is_m_lics:
                    msg = 'Node has more than one LIC, '
                    if list_returns[i][0] == list_returns[i + j][0]:
                        msg += ' different LICs have the same report time.'
                        test.passed(msg)
                    else:
                        msg += ' different LICs don\'t have the same report time.'
                        test.failed(msg)
            if i + number_of_lic < len(list_returns):
                # the pre-condition of this check point is: GUI list data decent by datetime
                if 300 == (list_returns[i][0] -
                           list_returns[i + number_of_lic][0]).seconds:
                    test.passed('Report delta time is 5 minutes.')
                else:
                    test.failed('Report delta time is not 5 minutes.')
    # if checked 1 hour PM and node has many LICs, will check the LIC
    if 12 == int(number_of_rows_be_checked / dict_additional['number_of_lic']):
        if is_m_lics:
            expected_lic = [
                t.split('-', 1)[1].strip() for t in sorted(dict_counters)
            ]
            if compare_lists(expected_lic, lic_from_gui):
                test.passed('Lic check passed.')
            else:
                test.failed('Lic check failed, E: ' + str(expected_lic) +
                            ', G: ' + str(lic_from_gui))
Ejemplo n.º 14
0
def check_attr_accuracy(mappingInstance,alarm_trap,dict_nbi_notif,nename,nodeid,attrs,mysqlInst):
    for a in attrs:
        expected_value = {}
        notif_value = {}
        if 'event_name' == a:
            if dict_nbi_notif.has_key('event_name'):
                notif_value['event_name'] = dict_nbi_notif['event_name']
                mapped_event_name = mappingInstance.convert_event_type(alarm_trap['alarmCategory'])
                if mapped_event_name != None:
                    expected_value['event_name'] = '"' + mapped_event_name + '"'
                    test.info("check 'event_name',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                    compare_data(notif_value,expected_value)
            else:
                test.failed("get 'event_name' from nbi notification Failed")

        elif "event_type" == a:
            if dict_nbi_notif.has_key("event_type"):
                notif_value['event_type'] = dict_nbi_notif["event_type"]
                type_name = '"' + mappingInstance.dict_mapping_info["type_name"] + '"'
                expected_value = {'event_type':{'none':{'domain_name':'"Alarm IRP V3.0.0"','type_name':type_name}}}
                test.info("check 'event_type',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                compare_data(notif_value, expected_value)
            else:
                test.failed("get 'event_type' from nbi notification Failed")

        elif 'd'  == a:
            if dict_nbi_notif.has_key("d"):
                notif_value['d'] = dict_nbi_notif["d"]
                object_class = '"' + mappingInstance.dict_mapping_info['object_class'] + '"'
                expected_value = {'d':{'value':{'CORBA::String':object_class}}}
                test.info("check 'objectClass',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                compare_data(notif_value, expected_value)
            else:
                test.failed("get 'd' from nbi notification Failed")

        elif "e" == a:
            if dict_nbi_notif.has_key("e"):
                notif_value['e'] = dict_nbi_notif["e"]
                dn = mappingInstance.convert_object_instance(nodeid,nename)
                if dn != None:
                    expected_value = {'e':{'value':{'CORBA::String':'"' + dn + '"'}}}
                    test.info("check 'objectInstance',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                    compare_data(notif_value,expected_value)
            else:
                test.failed("get 'e' from nbi notification Failed")
            
        elif "b" == a:
            if dict_nbi_notif.has_key("b"):
                notif_value["b"] = dict_nbi_notif["b"]
                mapped_event_time = mappingInstance.convert_event_time(alarm_trap["timeStamp"])
                if mapped_event_time!= None:
                    expected_value = {'b':{'value':{'TimeBase::UtcT':{'none':{'time':mapped_event_time,'inacclo':'0','inacchi':'0','tdf':'480'}}}}}
                    test.info("check 'eventTime',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                    compare_data(notif_value, expected_value)
            else:
                test.failed("get 'b' from nbi notification Failed")
           
        elif "c" == a:
            expected_value = {'c':{'value':{'CORBA::String':'"DC=Ericsson,SubNetwork=1,ManagementNode=1,IRPAgent=1"'}}}
            check_common_accuracy('c', dict_nbi_notif, expected_value)
        
        elif "jj" == a:
            if dict_nbi_notif.has_key("jj"):
                notif_value["jj"] = dict_nbi_notif["jj"]
                specific_problem = alarm_trap["specificProblem"]
                alarmtypeid = mappingInstance.convert_alarmtype_id(specific_problem)
                if alarmtypeid != None:
                    mapped_vender_specificAlarmType = '"' + alarmtypeid + "||" + specific_problem + '"'
                    expected_value = {'jj':{'value':{'CORBA::String':mapped_vender_specificAlarmType}}}
                    test.info("check 'vendorSpecificAlarmType',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                    compare_data(notif_value,expected_value)
            else:
                test.failed("get 'jj' from nbi notification Failed")
                
        elif "g" == a:
            if dict_nbi_notif.has_key("g"):
                notif_value["g"] = dict_nbi_notif["g"]
                mapped_probable_cause = mappingInstance.convert_probable_cause(alarm_trap["probableCause"])
                if mapped_probable_cause != None:
                    expected_value = {'g':{'value':{'CORBA::Short':mapped_probable_cause}}}
                    test.info("check 'probableCause',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                    compare_data(notif_value, expected_value)
            else:
                test.failed("get 'g' from nbi notification Failed")
        
        elif "h" == a:
            if dict_nbi_notif.has_key("h"):
                notif_value['h'] = dict_nbi_notif['h']
                mapped_alarm_severity = mappingInstance.convert_alarm_severity(alarm_trap["alarmLevel"])
                if mapped_alarm_severity != None:
                    expected_value = {'h':{'value':{'CORBA::Short':mapped_alarm_severity}}}
                    test.info("check 'perceivedSeverity',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                    compare_data(notif_value, expected_value)
            else:
                test.failed("get 'h' from nbi notification Failed")
                
        elif "a" == a:
            if dict_nbi_notif.has_key("a"):
                notif_value["a"] = dict_nbi_notif["a"]
                '''X use CORBA:LongLong although CORBA::Long is required in spec'''
                notif_id = dict_nbi_notif["a"]["value"]["CORBA::LongLong"]
                test.info("check 'notificationId',the nbi notification result is " + str(notif_value) )
                sqltext = ('SELECT notificationId from alarms where notificationId = "%s"'%notif_id)
                is_unique=check_unique_id(sqltext,mysqlInst)
                if is_unique == 0:
                    test.failed("the notificationId of " + notif_id + " not existed in database")
                elif is_unique == 1:
                    test.passed("the notificationId of " + notif_id + " is unique in database")
                elif is_unique > 1:
                    test.failed("more than one notificationId of " + notif_id + "found in database")
            else:
                test.failed("get 'a' from nbi notification Failed")
        
        elif "w" == a:
            if dict_nbi_notif.has_key("w"):
                notif_value["w"] = dict_nbi_notif["w"]
                dn = '"' + mappingInstance.convert_object_instance(nodeid,nename) + '"'
                if dn != None:
                    notification_id = dict_nbi_notif["a"]["value"]["CORBA::LongLong"]
                    expected_value = {'w':{'value':{'AlarmIRPConstDefs::CorrelatedNotification':{'none':{'source':dn,'notif_id_set':{'none':notification_id}}}}}}
                    test.info("check 'correlatedNotifications',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                    compare_data(notif_value, expected_value)
            else:
                test.failed("get 'w' from nbi notification Failed")
                
        elif "p" == a:
            expected_value = {'p':{'value':{'CORBA::Boolean':'FALSE'}}}
            check_common_accuracy('p',dict_nbi_notif,expected_value)
            
        elif "q"  == a:
            expected_value = {'q':{'value':{'CORBA::String':'"NULL"'}}}
            check_common_accuracy('q', dict_nbi_notif, expected_value)
            
        elif "s" == a:
            expected_value = {'s':{'value':{'AlarmIRPConstDefs::TrendIndication':'NO_CHANGE'}}}
            check_common_accuracy('s', dict_nbi_notif, expected_value)
            
        elif "v" == a:
            expected_value = {'v':{'value':{'CORBA::String':'""'}}}
            check_common_accuracy('v', dict_nbi_notif, expected_value)
            
        elif "j" == a:
            if dict_nbi_notif.has_key("j"):
                notif_value ["j"] = dict_nbi_notif["j"]
                additionaltext = '"' + alarm_trap["alarmDescription"] + '"'
                expected_value = {'j':{'value':{'CORBA::String':additionaltext}}}
                test.info("check 'additionalText',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                compare_data(notif_value, expected_value)
            else:
                test.failed("get 'j' from nbi notification Failed")
        
        elif "ai_vs_threshold" == a:
            expected_value = {'ai_vs_threshold':{'value':{'CORBA::String':'""'}}}
            check_common_accuracy('ai_vs_threshold', dict_nbi_notif, expected_value)
        
        elif "ai_ps" == a:
            if dict_nbi_notif.has_key("ai_ps"):
                notif_value["ai_ps"] = dict_nbi_notif["ai_ps"]
                mapped_alarm_severity = '"' + mappingInstance.convert_alarm_severity(alarm_trap["alarmLevel"]) + '"'
                if mapped_alarm_severity != None:
                    expected_value = {'ai_ps':{'value':{'CORBA::String':mapped_alarm_severity}}}
                    test.info("check 'AI_VS_PERCEIVED_SEVERITY',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                    compare_data(notif_value, expected_value)
            else:
                test.failed("get 'ai_ps' from nbi notification Failed")
                
        elif "ai_at" == a:
            if dict_nbi_notif.has_key('ai_at'):
                notif_value['ai_at'] = dict_nbi_notif['ai_at']
                mapped_event_name = '"' + mappingInstance.convert_event_type(alarm_trap['alarmCategory']) + '"'
                if mapped_event_name != None:
                    expected_value['ai_at'] = expected_value = {'ai_at':{'value':{'CORBA::String':mapped_event_name}}}
                    test.info("check 'AI_VS_ALARM_TYPE',the nbi notification result is " + str(notif_value) + ",and the expected result is " + str(expected_value))
                    compare_data(notif_value,expected_value)
            else:
                test.failed("get 'ai_at' from nbi notification Failed")
                
        elif "f"  == a:
            if dict_nbi_notif.has_key("f"):
                notif_value["f"] = dict_nbi_notif["f"]
                alarm_id = notif_value["f"]["value"]["CORBA::String"]
                sqltext = ("SELECT id from alarms where id = %s"%alarm_id)
                is_unique=check_unique_id(sqltext,mysqlInst)
                if is_unique == 0:
                    test.failed("alarmId of " + alarm_id + " not existed in database")
                elif is_unique == 1:
                    test.passed("the alarmId of " + alarm_id + " is unique in database")
                elif is_unique > 1:
                    test.failed("more than one alarmId of " + alarm_id + "found in database")
            else:
                test.failed("get 'f' from nbi notification Failed")
Ejemplo n.º 15
0
def check_pm_rows_updated(driver, ne_type, dict_counters, rows_of_page, dict_additional):
    '''
    The main function that check the PM Data accurate, it will first check the data of each row,
    then check the GUI time's minutes is multiple of 5,
    then check the Lics if the node has many LICs.
    :param ne_type: the ne's type
    :param dict_counters: the base counter values in dictionary
    :param rows_of_page: how many rows each page has on the GUI, default is 10
    :param dict_additional: additional information that used for special nodes, (number_of_lic: how many lics of a no
    de), (check_rows: how many rows that will be checked, if this value exist, will only check this number of rows,
    otherwise the number of rows will checked is equal the size of dict_counters)
    :return: None
    '''
    is_m_lics = True if dict_additional['number_of_lic'] > 1 else False
    list_returns = []
    id_table = (By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table")

    id_header_trs = (By.XPATH, "//div[@class='ebTabs']/div[2]/div/div/div/div/table/thead/tr/th")
    ths = find_all_widgets(driver, 20, id_header_trs)
    list_headers = []
    for th in ths:
        list_headers.append(th.get_attribute('innerHTML').encode('utf-8').strip())
    number_of_rows_be_checked = len(dict_counters)
    if dict_additional.has_key('check_rounds'):
        number_of_rows_be_checked = dict_additional['check_rounds']
    if not 0 == number_of_rows_be_checked % dict_additional['number_of_lic']:
        test.error('Number of checked rows should be integer multiples of number of LICs.')
    for row_index in range(1, number_of_rows_be_checked + 1):
        # check_pm_by_row returns [gui_datettime, lic_name] in List
        list_returns.append(check_pm_by_row(driver, id_table, row_index, ne_type, dict_counters, rows_of_page,
                                            list_headers, is_m_lics))
    # check GUI time and lic_name
    lic_from_gui = []
    if number_of_rows_be_checked != len(list_returns):
        test.failed('Number of rows need to be checked mis-match with the number we expected.')
    else:
        number_of_lic = dict_additional['number_of_lic']
        for i in range(0, len(list_returns), number_of_lic):
            for j in range(number_of_lic):
                lic_from_gui.append(list_returns[i + j][1])
                gui_time_and_lic_name = list_returns[i + j]
                if gui_time_and_lic_name[0] is not None and 0 == gui_time_and_lic_name[0].minute % 5:
                    test.passed('Row ' + str(i + j) + ' GUI time is correct, is: ' +
                                gui_time_and_lic_name[0].strftime('%Y-%m-%d %H:%M'))
                else:
                    test.failed('Row ' + str(i + j) + ' GUI time is not multiple of 5, is: ' +
                                gui_time_and_lic_name[0].strftime('%Y-%m-%d %H:%M'))
                if is_m_lics:
                    msg = 'Node has more than one LIC, '
                    if list_returns[i][0] == list_returns[i + j][0]:
                        msg += ' different LICs have the same report time.'
                        test.passed(msg)
                    else:
                        msg += ' different LICs don\'t have the same report time.'
                        test.failed(msg)
            if i + number_of_lic < len(list_returns):
                # the pre-condition of this check point is: GUI list data decent by datetime
                if 300 == (list_returns[i][0] - list_returns[i + number_of_lic][0]).seconds:
                    test.passed('Report delta time is 5 minutes.')
                else:
                    test.failed('Report delta time is not 5 minutes.')
    # if checked 1 hour PM and node has many LICs, will check the LIC
    if 12 == int(number_of_rows_be_checked / dict_additional['number_of_lic']):
        if is_m_lics:
            expected_lic = [t.split('-', 1)[1].strip() for t in sorted(dict_counters)]
            if compare_lists(expected_lic, lic_from_gui):
                test.passed('Lic check passed.')
            else:
                test.failed('Lic check failed, E: ' + str(expected_lic) + ', G: ' + str(lic_from_gui))
Ejemplo n.º 16
0
def foo():
    test.passed('This step passed.')
    # test.error('Error occured.')
    test.failed('This step failed.')