Esempio n. 1
0
def check_in_correct_pm_page(driver):
    '''
    This function works on the beginning editions and has been abandoned.
    :param driver:
    :return:
    '''
    id_search_btn = (By.ID, "idBtn-search")
    b_validate = False
    try:
        find_single_widget(driver, 10, id_search_btn)
        b_validate = True
    except TimeoutException as e:
        # page not loaded
        return False
    if b_validate:
        # check if in the correct page
        # id_navi = identifier = (By.XPATH, "//div[@class='ebLayout-Navigation']/div")
        # navi = find_single_widget(driver, 10, id_navi)
        id_divs = identifier = (By.XPATH, "//div[@class='ebLayout-Navigation']/div/div")
        children_divs = find_all_widgets(driver, 20, id_divs)
        str_last_navi = find_single_widget(children_divs[-1], 10, (By.XPATH, ".//a")).get_attribute('innerHTML').\
            encode('utf-8').strip()
        # logger.info(children_divs[-2].get_attribute('innerHTML').encode('utf-8'))
        lis = find_all_widgets(children_divs[-2], 10, (By.XPATH, ".//div/ul/li"))
        for li in lis:
            str_a_li = find_single_widget(li, 10, (By.XPATH, ".//a")).get_attribute('innerHTML').encode('utf-8').strip()
            if str_last_navi == str_a_li:
                return True
        # current page not in parent navigation
        return False
Esempio n. 2
0
def check_in_correct_pm_page(driver):
    '''
    This function works on the beginning editions and has been abandoned.
    :param driver:
    :return:
    '''
    id_search_btn = (By.ID, "idBtn-search")
    b_validate = False
    try:
        find_single_widget(driver, 10, id_search_btn)
        b_validate = True
    except TimeoutException as e:
        # page not loaded
        return False
    if b_validate:
        # check if in the correct page
        # id_navi = identifier = (By.XPATH, "//div[@class='ebLayout-Navigation']/div")
        # navi = find_single_widget(driver, 10, id_navi)
        id_divs = identifier = (By.XPATH,
                                "//div[@class='ebLayout-Navigation']/div/div")
        children_divs = find_all_widgets(driver, 20, id_divs)
        str_last_navi = find_single_widget(children_divs[-1], 10, (By.XPATH, ".//a")).get_attribute('innerHTML').\
            encode('utf-8').strip()
        # logger.info(children_divs[-2].get_attribute('innerHTML').encode('utf-8'))
        lis = find_all_widgets(children_divs[-2], 10,
                               (By.XPATH, ".//div/ul/li"))
        for li in lis:
            str_a_li = find_single_widget(
                li, 10,
                (By.XPATH,
                 ".//a")).get_attribute('innerHTML').encode('utf-8').strip()
            if str_last_navi == str_a_li:
                return True
        # current page not in parent navigation
        return False
Esempio n. 3
0
def get_1st_row_on_gui(driver):
    table_i = (
        By.XPATH,
        "//div[@class='table']/div/div/table[@class='ebTable elWidgets-Table-body']"
    )
    table = find_single_widget(driver, 10, table_i)

    name_i = (By.XPATH, "./thead/tr/th")
    column_name = find_all_widgets(table, 10, name_i)

    value_i = (By.XPATH, "./tbody/tr[1]/td")
    find_single_widget(table, 10, value_i).click()
    column_value = find_all_widgets(table, 10, value_i)

    name_list = []
    value_list = []

    if (len(column_name) != len(column_value)):
        logCommon.error("Alarm data mismatched on gui")

    for name in column_name:
        alarm_name = name.text.encode('utf-8')
        name_list.append(alarm_name)
    del name_list[0]

    for value in column_value:
        filed_value = value.text.encode('utf-8')
        value_list.append(filed_value)
    del value_list[0]

    alarm_gui = dict(zip(name_list, value_list))
    del alarm_gui["告警代码"]
    del alarm_gui["类型代码"]
    del alarm_gui["类型编号"]
    return alarm_gui
Esempio n. 4
0
def get_1st_row_on_gui(driver):
    table_i = (By.XPATH,"//div[@class='table']/div/div/table[@class='ebTable elWidgets-Table-body']")
    table=find_single_widget(driver,10,table_i)

    name_i=(By.XPATH,"./thead/tr/th")
    column_name = find_all_widgets(table,10,name_i)

    value_i = (By.XPATH,"./tbody/tr[1]/td")
    find_single_widget(table,10,value_i).click()
    column_value = find_all_widgets(table,10,value_i)

    name_list=[]
    value_list=[]

    if(len(column_name) != len(column_value)):
        logCommon.error("Alarm data mismatched on gui")

    for name in column_name:
        alarm_name = name.text.encode('utf-8')
        name_list.append(alarm_name)
    del name_list[0]

    for value in column_value:
        filed_value = value.text.encode('utf-8')
        value_list.append(filed_value)
    del value_list[0]

    alarm_gui=dict(zip(name_list,value_list))
    del alarm_gui["告警代码"]
    del alarm_gui["类型代码"]
    del alarm_gui["类型编号"]
    return alarm_gui
