Esempio n. 1
0
        
    dbs_name = args.dbs_name
    user_name = args.user_name
    user_password = args.user_password
    ignore_error = args.ignore_error
    
    sql_queries = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', "sql", "create_user.txt")
    control_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', "controlfile", "original_results.pickle")
    save_result_queries = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', "sql", "save_results.txt")
    save_result_output = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', "results_output.txt")
    tdtestpy.delete_one_file(save_result_output)

    udaExec = teradata.UdaExec (appName="tdtestpy", version="1.0", logConsole=True)
    db_connect = udaExec.connect(method="odbc", system=dbs_name, username=user_name, password=user_password)
    
    dbc_instance = tdtestpy.DBSaccess (db_connect)
    validate_instance = tdtestpy.SQLValidation (db_connect, control_file)
    allresults = validate_instance.load_control_file()
    sql1_org_result = allresults["dbcinfo1"]
    sql2_org_result = allresults["dbcinfo2"]
    sql3_org_result = allresults["dbcinfo3"]
    
    sql1 = "select count(*) from dbc.dbcinfo"
    sql2 = "select count(*) from dbc.dbcinfo where InfoKey = 'RELEASE'"
    sql3 = "select InfoKey from dbc.dbcinfo"
    sql4 = "select count(*) from dbc.dbcinf"
    
    save_results_instance = tdtestpy.SaveSQLResults (db_con = db_connect, output_file = save_result_output)
    # Clean up test database before start unit testing just in case it failed prior run 
    dbc_instance.drop_user("tdtestpy_unit_test")   
Esempio n. 2
0
        item_ldi_export_log = os.path.join(ldi_tables_write, i_export_name)
        item_ldi_stream_log = os.path.join(ldi_tables_write, i_stream_name)
        
        item_ldi_data_file = user_name + "_item_ldi_loop_" + iteration + ".dat"
        item_ldi_data_file_full_path = os.path.join(directory_path, item_ldi_data_file) 
                

        
        # Main test body start here
        
        logging.info("================== LDI Tables Write Testing Started ==================")
  
        # Check row count of LDI tables, if they're not the same with stage tables then we reload so we can get accurate count.
        logging.info("Check row count of LDI tables, reload if they are not the same with stage tables")
        with udaExec.connect(method="odbc", system=dbs_name, username=user_name, password=user_name) as db_connect:
            test_user_instance = tdtestpy.DBSaccess (db_connect) 
            stage_database = "sit_ldi_pll_stage"
             
            org_iip_count = test_user_instance.get_table_row_count(user_name, "ITEM_INVENTORY_PLAN_LDI")               
            org_ii_count = test_user_instance.get_table_row_count(user_name, "ITEM_INVENTORY_LDI")
            org_rtl_count = test_user_instance.get_table_row_count(user_name, "RETURN_TRANSACTION_LINE_LDI")
            org_i_count = test_user_instance.get_table_row_count(user_name, "item_ldi")
            
            with db_connect.cursor() as cursor:
                tb_name = "ITEM_INVENTORY_PLAN_LDI"
                stage_db = "sit_ldi_pll_stage"
                if org_iip_count != test_user_instance.get_table_row_count(stage_database, tb_name):
                    item_inv_plan_eil = user_name.strip() + "_ITEM_INV_PLAN_LDI"
                    cursor.execute("END ISOLATED LOADING FOR QUERY_BAND 'LDILoadGroup=%s;'" % (item_inv_plan_eil), ignoreErrors=[9887])
                    cursor.execute("delete %s" % (tb_name))
                    cursor.execute("insert into %s select * from %s.%s" % (tb_name, stage_db, tb_name))
Esempio n. 3
0
        cleanup_ignore_errors = tdtestpy.get_ignore_errors(
            common_error) + ignore_error

        # dump python log to demo_log_path
        fh = logging.FileHandler(cleanup_log_name, mode="a", encoding="utf8")
        fh.setFormatter(
            logging.Formatter(
                "%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
        fh.setLevel(logging.DEBUG)
        root = logging.getLogger()
        root.addHandler(fh)

        logging.info("================== Cleanup Start ==================")
        # Using tdtestpy drop_users function to drop all users start with sitq_ldi_pll_user
        delete_user_with = "sit_ldi_pll_"
        cleanup_task = tdtestpy.DBSaccess(dbc_con)

        with dbc_con.cursor() as cursor:
            cursor.execute(
                "select UserName from dbc.users where UserName like '%s'" %
                (delete_user_with + '%'))
            user_list = [item[0] for item in cursor.fetchall()]
            if len(user_list) != 0:
                for user_name in user_list:
                    # Make sure to end ilolated loading just in case TPT for LDI tables failed during test
                    item_inv_eil = user_name.strip() + "_ITEM_INV_LDI"
                    item_inv_plan_eil = user_name.strip(
                    ) + "_ITEM_INV_PLAN_LDI"
                    item_eil = user_name.strip() + "_ITEM_LDI"
                    return_rea_eil = user_name.strip() + "_RETURN_REASON_LDI"
                    return_trans_line_eil = user_name.strip(
Esempio n. 4
0
        setup_log_name = os.path.join(setup_log_path, "setup.log")
        setup_ignore_errors = tdtestpy.get_ignore_errors(common_error) + ignore_error

        
        # dump python log to demo_log_path        
        fh = logging.FileHandler(setup_log_name, mode="a", encoding="utf8")
        fh.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
        fh.setLevel(logging.DEBUG)
        root = logging.getLogger()
        root.addHandler(fh) 
                
        logging.info("================== Main Setup Starts ==================")
        setup_con = udaExec.connect(method=con_method, system=dbs_name, username= "******", password= dbc_password)
                
        source_db = "sit_pdm"
        dbaccess_instance = tdtestpy.DBSaccess (setup_con)

        # Check see if sit_pdm exist and exit if it is not.
        if not dbaccess_instance.is_database_exist (source_db):
            logging.error("SIT_PDM does not exists, please run SIT_SEA setup first before running setup for this test")
            tdtestpy.copy_file (setup_log_name, failedtask)
            exit(1)
        
        # Check see if DBC has enough space to run setup based on number of users provided.
        sit_pdm_current_perm = dbaccess_instance.get_db_current_perm (source_db)
        # Number of user plus one for stage database.
        total_perm_required = (sit_pdm_current_perm * 3) * (num_users + 1)
        dbc_free_perm = dbaccess_instance.get_db_free_perm ("dbc")
        if dbc_free_perm < total_perm_required:
            logging.error ("DBC does not have enough space to run setup for %s users" % (num_users))
            logging.info ("DBC Free perm is: %s" % (dbc_free_perm))