Esempio n. 5
0
def check_ne_exist_by_type(driver, ne_type, ne_ip, page_no=20):
    # note there is another way to check if NE with certain IP exist, that is connect to the server's database and
    # check the NES data table
    id_table = (By.XPATH,
                "//div[@id='dv1']/div[2]/div/div/div[3]/div/div/div/table")
    table = find_single_widget(driver, 10, id_table)

    id_page = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[2]/div/input")
    pages = find_single_widget(driver, 10, id_page)
    pages.clear()
    pages.send_keys(page_no)
    ActionChains(driver).key_down(Keys.ENTER).key_up(Keys.ENTER).perform()

    # set ne type
    # id_type = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[3]/div/div/div/table/thead/tr[2]/th[2]/input")
    # w_ne_type = find_single_widget(driver, 10, id_type)
    # w_ne_type.clear()
    # w_ne_type.send_keys(ne_type)

    id_trs = (By.XPATH, ".//tbody/tr")
    try:
        trs = find_all_widgets(table, 20, id_trs)
        is_has_pair_nes = False
        for tr in trs:
            # gui_type = tr.get_attribute('innerHTML').encode('utf-8')
            gui_ne_name = find_single_widget(
                tr, 10,
                (By.XPATH,
                 ".//td[1]")).get_attribute('innerHTML').encode('utf-8')
            gui_ne_type = find_single_widget(
                tr, 10,
                (By.XPATH,
                 ".//td[2]")).get_attribute('innerHTML').encode('utf-8')

            tr.click()
            if wait_until_text_shown_up(driver, 10, (By.ID, "i_nename"),
                                        gui_ne_name):
                gui_ip = find_single_widget(driver, 10, (By.ID, "i_neip"))
                if ne_ip == gui_ip.get_attribute('value').encode(
                        'utf-8').strip():
                    if ne_type == gui_ne_type:
                        # NE with same ip and same type exit
                        return 1, gui_ne_name
                    else:
                        if is_pair_nes(gui_ne_type.upper(), ne_type.upper()):
                            # this means that there is a pair NE with same IP exist, but we can still add a NE
                            # but will check if NE with the same type & same IP exist
                            is_has_pair_nes = True
                        else:
                            # this means a NE with different type but the same IP already exist.
                            return 2, gui_ne_name
        if is_has_pair_nes:
            return 0, None
        # the ip that we want to add does not exist
        return -1, None
    except Exception as e:
        # the ip that we want to add does not exist
        return -2, None
Esempio n. 6
0
def make_in_correct_tab(driver, prefix, postfix):
    id_tabs = (By.XPATH, "//div[@class='ebTabs']/div[1]/div[2]/div")
    tabs = find_all_widgets(driver, 10, id_tabs)
    for tab in tabs:
        if prefix + postfix == tab.get_attribute('innerHTML').encode('utf-8').strip():
            if not tab.get_attribute('class').encode('utf-8').find('ebTabs-tabItem_selected_true') > -1:
                tab.click()
                wait_noti_widget_show(driver)
                test.info('Switch to the TAB: ' + prefix + postfix)
Esempio n. 7
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.')
Esempio n. 8
0
def make_in_correct_tab(driver, prefix, postfix):
    id_tabs = (By.XPATH, "//div[@class='ebTabs']/div[1]/div[2]/div")
    tabs = find_all_widgets(driver, 10, id_tabs)
    for tab in tabs:
        if prefix + postfix == tab.get_attribute('innerHTML').encode(
                'utf-8').strip():
            if not tab.get_attribute('class').encode('utf-8').find(
                    'ebTabs-tabItem_selected_true') > -1:
                tab.click()
                wait_noti_widget_show(driver)
                test.info('Now in TAB: ' + prefix + postfix)
Esempio n. 9
0
def check_ne_exist_by_type(driver, ne_type, ne_ip, page_no=20):
    # note there is another way to check if NE with certain IP exist, that is connect to the server's database and
    # check the NES data table
    id_table = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[3]/div/div/div/table")
    table = find_single_widget(driver, 10, id_table)

    id_page = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[2]/div/input")
    pages = find_single_widget(driver, 10, id_page)
    pages.clear()
    pages.send_keys(page_no)
    ActionChains(driver).key_down(Keys.ENTER).key_up(Keys.ENTER).perform()

    # set ne type
    # id_type = (By.XPATH, "//div[@id='dv1']/div[2]/div/div/div[3]/div/div/div/table/thead/tr[2]/th[2]/input")
    # w_ne_type = find_single_widget(driver, 10, id_type)
    # w_ne_type.clear()
    # w_ne_type.send_keys(ne_type)

    id_trs = (By.XPATH, ".//tbody/tr")
    try:
        trs = find_all_widgets(table, 20, id_trs)
        is_has_pair_nes = False
        for tr in trs:
            # gui_type = tr.get_attribute('innerHTML').encode('utf-8')
            gui_ne_name = find_single_widget(tr, 10, (By.XPATH, ".//td[1]")).get_attribute('innerHTML').encode('utf-8')
            gui_ne_type = find_single_widget(tr, 10, (By.XPATH, ".//td[2]")).get_attribute('innerHTML').encode('utf-8')

            tr.click()
            if wait_until_text_shown_up(driver, 10, (By.ID, "i_nename"), gui_ne_name):
                gui_ip = find_single_widget(driver, 10, (By.ID, "i_neip"))
                if ne_ip == gui_ip.get_attribute('value').encode('utf-8').strip():
                    if ne_type == gui_ne_type:
                        # NE with same ip and same type exit
                        return 1, gui_ne_name
                    else:
                        if is_pair_nes(gui_ne_type.upper(), ne_type.upper()):
                            # this means that there is a pair NE with same IP exist, but we can still add a NE
                            # but will check if NE with the same type & same IP exist
                            is_has_pair_nes = True
                        else:
                            # this means a NE with different type but the same IP already exist.
                            return 2, gui_ne_name
        if is_has_pair_nes:
            return 0, None
        # the ip that we want to add does not exist
        return -1, None
    except Exception as e:
        # the ip that we want to add does not exist
        return -2, None
Esempio n. 10
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.'
    )
Esempio n. 11
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.')
Esempio n. 12
0
def check_pm_rows(driver, logger, ne_type, dict_counters, rows_of_page,
                  dict_additional):
    bool_overall = True
    list_time = []
    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())
    # table = find_single_widget(driver, 10, id_table)

    rounds = len(dict_counters)
    if 'SBC' == ne_type:
        if dict_additional.has_key('rounds'):
            rounds = dict_additional['rounds']

    for i in range(1, rounds + 1):
        bool_row, gui_time = check_pm_by_row(driver, id_table, logger, i,
                                             ne_type, dict_counters,
                                             rows_of_page, list_headers)
        list_time.append(gui_time)
        if not bool_row:
            bool_overall = False
            logger.error(
                'Row ' + str(i) +
                " check FAILED. Check the log for detailed information.")
        else:
            logger.info('Row ' + str(i) + " check PASSED.")

    if bool_overall:
        if len(list_time) < 1:
            bool_overall = False
            logger.error(
                'Failed: 0 rounds of PM checked, this does not make any sense.'
            )
        elif len(list_time) < 2:
            if 'OCGAS' == ne_type:
                bool_overall = False
                logger.error(
                    'Failed: Node OCGAS is supposed to have two LICs, there is only one record of PM Data.'
                )
            elif list_time[0] is None:
                bool_overall = False
                logger.error('Failed: Fail to get the PM data time.')
            else:
                if 0 != list_time[0].minute % 5:
                    bool_overall = False
                    logger.error('Failed: PM Data time is not multiples of 5.')
        else:
            if ne_type in ['SGW', 'PGW', 'SGSN', 'MME', 'SBC']:
                for i in range(0, len(list_time) - 1):
                    if list_time[i] is None or list_time[i + 1] is None:
                        bool_overall = False
                        logger.error('Failed: Fail to get the PM data time.')
                        break
                    else:
                        if 0 != list_time[i].minute % 5 or 0 != list_time[
                                i + 1].minute % 5:
                            bool_overall = False
                            logger.error(
                                'Failed: PM Data time is not multiples of 5.')
                            break
                        if 300 != abs(
                            (list_time[i] - list_time[i + 1]).seconds):
                            bool_overall = False
                            logger.error('Failed: PM period is not 5 minutes.')
                            break
            elif 'OCGAS' == ne_type:
                for i in range(0, len(list_time), 2):
                    if i != len(list_time) - 2:
                        if list_time[i] is None or list_time[
                                i + 1] is None or list_time[i + 2] is None:
                            bool_overall = False
                            logger.error(
                                'Failed: Fail to get the PM data time.')
                            break
                        else:
                            if list_time[i] != list_time[i + 1]:
                                bool_overall = False
                                logger.error(
                                    'Failed: Two LICs of Node OCGAS should be the same.'
                                )
                                break
                            else:
                                if 0 != list_time[
                                        i].minute % 5 or 0 != list_time[
                                            i + 2].minute % 5:
                                    bool_overall = False
                                    logger.error(
                                        'Failed: PM Data time is not multiples of 5.'
                                    )
                                    break
                                elif 300 != abs(
                                    (list_time[i] - list_time[i + 2]).seconds):
                                    bool_overall = False
                                    logger.error(
                                        'Failed: PM period is not 5 minutes. '
                                        + str(list_time[i]) + ' ' +
                                        str(list_time[i + 2]))
                                    break
    logger.info('GUI times: ' + ', '.join([str(t) for t in list_time]))
    if bool_overall:
        logger.info("Overall PASSED.")
    else:
        logger.error("Overall FAILED.")
Esempio 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))
Esempio n. 14
0
def check_pm_rows(driver, logger, ne_type, dict_counters, rows_of_page, dict_additional):
    bool_overall = True
    list_time = []
    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())
    # table = find_single_widget(driver, 10, id_table)

    rounds = len(dict_counters)
    if 'SBC' == ne_type:
        if dict_additional.has_key('rounds'):
            rounds = dict_additional['rounds']

    for i in range(1, rounds + 1):
        bool_row, gui_time = check_pm_by_row(driver, id_table, logger, i, ne_type, dict_counters, rows_of_page, list_headers)
        list_time.append(gui_time)
        if not bool_row:
            bool_overall = False
            logger.error('Row ' + str(i) + " check FAILED. Check the log for detailed information.")
        else:
            logger.info('Row ' + str(i) + " check PASSED.")

    if bool_overall:
        if len(list_time) < 1:
            bool_overall = False
            logger.error('Failed: 0 rounds of PM checked, this does not make any sense.')
        elif len(list_time) < 2:
            if 'OCGAS' == ne_type:
                bool_overall = False
                logger.error('Failed: Node OCGAS is supposed to have two LICs, there is only one record of PM Data.')
            elif list_time[0] is None:
                bool_overall = False
                logger.error('Failed: Fail to get the PM data time.')
            else:
                if 0 != list_time[0].minute % 5:
                    bool_overall = False
                    logger.error('Failed: PM Data time is not multiples of 5.')
        else:
            if ne_type in ['SGW', 'PGW', 'SGSN', 'MME', 'SBC']:
                for i in range(0, len(list_time) - 1):
                    if list_time[i] is None or list_time[i + 1] is None:
                        bool_overall = False
                        logger.error('Failed: Fail to get the PM data time.')
                        break
                    else:
                        if 0 != list_time[i].minute % 5 or 0 != list_time[i + 1].minute % 5:
                            bool_overall = False
                            logger.error('Failed: PM Data time is not multiples of 5.')
                            break
                        if 300 != abs((list_time[i] - list_time[i + 1]).seconds):
                            bool_overall = False
                            logger.error('Failed: PM period is not 5 minutes.')
                            break
            elif 'OCGAS' == ne_type:
                for i in range(0, len(list_time), 2):
                    if i != len(list_time) - 2:
                        if list_time[i] is None or list_time[i + 1] is None or list_time[i + 2] is None:
                            bool_overall = False
                            logger.error('Failed: Fail to get the PM data time.')
                            break
                        else:
                            if list_time[i] != list_time[i + 1]:
                                bool_overall = False
                                logger.error('Failed: Two LICs of Node OCGAS should be the same.')
                                break
                            else:
                                if 0 != list_time[i].minute % 5 or 0 != list_time[i + 2].minute % 5:
                                    bool_overall = False
                                    logger.error('Failed: PM Data time is not multiples of 5.')
                                    break
                                elif 300 != abs((list_time[i] - list_time[i + 2]).seconds):
                                    bool_overall = False
                                    logger.error('Failed: PM period is not 5 minutes. ' + str(list_time[i]) + ' '
                                                 + str(list_time[i + 2]))
                                    break
    logger.info('GUI times: ' + ', '.join([str(t) for t in list_time]))
    if bool_overall:
        logger.info("Overall PASSED.")
    else:
        logger.error("Overall FAILED.")
Esempio 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))