Professional Documents
Culture Documents
'**********************************************************************************
**************************
'Project Name : <Generic Framework>
'Author : Khadeer
'Creation Date : 2-Apr-2015
'Module Name : Controller
'Description : Regression tool is used to compare two files/tables
also for executing testcases
'**********************************************************************************
**************************
'Option Explicit
'==================================================================================
==========================
'Declaration of Variables
'==================================================================================
==========================
Dim vProjectFdr_Path, vControllerFdr, vDatasheetFdr, vResultFdr,
vComparisonFilesFdr
Dim vTD_FileName, vTD_Mainsheet,vTD_DbCredentials
Dim vSmplResSumry_Path, vResSummary_SheetName
Dim vTDResult_FileName, vResSummary_FileName
Dim vColValdt_Path, vColValdt_SheetName
Dim vFixedWidth_Path, vFixedWidth_SheetName
Dim Obj_FSO, Obj_Dict_Conf, Obj_Dict_RegTC, Obj_Wsh
Dim ObjXL_Main, ObjWB_Main, ObjWS_Main
Dim vTotalColumn_Used, vTotalRow_Used, vRowTitleNo
Dim vTempTextValue
Dim vArrFilters(), vArrDifferences()
Dim vRowNoConf
Dim vAlphaExcl_TotCol_Used
Dim vModuleName_ColNo, vScenarioName_ColNo, vSetFlag_ColNo, vTDStatus_ColNo
'==================================================================================
==========================
'Initialisation of variable whose values will be constant
vProjectFdr_Path = "C:\temp\KRegression_Tool\"
'vProjectFdr_Path =
CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
'vProjectFdr_Path = Replace(Replace(vProjectFdr_Path, "Library",""),
"Controller","")
vControllerFdr = vProjectFdr_Path & "Controller\"
vDatasheetFdr = vProjectFdr_Path & "DataSheets\"
vResultFdr = vProjectFdr_Path & "Result\"
vComparisonFilesFdr = vProjectFdr_Path & "Comparison_Files\"
vLibraryFdr = vProjectFdr_Path & "Library\"
vLogFilesFdr = vProjectFdr_Path & "LogFiles\"
vTD_FileName = "RegressionTool_TD.xlsx"
vTD_Filepath = vDatasheetFdr & vTD_FileName
vTD_Mainsheet = "Configuration"
vTD_DbCrdnSheet = "DB_ConnectionDetails"
vTD_UnixCrdnSheet = "Unix_ConnectionDetails"
vTD_QCCrdnSheet = "QC_ConnectionDetails"
vSmplResSumry_Path = vControllerFdr & "Sample_Result_Summary.xlsx"
vResSummary_SheetName = "Result_Summary"
vResSummary_FileName = "ResultSummary" & Day(Date) & Month(Date) &
Hour(Time) & Minute(Time)
vExecutionLog_FileName = "ExecutionLog" & Day(Date) & Month(Date) & Hour(Time)
& Minute(Time) & ".txt"
vColValdt_Path = vDatasheetFdr & "Column_Validation.xlsx"
vFixedWidth_Path = vDatasheetFdr & "FixedWidth_Schema.xlsx"
vMasterData_Path = vDatasheetFdr & "Master_Data.xlsx"
vDiffSheetName = "Diff_Actual_Baseline"
varf_FilterFile_path = vResultFdr & "Filter.txt"
vNoOfRec_PerDynFilter = 500
vRowNoConf = 2
vRowNoTC = 1
Call KillProcessor("excel.exe")
'==================================================================================
==========================
'Defining the class objects FSO, Wscript, Excel, Dictionary
'==================================================================================
==========================
'Create and define the log file and validate the folder structure
'==================================================================================
==========================
'Fetch the column Number from configuration sheet for few attributes
vTotCol_Main = Cint(ObjWS_Main.UsedRange.Columns.Count)
vTotRow_Main = Cint(ObjWS_Main.UsedRange.Rows.Count)
'==================================================================================
==========================
'Fetch the scenario for execution whose trigger mentioned in setflag "Y" from
configuration sheet
'==================================================================================
==========================
'Create Result File with name as specific to scenario name, data and time stamp
'==================================================================================
==========================
'Create Result Folder if not exist and copy the TD to result folder and set the
result TD object
If Obj_Dict_Conf("Result_Location") = "" Or
Obj_Dict_Conf("Result_Location") = Empty Then
If Not Obj_FSO.FolderExists(vResultFdr) Then
Obj_FSO.CreateFolder(vResultFdr)
Obj_FSO.CopyFile (vTD_Filepath), (vResultFdr &
vTDResult_FileName), True
Set ObjWB_Result = ObjXL_Main.Workbooks.Open(vResultFdr &
vTDResult_FileName)
Obj_ExeLog.WriteLine "# Result Report " & vTDResult_FileName
& " is created into folder " & vResultFdr
varf_WBResultReport_Location = vResultFdr &
vTDResult_FileName
Else
If Obj_FSO.FolderExists(Obj_Dict_Conf("Result_Location")) =
True Then
Obj_FSO.CopyFile (vTD_Filepath),
Obj_Dict_Conf("Result_Location") & vTDResult_FileName , True
Set ObjWB_Result =
ObjXL_Main.Workbooks.Open(Obj_Dict_Conf("Result_Location") & vTDResult_FileName)
Obj_ExeLog.WriteLine "# Result Report " &
vTDResult_FileName & " is created into folder " & Obj_Dict_Conf("Result_Location")
varf_WBResultReport_Location =
Obj_Dict_Conf("Result_Location") & vTDResult_FileName
Else
If Not Obj_FSO.FolderExists(vResultFdr) Then
Obj_FSO.CreateFolder(vResultFdr)
Obj_FSO.CopyFile (vTD_Filepath), (vResultFdr &
vTDResult_FileName), True
Set ObjWB_Result =
ObjXL_Main.Workbooks.Open(vResultFdr & vTDResult_FileName)
Obj_ExeLog.WriteLine "# Provided Result location not
exist and so copying the TD into result folder"
Obj_ExeLog.WriteLine "# Result Report " &
vTDResult_FileName & " is created into folder " & vResultFdr
varf_WBResultReport_Location = vResultFdr &
vTDResult_FileName
End If
End If
'==================================================================================
==========================
'Delete all the records under result TD configuration sheet except being executed
If StrComp(ObjWS_Result.cells(vRowNo_DelScenario,
vScenarioName_ColNo).Value, vScenarioName, 1) <> 0 Then
On Error Resume Next
Set TargetSheet =
ObjWB_Result.Worksheets(ObjWS_Result.Cells(vRowNo_DelScenario,vScenarioName_ColNo).
Value)
If Not TargetSheet Is Nothing Then
ObjWB_Result.Worksheets(ObjWS_Result.Cells(vRowNo_DelScenario,vScenarioName_ColNo).
Value).Delete
ObjWS_Result.Rows(vRowNo_DelScenario).EntireRow.Delete
Set TargetSheet = Nothing
On Error Goto 0
Else
vRowNo_DelScenario = vRowNo_DelScenario + 1
End If
Next
ObjWB_Result.Worksheets(vTD_Mainsheet).Activate
ObjWB_Result.Worksheets(vTD_Mainsheet).Cells(1,3).Select
Obj_ExeLog.WriteLine "# All scenarios define in result report
configuration sheet are deleted except "& vScenarioName &" scenario which is under
execution"
'==================================================================================
==========================
' Based on the comparison data availablity column value specific function will be
executed
'==================================================================================
==========================
' Regression Framework to execute the test cases
varf_AutoResultFileOpening = varf_AutoResultFileOpening & "
REG"
Obj_ExeLog.WriteLine "# Test Case Regression Framework is
triggered"
If Func_Worksheet_Exist(vScenarioName, ObjWB_Result) =1 Then
Obj_ExeLog.WriteLine "# " & vScenarioName & " scenario
sheet found in Test data"
Set ObjWS_ResultScen =
ObjWB_Result.Worksheets(vScenarioName)
vTotRow_Scenario =
CInt(ObjWS_ResultScen.UsedRange.Rows.count)
vTotCol_Scenario =
CInt(ObjWS_ResultScen.UsedRange.Columns.count)
'==================================================================================
==================================
' Delete all Test cases sheet which are not mentioned as "Y" in scenario sheet
ObjWB_Result.Worksheets(ObjWS_ResultScen.Cells(vRowCnt_Scen,vTC_Name_ColNo).Value).
Delete
End If
On Error Goto 0
Next
Obj_ExeLog.WriteLine "# Deleted successfully all the TC
sheet which are not mentioned as Y in scenario sheet"
'==================================================================================
==================================
' Execute the TestCase on the basis of row number
"vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rem
arks_ColNo,vTC_FuncRowNo_Value,vStatus)"
Call
Func_UpdateStatus(ObjWS_ResultTC, vRowCnt_TC, vFuncTC_Status_ColNo, vStatus)
'Update the status in TC Sheet
If vStatus = "FAIL" Then
vStatus_Once = "FAIL"
Obj_Dict_RegTC.RemoveAll
Obj_ExeLog.WriteLine "# " &
vRowCnt_TC-1 & " record executed successfully and its status is " & vStatus
Next
Obj_ExeLog.WriteLine "# All the
rows available in TC sheet " & vTC_Name & " are executed successfully"
Obj_ExeLog.WriteBlankLines 1
"vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rem
arks_ColNo,vTC_FuncRowNo_Value,vStatus)"
Call
Func_UpdateStatus(ObjWS_ResultTC, vTC_FuncRowNo_Value, vFuncTC_Status_ColNo,
vStatus)
If vStatus = "FAIL" Then
vStatus_Once = "FAIL"
Obj_Dict_RegTC.RemoveAll
Obj_ExeLog.WriteLine "# " &
vTC_FuncRowNo_Value & " record executed successfully and its status is " & vStatus
Next
Obj_ExeLog.WriteLine "# " &
vTC_FuncRowNo & " row available in TC sheet " & vTC_Name & " are executed
successfully"
"vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rem
arks_ColNo,vTC_FuncRowNo_Value,vStatus)"
Call
Func_UpdateStatus(ObjWS_ResultTC, vTC_FuncRowNo_Value, vFuncTC_Status_ColNo,
vStatus)
If vStatus = "FAIL" Then
vStatus_Once = "FAIL"
Obj_Dict_RegTC.RemoveAll
Obj_ExeLog.WriteLine "# " &
vTC_FuncRowNo_Value & " record executed successfully and its status is " & vStatus
Next
Obj_ExeLog.WriteLine "# " &
vTC_FuncRowNo & " row available in TC sheet " & vTC_Name & " are executed
successfully"
Else
vStatus = "FAIL"
' Row Number column for respective testcase should not be empty
Obj_ExeLog.WriteLine "# unexpected
or empty Function_RowNumber mentioned in scenario sheet"
End If
Else
vStatus = "FAIL"
vRemarkcTC =
"None" ' TC sheet not found in TestDate
File
Obj_ExeLog.WriteLine "# Under scenarion
sheet TC " & vTC_Name & " flag is up but TC sheet is not available in TD file"
Call Func_UpdateStatus(ObjWS_ResultScen,
vRowCnt_Scen, vTC_STATUS_ColNo, vStatus,vFuncTC_Remarks_ColNo, vRemarkcTC)
End If
Else
vStatus = "Not Executed"
vRemarkcTC = "None"
' TC sheet not found in TestDate File ' Update
status TC not mentioned "Y"
Obj_ExeLog.WriteLine "# Test case function No.
" & vRowCnt_Scen-1 & " flag is not set in TD file"
Obj_ExeLog.WriteBlankLines 1
Call Func_UpdateStatus(ObjWS_ResultScen,
vRowCnt_Scen, vTC_STATUS_ColNo, vStatus)
End If
Next
' Extract the final vstatus from complete test cases executed under the scenario
vStatus_Fail = Empty
vStatus_Pass = Empty
For vRowScenCnt_Status = 2 To vTotRow_Scenario
If UCase(ObjWS_ResultScen.Cells(vRowScenCnt_Status,
vTC_STATUS_ColNo).Value) = "FAIL" Then
vStatus_Fail = "Found"
ElseIf
UCase(ObjWS_ResultScen.Cells(vRowScenCnt_Status, vTC_STATUS_ColNo).Value) = "PASS"
Then
vStatus_Pass = "Found"
End If
Next
Else
vStatus = "FAIL" ' Scenario
Sheet not found in Test Data file
Obj_ExeLog.WriteLine "# Test Case regression scenario flag
is up in config sheet but scenario sheet " & vScenarioName & " is not available in
TD file"
Obj_ExeLog.WriteBlankLines 1
End If
Else
vStatus = "FAIL"
Obj_ExeLog.WriteLine "# Unexpected value found in column
cmp_data_avalibility"
Obj_ExeLog.WriteBlankLines 1
End If
' Delete the sheet which are not required in Result report
On Error Resume Next
If UCase(Obj_Dict_Conf("Testing_Type")) = "FILE CMP" Or
UCase(Obj_Dict_Conf("Testing_Type")) = "TABLE CMP" Then
For Each vSheet_to_Delete In ObjWB_Result.Sheets
If InStr(1, vSheet_to_Delete.Name, "Configuration") > 0
Or InStr(1, vSheet_to_Delete.Name, "===") > 0 Or _
((InStr(1, vSheet_to_Delete.Name,
"Diff_Actual_Baseline") > 0 And TRIM(UCASE(vStatus)) <> "PASS") And _
ObjWB_Result.Worksheets(vSheet_to_Delete.Name).Visible = True
Else
vSheet_to_Delete.Delete
End If
Next
Else
For Each vSheet_to_Delete In ObjWB_Result.Sheets
If InStr(1, vSheet_to_Delete.Name, vTD_DbCrdnSheet) > 0
Or InStr(1, vSheet_to_Delete.Name, vTD_UnixCrdnSheet) > 0 Or InStr(1,
vSheet_to_Delete.Name, vTD_QCCrdnSheet) > 0 Or _
InStr(1, vSheet_to_Delete.Name,
"Diff_Actual_Baseline") > 0 or InStr(1, vSheet_to_Delete.Name, "All_TC") > 0 Then
vSheet_to_Delete.Delete
Else
ObjWB_Result.Worksheets(vSheet_to_Delete.Name).Visible = True
End If
Next
ObjWB_Result.Worksheets("Configuration").Activate
End If
ObjWB_Result.Worksheets("===").Visible = False
On Error Goto 0
ObjWS_Result.Cells(1,vTDStatus_ColNo).EntireColumn.Hidden = False
ObjWB_Result.Save
ObjWB_Result.Close
Obj_Dict_Conf.RemoveAll
Else
' As per the framework all the scenarios which are mentioned as N or
empty will be deleted
' vStatus = "Not Executed" ' Update Status
scenario record not mentioned "Y" in scenraio sheet
Obj_ExeLog.WriteLine "# Scenario No. " & vRowCnt_Conf-2 & " Flag is
not set and it is not executed "
Obj_ExeLog.WriteBlankLines 1
End If
vStatus = ""
Next
ObjWB_Main.Close
ObjXL_Main.Quit
Obj_ExeLog.Close
Call KillProcessor("cmd.exe")
Call KillProcessor("Excel.exe")
'**********************************************************************************
**************************
' File Comparison Functions
'**********************************************************************************
**************************
' Extract the values from main dictionary object into variables
varf_ModuleName =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("ModuleName"))," ,
",",")," ,",","),", ",",")," ","_")
varf_ScenarioName =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("ScenarioName"))," ,
",",")," ,",","),", ",",")," ","_")
varf_SetFlag = Trim(Ucase(Obj_Dict_Conf("SetFlag")))
varf_Testing_Type = Trim(Ucase(Obj_Dict_Conf("Testing_Type")))
varf_Comparison_Format =
Trim(Ucase(Obj_Dict_Conf("Comparison_Format")))
varf_Actual_FileLocation_DBName = Trim(Obj_Dict_Conf("Actual_FileLocation /
Actual_DB"))
varf_Base_FileLocation_DBName = Trim(Obj_Dict_Conf("Baseline_FileLocation /
Baseline_DB"))
varf_ActEnviConf = Trim(Obj_Dict_Conf("Actual Environment") )
varf_ActFileName = Trim(Obj_Dict_Conf("Actual File/Query/Table
Name"))
varf_BaseEnviConf = Trim(Obj_Dict_Conf("Baseline Environment"))
varf_BaseFileName = Trim(Obj_Dict_Conf("Baseline
File/Query/Table Name"))
varf_Filter_Type = Trim(Ucase(Obj_Dict_Conf("Filter_Type")))
varf_Static_Filter = Trim(Obj_Dict_Conf("Static_Filter"))
varf_Dynamic_Filter_set1 =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Dynamic_Filter_set1"))," ,
",",")," ,",","),", ",",")," ","_")
varf_Dynamic_Filter_set2 =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Dynamic_Filter_set2"))," ,
",",")," ,",","),", ",",")," "," ")
varf_Derived_Filter = Trim(Obj_Dict_Conf("Derived_Filter"))
varf_Logical_columns =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Logical_columns"))," , ",","),"
,",","),", ",",")," ","_")
varf_Ignore_columns =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Ignore_columns"))," ,
",",")," ,",","),", ",",")," ","_")
varf_Sorting_columns =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Sorting_columns"))," , ",","),"
,",","),", ",",")," ","_")
varf_PC_trigger_Flag =
Trim(Ucase(Obj_Dict_Conf("PC_trigger_Flag")))
varf_Parent_table_Name = Trim(Obj_Dict_Conf("Parent_table_Name"))
varf_Parenttable_columns =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Parenttable_columns"))," ,
",",")," ,",","),", ",",")," ","_")
varf_Childtable_columns =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Childtable_columns"))," ,
",",")," ,",","),", ",",")," ","_")
varf_ReqColumns_Parent =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("ReqColumns_Parent"))," ,
",",")," ,",","),", ",",")," ","_")
varf_Max_No_Differences = Trim(Obj_Dict_Conf("Max_NoOfDifferences"))
varf_Column_Tolerance = Trim(Obj_Dict_Conf("Column_Tolerance"))
varf_Record_Grouping = Trim(Obj_Dict_Conf("Record_Grouping"))
varf_FixedWidth_Schema = Trim(Obj_Dict_Conf("FixedWidth_Schema"))
varf_Column_validation = Trim(Obj_Dict_Conf("Column_validation"))
varf_Result_Format = Trim(Ucase(Obj_Dict_Conf("Result_Format")))
varf_Extra_Fields =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Extra_Fields"))," ,
",",")," ,",","),", ",",")," ","_")
varf_Result_Location = Trim(Obj_Dict_Conf("Result_Location"))
vSybIQ_JProcLocation = vProjectFdr_Path &
"pTools\DbToFileDataExtract.jar"
varf_CompoLogicalKeys_alias = "vConcLogicalKey"
varf_dummydttype = "DummyDTValue"
varf_CmpTimer_Start = Timer
'==================================================================================
================================
' Extract the Db details from DB_Credentail sheet
If vComparisonType = "TABLE" Then
' Check the db credential sheet exist
' Find the type of environment file to be created - Actual or Baseline
If Instr(1, Ucase(varf_Comparison_Format)," VS ") <= 0 Then
vDBFile_Remarks = " Improper comparison format , no Vs key
available"
vStatus = "FAIL"
Exit Function
End If
If Func_Worksheet_Exist(vTD_DbCrdnSheet, ObjWB_Result) = 1 Then
varf_Actual_Trigger =
Split(Ucase(varf_Comparison_Format),"VS")(0)
varf_Baseline_Trigger =
Split(Ucase(varf_Comparison_Format),"VS")(1)
If Instr(1,varf_Actual_Trigger,"FILE") <= 0 Then
' Establish the Actual DB connection
Call f_GetDBConnectionString(ObjWB_Result,
vTD_DbCrdnSheet, varf_Actual_FileLocation_DBName, varf_ActEnviConf,
varf_ConnString, _
varf_ConnString_Status, varf_ConnString_Remarks )
If Instr(1,varf_ConnString,"SYBASEIQ") <= 0 Then
If varf_ConnString_Status = "PASS" Then
Obj_AdodbConnActual.Open
varf_ConnString
Obj_AdodbConnActual.CommandTimeOut =
3000
Else
' <Issue with connection details of
actual >
' <varf_ConnString_Remarks -
mention the comments in result and log file>
' Execute "End Function"
End if
End If
' Create actual database table into Pipeline delimited
file
If Obj_AdodbConnActual.State = 1 or
Instr(1,varf_ConnString,"SYBASEIQ") > 0 then
vDBFileName = Mid(varf_ScenarioName,1,10) &
"_Actual_" & vStaticTimestamp_DDMMHHMM & ".DAT"
' vComparisonFilesFdr_tmp =
vComparisonFilesFdr
' vComparisonFilesFdr =
"P:\VMDR_Archival_HIVE\"
Call f_CreateDB_to_PipeLineFile
(Obj_AdodbConnActual, Obj_RSGeneric, varf_Actual_Trigger,
varf_Actual_FileLocation_DBName, varf_ActFileName, varf_ConnString,_
varf_ConnString_Status, varf_ConnString_Remarks )
If Instr(1,varf_ConnString,"SYBASEIQ") <= 0 Then
If varf_ConnString_Status = "PASS" Then
Obj_AdodbConnBaseline.Open
varf_ConnString
Obj_AdodbConnBaseline.CommandTimeOut =
3000
Else
' <Issue with connection details of
actual >
' <varf_ConnString_Remarks -
mention the comments in result and log file>
' Execute "End Function"
End if
End If
' Create Baseline database table into Pipeline
delimited file
If Obj_AdodbConnBaseline.State = 1 or
Instr(1,varf_ConnString,"SYBASEIQ") > 0 then
vDBFileName = Mid(varf_ScenarioName,1,10) &
"_Baseline_" & vStaticTimestamp_DDMMHHMM & ".DAT"
' vComparisonFilesFdr_tmp =
vComparisonFilesFdr
' vComparisonFilesFdr =
"P:\VMDR_Archival_HIVE\"
Call f_CreateDB_to_PipeLineFile
(Obj_AdodbConnBaseline,Obj_RSGeneric, varf_Baseline_Trigger,
varf_Base_FileLocation_DBName, varf_BaseFileName, varf_ConnString,_
'==================================================================================
===============================
' Change the format of the file if the extension is (.file) in the defined
configuration sheet
' Frame the temp File Names which are under in test
varf_ActFileFormat_Split = Split(varf_ActFileName, ".")
varf_BaseFileFormat_Split = Split(varf_BaseFileName, ".")
'==================================================================================
================================
' Clear the temp folder
Obj_FSO.DeleteFile varf_TempDB_FdrPath & "*", True
'==================================================================================
================================
'Copy the file into temp location -------------- check this required
Obj_FSO.copyFile varf_Actual_FileLocation_DBName & varf_ActFileName,
varf_TempDB_FdrPath & varf_ActFileName_Cpy2Local, True
Obj_FSO.copyFile varf_Base_FileLocation_DBName &
varf_BaseFileName,varf_TempDB_FdrPath & varf_BaseFileName_Cpy2Local, True
'==================================================================================
================================
' Update registry and create test connection string
' varf_Regedit_JetEngine_path =
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\"
varf_Regedit_JetEngine_path =
"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Jet\4.0\Engines\"
Case "PIPE"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path & "Text\Format",
"DELIMITED(|)","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\Extensions", "txt,csv,tab,asc,dat,ppe","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\DisabledExtensions", "!txt,csv,tab,asc,tmp,htm,html,dat,ppe","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\MaxScanRows", 10, "REG_DWORD"
Obj_AdodbConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & varf_TempDB_FdrPath & "; Extended Properties =""text;HDR =
YES;FMT=Delimited"""
varf_fileDelimiter = Chr(124)
Case "CAP"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path & "Text\Format",
"DELIMITED(^)","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\Extensions", "txt,csv,tab,asc,dat,ppe","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\DisabledExtensions", "!txt,csv,tab,asc,tmp,htm,html,dat,ppe","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\MaxScanRows", 10, "REG_DWORD"
Obj_AdodbConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & varf_TempDB_FdrPath & "; Extended Properties =""text;HDR =
YES;FMT=Delimited"""
varf_fileDelimiter = Chr(94)
Case "CSV"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path & "Text\Format",
"CSVDelimited","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\Extensions", "txt,csv,tab,asc,dat,ppe","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\DisabledExtensions", "!txt,csv,tab,asc,tmp,htm,html,dat,ppe","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\MaxScanRows", 10, "REG_DWORD"
Obj_AdodbConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & varf_TempDB_FdrPath & "; Extended Properties =""text;HDR =
YES;FMT=Delimited"""
varf_fileDelimiter = Chr(44)
Case "FIXEDWIDTH"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path & "Text\Format",
"FixedLength","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\Extensions", "txt,csv,tab,asc,dat,ppe","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\DisabledExtensions", "!txt,csv,tab,asc,tmp,htm,html,dat,ppe","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\MaxScanRows", 10, "REG_DWORD"
Obj_AdodbConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=" & varf_TempDB_FdrPath & "; Extended Properties =""text;HDR =
No;FMT=FixedLength"""
If varf_FixedWidth_Schema <> "" Or varf_FixedWidth_Schema <>
Empty Then
Call vFixedWidth_to_PIPE (varf_FixedWidth_Schema,
Obj_AdodbConnection, varf_ActFileName_Cpy2Local, varf_BaseFileName_Cpy2Local,_
Obj_RSActual,Obj_RSBaseline,varf_TempDB_FdrPath,ObjXL_Main,Obj_FSO,Obj_ExeLog,ObjWB
_Result,vFixedWidth2PIPE_Status)
If vFixedWidth2PIPE_Status = "Pass - PipeLine Created"
Then
If Obj_AdodbConnection.State = 1 Then
Obj_AdodbConnection.Close
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Text\Format", "DELIMITED(|)","REG_SZ"
Obj_AdodbConnection.Open
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & varf_TempDB_FdrPath & _
"; Extended
Properties =""text;HDR = YES;FMT=Delimited"""
varf_fileDelimiter = Chr(124)
Else
' <Exit Function>
' Unable to covert the fixed width file into PIPE line
delimited
End If
Else
' <Exit Function>
' < Format of the file is Fixed Width but schema file is
not available >
End If
Case "EXCEL"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Excel\DisabledExtensions", "!xls","REG_SZ"
Obj_Wsh.RegWrite varf_Regedit_JetEngine_path &
"Excel\TypeGuessRows", 1000000, "REG_DWORD"
Obj_AdodbConnection.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data
Source=" & varf_TempDB_FdrPath & vSourceFileName & _
"; Extended Properties=""Excel 12.0;HDR=YES;
IMEX=2;"""
Obj_AdodbConnection_XL.Open
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & varf_TempDB_FdrPath & "123" &
vSourceFileName & _
"; Extended Properties=""Excel 12.0;HDR=YES;
IMEX=2;"""
vSourceFileName = "[Sheet123$]"
Case Else
' <Terminate the execution if no proper format define in config
sheet>
' Exit Function
End Select
'==================================================================================
================================
' Validate the baseline and actual columns and report the missing columns
against the file
' Create new files with dummy records and relevant columns also adding line
number to the file
' Validate the column mapping sheet
Call vColumnValidation_MissDiffExpected
( varf_ActColName_DumLineDT,varf_BaseColName_DumLineDT,varf_Column_validation,ObjXL
_Main,Obj_FSO,Obj_ExeLog,ObjWB_Result,_
varf_diff,
varf_DiffCnt,varf_ActDumyRec_insert,varf_BaseDumyRec_insert, vBaseAttribute_Names,
vColumnVerf_Status)
' varf_ActDumyRec_insert
' varf_BaseDumyRec_insert
' vBaseAttribute_Names
'
Else
vColumnVerf_Status = "Not Found"
End If
varf_ActDumyRec_insert = Mid(varf_ActDumyRec_insert, 2)
varf_BaseDumyRec_insert = Mid(varf_BaseDumyRec_insert, 2)
vBaseAttribute_Names = Mid(vBaseAttribute_Names, 2)
vBaseAttribute_Names = vBaseAttribute_Names & varf_fileDelimiter &
"LineNo"
End If
' Ignore Columns - Remove the columns from Baseline attribute name variable
If varf_Ignore_columns <> "" Or varf_Ignore_columns <> Empty Then
varf_Ignore_columns_split = Split(varf_Ignore_columns,Chr(44))
For vIgnoreColCnt = 0 To Ubound(varf_Ignore_columns_split)
If Instr(1,
vBaseAttribute_Names,varf_Ignore_columns_split(vIgnoreColCnt)) > 0 Then
vBaseAttribute_Names_IGSplit =
Split(vBaseAttribute_Names,varf_fileDelimiter)
vBaseAttribute_Names_IGtemp = Empty
For vBaseAttriCnt = 0 To
Ubound(vBaseAttribute_Names_IGSplit)
If
Trim(varf_Ignore_columns_split(vIgnoreColCnt)) =
Trim(vBaseAttribute_Names_IGSplit(vBaseAttriCnt)) Then
' <The following column will be ignored
while comparison>
Else
vBaseAttribute_Names_IGtemp =
vBaseAttribute_Names_IGtemp & varf_fileDelimiter &
vBaseAttribute_Names_IGSplit(vBaseAttriCnt)
End If
Next
vBaseAttribute_Names =
Mid(vBaseAttribute_Names_IGtemp,Len(varf_fileDelimiter)+1)
End If
Next
vBaseAttribute_Names_IGSplit = Empty
varf_Ignore_columns_split = Empty
vBaseAttribute_Names_IGtemp = Empty
End If
'==================================================================================
================================
' Validate the logical, sorting, filter columns defined in TD configuration
sheet exist in both the tables/files under test
' <if any logical key not exist then exit the function>
' Check the ignored columns should not be part of logical, sorting, dynamic keys
' <Also check parent table/file parent table columns, child table columns and
required columns are exist>
'==================================================================================
================================
' Create the Actual file with dummy records & Line number
Set ObjWrt_ActDumLineDT = Obj_FSO.OpenTextFile( varf_TempDB_FdrPath &
varf_ActFileName_DumLineDT, 2, True)
ObjWrt_ActDumLineDT.WriteLine "LineNo" & varf_fileDelimiter &
varf_ActColName_DumLineDT
varf_ActLineNo = 0
For varf_ActDumInsrtCnt = 1 To 15
ObjWrt_ActDumLineDT.WriteLine ";;" & varf_ActLineNo &
varf_fileDelimiter & Replace(varf_ActDumyRec_insert, varf_dummydttype,
varf_dummydttype & varf_ActDumInsrtCnt)
Next
ObjRead_ActCpy2Local.Close
ObjWrt_ActDumLineDT.Close
'Create the Actual file with dummy records & Line number
Set ObjWrt_BaseDumLineDT = Obj_FSO.OpenTextFile( varf_TempDB_FdrPath &
varf_BaseFileName_DumLineDT, 2, True)
ObjWrt_BaseDumLineDT.WriteLine "LineNo" & varf_fileDelimiter &
varf_BaseColName_DumLineDT
varf_baseLineNo = 0
For varf_BaseDumInsrtCnt = 1 To 15
ObjWrt_BaseDumLineDT.WriteLine ";;" & varf_baseLineNo &
varf_fileDelimiter & Replace(varf_BaseDumyRec_insert, varf_dummydttype,
varf_dummydttype & varf_BaseDumInsrtCnt)
Next
ObjRead_BaseCpy2Local.Close
ObjWrt_BaseDumLineDT.Close
'==================================================================================
================================
' Based on Parent join create normal or parent join query builder
varf_ReqColumns_Parent_Split =
Split(varf_ReqColumns_Parent,",")
For vJT_ReqColCnt = 0 to
Ubound(varf_ReqColumns_Parent_Split)
varf_CompoConcat_LogicalKeys =
varf_CompoConcat_LogicalKeys & " & ';' & " &
varf_ReqColumns_Parent_Split(vJT_ReqColCnt)
Next
If varf_CompoConcat_LogicalKeys <> "" Then
varf_CompoConcat_LogicalKeys = Mid(varf_CompoConcat_LogicalKeys,len(" & ';' & ")+1)
varf_FinalAttriNames_query =
varf_CompoConcat_LogicalKeys & " As " & varf_CompoLogicalKeys_alias & Chr(44) &
varf_CmpAttriNames_query
varf_FinalAttriNames = varf_CompoLogicalKeys_alias &
varf_fileDelimiter & varf_CmpAttriNames
varf_Parenttable_columns_Split =
Split(varf_Parenttable_columns,",")
varf_Childtable_columns_Split =
Split(varf_Childtable_columns,",")
For vPrntbl_ColCnt = 0 To
Ubound(varf_Parenttable_columns_Split)
vJoinCol_ParentChild = "parent." &
varf_Parenttable_columns_Split(vPrntbl_ColCnt) & "=child." &
varf_Childtable_columns_Split(vPrntbl_ColCnt)
Next
Else
' <Logical Key is empty only required columns as to be
used>
End If
Else
' <Join trigger is selected but >
End If
Else
varf_FinalAttriNames = vBaseAttribute_Names
varf_FinalAttriNames_query =
Replace(vBaseAttribute_Names,varf_fileDelimiter,Chr(44))
varf_ActNVL_JoinNormal_Query = "Select " & varf_FinalAttriNames_query
& " from " & varf_ActFileName_DumLineDT
varf_BaseNVL_JoinNormal_Query = "Select " & varf_FinalAttriNames_query
& " from " & varf_BaseFileName_DumLineDT
' <Logic has to be implemented for no logical keys, how to handle inner
join, record missing queries and execution>
End If
'==================================================================================
================================================
' Define sort keys for main join query other than logical keys
varf_CmpSortingColumns = Empty
If varf_Logical_columns <> "" or varf_Logical_columns <> Empty Then
If varf_Sorting_columns <> "" or varf_Sorting_columns <> Empty Then
varf_SortCol_Split = Split(varf_Sorting_columns,Chr(44))
For varf_SortCnt = 0 To ubound(varf_SortCol_Split)
If Instr(1, Ucase(varf_Logical_columns),
Ucase(varf_SortCol_Split(varf_SortCnt))) <= 0 Then
varf_CmpSortingColumns = varf_CmpSortingColumns
& Chr(44) & "vMisBaseline." & varf_SortCol_Split(varf_SortCnt)
End If
Next
varf_CmpSortingColumns = " Order By vMisBaseline." &
varf_CompoLogicalKeys_alias & varf_CmpSortingColumns
Else
varf_CmpSortingColumns = " Order By vMisBaseline." &
varf_CompoLogicalKeys_alias
End If
ElseIf varf_Sorting_columns <> "" or varf_Sorting_columns <> Empty Then
varf_SortCol_Split = Split(varf_Sorting_columns,Chr(44))
For varf_SortCnt = 0 To ubound(varf_SortCol_Split)
varf_CmpSortingColumns = varf_CmpSortingColumns & Chr(44) &
"vMisBaseline." & varf_SortCol_Split(varf_SortCnt)
Next
varf_CmpSortingColumns = " Order By " &
Mid(varf_CmpSortingColumns,2)
Else
varf_CmpSortingColumns = " Order By 1,2,3"
End If
'==================================================================================
================================
'3 Define dynamic filters - STATIC / DYNAMIC / COMBINED
varrFilters,vFilter_OutOfRange,vNoOfRec_PerDynFilter,varf_dummydttype)
If varf_DynamicFilterCnt = 0 Then
ReDim Preserve
varrFilters(varf_DynamicFilterCnt)
varrFilters(varf_DynamicFilterCnt) = ""
End If
Else
' <Warning:= Filter is Dynamic but no attribute is
defined in the field and so no filter is used>
ReDim Preserve varrFilters(0)
varrFilters(0) =""
varf_DataFilterValue = ""
End If
Case "COMBINED"
If varf_Dynamic_Filter_set1 <> "" Or
varf_Dynamic_Filter_set1 <> Empty Then
varf_DynamicFilterCnt =
f_GetDynamicFilters(Obj_Dict_Conf,Obj_AdodbConnection,varf_ActFileName_DumLineDT,
varf_BaseFileName_DumLineDT, _
varrFilters,vFilter_OutOfRange,vNoOfRec_PerDynFilter,varf_dummydttype)
End If
If varf_DynamicFilterCnt = 0 Then
ReDim Preserve varrFilters(varf_DynamicFilterCnt)
varrFilters(varf_DynamicFilterCnt) = ""
End If
For vCtr =0 To Ubound(varrFilters)
If Cbool(varf_Static_Filter & "!@#$" <> "!@#$" ) =
True Then
If Cbool(varrFilters(vCtr) & "!@#$" <> "!
@#$" ) = True Then
varrFilters(vCtr) =
varrFilters(vCtr) & " And " & varf_Static_Filter
Else
varrFilters(vCtr) =
varf_Static_Filter
End If
End If
Next
Case Else
ReDim Preserve varrFilters(0)
varrFilters(0) =""
varf_DataFilterValue = ""
End Select
Else
ReDim Preserve varrFilters(0)
varrFilters(0) =""
varf_DataFilterValue = ""
End If
'==================================================================================
================================================
' Create new file with filter data and composite logical key
' Also extract the total number of records baseline and actual
'==================================================================================
================================================
' Define a command for maximum no of differences
Varf_CmdCond_MaxNoDiff = ""
If varf_Max_No_Differences <> "" Then Varf_CmdCond_MaxNoDiff = "If
Cint(varf_DiffCnt) >= Cint(varf_Max_No_Differences) Then varf_MaxNoDiff_trigger =
True"
'==================================================================================
================================================
' Inner join to find the mismatch in field values
' Obj_RSActual.RecordCount
' Obj_RSActual.AbsolutePosition
varf_CmpAttriNames_Split =
Split(Replace(varf_CmpAttriNames,varf_fileDelimiter & "LineNo",
""),varf_fileDelimiter)
varf_DistinctFieldsMismatch = ""
varf_tempvalue = "!@$&"
varf_DistinctRecordsMismatch = 0
varf_MaxNoDiff_trigger = False
vExtraFields_Baseline_value = ""
vExtraFields_Actual_value = ""
vExtraFields_Baseline_query = ""
vExtraFields_Actual_query = ""
vExtraFields_Baseline_Execute = ""
vExtraFields_Actual_Execute = ""
"^$!" &
Replace(Replace(Replace(Replace(Replace(Replace(Replace(varf_FieldName,"_Y_","/"),"
_Z_","#"),"_W_","*"),"_V_","@"),"_U_","?"),"_P_","-"),"_Q_","+") & _
"^$!" & varf_ActualFieldValue & "^$!" & varf_BaselineFieldValue & "^$!" & "" &
"^$!" & vExtraFields_Baseline_value
varf_DiffCnt = varf_DiffCnt + 1
If Instr(1,
varf_DistinctFieldsMismatch, varf_FieldName)<=0 Then varf_DistinctFieldsMismatch =
varf_DistinctFieldsMismatch & varf_FieldName & "|"
' End If
End If
Next
varf_DistinctRecordsMismatch =
varf_DistinctRecordsMismatch + 1
vExtraFields_Baseline_value = empty
Obj_RSActual.MoveNext
Obj_RSBaseline.MoveNext
End If
Execute Varf_CmdCond_MaxNoDiff
Loop
If varf_DistinctFieldsMismatch <> "" Then varf_DistinctFieldsMismatch
= Mid (varf_DistinctFieldsMismatch, 1, len(varf_DistinctFieldsMismatch)-1)
If Obj_RSActual.State = 1 Then Obj_RSActual.Close
If Obj_RSBaseline.State = 1 Then Obj_RSBaseline.Close
'==================================================================================
================================================
' Record missing in ACTUAL
varf_RecordMissingQuery_Actual = "Select vMisBaseline.* from " &
varf_BaseFileName_FtrFinal & " vMisBaseline Left Outer Join " & _
varf_ActFileName_FtrFinal & "
vMisActual " & varf_PrimaryJoin_ActRecMissing
Obj_RSActual.Open varf_RecordMissingQuery_Actual,
Obj_AdodbConnection,1,3
If Obj_RSActual.EOF <> True Then
varf_MissRecord_Actual = Obj_RSActual.RecordCount
Do Until Obj_RSActual.EOF Or varf_MaxNoDiff_trigger
varf_PrimaryKeyValue =
Obj_RSActual.Fields(varf_CompoLogicalKeys_alias).Value
Execute vExtraFields_Actual_Execute
ReDim Preserve varf_diff(varf_DiffCnt)
varf_diff(varf_DiffCnt) = varf_PrimaryKeyValue & "^$!" &
" - " & "^$!" & Replace(Obj_RSActual.Fields("LineNo").Value,";;","") & _
"^$!" & "Record Missing" & "^$!" & "Not Found" & "^$!" & "Found" & "^$!" &
varf_FilterintoQuery & "^$!" & vExtraFields_Baseline_value
varf_DiffCnt = varf_DiffCnt + 1
Obj_RSActual.MoveNext
vExtraFields_Actual_value = Empty
Execute Varf_CmdCond_MaxNoDiff
Loop
Else
varf_MissRecord_Actual = 0
End If
If Obj_RSActual.State = 1 Then Obj_RSActual.Close
'==================================================================================
================================================
'9 Record missing in BASELINE
varf_RecordMissingQuery_Baseline = "Select vMisActual.* from " &
varf_BaseFileName_FtrFinal & " vMisBaseline Right Outer Join " & _
varf_ActFileName_FtrFinal &
" vMisActual " & varf_PrimaryJoin_BaseRecMissing
Obj_RSBaseline.Open varf_RecordMissingQuery_Baseline,
Obj_AdodbConnection,1,3
If Obj_RSBaseline.EOF <> True Then
varf_MissRecord_Baseline = Obj_RSBaseline.RecordCount
Do Until Obj_RSBaseline.EOF Or varf_MaxNoDiff_trigger
varf_PrimaryKeyValue =
Obj_RSBaseline.Fields(varf_CompoLogicalKeys_alias).Value
Execute vExtraFields_Baseline_Execute
ReDim Preserve varf_diff(varf_DiffCnt)
varf_diff(varf_DiffCnt) = varf_PrimaryKeyValue & "^$!" &
Replace(Obj_RSBaseline.Fields("LineNo").Value,";;","") & "^$!" & " - " & _
"^$!" & "Record Missing" & "^$!" & "Found" & "^$!" & "Not Found" & "^$!" &
varf_FilterintoQuery & "^$!" & vExtraFields_Baseline_value
varf_DiffCnt = varf_DiffCnt + 1
Obj_RSBaseline.MoveNext
Execute Varf_CmdCond_MaxNoDiff
Loop
Else
varf_MissRecord_Baseline = 0
End If
If Obj_RSBaseline.State = 1 Then Obj_RSBaseline.Close
'==================================================================================
================================================
' Report the difference report into temp
Call
f_DifferenceReporting_Excel(varf_Extra_Fields, varf_Logical_columns, varf_diff,
varf_ScenarioName,vDiffSheetName, Obj_ExeLog, ObjWB_Result,
vDiffReportExcel_Status)
varf_ResultFileName_SummaryReport = vResultFdr &
vTDResult_FileName
Case "CSV","EMAIL, CSV"
Call f_DifferenceReporting_CSV(varf_Extra_Fields,
varf_Logical_columns, varf_diff, vDiffSheetName, Obj_FSO, Obj_ExeLog, ObjWB_Result,
_
Case Else
Call
f_DifferenceReporting_Excel(varf_Extra_Fields, varf_Logical_columns, varf_diff,
varf_ScenarioName,vDiffSheetName, Obj_ExeLog, ObjWB_Result,
vDiffReportExcel_Status)
End Select
vStatus = "FAIL"
End If
If vStatus = "" Then vStatus = "PASS"
varf_Final_Actual_TotalNumberRec =
varf_Final_Actual_TotalNumberRec + varf_Actual_TotalNumberRec
varf_Final_Baseline_TotalNumberRec =
varf_Final_Baseline_TotalNumberRec + varf_Baseline_TotalNumberRec
varf_Final_MissRecord_Actual = varf_Final_MissRecord_Actual +
varf_MissRecord_Actual
varf_Final_MissRecord_Baseline = varf_Final_MissRecord_Baseline
+ varf_MissRecord_Baseline
varf_Final_DistinctRecordsMismatch =
varf_Final_DistinctRecordsMismatch + varf_DistinctRecordsMismatch
If varf_DistinctFieldsMismatch <> "" Then
varf_DistinctFieldsMismatch_split =
Split(varf_DistinctFieldsMismatch,"|")
For VDisntFldCnt = 0 To
Ubound(varf_DistinctFieldsMismatch_split)
If Instr(1, varf_Final_DistinctFieldsMismatch,
Trim(varf_DistinctFieldsMismatch_split(VDisntFldCnt)))<=0 Then
varf_Final_DistinctFieldsMismatch =
varf_Final_DistinctFieldsMismatch & "|" & _
ObjRead_FilterFile.Close
If vStatus <> "FAIL" Then vStatus = "PASS"
If Obj_FSO.FileExists(varf_FilterFile_path) Then Obj_FSO.DeleteFile
varf_FilterFile_path
'==================================================================================
================================================
' Final difference report adding temp results
vRowNo_ResSum = 1
If Not Obj_FSO.FileExists(vResultFdr & vResSummary_FileName & ".xlsx") Then
Obj_FSO.CopyFile vSmplResSumry_Path, vResultFdr & vResSummary_FileName & ".xlsx",
True
Set ObjWB_ResultSummary = ObjXL_Main.WorkBooks.Open(vResultFdr &
vResSummary_FileName & ".xlsx")
Set ObjWS_ResultSummary =
ObjWB_ResultSummary.WorkSheets(vResSummary_SheetName)
vTotRow_ResultSummary = Cint(ObjWS_ResultSummary.UsedRange.Rows.Count)
vTotCol_ResultSummary = Cint(ObjWS_ResultSummary.UsedRange.Columns.Count)
vResSummary_ScenarioName_ColNo = ObjWS_ResultSummary.Range("A" &
vRowNo_ResSum & ":" & Chr(vTotCol_ResultSummary +64 ) & _
vRowNo_ResSum).Find("ScenarioName").Column
vResSummary_BaselineName_ColNo = ObjWS_ResultSummary.Range("A" &
vRowNo_ResSum & ":" & Chr(vTotCol_ResultSummary +64 ) & _
vRowNo_ResSum).Find("Baseline_FileName / Baseline_TableName").Column
vResSummary_Status_ColNo = ObjWS_ResultSummary.Range("A" & vRowNo_ResSum &
":" & Chr(vTotCol_ResultSummary +64 ) & _
vRowNo_ResSum).Find("Status").Column
vResSummary_TotNoRecords_ColNo = ObjWS_ResultSummary.Range("A" &
vRowNo_ResSum & ":" & Chr(vTotCol_ResultSummary +64 ) & _
vRowNo_ResSum).Find("Comparison_Time").Column
vResSummary_DetailedDiffLoc_ColNo = ObjWS_ResultSummary.Range("A" &
vRowNo_ResSum & ":" & Chr(vTotCol_ResultSummary +64 ) & _
vRowNo_ResSum).Find("Detailed difference location").Column
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1,
vResSummary_ScenarioName_ColNo ) = varf_ScenarioName
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1,
vResSummary_BaselineName_ColNo ) = varf_BaseFileName
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1, vResSummary_Status_ColNo )
= vStatus
If StrComp(UCase(vStatus), "PASS",1) = 0 Then
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1,
vResSummary_Status_ColNo ).Interior.ColorIndex = 50
ElseIf StrComp(UCase(vStatus), "FAIL",1) = 0 Then
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1,
vResSummary_Status_ColNo ).Interior.ColorIndex = 3
End If
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1,
vResSummary_TotNoRecords_ColNo ) = varf_Final_Actual_TotalNumberRec & " / "
&varf_Final_Baseline_TotalNumberRec
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1,
vResSummary_TotRecMissing_ColNo ) = varf_Final_MissRecord_Actual & " / " &
varf_Final_MissRecord_Baseline
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1,
vResSummary_TotRecMissmatches_ColNo ) = varf_Final_DistinctRecordsMismatch
If varf_Final_DistinctFieldsMismatch = "" then
varf_Final_DistinctFieldsMismatch = " --- "
Else
varf_Final_DistinctFieldsMismatch =
Replace(Mid(varf_Final_DistinctFieldsMismatch,1,1),"|","") &
Mid(varf_Final_DistinctFieldsMismatch,2)
varf_length_FDFM = len(varf_Final_DistinctFieldsMismatch)
varf_Final_DistinctFieldsMismatch =
Mid(varf_Final_DistinctFieldsMismatch,1,varf_length_FDFM-1) &
Replace(Mid(varf_Final_DistinctFieldsMismatch,varf_length_FDFM),"|","")
End If
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1,
vResSummary_TotColumnsmatches_ColNo ) =
Replace(varf_Final_DistinctFieldsMismatch,"||","|")
varf_CmpTimer_End = Round((Timer - varf_CmpTimer_Start),0)
If varf_CmpTimer_End>= 3600 Then
varf_CmpTimer_End = (varf_CmpTimer_End\3600) & "hr " &
((varf_CmpTimer_End mod 3600)\60) & "min"
ElseIf varf_CmpTimer_End>=60 Then
varf_CmpTimer_End = (varf_CmpTimer_End\60) & "min " &
(varf_CmpTimer_End mod 60) & "sec"
Else
varf_CmpTimer_End = varf_CmpTimer_End & " sec"
End If
ObjWS_ResultSummary.Cells(vTotRow_ResultSummary+1, vResSummary_CmpTime_ColNo )
= varf_CmpTimer_End
If varf_TotalDiffCnt > 0 then
ObjWS_ResultSummary.Hyperlinks.add
ObjWS_ResultSummary.Range(Chr(vTotCol_ResultSummary + 64) & vTotRow_ResultSummary +
1), _
varf_ResultFileName_SummaryReport,,,vTDResult_FileName
End If
ObjWS_ResultSummary.Range("A1:" & Chr(vTotCol_ResultSummary +64 ) &
vTotRow_ResultSummary+1).Borders.LineStyle = xlContinuous
ObjWS_ResultSummary.Range("A1:" & Chr(vTotCol_ResultSummary +64 ) &
vTotRow_ResultSummary+1).Borders.color = vbBlack
ObjWB_ResultSummary.Save
ObjWB_ResultSummary.Close
'==================================================================================
================================================
'==================================================================================
================================================
' Clear the temp folder
Obj_FSO.DeleteFile varf_TempDB_FdrPath & "*", True
'==================================================================================
================================================
Set Obj_AdodbConnection = Nothing
Set Obj_AdodbConnActual = Nothing
Set Obj_AdodbConnBaseline = Nothing
Set Obj_RSActual = Nothing
Set Obj_RSBaseline = Nothing
Set Obj_RSGeneric = Nothing
End Function
'==================================== End Function
==========================================
varf_Cred_Environment =
Ucase(Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_Environment_ColNo)))
varf_Cred_DBName =
Ucase(Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_Database_ColNo)))
varf_DBMS_Type =
Ucase(Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_DBMS_Type_ColNo)))
varf_DBCred_Provider =
Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_Provider_ColNo))
varf_Host =
Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_Host_ColNo))
varf_port =
Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_Port_ColNo))
varf_DataSource =
Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_DataSource_ColNo))
varf_Schema =
Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_Schema_ColNo))
varf_DB_UserName =
Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_DB_UserName_ColNo))
varf_DB_Password =
Trim(ObjWS_DBCredentials.Cells(varf_DBRowCnt, varf_DB_Password_ColNo))
varf_ConnString_Status = "PASS"
Exit For
End If
Next
End Function
'==================================== End Function
==========================================
' Determine the type of trigger for creating the file Query or table or already
file is available
If Instr(1,Ucase(varf_Type_Trigger),"QUERY") > 0 Then
If Obj_FSO.FileExists (varf_GenFileName) Then
Set Obj_QueryRead = Obj_FSO.OpenTextFile(varf_GenFileName,1)
varf_QuerytoExtract =
Replace(Replace(Trim(Replace(Obj_QueryRead.ReadAll," "," ")),Chr(10),"
"),Chr(13)," ")
Obj_QueryRead.Close
Else
vDBFile_Remarks = " Script unable to find the file in the
location - " & varf_GenFile_DB_Query_Location & varf_GenFileName
vDbFile_Status = "FAIL"
Exit Function
End If
ElseIf Instr(1,Ucase(varf_Type_Trigger),"TABLE") > 0 Then
'If varf_Static_Filter <> Empty Or varf_Static_Filter <> "" Then
varf_Static_Filter_Query = " Where " & varf_Static_Filter
varf_QuerytoExtract = "Select * from " & varf_GenFileLocation_DBName
& "." & varf_GenFileName '& varf_Static_Filter_Query
Else
vDBFile_Remarks = " Improper comparison format , not file/query/table
found in the key"
vDbFile_Status = "FAIL"
Exit Function
End If
' Create the Pipe line delimited file from the query available or from direct table
If varf_QuerytoExtract <> Empty Or varf_QuerytoExtract <> "" Then
If varf_Static_Filter <> "" or varf_Static_Filter <> Empty
Then
varf_QuerytoExtract =
Replace(Split(Split(Split(Split(varf_QuerytoExtract,"order by")(0),"ORDER BY")
(0),"Order by")(0),"Order By")(0),";","")
If Instr(1, Ucase(varf_QuerytoExtract), "WHERE") > 0
Then
varf_QuerytoExtract = varf_QuerytoExtract &
" and " & varf_Static_Filter
Else
varf_QuerytoExtract = varf_QuerytoExtract &
" where " & varf_Static_Filter
End If
End If
" " & Replace(vComparisonFilesFdr,"\","\\") & " " & vDBFileName & " " & Chr(34) &
"|" & Chr(34)
vJavaBinLocation = "set
Path=C:\temp\jdk1.7.0_11\bin;C:\temp\jdk1.7.0_09\bin; &"
vJavaBinLocation = ""
vSybaseIQ_JavaCMD_Process = "cmd /c " &
vJavaBinLocation & vSybaseIQ_JavaCMD_DataExtract
ObjWsh_SybaseQuery.Run
vSybaseIQ_JavaCMD_Process
' Wait until the extracted and trigger
file is genrated
vSybIQ_DataExtracted_Triggger = Empty
vFilePull_Timer = Timer
vFileExtract_TimeExceed = Empty
Do Until vSybIQ_DataExtracted_Triggger =
"Found" Or vFileExtract_TimeExceed = True
If Obj_FSO.FileExists
(vComparisonFilesFdr & vDBFileName & ".txt") Then vSybIQ_DataExtracted_Triggger =
"Found"
' ObjWsh_SybaseQuery.Sleep 1000
Wait 1
If (Timer - vFilePull_Timer) >
300 Then vFileExtract_TimeExceed = True
Loop
Else
vDBFile_Remarks = " Java Process not
exist in the location - " & vSybIQ_JProcLocation
vDbFile_Status = "FAIL"
Exit Function
End If
Else
Obj_RSGeneric.Open
varf_QuerytoExtract,Obj_AdodbConnGen,3,3
If Obj_RSGeneric.EOF <> True Then
If Obj_RSGeneric.BOF <> True Then
Obj_RSGeneric.MoveFirst
vFieldNames_Extraction = Empty
For Each vColName in Obj_RSGeneric.Fields
vFieldNames_Extraction =
vFieldNames_Extraction & Chr(124) & vColName.Name
Next
vFieldNames_Extraction =
Mid(vFieldNames_Extraction,2)
Set ObjPipeFile_Extract =
Obj_FSO.OpenTextFile(vComparisonFilesFdr & vDBFileName,2,True)
ObjPipeFile_Extract.WriteLine
vFieldNames_Extraction
vRecCount_Extraction = 0
Do Until Obj_RSGeneric.EOF
ObjPipeFile_Extract.writeline
Replace(Obj_RSGeneric.GetString(2,1,"|",""),Chr(13),"")
vRecCount_Extraction =
vRecCount_Extraction + 1
Loop
ObjPipeFile_Extract.Close
Else
vDBFile_Remarks = " No Records are available
from query output"
vDbFile_Status = "FAIL"
End If
End If
End Function
Obj_RSActual,Obj_RSBaseline,varf_TempDB_FdrPath,ObjXL_Main,Obj_FSO,Obj_ExeLog,ObjWB
_Result,vFixedWidth2PIPE_Status)
Else
' < Fixed Width Xlsx file not exist >
' Exit Function
End If
ElseIf
Func_Worksheet_Exist(Trim(Replace(Replace(Replace(varf_FixedWidth_Schema,"@FixedWid
th_Sheet",""),"-",""),Chr(10),"")), ObjWB_Result) =1 Then
Set ObjWS_FixedWidth_Schema =
ObjWB_Result.WorkSheets(Trim(Replace(Replace(Replace(varf_FixedWidth_Schema,"@Fixed
Width_Sheet",""),"-",""),Chr(10),"")))
Else
' < Fixed Width Sheet not exist >
' Exit Function
End If
' ObjWS_FixedWidth_Schema
vFixedWidth_UsedColCnt =
Cint(ObjWS_FixedWidth_Schema.UsedRange.Columns.Count)
vFixedWidth_UsedRowCnt =
Cint(ObjWS_FixedWidth_Schema.UsedRange.Rows.Count)
vRowNoFW = 1
varf_ActFileName_Cpy2Local = varf_ActFileName_Cpy2Local_FW
varf_BaseFileName_Cpy2Local = varf_BaseFileName_Cpy2Local_FW
End Function
'==================================== End Function
==========================================
Else
' < Column Mapping Xlsx file not exist >
' Exit Function
End If
ElseIf
Func_Worksheet_Exist(Trim(Replace(Replace(Replace(varf_Column_validation,"@ColumnMa
pping_Sheet",""),"-",""),Chr(10),"")), ObjWB_Result) =1 Then
Set ObjWS_ColumnMapping_Schema =
ObjWB_Result.WorkSheets(Trim(Replace(Replace(Replace(varf_Column_validation,"@Colum
nMapping_SchemaSheet",""),"=",""),Chr(10),"")))
Else
' < Column Mapping Sheet not exist >
' Exit Function
End If
' ObjWS_ColumnMapping_Schema
' varf_dummydttype
' < The above three attributes should be send to main comparison function>
' < complete the function for 3 validation, differnece in files -- Missing
columns and adding to list ---- validate the expected columns >
End Function
vDelimiter = Chr(124)
'vDiffSheetName
'ObjWB_Result
vLogicalKey_DiffReport_ColNo = 1
vLineNoActual_DiffReport_ColNo = 2
vLineNoBase_DiffReport_ColNo = 3
vFieldName_DiffReport_ColNo = 4
vActFieldValue_DiffReport_ColNo = 5
vBaseFieldvalue_DiffReport_ColNo = 6
vStartingRowNo_DiffReport = 3
vTotalNoColUsed_DiffReport = 8
ObjWS_DiffReport.Cells(vStartingRowNo_DiffReport-1,
vLogicalKey_DiffReport_ColNo).Value = " Logical Keys (" &
varf_Logical_columns & ")"
ObjWS_DiffReport.Cells(vStartingRowNo_DiffReport-1,
vLineNoActual_DiffReport_ColNo).Value = "LineNo_Actual"
ObjWS_DiffReport.Cells(vStartingRowNo_DiffReport-1,
vLineNoBase_DiffReport_ColNo).Value = "LineNo_Baseline"
ObjWS_DiffReport.Cells(vStartingRowNo_DiffReport-1,
vFieldName_DiffReport_ColNo).Value = "Attribute Name"
ObjWS_DiffReport.Cells(vStartingRowNo_DiffReport-1,
vActFieldValue_DiffReport_ColNo).Value = "ActualField_Value"
ObjWS_DiffReport.Cells(vStartingRowNo_DiffReport-1,
vBaseFieldvalue_DiffReport_ColNo).Value = "BaselineField_Value"
Else
vStartingRowNo_DiffReport = vTotRow_DiffReport + 1
End If
ObjWS_DiffReport.Activate
vDiffReportExcel_Status = "PASS"
ObjWB_Result.Worksheets(vDiffSheetName).Visible = True
ObjWB_Result.Save
Else
' <Temporary result difference sheet not available in the result report
excel file>
End If
End Function
Public Function
f_GetDynamicFilters(Obj_Dict_Conf,Obj_AdodbConnection,varf_ActFileName_DumLineDT,
varf_BaseFileName_DumLineDT, _
varrDynamicFilters,vFilter_OutOfRange,vNoOfRec_PerDynFilter,varf_dummydttype)
vDynamicFilter_Set1 =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Dynamic_Filter_set1"))," ,
",",")," ,",","),", ",",")," ","_")
vDynamicFilter_Set2 =
Replace(Replace(Replace(Replace(Trim(Obj_Dict_Conf("Dynamic_Filter_set2"))," ,
",",")," ,",","),", ",",")," ","_")
vStaticFilter = Trim(Obj_Dict_Conf("Static_Filter"))
vTableName = Trim(Obj_Dict_Conf("Baseline_File_Name /
Baseline_table_Name"))
vDataBaseName = Trim(Obj_Dict_Conf("Folder_Name / Database_Name"))
vJoinTrigger = Trim(Obj_Dict_Conf("PC_trigger_Flag"))
vJoinTableName = Trim(Obj_Dict_Conf("ParentTable_Name"))
vJoinTableJoinColumns = Trim(Obj_Dict_Conf("ParentTable_columns"))
vMainTableJoinColumns = Trim(Obj_Dict_Conf("ChildTable_columns"))
vNoOfRecords_SetFilters = vNoOfRec_PerDynFilter
vNoOfRec_SetFilters_P1 = vNoOfRecords_SetFilters + 1
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++
' Dynamic Filter ------ Set 1 and less than 400,000 Records
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++
' Identify the data tyep of the filters which will help to define kind of
statement
varrDyn_Filter_Split = Split(vDynamicFilter_Set1,",")
vQueyJoin = ""
If Instr(1, vJoinTableJoinColumns,",") Then
varrJoinTableJoinColumns = Split(vJoinTableJoinColumns,",")
varrMainTableJoinColumns = Split(vMainTableJoinColumns,",")
For VCtr = 0 To Ubound(varrJoinTableJoinColumns)-1
vQueyJoin = vQueyJoin & vTableName & "." &
varrMainTableJoinColumns(vCtr) & " = " & vJoinTableName & "." &
varrJoinTableJoinColumns(vCtr) & " And "
Next
vQueyJoin = vQueyJoin & vTableName & "." &
varrMainTableJoinColumns(vCtr) & " = " & vJoinTableName & "." &
varrJoinTableJoinColumns(vCtr)
Else
vQueyJoin = vQueyJoin & vTableName & "." &
varrMainTableJoinColumns(vCtr) & " = " & vJoinTableName & "." &
varrJoinTableJoinColumns(vCtr)
End If
vFilterQuery = "Select " & vFilterColumns & ", Count(*) Filter_Cnt From "
& vEnvSpecificDatabaseName & "." & vTableName & " " & vTableName
vFilterQuery = vFilterQuery & "Left Outer Join " &
vEnvSpecificDatabaseName & "." & vJoinTableName & " " & vJoinTableName
vFilterQuery = vFilterQuery & "On " & vQueyJoin & vStaticFilter & " Group
By " & vFilterColumns & " having count(*) < " & _
vNoOfRec_SetFilters_P1 & "Order by count(*) desc"
Else
vFilterQuery = "Select " & vDynamicFilter_Set1 & ", max(BaseCnt) as
finalgrpcnt from (" & _
"select " & vDynamicFilter_Set1 & ", count(*) as BaseCnt
from " & varf_BaseFileName_DumLineDT & vStaticFilter & " group by " & _
vDynamicFilter_Set1 & " having count(*) <= "
& vNoOfRec_PerDynFilter & " union " & _
"select " & vDynamicFilter_Set1 & ", count(*) as ActCnt
from " & varf_ActFileName_DumLineDT & vStaticFilter & " group by " & _
vDynamicFilter_Set1 & " having count(*) <= "
& vNoOfRec_PerDynFilter & _
") group by " & vDynamicFilter_Set1 & " order
by max(BaseCnt) desc"
End If
RS_GetFilters.Close
Set RS_GetFilters = Nothing
'++++++++++++++++++++++++++
' Dynamic Filter ------ Set 2 and more than 400,000 Records
'++++++++++++++++++++++++++
'Identify the data_type of the filter which will help to define kind of statement
vDynamicFilter_Conct_Set1 = ""
vDynamicFilter_Set1_Split = Split(vDynamicFilter_Set1,",")
For vDynamicFtrSet1_Ctr = 0 to Ubound(vDynamicFilter_Set1_Split)
vDynamicFilter_Conct_Set1 = vDynamicFilter_Conct_Set1 & "||" &
Ucase(Trim(vDynamicFilter_Set1_Split(vDynamicFtrSet1_Ctr)))
Next
vDynamicFilter_Conct_Set1 = Mid(vDynamicFilter_Conct_Set1,3)
End If
vQueyJoin = ""
If Instr(1, vJoinTableJoinColumns,",") Then
varrJoinTableJoinColumns = Split(vJoinTableJoinColumns,",")
varrMainTableJoinColumns = Split(vMainTableJoinColumns,",")
For VCtr = 0 To Ubound(varrJoinTableJoinColumns)-1
vQueyJoin = vQueyJoin & vTableName & "." &
varrMainTableJoinColumns(vCtr) & " = " & vJoinTableName & "." &
varrJoinTableJoinColumns(vCtr) & " And "
Next
vQueyJoin = vQueyJoin & vTableName & "." &
varrMainTableJoinColumns(vCtr) & " = " & vJoinTableName & "." &
varrJoinTableJoinColumns(vCtr)
Else
vQueyJoin = vQueyJoin & vTableName & "." &
varrMainTableJoinColumns(vCtr) & " = " & vJoinTableName & "." &
varrJoinTableJoinColumns(vCtr)
End If
End If
vTempFilterStoreValue = ""
vTotal_Filter_cnt = 0
vNoFilters_into_Query = 0
Dim vFilter_OutOfRange_temp()
vFilter_OOR_Cnt = 0
Do
If Instr(1, lcase(vTempFilterStoreValue),
lcase(varf_dummydttype)) > 0 Then Exit Do
If vTotal_Filter_cnt > vNoOfRecords_SetFilters Or
vNoFilters_into_Query > 999 Then
If vNoFilters_into_Query = 0 Then
ReDim Preserve
vFilter_OutOfRange_temp(vFilter_OOR_Cnt)
vFilter_OutOfRange_temp(vFilter_OOR_Cnt) = "("
& vTempFilterStoreValue & ")" & "@# " & vTotal_Filter_cnt
vFilter_OOR_Cnt = vFilter_OOR_Cnt + 1
vTotal_Filter_cnt = 0
Exit Do
End If
varrDynamicFilters(vFilterCtr) = "(" &
Mid(varrDynamicFilters(vFilterCtr),5) & ")"
vFilterCtr = vFilterCtr + 1
vTotal_Filter_cnt =
CDBL(RS_GetFilters.Fields("finalgrpcnt").Value)
vNoFilters_into_Query = 1
ReDim Preserve varrDynamicFilters(vFilterCtr)
varrDynamicFilters(vFilterCtr) =
varrDynamicFilters(vFilterCtr) & " Or ( " & vTempFilterStoreValue & ")"
Else
varrDynamicFilters(vFilterCtr) =
varrDynamicFilters(vFilterCtr) & " Or ( " & vTempFilterStoreValue & ")"
vNoFilters_into_Query = vNoFilters_into_Query + 1
End If
Exit Do
Loop
vTempFilterStoreValue = ""
RS_GetFilters.MoveNext
Loop
vFilter_OutOfRange = vFilter_OutOfRange_temp
RS_GetFilters.Close
Set RS_GetFilters = Nothing
End Function
'**********************************************************************************
**************************
' TC Regression Specific Functions
'**********************************************************************************
**************************
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
vStatus ="PASS"
End Function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_HiveDatabase_Name, varf_TC_HiveTable_Name,
varf_TC_HiveReferenceSheet, varf_TC_HiveOutput_Location
Dim vHC_Source_ColumnNames_ColNo, vHC_Source_DataTypes_ColNo,
vHC_Primary_Key_ColNo, vHC_Not_Null_ColNo, vHC_HiveTable_ColumnNames_ColNo
Dim vHC_HiveTable_DataType_ColNo, vHC_Status_ColNo, vHC_Remarks_ColNo,
vHC_Actual_HiveOutput_DataType_ColNo
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_HiveDatabase_Name = Trim(Obj_Dict_RegTC("Hive_Database"))
varf_TC_HiveTable_Name = Trim(Obj_Dict_RegTC("Hive_table"))
varf_TC_HiveReferenceSheet = Trim(Obj_Dict_RegTC("Reference_ColumnSheet"))
varf_TC_HiveOutput_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
varf_TC_AVRO_Location = Replace(Trim(Obj_Dict_RegTC("AVRO_Location")),"
","")
If Mid(Trim(varf_TC_HiveOutput_Location),
len(Trim(varf_TC_HiveOutput_Location)),1) <> "\" Then varf_TC_HiveOutput_Location =
Trim(varf_TC_HiveOutput_Location) & "\"
' Extract the Hive column - file path and sheet name from variable
varf_TC_HiveReferenceSheet. Also copy the hive column sheet to result xl
' Establish the worksheet object for hive column available in result xl
If Instr(1, varf_TC_HiveReferenceSheet, "$HiveColumn_FilePath") > 0 And
Instr(1,varf_TC_HiveReferenceSheet,"@HiveColumn_SchemaSheet") > 0 Then
varf_HiveColumn_FilePath =
Trim(Replace(Replace(Split(Replace(varf_TC_HiveReferenceSheet,"$HiveColumn_FilePath
",""),"@HiveColumn_SchemaSheet")(0),"=",""),Chr(10),""))
varf_HiveColumn_SchemaSheet =
Ucase(Trim(Replace(Replace(Split(Replace(varf_TC_HiveReferenceSheet,"$HiveColumn_Fi
lePath",""),"@HiveColumn_SchemaSheet")(1),"=",""),Chr(10),"")))
If Func_Worksheet_Exist(varf_HiveColumn_SchemaSheet, ObjWB_Result) =1 Then
Set ObjWS_HiveColumn_Schema =
ObjWB_Result.Worksheets(varf_HiveColumn_SchemaSheet)
ElseIf Obj_FSO.FileExists(varf_HiveColumn_FilePath) Then
Set ObjWB_HiveColumn_Schema =
ObjXL_Main.WorkBooks.Open(varf_HiveColumn_FilePath)
If Func_Worksheet_Exist(varf_HiveColumn_SchemaSheet,
ObjWB_HiveColumn_Schema) =1 Then
Set ObjFSO_Getfile =
Obj_FSO.GetFile(varf_HiveColumn_FilePath)
vHiveResult_FileNameLocation = varf_TC_HiveOutput_Location
& Replace(Split(ObjFSO_Getfile.name,".")(0),"Tables_ColName","TabColNames_") &
vStaticTimestamp_DDMMHHMM & "." &
Obj_FSO.GetExtensionName(varf_HiveColumn_FilePath)
If Not Obj_FSO.FileExists(vHiveResult_FileNameLocation) Then
ObjWB_HiveColumn_Schema.WorkSheets(varf_HiveColumn_SchemaSheet).Copy
,ObjWB_Result_HiveCol.Worksheets(1) ' copy hive column sheet to result report
For Each vSheet_New In ObjWB_Result_HiveCol.Sheets
If Ucase(vSheet_New.name) = "SHEET1" or
Ucase(vSheet_New.name) = "SHEET2" or Ucase(vSheet_New.name) = "SHEET3" Then
vSheet_New.Delete
Next
Else
Set ObjWB_Result_HiveCol =
ObjXL_Main.WorkBooks.open(vHiveResult_FileNameLocation)
ObjWB_HiveColumn_Schema.WorkSheets(varf_HiveColumn_SchemaSheet).Copy
,ObjWB_Result_HiveCol.Worksheets(1) ' copy hive column sheet to result report
End If
Set ObjWS_HiveColumn_Schema =
ObjWB_Result_HiveCol.Worksheets(varf_HiveColumn_SchemaSheet)
Else
vRemarksTC = "The sheet "& varf_HiveColumn_SchemaSheet & "
mentioned in Refcolumn is not exist in the file" & varf_HiveColumn_FilePath
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
ObjWB_HiveColumn_Schema.Close
Else
vRemarksTC = "The excel file mentioned in Refcolumn is not exist -
- " & varf_HiveColumn_FilePath
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
ElseIf
Func_Worksheet_Exist(Trim(Replace(Replace(Replace(varf_TC_HiveReferenceSheet,"@Hive
Column_SchemaSheet",""),"-",""),Chr(10),"")), ObjWB_Result) =1 Then
Set ObjWS_HiveColumn_Schema =
ObjWB_Result.WorkSheets(Trim(Replace(Replace(Replace(varf_TC_HiveReferenceSheet,"@H
iveColumn_SchemaSheet",""),"-",""),Chr(10),"")))
Else
vRemarksTC = "Ref column sheet variable may be empty or expected keywords
are missing like $HiveColumn_FilePath and @HiveColumn_SchemaSheet"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
ObjWS_ResultTC.Hyperlinks.add ObjWS_ResultTC.Range(Chr(vFuncTC_Remarks_ColNo +
64) & vTC_FuncRowNo_Value), vHiveResult_FileNameLocation,_
Chr(39) & varf_HiveColumn_SchemaSheet &
Chr(39)&"!A1", , varf_HiveColumn_SchemaSheet
' Create the column number variables to fetch the hive column values from sheet
vHiveColumn_UsedColCnt =
Cint(ObjWS_HiveColumn_Schema.UsedRange.Columns.Count)
vHiveColumn_UsedRowCnt =
Cint(ObjWS_HiveColumn_Schema.UsedRange.Rows.Count)
vRowNoHC = 1
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
If Func_Worksheet_Exist(vTD_UnixCrdnSheet, ObjWB_Result) =1 Then
Set ObjWS_UnixConnection_Sheet =
ObjWB_Result.Worksheets(vTD_UnixCrdnSheet)
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
' Output file name with time stamp(static time stamp from function parameter)
vHiveOutput_FileNameLocation = varf_TC_HiveOutput_Location & "HiveCol_" &
varf_TC_HiveTable_Name & "_" & vStaticTimestamp_DDMMHHMM & ".txt"
vHiveOutput_CommandFileLocation = varf_TC_HiveOutput_Location & "HiveCmdStruc_"
& varf_TC_HiveTable_Name & "_" & vStaticTimestamp_DDMMHHMM & ".txt"
' Write a script to dynamicaly create a hive command file and each line should have
output file
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vHiveOutput_CommandFileLocation,2,True)
vObj_HiveCmd_File_Dynamic.WriteLine "su - cdhqa " & Chr(34) & "hive --service
beeline -u
'jdbc:hive2://wupra97a0033.mylocal.com:10001/default;auth=maprsasl;saslQop=auth-
conf;ssl=true' -e '" &_
"describe " & varf_TC_HiveDatabase_Name &
"." & varf_TC_HiveTable_Name & "'" & Chr(34)
vObj_HiveCmd_File_Dynamic.Close
' Create and Execute the Plink command file into Unix
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " & vPlinkExe_Location_Split(0) & ":" & "&cd \
&cd " & Chr(34) & vPlinkExe_Location_Split(1) & Chr(34) & "&plink -t " &
varf_TC_UnixBox_HostName
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " -l " & vUnixConn_Server_USN & "
-pw " & vUnixConn_Server_PWD & " -m " & vHiveOutput_CommandFileLocation
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " > " &
vHiveOutput_FileNameLocation & " &exit"
Wshell.Run vExecute_CMD_Prompt,0,True
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
' Hive Ouput didn't create a file
vRemarksTC = "The unix command output file is not created, there
may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
' Match All the FSD column Names & FSD datatypes present in sheet with Hive Output
Column Names and Data Types
For vSColDT_RowCnt = 2 To vHiveColumn_UsedRowCnt
vHC_FSD_ColumnNames =
Ucase(Trim(ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_FSD_Columns_ColNo).Value))
vHC_FSD_DataTypes =
Ucase(Trim(ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_FSD_Data_Type_ColNo).Value))
'Modify the Column names to match with standard Hive and AVRO column Names
Do While Instr(1,vHC_Source_ColumnNames,Chr(32)) > 0
vspace_pos = Instr(1,vHC_Source_ColumnNames,Chr(32))
'Multiple consecutive space will be replace by single underscore
If Mid(vHC_Source_ColumnNames,vspace_pos+1,1) = Chr(32) Then
vHC_Source_ColumnNames =
Replace(Mid(vHC_Source_ColumnNames,1,vspace_pos),Chr(32),"") &
Mid(vHC_Source_ColumnNames,vspace_pos+1)
Else
vHC_Source_ColumnNames =
Replace(Mid(vHC_Source_ColumnNames,1,vspace_pos),Chr(32),"_") &
Mid(vHC_Source_ColumnNames,vspace_pos+1)
End If
Loop
vHC_Source_ColumnNames =
Replace(Replace(Replace(Replace(Replace(Replace(vHC_Source_ColumnNames,"$","_DOLLAR
_"),"%","_PCT_"),"(",""),")",""),"/","_"),"P&L","PNL")
'Modify the Data types to match with standard Hive and AVRO column Names
Select Case True
Case Instr(1,Ucase(vHC_Source_DataTypes),"DOUBLE") > 0 or
Instr(1,Ucase(vHC_Source_DataTypes),"DECIM") > 0 or
Instr(1,Ucase(vHC_Source_DataTypes),"NUMBER")
vHC_Source_DataTypes = "DOUBLE"
Case Instr(1,Ucase(vHC_Source_DataTypes),"TIME") > 0 or
Instr(1,Ucase(vHC_Source_DataTypes),"STAMP") > 0 or
Instr(1,Ucase(vHC_Source_DataTypes),"DATE") > 0
vHC_Source_DataTypes = "STRING"
Case Instr(1,Ucase(vHC_Source_DataTypes),"CHAR") > 0 or
Instr(1,Ucase(vHC_Source_DataTypes),"VAR") > 0
vHC_Source_DataTypes = "STRING"
Case Instr(1,Ucase(vHC_Source_DataTypes),"BOOL") > 0
vHC_Source_DataTypes = "BOOLEAN"
Case Trim(vHC_Source_DataTypes) = ""
vHC_Source_DataTypes = "STRING"
Case Instr(1,Ucase(vHC_Source_DataTypes),"INT") > 0
vHC_Source_DataTypes = "INT"
Case Instr(1,Ucase(vHC_Source_DataTypes),"FLOAT") > 0
vHC_Source_DataTypes = "FLOAT"
Case Else
vHC_Source_DataTypes = "STRING"
End Select
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_ColumnNames_ColNo).Value = vHC_Source_ColumnNames
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_DataTypes_ColNo).Value = vHC_Source_DataTypes
If ObjDict_HiveColumns_DataTypes.Exists(vHC_Source_ColumnNames) Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_HiveTable_ColumnNames_ColNo) = vHC_Source_ColumnNames
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_HiveTable_DataType_ColNo) =
ObjDict_HiveColumns_DataTypes(vHC_Source_ColumnNames)
If ObjDict_HiveColumns_DataTypes(vHC_Source_ColumnNames) =
vHC_Source_DataTypes Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "PASS"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo).Interior.ColorIndex = 50
Else
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "FAIL"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "Hive Data Type didn't match with FSD"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_DataTypes_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_HiveTable_DataType_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo).Interior.ColorIndex = 3
vStatus = "FAIL"
End If
ElseIf
ObjDict_HiveColumns_DataTypes_rep.Exists(Replace(vHC_Source_ColumnNames,"_",""))
Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_HiveTable_ColumnNames_ColNo) =
Split(ObjDict_HiveColumns_DataTypes_rep(Replace(vHC_Source_ColumnNames,"_","")),"|"
)(1)
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_HiveTable_DataType_ColNo) =
Split(ObjDict_HiveColumns_DataTypes_rep(Replace(vHC_Source_ColumnNames,"_","")),"|"
)(0)
If
Split(ObjDict_HiveColumns_DataTypes_rep(Replace(vHC_Source_ColumnNames,"_","")),"|"
)(0) = vHC_Source_DataTypes Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "WARN"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "Hive Column match by replacing underscore by blank"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo).Interior.ColorIndex = 15
Else
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "FAIL"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "Hive Data Type didn't match with FSD"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_DataTypes_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_HiveTable_DataType_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo).Interior.ColorIndex = 3
vStatus = "FAIL"
End If
Else
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_HiveTable_ColumnNames_ColNo) = " Not Found "
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt, vHC_Status_ColNo) =
"FAIL"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt, vHC_Remarks_ColNo) =
"FSD Column Not Exist in Hive Table"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_ColumnNames_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_HiveTable_ColumnNames_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo).Interior.ColorIndex = 3
vStatus = "FAIL"
End If
Next
' Match All the Hive Output Column Names with FSD column Names present in sheet
( to find extra columns in hive )
For vSColDT_RowCnt = 2 To vHiveColumn_UsedRowCnt
vHC_Source_ColumnNames =
Ucase(Trim(ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_ColumnNames_ColNo).Value))
vHC_Source_DataTypes =
Ucase(Trim(ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_DataTypes_ColNo).Value))
ObjDict_SourceColumns_DataTypes.Add vHC_Source_ColumnNames,
vHC_Source_DataTypes
On Error Resume Next ' "This key is already associated with an element of
this collection" and Error Number -- 457
ObjDict_SourceColumns_DataTypes_rep.Add
Replace(vHC_Source_ColumnNames,"_",""), vHC_Source_DataTypes
On Error Goto 0
Next
' Output AVRO file name with time stamp(static time stamp from function
parameter)
If Mid(Trim(varf_TC_HiveOutput_Location),
len(Trim(varf_TC_HiveOutput_Location)),1) <> "\" Then varf_TC_HiveOutput_Location =
Trim(varf_TC_HiveOutput_Location) & "\"
vAVROutput_FileNameLocation = varf_TC_HiveOutput_Location &
"AVROColCMP_" & varf_TC_HiveTable_Name & "_" & vStaticTimestamp_DDMMHHMM & ".txt"
' Create and Execute the Plink command file into Unix
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " & vPlinkExe_Location_Split(0) & ":" &
"&cd \ &cd " & Chr(34) & vPlinkExe_Location_Split(1) & Chr(34) & "&plink -t " &
varf_TC_UnixBox_HostName
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " -l " &
vUnixConn_Server_USN & " -pw " & vUnixConn_Server_PWD & " su - cdhqa 'cat " &
varf_TC_AVRO_Location & "'"
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " > " &
vAVROutput_FileNameLocation & " &exit"
Obj_ExeLog.WriteLine " Below AVRO command will be executed into unix box"
Obj_ExeLog.WriteLine vExecute_CMD_Prompt
Obj_ExeLog.WriteBlankLines 1
Wshell.Run vExecute_CMD_Prompt,0,True
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
' Hive Ouput didn't create a file
vRemarksTC = "The AVRO output file is not created, there may
be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
If ObjDict_AVROColumns_DataTypes.Exists(vHC_Source_ColumnNames)
Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_ColumnNames_ColNo) = vHC_Source_ColumnNames
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_DataType_ColNo) = ObjDict_AVROColumns_DataTypes(vHC_Source_ColumnNames)
If ObjDict_AVROColumns_DataTypes(vHC_Source_ColumnNames) <>
vHC_Source_DataTypes and ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "PASS" Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "FAIL"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "AVRO Data Type didn't match with FSD"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_DataTypes_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_DataType_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo).Interior.ColorIndex = 3
vStatus = "FAIL"
ElseIf ObjDict_AVROColumns_DataTypes(vHC_Source_ColumnNames)
<> vHC_Source_DataTypes and ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "FAIL" Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "Hive Data Type didn't match with FSD" & Chr(10) & "AVRO Data
Type didn't match with FSD"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_DataType_ColNo).Font.ColorIndex = 3
vStatus = "FAIL"
End If
ElseIf
ObjDict_AVROColumns_DataTypes_rep.Exists(Replace(vHC_Source_ColumnNames,"_",""))
Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_ColumnNames_ColNo) =
Split(ObjDict_AVROColumns_DataTypes_rep(Replace(vHC_Source_ColumnNames,"_","")),"|"
)(1)
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_DataType_ColNo) =
Split(ObjDict_AVROColumns_DataTypes_rep(Replace(vHC_Source_ColumnNames,"_","")),"|"
)(0)
If
Split(ObjDict_AVROColumns_DataTypes_rep(Replace(vHC_Source_ColumnNames,"_","")),"|"
)(0) <> vHC_Source_DataTypes and ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "PASS" Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "FAIL"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "AVRO Data Type didn't match with FSD"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_DataTypes_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_DataType_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo).Interior.ColorIndex = 3
vStatus = "FAIL"
ElseIf
Split(ObjDict_AVROColumns_DataTypes_rep(Replace(vHC_Source_ColumnNames,"_","")),"|"
)(0) <> vHC_Source_DataTypes and ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "FAIL" Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "Hive Data Type didn't match with FSD" & Chr(10) & "AVRO Data
Type didn't match with FSD"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_DataType_ColNo).Font.ColorIndex = 3
vStatus = "FAIL"
ElseIF
Split(ObjDict_AVROColumns_DataTypes_rep(Replace(vHC_Source_ColumnNames,"_","")),"|"
)(0) <> vHC_Source_DataTypes and ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "WARN" Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "FAIL"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "Hive Column match by replacing underscore by blank" & Chr(10)
& "And also AVRO Data Type didn't match with FSD"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_DataType_ColNo).Font.ColorIndex = 3
vStatus = "FAIL"
End If
ElseIf ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "PASS" Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_ColumnNames_ColNo) = " Not Found "
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "FAIL"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "FSD Column Not Exist in AVRO File"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Modified_ColumnNames_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_ColumnNames_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo).Interior.ColorIndex = 3
vStatus = "FAIL"
ElseIf vHC_Source_ColumnNames = "" and
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_HiveTable_ColumnNames_ColNo).Value <> "" Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "Extra Column Found in Hive Table" & Chr(10) & "Extra Column
Found in AVRO File"
Else
If ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "WARN" Then
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Status_ColNo) = "FAIL"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_ColumnNames_ColNo) = " Not Found "
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "Hive Column match by replacing underscore by blank" &
Chr(10) & "FSD Column Not Exist in AVRO File"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_ColumnNames_ColNo).Font.ColorIndex = 3
vStatus = "FAIL"
Else
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_ColumnNames_ColNo) = " Not Found "
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Remarks_ColNo) = "FSD Column Not Exist in Hive Table" & Chr(10) & "FSD Column
Not Exist in AVRO File"
ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_AVRO_ColumnNames_ColNo).Font.ColorIndex = 3
vStatus = "FAIL"
End If
End If
Next
' Match All the Hive Output Column Names with FSD column Names present in sheet
( to find extra columns in hive )
For Each vHiveColCnt in ObjDict_AVROColumns_DataTypes
If Not ObjDict_SourceColumns_DataTypes.Exists(vHiveColCnt) and
vHiveColCnt <> "BZ_DATE" and vHiveColCnt <> "BUSINESSDATE" and Not
ObjDict_HiveColumns_DataTypes.Exists(vHiveColCnt) Then
vHiveColumn_UsedRowCnt = vHiveColumn_UsedRowCnt + 1
ObjWS_HiveColumn_Schema.Cells(vHiveColumn_UsedRowCnt,
vHC_AVRO_ColumnNames_ColNo) = vHiveColCnt
ObjWS_HiveColumn_Schema.Cells(vHiveColumn_UsedRowCnt,
vHC_AVRO_DataType_ColNo) = ObjDict_AVROColumns_DataTypes(vHiveColCnt)
ObjWS_HiveColumn_Schema.Cells(vHiveColumn_UsedRowCnt,
vHC_AVRO_ColumnNames_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vHiveColumn_UsedRowCnt,
vHC_AVRO_DataType_ColNo).Font.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vHiveColumn_UsedRowCnt,
vHC_Status_ColNo) = "FAIL"
ObjWS_HiveColumn_Schema.Cells(vHiveColumn_UsedRowCnt,
vHC_Status_ColNo).Interior.ColorIndex = 3
ObjWS_HiveColumn_Schema.Cells(vHiveColumn_UsedRowCnt,
vHC_Remarks_ColNo) = "Extra Column Found in AVRO FILE"
vStatus = "FAIL"
End If
Next
End If
If vStatus <> "FAIL" Then vStatus = "PASS" ' Overall status of the function
ObjWB_Result_HiveCol.Save
ObjWB_Result_HiveCol.close
End Function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
If Mid(Trim(varf_TC_Evidence_Location),
len(Trim(varf_TC_Evidence_Location)),1) <> "\" Then varf_TC_Evidence_Location =
Trim(varf_TC_Evidence_Location) & "\"
vUnix_TestUnixCommand = varf_TC_Evidence_Location &
"vUnix_TestUnixCommand" & vStaticTimestamp_DDMMHHMM & ".txt"
vUnix_TestUnixCommand_Output = varf_TC_Evidence_Location &
"vUnix_TestUnixCommand_Output" & vStaticTimestamp_DDMMHHMM & ".txt"
Obj_FSO.CreateTextFile vUnix_TestUnixCommand,true
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vUnix_TestUnixCommand,2,True)
Redim preserve command(0)
command(0) = "echo hostname"
' Write a test command to a input file
call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
If Obj_FSO.FileExists(vUnix_TestUnixCommand_Output) Then
Set Obj_ReadOutput_File =
Obj_FSO.GetFile(vUnix_TestUnixCommand_Output)
If Obj_ReadOutput_File.Size > 0 Then
Set ObjRead_OutputFile =
Obj_FSO.OpenTextfile(vUnix_TestUnixCommand_Output,1)
vFlag ="NotFound"
Do Until ObjRead_OutputFile.AtEndOfStream
vReadColumnDT = ObjRead_OutputFile.ReadLine
If Instr(vReadColumnDT,
lcase(varf_TC_SystemName)&"hostname") Then
vFlag = "Found"
Exit Do
End If
Loop
End If
End If
vFlag=""
End Function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
varf_TC_Hive_Url_Location = Trim(Obj_Dict_RegTC("HIVE_URL_Location"))
varf_TC_Hive_Url = Trim(Obj_Dict_RegTC("HIVE_URL"))
varf_RC_Hive_Query =Trim(Obj_Dict_RegTC("HIVE_QUERY"))
Set Wshell = CreateObject("Wscript.Shell") ' Extract the unix details -USN, PWD,
Plink location, PSFTP location from Unix Connection details sheet
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
vUnixConn_HostName_ColNo = ObjWS_UnixConnection_Sheet.Range("A" &
vRowNoUC & ":" & Chr(vUnixConnection_UsedColCnt + 64) &
vRowNoUC).Find("UnixBox_HostName").Column
vUnixConn_Server_USN_ColNo = ObjWS_UnixConnection_Sheet.Range("A" &
vRowNoUC & ":" & Chr(vUnixConnection_UsedColCnt + 64) &
vRowNoUC).Find("UnixServer_USN").Column
vUnixConn_Server_PWD_ColNo = ObjWS_UnixConnection_Sheet.Range("A" &
vRowNoUC & ":" & Chr(vUnixConnection_UsedColCnt + 64) &
vRowNoUC).Find("UnixServer_PWD").Column
vUnixConn_Port_ColNo = ObjWS_UnixConnection_Sheet.Range("A" &
vRowNoUC & ":" & Chr(vUnixConnection_UsedColCnt + 64) &
vRowNoUC).Find("Unix_Port").Column
vUnixConn_Protocol_Type_ColNo = ObjWS_UnixConnection_Sheet.Range("A" &
vRowNoUC & ":" & Chr(vUnixConnection_UsedColCnt + 64) &
vRowNoUC).Find("Unix_Protocol_Type").Column
vPlinkExe_Location_ColNo = ObjWS_UnixConnection_Sheet.Range("A" &
vRowNoUC & ":" & Chr(vUnixConnection_UsedColCnt + 64) &
vRowNoUC).Find("PlinkExe_Location").Column
vPSFTPExe_Location_ColNo = ObjWS_UnixConnection_Sheet.Range("A" &
vRowNoUC & ":" & Chr(vUnixConnection_UsedColCnt + 64) &
vRowNoUC).Find("PSFTPExe_Location").Column
vHiveURL_Location_ColNo = ObjWS_UnixConnection_Sheet.Range("A"
& vRowNoUC & ":" & Chr(vUnixConnection_UsedColCnt + 64) &
vRowNoUC).Find("Hive_URL").Column
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
If Mid(Trim(varf_TC_Evidence_Location),
len(Trim(varf_TC_Evidence_Location)),1) <> "\" Then varf_TC_Evidence_Location =
Trim(varf_TC_Evidence_Location) & "\"
vHive_Command = varf_TC_Evidence_Location & "vHiveCommand" &
vStaticTimestamp_DDMMHHMM & ".txt"
vHive_CommandOutput = varf_TC_Evidence_Location & "vHive_CommandOutput"
& vStaticTimestamp_DDMMHHMM & ".txt"
Obj_FSO.CreateTextFile vHive_Command,true
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vHive_Command,2,True)
Redim preserve command(0)
command(0) = "hive --service beeline -u " & chr(34) &
vHiveURL_Location & chr(34) & " -e " & chr(34) & varf_RC_Hive_Query & ";" &
chr(34)
call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
End Function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_Unix_QA_FolderLocation,
varf_TC_Unix_FileName, varf_TC_QA_TargetFileLocation, varf_TC_Evidence_Location
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
If Mid(Trim(varf_TC_Evidence_Location),
len(Trim(varf_TC_Evidence_Location)),1) <> "\" Then varf_TC_Evidence_Location =
Trim(varf_TC_Evidence_Location) & "\"
vUnix_TestSpringXD_Command = varf_TC_Evidence_Location &
"vUnix_TestSpingXD_Command" & vStaticTimestamp_DDMMHHMM & ".txt"
vUnix_TestSpringXD_Command_Output = varf_TC_Evidence_Location &
"vUnix_TestSpingXD_Command_Output" & vStaticTimestamp_DDMMHHMM & ".txt"
Obj_FSO.CreateTextFile vUnix_TestSpringXD_Command,true
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vUnix_TestSpringXD_Command,2,True)
' Create and Execute the Plink command file into Unix
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
If Obj_FSO.FileExists(vUnix_TestSpringXD_Command_Output) Then
Set Obj_ReadOutput_File =
Obj_FSO.GetFile(vUnix_TestSpringXD_Command_Output)
vFlag ="NotFound"
If Obj_ReadOutput_File.Size > 0 Then
Set ObjRead_OutputFile =
Obj_FSO.OpenTextfile(vUnix_TestSpringXD_Command_Output,1)
Do Until ObjRead_OutputFile.AtEndOfStream
vReadColumnDT = ObjRead_OutputFile.ReadLine
If Instr(vReadColumnDT, "ExitCode") Then
vExitCodeVal = Split(vReadColumnDT,"-")
If trim(vExitCodeVal(1)) = "0" Then
vRemarksTC = "SpringXD is launched and the
connection is successful"
vStatus = "PASS"
Obj_ExeLog.WriteLine vRemarksTC
vFlag = "Found"
Exit do
End If
End If
Loop
ObjRead_OutputFile.Close
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
' When Hive Ouput didn't create a file
vRemarksTC = "The unix command output file is not created, there
may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & "Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
vFlag = ""
End Function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
varf_TC_HDFSLocation = Trim(Obj_Dict_RegTC("HDFS_FileName"))
varf_TC_BusinessDate = Trim(Obj_Dict_RegTC("BusinessDate"))
varf_TC_SourceSystem = Trim(Obj_Dict_RegTC("SourceSystem"))
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
If Mid(Trim(varf_TC_Evidence_Location), len(Trim(varf_TC_Evidence_Location)),1)
<> "\" Then varf_TC_Evidence_Location = Trim(varf_TC_Evidence_Location) & "\"
vClear_Command = varf_TC_Evidence_Location & ucase(varf_TC_SourceSystem) &
"_vClearCommand" & vStaticTimestamp_DDMMHHMM & ".txt"
vClear_CommandOutput = varf_TC_Evidence_Location & ucase(varf_TC_SourceSystem)
& "_vClearCommandOutput" & vStaticTimestamp_DDMMHHMM & ".txt"
Obj_FSO.CreateTextFile vClear_Command,true
Set vObj_HiveCmd_File_Dynamic = Obj_FSO.OpenTextFile(vClear_Command,2,True)
Redim preserve command(0)
command(0) = "ls /opt/cdhqa/logs/" & varf_TC_SourceSystem & "/" &
varf_TC_BusinessDate & ".log" & ";" & "echo ExitCode = $?"
' Write a test command to a input file
call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
Wshell.Run vExecute_CMD_Prompt,0,True
call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " & vPlinkExe_Location_Split(0) & ":" &
"&cd \ &cd " & Chr(34) & vPlinkExe_Location_Split(1) & Chr(34) & "&plink -t " &
varf_TC_UnixBox_HostName
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " -l " & vUnixConn_Server_USN
& " -pw " & vUnixConn_Server_PWD & " -m " & vLog_ClearCommandrm
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " > " &
vLog_ClearCommandOutputrm & " &exit"
Wshell.Run vExecute_CMD_Prompt,0,True
vStatus = "PASS"
Obj_ExeLog.WriteLine "Successfully removed the Log File for the
businessdate" & varf_TC_BusinessDate & " .Test case is passed "
Else
vStatus = "FAIL"
Obj_ExeLog.WriteLine "Failed in removing the Log File for the
businessdate " & varf_TC_BusinessDate & " .Test Case is Failed "
End if
Else
Obj_ExeLog.WriteLine "There is no Log File Exists for the businessdate
" & varf_TC_BusinessDate & " . Hence no need to perform any action"
vStatus = "PASS"
End if
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
Set vReadFile =
Obj_FSO.OpenTextfile(vHDFS_ClearCommandOutputrm,1)
strLine = vReadFile.ReadAll
If Instr(strline,"ExitCode = 0") > 0 Then
vStatus = "PASS"
Obj_ExeLog.WriteLine "Successfully removed the HDFS Folder
for the businessdate" & varf_TC_BusinessDate & " .Test case is passed "
Else
vStatus = "FAIL"
Obj_ExeLog.WriteLine vstatus & "Failed in removing the HDFS
folder for the businessdate " & varf_TC_BusinessDate & " .Test Case is Failed "
End if
Else
Obj_ExeLog.WriteLine "There is no HDFS Folder for the
businessdate " & varf_TC_BusinessDate & " . Hence no need to perform any action"
vstatus="PASS"
End if
End Function
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_Unix_QA_FolderLocation,
varf_TC_Unix_FileName, varf_TC_QA_TargetFileLocation, varf_TC_Evidence_Location
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_SystemName = Trim(Obj_Dict_RegTC("SystemName"))
varf_TC_BusinessDate = Trim(Obj_Dict_RegTC("BusinessDate"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
varf_AutosysBoxJob =
Trim(Obj_Dict_RegTC("Autosys_BoxJobName"))
varf_AutosysChildJob =
Trim(Obj_Dict_RegTC("Autosys_ChildJobName"))
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
vChildJobsSplit = split(Trim(varf_AutosysChildJob),",")
If Mid(Trim(varf_TC_Evidence_Location), len(Trim(varf_TC_Evidence_Location)),1)
<> "\" Then varf_TC_Evidence_Location = Trim(varf_TC_Evidence_Location) & "\"
vAutosys_KillCommand = varf_TC_Evidence_Location &
varf_TC_SystemName&"vAutosys_KillCommand" & vStaticTimestamp_DDMMHHMM & ".txt"
vAutosys_KillCommandOutput = varf_TC_Evidence_Location &
varf_TC_SystemName&"vAutosys_KillCommandOutput" & vStaticTimestamp_DDMMHHMM &
".txt"
Obj_FSO.CreateTextFile vAutosys_KillCommand,true
Set vObj_Cmd_File_Dynamic =
Obj_FSO.OpenTextFile(vAutosys_KillCommand,2,True)
vObj_Cmd_File_Dynamic.Write "source ./.profile;"
For i = 0 To ubound(vChildJobsSplit)
vObj_Cmd_File_Dynamic.Write "sendevent -e KILLJOB -J " &
vChildJobsSplit(i) & ";"
Next
vObj_Cmd_File_Dynamic.Write "sendevent -e KILLJOB -J " &
Trim(varf_AutosysBoxJob) & ";" & "sleep 10" & ";" & "autorep -J " &
Trim(varf_AutosysBoxJob) & ";"
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " & vPlinkExe_Location_Split(0) & ":" &
"&cd \ &cd " & Chr(34) & vPlinkExe_Location_Split(1) & Chr(34) & "&plink -t " &
varf_TC_UnixBox_HostName
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " -l " &
vUnixConn_Server_USN & " -pw " & vUnixConn_Server_PWD & " -m " &
vAutosys_KillCommand
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " > " &
vAutosys_KillCommandOutput
Wshell.Run vExecute_CMD_Prompt,0,True
'To check If any autosys Jobs are still in RU Status after killing them
For i = 0 To ubound(vChildJobsSplit)
Set vReadFile =
Obj_Fso.Opentextfile(vAutosys_KillCommandOutput,1)
Do until vReadFile.AtEndOfStream
vline = vReadFile.ReadLine
If Instr(replace(vline," ",""),vChildJobsSplit(i)) Then
'msgbox replace(vline," ","")
fileval = split(trim(vline)," ")
jobstatusval_su = fileval(ubound(fileval)-1)
If (Instr(split(vline,vChildJobsSplit(i))(1),"RU") >
0 and jobstatusval_ru=trim("RU")) Then
Obj_ExeLog.WriteLine split(trim(vline)," ")(0) & "
Job is Still Running"
JobsRunning = JobsRunning + 1
End If
End If
Loop
Next
If JobsRunning > 0 Then
Obj_ExeLog.WriteLine "One or more jobs are still not
Terminated. Hence stopping from trigerring the box job"
vStatus="FAIL"
Exit Function
else
Obj_ExeLog.WriteLine "The Child jobs and the Box job is Killed.
Hence trigerring the Box Job"
End If
k=0
Do while (k<1)
' msgbox "Value of k is " & k
For i = 0 To ubound(vChildJobsSplit) Step 1
Set vObj_Cmd_File_Dynamic =
Obj_FSO.OpenTextFile(vAutosysjobCheck_Command,2,True)
vObj_Cmd_File_Dynamic.Write "source ./.profile;autorep -J
" & Trim(varf_AutosysBoxJob) & ";"
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " &
vPlinkExe_Location_Split(0) & ":" & "&cd \ &cd " & Chr(34) &
vPlinkExe_Location_Split(1) & Chr(34) & "&plink -t " & varf_TC_UnixBox_HostName
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " -l " &
vUnixConn_Server_USN & " -pw " & vUnixConn_Server_PWD & " -m " &
vAutosysjobCheck_Command
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " > " &
vAutosysjobCheck_CommandOutput
Wshell.Run vExecute_CMD_Prompt,0,True
Set vReadFile =
Obj_FSO.OpenTextFile(vAutosysjobCheck_CommandOutput,1)
Do until vReadFile.AtEndOfStream
vline = vReadFile.ReadLine
If Instr(vline,vChildJobsSplit(i)) Then
'msgbox replace(vline," ","")
fileval = split(trim(vline)," ")
If cstr(fileval(0))=cstr(vChildJobsSplit(i)) Then
'msgbox jobstatusval_su
If (Instr(vline,jobstatusval_su) > 0 and
jobstatusval_su=trim("SU")) Then
'msgbox vline & "," & vChildJobsSplit(i)
JobsSuccess = JobsSuccess + 1
'Obj_ExeLog.WriteLine fileval(0) & " Job is
Successfull"
else
jobstatusval_fa = fileval(ubound(fileval)-2)
loop
End function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_Unix_QA_FolderLocation,
varf_TC_Unix_FileName, varf_TC_QA_TargetFileLocation, varf_TC_Evidence_Location
'Initialisation of variables
varf_TC_UnixBox_HostName =Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_SystemName = Trim(Obj_Dict_RegTC("SystemName"))
varf_TC_Syntax = Trim(Obj_Dict_RegTC("Syntax"))
varf_TC_BusinessDate = Trim(Obj_Dict_RegTC("BusinessDate"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
vMasterData_UsedColCnt =
Cint(ObjWS_Master_Data_Sheet.UsedRange.Columns.Count)
vMasterData_UsedRowCnt =
Cint(ObjWS_Master_Data_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
If Mid(Trim(varf_TC_Evidence_Location), len(Trim(varf_TC_Evidence_Location)),1)
<> "\" Then varf_TC_Evidence_Location = Trim(varf_TC_Evidence_Location) & "\"
'Create a new file to write the command to trigger the data loading script
vUnix_DataIngest_ViaScript_Command = varf_TC_Evidence_Location &
ucase(varf_TC_SystemName) & "_DataIngest_ViaScript_Command" &
vStaticTimestamp_DDMMHHMM & ".txt"
vUnix_DataIngest_ViaScript_CommandOutput = varf_TC_Evidence_Location &
ucase(varf_TC_SystemName) & "_DataIngest_ViaScript_CommandOutput" &
vStaticTimestamp_DDMMHHMM & ".txt"
Obj_FSO.CreateTextFile vUnix_DataIngest_ViaScript_Command,true
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vUnix_DataIngest_ViaScript_Command,2,True)
Call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
' Create and Execute the Plink command file into Unix
Obj_ExeLog.WriteLine "Triggering DataLoading through script for all tables of
system " & ucase(varf_TC_SystemName)
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
If Obj_FSO.FileExists(vUnix_DataIngest_ViaScript_CommandOutput) Then
Set Obj_ReadOutput_File =
Obj_FSO.GetFile(vUnix_DataIngest_ViaScript_CommandOutput)
If Obj_ReadOutput_File.Size > 0 Then
Set ObjRead_OutputFile =
Obj_FSO.OpenTextfile(vUnix_DataIngest_ViaScript_CommandOutput,1)
Do Until ObjRead_OutputFile.AtEndOfStream
vReadColumnDT = ObjRead_OutputFile.ReadLine
If Instr(vReadColumnDT, "ExitCode -") Then
If Instr(vReadColumnDT, "0") Then
vExitcodePassCount = vExitcodePassCount + 1
else
vExitcodeFailCount = vExitcodeFailCount + 1
End If
End If
Loop
ObjRead_OutputFile.Close
Else
vRemarksTC = "The unix command output file is 0KB, no data
into file. there may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
' When Hive Ouput didn't create a file
vRemarksTC = "The unix command output file is not created, there
may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & "Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
End function
Public Function f_Validate_Parquet_Validation(vTC_Name, Obj_Dict_Conf,
Obj_Dict_RegTC, ObjWS_ResultTC, ObjWB_Result, Obj_FSO, ObjXL_Main,
ObjWB_Master_Data, _
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_Unix_QA_FolderLocation,
varf_TC_Unix_FileName, varf_TC_QA_TargetFileLocation, varf_TC_Evidence_Location
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_SystemName = Trim(Obj_Dict_RegTC("SystemName"))
varf_TC_Syntax = Trim(Obj_Dict_RegTC("Syntax"))
varf_TC_BusinessDate = Trim(Obj_Dict_RegTC("BusinessDate"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
Set Wshell = CreateObject("Wscript.Shell")
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
vMasterData_UsedColCnt =
Cint(ObjWS_Master_Data_Sheet.UsedRange.Columns.Count)
vMasterData_UsedRowCnt =
Cint(ObjWS_Master_Data_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
Dim vSyntax_Val()
i=0
For vUnixCnt = 2 To vMasterData_UsedRowCnt Step 1
ReDim preserve vHdfsLoc_Val(i)
vHdfsLoc_Val(i) =
trim(ObjWS_Master_Data_Sheet.Cells(vUnixCnt,vHdfsLoc_ColNo).Value)
i=i+1
Next
Else
vRemarksTC = "Source system " & lcase(varf_TC_SystemName)
& "sheet does not exist in the Master Data workbook"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
If Mid(Trim(varf_TC_Evidence_Location), len(Trim(varf_TC_Evidence_Location)),1)
<> "\" Then varf_TC_Evidence_Location = Trim(varf_TC_Evidence_Location) & "\"
'Create a new file to write the command to trigger the data loading script
vUnix_ParquetValidation_Command = varf_TC_Evidence_Location &
ucase(varf_TC_SourceSystem) & "_vUnix_ParquetValidation_Command" &
vStaticTimestamp_DDMMHHMM & ".txt"
vUnix_ParquetValidation_CommandOutput = varf_TC_Evidence_Location &
ucase(varf_TC_SourceSystem) & "_vUnix_ParquetValidation_CommandOutput" &
vStaticTimestamp_DDMMHHMM & ".txt"
Obj_FSO.CreateTextFile vUnix_ParquetValidation_Command,true
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vUnix_ParquetValidation_Command,2,True)
For iCount = 0 To Ubound(vHdfsLoc_Val) Step 1
ReDim preserve command(iCount)
command(iCount) = "hadoop fs -ls " &
Replace(vHdfsLoc_Val(iCount),"$BZDATE",trim(varf_TC_BusinessDate))
Next
Call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
' Create and Execute the Plink command file into Unix
Obj_ExeLog.WriteLine "Parquet Validation check for all tables of system " &
ucase(varf_TC_SystemName)
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
If Obj_FSO.FileExists(vUnix_ParquetValidation_CommandOutput) Then
Set Obj_ReadOutput_File =
Obj_FSO.GetFile(vUnix_ParquetValidation_CommandOutput)
If Obj_ReadOutput_File.Size > 0 Then
vPresenceCount = 0
vAbsenceCount = 0
For iCount = 0 To Ubound(vHdfsLoc_Val) Step 1
Set ObjRead_OutputFile =
Obj_FSO.OpenTextfile(vUnix_ParquetValidation_CommandOutput,1)
Do Until ObjRead_OutputFile.AtEndOfStream
vReadColumnDT = ObjRead_OutputFile.ReadLine
vSearchStr =
Trim(Replace(vHdfsLoc_Val(iCount),"$BZDATE",trim(varf_TC_BusinessDate)))
If Instr(vReadColumnDT, vSearchStr) > 0 Then
If Instr(vReadColumnDT, "parquet") Then
Obj_ExeLog.WriteLine "INFO: Parquet
file is available in this location " &
Replace(vHdfsLoc_Val(iCount),"$BZDATE",trim(varf_TC_BusinessDate))
vPresenceCount = vPresenceCount + 1
Exit Do
Else
Obj_ExeLog.WriteLine "ERROR:
Parquet file is not available in this location " &
Replace(vHdfsLoc_Val(iCount),"$BZDATE",trim(varf_TC_BusinessDate))
vAbsenceCount = vAbsenceCount + 1
End If
End If
Loop
ObjRead_OutputFile.Close
Next
If vAbsenceCount>1 Then
Obj_ExeLog.WriteLine "Parquet files are not available
for " & vAbsenceCount & "file/s"
vStatus = "FAIL"
Else
Obj_ExeLog.WriteLine "Parquet files are available for
all file/s"
vStatus = "PASS"
End If
Else
vRemarksTC = "The unix command output file is 0KB, no data
into file. there may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
' When Hive Ouput didn't create a file
vRemarksTC = "The unix command output file is not created, there
may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & "Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
End function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_Unix_QA_FolderLocation,
varf_TC_Unix_FileName, varf_TC_QA_TargetFileLocation, varf_TC_Evidence_Location
'Initialisation of variables
varf_TC_UnixBox_HostName =Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_SystemName = Trim(Obj_Dict_RegTC("SystemName"))
varf_TC_BusinessDate = Trim(Obj_Dict_RegTC("BusinessDate"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
vMasterData_UsedColCnt =
Cint(ObjWS_Master_Data_Sheet.UsedRange.Columns.Count)
vMasterData_UsedRowCnt =
Cint(ObjWS_Master_Data_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
vSrcFileLoc_ColNo = ObjWS_Master_Data_Sheet.Range("A" & vRowNoUC
& ":" & Chr(vMasterData_UsedColCnt + 64) &
vRowNoUC).Find("SourceFile_Location").Column
vSrcFileName_ColNo = ObjWS_Master_Data_Sheet.Range("A" & vRowNoUC
& ":" & Chr(vMasterData_UsedColCnt + 64) & vRowNoUC).Find("SourceFile_Name").Column
If Mid(Trim(varf_TC_Evidence_Location),
len(Trim(varf_TC_Evidence_Location)),1) <> "\" Then varf_TC_Evidence_Location =
Trim(varf_TC_Evidence_Location) & "\"
vUnix_SourceCount_Command = varf_TC_Evidence_Location &
ucase(varf_TC_SystemName) & "_SourceCount_Command" & vStaticTimestamp_DDMMHHMM &
".txt"
vUnix_SourceCount_CommandOutput = varf_TC_Evidence_Location &
ucase(varf_TC_SystemName) & "_SourceCount_CommandOutput" &
vStaticTimestamp_DDMMHHMM & ".txt"
Obj_FSO.CreateTextFile vUnix_SourceCount_Command,true
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vUnix_SourceCount_Command,2,True)
iCount = 0
Call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
' Create and Execute the Plink command file into Unix
'Obj_ExeLog.WriteLine "Parquet Validation check for all tables of system " &
ucase(varf_TC_SystemName)
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
If Obj_FSO.FileExists(vUnix_SourceCount_CommandOutput) Then
Set Obj_ReadOutput_File =
Obj_FSO.GetFile(vUnix_SourceCount_CommandOutput)
If Obj_ReadOutput_File.Size > 0 Then
Select Case lcase(varf_TC_SystemName)
Case galaxy
Case Else
For Each vHiveTable in Obj_Dict_Src_Hive.Keys
Set ObjRead_OutputFile =
Obj_FSO.OpenTextfile(vUnix_SourceCount_CommandOutput,1)
Do Until ObjRead_OutputFile.AtEndOfStream
vReadColumnDT = ObjRead_OutputFile.ReadLine
vSearchStr =
Replace(trim(Obj_Dict_Src_Hive(vHiveTable)),"$BZDATE",trim(varf_TC_BusinessDate))
If Instr(vReadColumnDT, vSearchStr) > 0 Then
If vFirstLineHeader = "Y" Then
Print vReadColumnDT
Print Split(vReadColumnDT,":")(1)
vSrcCount =
clng(trim(Split(vReadColumnDT,":")(1)))-1
Print vSrcCount
Obj_Dict_SrcTable_Count.Add
trim(vHiveTable), trim(vSrcCount)
Exit Do
Else
vSrcCount =
trim(Split(vReadColumnDT,":")(1))
Obj_Dict_SrcTable_Count.Add
trim(vHiveTable), trim(vSrcCount)
Exit Do
End If
End If
Loop
ObjRead_OutputFile.Close
Next
End Select
Else
vRemarksTC = "The unix command output file is 0KB, no data
into file. there may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
' When Hive Ouput didn't create a file
vRemarksTC = "The unix command output file is not created, there
may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & "Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
'Fetching the Hive count for the respective system tables
vUnix_HiveCount_Command = varf_TC_Evidence_Location &
ucase(varf_TC_SystemName) & "_HiveCount_Command" & vStaticTimestamp_DDMMHHMM &
".txt"
vUnix_HiveCount_CommandOutput = varf_TC_Evidence_Location &
ucase(varf_TC_SystemName) & "_HiveCount_CommandOutput" &
vStaticTimestamp_DDMMHHMM & ".txt"
Obj_FSO.CreateTextFile vUnix_HiveCount_Command,true
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vUnix_HiveCount_Command,2,True)
iCount = 0
vHiveTable_Name_Val = ObjWS_Master_Data_Sheet.Cells(vRowMastCnt,
vHiveTable_ColNo).Value
vHiveDB_Name_Val = ObjWS_Master_Data_Sheet.Cells(vRowMastCnt,
vHiveDB_ColNo).Value
vHiveCountQuery = "select count(*) as " &
trim(vHiveTable_Name_Val) & " from " & vHiveDB_Name_Val & "." &
trim(vHiveTable_Name_Val) & " where businessdate=" & trim(varf_TC_BusinessDate)
ReDim preserve command(iCount)
command(iCount) = "hive --service beeline -u " & chr(34) &
"jdbc:hive2://" & vHiveURL & "/default;auth=maprsasl;saslQop=auth-conf;ssl=true" &
chr(34) & " -e " & chr(34) & vHiveCountQuery & ";" & chr(34)
iCount = iCount + 1
Next
Call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
' Create and Execute the Plink command file into Unix
'Obj_ExeLog.WriteLine "Parquet Validation check for all tables of system " &
ucase(varf_TC_SystemName)
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
If Obj_FSO.FileExists(vUnix_HiveCount_CommandOutput) Then
Set Obj_ReadOutput_File = Obj_FSO.GetFile(vUnix_HiveCount_CommandOutput)
If Obj_ReadOutput_File.Size > 0 Then
Set ObjRead_OutputFile =
Obj_FSO.OpenTextfile(vUnix_HiveCount_CommandOutput,1)
vTableIterator = 0
vCountIterator = 0
For Each vHiveTable in Obj_Dict_Src_Hive.Keys
Do Until ObjRead_OutputFile.AtEndOfStream
vReadColumnDT = ObjRead_OutputFile.ReadLine
If Instr(1,vReadColumnDT,"|") and
Instr(1,vReadColumnDT,vHiveTable) Then
Redim preserve vTable(vTableIterator)
vTable(vTableIterator) =
Split(vReadColumnDT,"|")(1)
Print "TableName: " &
vTable(vTableIterator)
ObjRead_OutputFile.skipline
vReadColumnDT =
ObjRead_OutputFile.ReadLine
Redim preserve vCount(vTableIterator)
vCount(vTableIterator) =
Split(vReadColumnDT, "|")(1)
Print "Count: " & vCount(vTableIterator)
vTableIterator = vTableIterator + 1
Exit Do
End If
' ElseIf Instr(1,vReadColumnDT,"|") and
Instr(1,vReadColumnDT,vHiveTable) = 0 Then
' Redim preserve vCount(vCountIterator)
' vCount(vCountIterator) =
Split(vReadColumnDT, "|")(1)
' Print "Count: " & vCount(vCountIterator)
' vCountIterator = vCountIterator + 1
' End if
Loop
Next
ObjRead_OutputFile.Close
If Obj_Dict_SrcTable_Count.Count <>
Obj_Dict_Hive_Count.Count Then
Obj_ExeLog.WriteLine "Mismatch in the number of
source files and hive table"
Else
arrKeys = Obj_Dict_SrcTable_Count.Keys
For i = 0 to ubound(arrKeys) step 1
Obj_ExeLog.WriteLine "INFO: Source File Count
for " & arrKeys(i) & " is " & Obj_Dict_SrcTable_Count(arrKeys(i))
Print "INFO: Source File Count for " &
arrKeys(i) & " is " & Obj_Dict_SrcTable_Count(arrKeys(i))
Obj_ExeLog.WriteLine "INFO:Hive Count for " &
arrKeys(i) & " is " & Obj_Dict_Hive_Count(arrKeys(i))
Print "INFO:Hive Count for " & arrKeys(i) & "
is " & Obj_Dict_Hive_Count(arrKeys(i))
If Not Obj_Dict_Hive_Count.Exists(arrKeys(i))
Then
Obj_ExeLog.WriteLine "ERROR: Hive Table "
& ucase(arrKeys(i)) & "is not present in the source file list"
Print "ERROR: Hive Table " &
ucase(arrKeys(i)) & "is not present in the source file list"
vStatus = "FAIL"
ElseIf Obj_Dict_SrcTable_Count(arrKeys(i)) =
Obj_Dict_Hive_Count(arrKeys(i)) Then
Obj_ExeLog.WriteLine "INFO: Source and
Hive Count is matching"
Print "INFO: Source and Hive Count is
matching"
vStatus = "PASS"
Else
Obj_ExeLog.WriteLine "ERROR: Source and
Hive Count is not matching"
vStatus = "FAIL"
End If
Next
End If
Else
vRemarksTC = "The unix command output file is 0KB, no data
into file. there may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
' When Hive Ouput didn't create a file
vRemarksTC = "The unix command output file is not created, there
may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & "Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
End If
End Function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_Unix_QA_FolderLocation,
varf_TC_Unix_FileName, varf_TC_QA_TargetFileLocation, varf_TC_Evidence_Location
'Initialisation of variables
varf_TC_UnixBox_HostName =Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_SystemName = Trim(Obj_Dict_RegTC("SystemName"))
varf_TC_BusinessDate = Trim(Obj_Dict_RegTC("BusinessDate"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
vMasterData_UsedColCnt =
Cint(ObjWS_Master_Data_Sheet.UsedRange.Columns.Count)
vMasterData_UsedRowCnt =
Cint(ObjWS_Master_Data_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
vLogFileLoc_ColNo = ObjWS_Master_Data_Sheet.Range("A" & vRowNoUC
& ":" & Chr(vMasterData_UsedColCnt + 64) &
vRowNoUC).Find("LogFile_Location").Column
vLogMessage_ColNo = ObjWS_Master_Data_Sheet.Range("A" & vRowNoUC
& ":" & Chr(vMasterData_UsedColCnt + 64) & vRowNoUC).Find("Log_Message").Column
If Mid(Trim(varf_TC_Evidence_Location),
len(Trim(varf_TC_Evidence_Location)),1) <> "\" Then varf_TC_Evidence_Location =
Trim(varf_TC_Evidence_Location) & "\"
vUnix_LogFileErrorMsg_Command = varf_TC_Evidence_Location &
ucase(varf_TC_SystemName) & "_LogFileErrorMsg_Command" & vStaticTimestamp_DDMMHHMM
& ".txt"
vUnix_LogFileErrorMsg_CommandOutput = varf_TC_Evidence_Location &
ucase(varf_TC_SystemName) & "_LogFileErrorMsg_CommandOutput" &
vStaticTimestamp_DDMMHHMM & ".txt"
Obj_FSO.CreateTextFile vUnix_LogFileErrorMsg_Command,true
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vUnix_LogFileErrorMsg_Command,2,True)
iCount = 0
Next
Call
f_WriteCommand_TextFile( vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
Erase command
' Create and Execute the Plink command file into Unix
Obj_ExeLog.WriteLine "Checking for ERROR message in the log file for system "
& ucase(varf_TC_SystemName)
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
Else
vRemarksTC = "The unix command output file is 0KB, no data
into file. there may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
' When Hive Ouput didn't create a file
vRemarksTC = "The unix command output file is not created, there
may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & "Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
End If
End Function
Public Function f_DataUpload_into_HiveTempTable(vTC_Name, Obj_Dict_Conf,
Obj_Dict_RegTC, ObjWS_ResultTC, ObjWB_Result, Obj_FSO, ObjXL_Main,
ObjWB_Master_Data, _
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_Source_DBName, varf_TC_Source_TableName,
varf_TC_Source_ColumnSheet, varf_TC_Source_Partition_WC
Dim varf_TC_QA_DatabaseName, varf_TC_QA_TableName,
varf_TC_QA_Table_HDFS_Location,
varf_TC_QA_ColumnDelimiter,varf_TC_HiveOutput_Location
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_Source_DBName = Trim(Obj_Dict_RegTC("Source_DatabaseName"))
varf_TC_Source_TableName = Trim(Obj_Dict_RegTC("Source_TableName"))
varf_TC_Source_ColumnSheet = Trim(Obj_Dict_RegTC("Source_ColumnSheet"))
varf_TC_Source_Partition_WC =
Trim(Obj_Dict_RegTC("Source_Partition_WhereClause"))
varf_TC_QA_DatabaseName = Trim(Obj_Dict_RegTC("QA_DatabaseName"))
varf_TC_QA_TableName = Trim(Obj_Dict_RegTC("QA_TableName"))
varf_TC_QA_Table_HDFS_Location =
Trim(Obj_Dict_RegTC("QA_Table_HDFS_Location"))
varf_TC_QA_ColumnDelimiter = Trim(Obj_Dict_RegTC("ColumnDelimiter"))
varf_TC_HiveOutput_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
'Create the objects
Set ObjDict_SourceCol_Status = CreateObject("Scripting.Dictionary")
Set Wshell = CreateObject("Wscript.Shell")
' Extract the Hive column - file path and sheet name from variable
varf_TC_Source_ColumnSheet. Also copy the hive column sheet to result xl
' Establish the worksheet object for hive column available in result xl
If Instr(1, varf_TC_Source_ColumnSheet, "$HiveColumn_FilePath") > 0 And
Instr(1,varf_TC_Source_ColumnSheet,"@HiveColumn_SchemaSheet") > 0 Then
varf_HiveColumn_FilePath =
Trim(Replace(Replace(Split(Replace(varf_TC_Source_ColumnSheet,"$HiveColumn_FilePath
",""),"@HiveColumn_SchemaSheet")(0),"=",""),Chr(10),""))
varf_HiveColumn_SchemaSheet =
Trim(Replace(Replace(Split(Replace(varf_TC_Source_ColumnSheet,"$HiveColumn_FilePath
",""),"@HiveColumn_SchemaSheet")(1),"=",""),Chr(10),""))
If Func_Worksheet_Exist(varf_HiveColumn_SchemaSheet, ObjWB_Result) =1 Then
Set ObjWS_HiveColumn_Schema =
ObjWB_Result.Worksheets(varf_HiveColumn_SchemaSheet)
ElseIf Obj_FSO.FileExists(varf_HiveColumn_FilePath) Then
Set ObjWB_HiveColumn_Schema =
ObjXL_Main.WorkBooks.Open(varf_HiveColumn_FilePath)
If Func_Worksheet_Exist(varf_HiveColumn_SchemaSheet,
ObjWB_HiveColumn_Schema) =1 Then
ObjWB_HiveColumn_Schema.WorkSheets(varf_HiveColumn_SchemaSheet).Copy
,ObjWB_Result.Worksheets(vTD_UnixCrdnSheet) ' copy hive column sheet to result
report
Set ObjWS_HiveColumn_Schema =
ObjWB_Result.Worksheets(varf_HiveColumn_SchemaSheet)
Else
vRemarksTC = "The sheet "& varf_HiveColumn_SchemaSheet & "
mentioned in Refcolumn is not exist in the file" & varf_HiveColumn_FilePath
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & "Test case is failed"
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
ObjWB_HiveColumn_Schema.Close
Else
vRemarksTC = "The excel file mentioned in Refcolumn is not exist -
- " & varf_HiveColumn_FilePath
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
ElseIf
Func_Worksheet_Exist(Trim(Replace(Replace(Replace(varf_TC_Source_ColumnSheet,"@Hive
Column_SchemaSheet",""),"-",""),Chr(10),"")), ObjWB_Result) =1 Then
Set ObjWS_HiveColumn_Schema =
ObjWB_Result.WorkSheets(Trim(Replace(Replace(Replace(varf_TC_Source_ColumnSheet,"@H
iveColumn_SchemaSheet",""),"-",""),Chr(10),"")))
Else
vRemarksTC = "Ref column sheet variable may be empty or expected keywords
are missing like $HiveColumn_FilePath and @HiveColumn_SchemaSheet"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
' Create the column number variables to fetch the hive column values from sheet
vHiveColumn_UsedColCnt =
Cint(ObjWS_HiveColumn_Schema.UsedRange.Columns.Count)
vHiveColumn_UsedRowCnt =
Cint(ObjWS_HiveColumn_Schema.UsedRange.Rows.Count)
vRowNoHC = 1
' Fetch the column Names into a variable and that will be used in command to
create temp table
For vSColDT_RowCnt = 2 To vHiveColumn_UsedRowCnt
vHC_Source_ColumnNames =
Ucase(Trim(ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt,
vHC_Source_ColumnNames_ColNo).Value))
vHC_HiveCol_MatchStatus =
Ucase(Trim(ObjWS_HiveColumn_Schema.Cells(vSColDT_RowCnt, vHC_Status_ColNo).Value))
If vHC_Source_ColumnNames<>"" Or vHC_HiveCol_MatchStatus<>"FAIL" then
ObjDict_SourceCol_Status.Add vHC_Source_ColumnNames, vHC_HiveCol_MatchStatus
Next
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
If Func_Worksheet_Exist(vTD_UnixCrdnSheet, ObjWB_Result) =1 Then
Set ObjWS_UnixConnection_Sheet =
ObjWB_Result.Worksheets(vTD_UnixCrdnSheet)
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
' Output file name with time stamp(static time stamp from function parameter)
If Mid(Trim(varf_TC_HiveOutput_Location),
len(Trim(varf_TC_HiveOutput_Location)),1) <> "\" Then varf_TC_HiveOutput_Location =
Trim(varf_TC_HiveOutput_Location) & "\"
vHiveOutput_FileNameLocation = varf_TC_HiveOutput_Location &
"HiveTempTableConfirm_" & vStaticTimestamp_DDMMHHMM & ".txt"
vHiveOutput_CommandFileLocation = varf_TC_HiveOutput_Location &
"HiveCreateCommand_TempTable_" & vStaticTimestamp_DDMMHHMM & ".txt"
' Extract the column delimiter from testdata and standardise into hive format
Select Case Trim(Ucase(varf_TC_QA_ColumnDelimiter))
Case "PIPE" varf_TC_QA_ColumnDelimiter = Chr(39) & Chr(124) & Chr(39)
Case "COMMA" varf_TC_QA_ColumnDelimiter = Chr(39) & Chr(44) & Chr(39)
Case "DOT" varf_TC_QA_ColumnDelimiter = Chr(39) & Chr(46) & Chr(39)
End Select
' Write a script to dynamicaly create a hive command file and each line should have
output file
Set vObj_HiveCmd_File_Dynamic =
Obj_FSO.OpenTextFile(vHiveOutput_CommandFileLocation,2,True)
vObj_HiveCmd_File_Dynamic.WriteLine "hive -e " & Chr(34) & "DROP TABLE IF EXISTS
" & varf_TC_QA_DatabaseName & "." & varf_TC_QA_TableName & ";" & Chr(34)
vObj_HiveCmd_File_Dynamic.WriteLine "hive -e " & Chr(34) & "CREATE TABLE " &
varf_TC_QA_DatabaseName & "." & varf_TC_QA_TableName & _
" ROW FORMAT DELIMITED FIELDS TERMINATED BY
" & varf_TC_QA_ColumnDelimiter & " LINES TERMINATED BY '\n' LOCATION " &_
Chr(39) & varf_TC_QA_Table_HDFS_Location &
varf_TC_QA_TableName & Chr(39) & "STORED AS TEXTFILE AS SELECT " &
vHiveTemptable_ColNames & " FROM " & _
varf_TC_Source_DBName & "." &
varf_TC_Source_TableName & varf_TC_Source_Partition_WC & ";" & Chr(34)
vObj_HiveCmd_File_Dynamic.WriteLine "hdfs dfs -ls " &
varf_TC_QA_Table_HDFS_Location & varf_TC_Source_TableName
vObj_HiveCmd_File_Dynamic.Close
' Create and Execute the Plink command file into Unix
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " & vPlinkExe_Location_Split(0) & ":" & "&cd \
&cd " & Chr(34) & vPlinkExe_Location_Split(1) & Chr(34) & "&plink " &
varf_TC_UnixBox_HostName
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " -l " & vUnixConn_Server_USN & "
-pw " & vUnixConn_Server_PWD & " -m " & vHiveOutput_CommandFileLocation
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " > " &
vHiveOutput_FileNameLocation & " &exit"
Wshell.Run vExecute_CMD_Prompt,0,True
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
vRemarksTC = "The unix command output file is not created, there may be
error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
End Function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_QA_Table_HDFSLocation,
varf_TC_Unix_QA_FolderLocation
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_QA_Table_HDFSLocation = Trim(Obj_Dict_RegTC("QA_Table_HDFSLocation"))
varf_TC_Unix_QA_FolderLocation =
Trim(Obj_Dict_RegTC("Unix_QA_FolderLocation"))
varf_TC_HDFS_FileName = Trim(Obj_Dict_RegTC("HDFS_FileName"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
If Func_Worksheet_Exist(vTD_UnixCrdnSheet, ObjWB_Result) =1 Then
Set ObjWS_UnixConnection_Sheet =
ObjWB_Result.Worksheets(vTD_UnixCrdnSheet)
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
' Output file name with time stamp(static time stamp from function parameter)
If Mid(Trim(varf_TC_QA_Table_HDFSLocation),
len(Trim(varf_TC_QA_Table_HDFSLocation)),1) <> "/" Then
varf_TC_QA_Table_HDFSLocation = Trim(varf_TC_QA_Table_HDFSLocation) & "/"
If Mid(Trim(varf_TC_Unix_QA_FolderLocation),
len(Trim(varf_TC_Unix_QA_FolderLocation)),1) <> "/" Then
varf_TC_Unix_QA_FolderLocation = Trim(varf_TC_Unix_QA_FolderLocation) & "/"
If Mid(Trim(varf_TC_Evidence_Location), len(Trim(varf_TC_Evidence_Location)),1)
<> "\" Then varf_TC_Evidence_Location = Trim(varf_TC_Evidence_Location) & "\"
vHDFS_FileCopyConfirmation = varf_TC_Evidence_Location &
"HDFS_FileCopyConfirmation_" & vStaticTimestamp_DDMMHHMM & ".txt"
vHDFS_GETCommand = varf_TC_Evidence_Location & "HDFS_GetCommand_" &
vStaticTimestamp_DDMMHHMM & ".txt"
' Write a script to dynamicaly create a hive command file and each line should have
output file
Set vObj_HiveCmd_File_Dynamic = Obj_FSO.OpenTextFile(vHDFS_GETCommand,2,True)
vObj_HiveCmd_File_Dynamic.WriteLine "rm -r " & varf_TC_Unix_QA_FolderLocation &
varf_TC_HDFS_FileName
vObj_HiveCmd_File_Dynamic.WriteLine "hdfs dfs -get " &
varf_TC_QA_Table_HDFSLocation & "* " & varf_TC_Unix_QA_FolderLocation &
varf_TC_HDFS_FileName
vObj_HiveCmd_File_Dynamic.WriteLine "ls " & varf_TC_Unix_QA_FolderLocation &
varf_TC_HDFS_FileName
vObj_HiveCmd_File_Dynamic.Close
' Create and Execute the Plink command file into Unix
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " & vPlinkExe_Location_Split(0) & ":" & "&cd \
&cd " & Chr(34) & vPlinkExe_Location_Split(1) & Chr(34) & "&plink " &
varf_TC_UnixBox_HostName
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " -l " & vUnixConn_Server_USN & "
-pw " & vUnixConn_Server_PWD & " -m " & vHDFS_GETCommand
vExecute_CMD_Prompt = vExecute_CMD_Prompt & " > " & vHDFS_FileCopyConfirmation
Wshell.Run vExecute_CMD_Prompt,0,True
If Obj_FSO.FileExists(vHDFS_FileCopyConfirmation) Then
Set Obj_ReadProp_File = Obj_FSO.GetFile(vHDFS_FileCopyConfirmation)
If Obj_ReadProp_File.Size > 0 Then
Set vObjRead_HDFSFileConfirm =
Obj_FSO.OpenTextFile(vHDFS_FileCopyConfirmation,1)
vUnix_FileLocation_available =
Replace(Replace(Trim(vObjRead_HDFSFileConfirm.ReadAll),Chr(10),""),Chr(13),"")
If StrComp(varf_TC_Unix_QA_FolderLocation & varf_TC_HDFS_FileName,
vUnix_FileLocation_available) = 0 Then
vStatus = "PASS"
vRemarksTC = vUnix_FileLocation_available & " File copied
from HDFS to Unix successfully"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Else
vStatus = "FAIL"
vRemarksTC = varf_TC_Unix_QA_FolderLocation &
varf_TC_HDFS_FileName & " Unable to copy file from HDFS to Unix"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
End If
vObjRead_HDFSFileConfirm.Close
Else
vRemarksTC = "The unix command output file is 0KB, no data into
file. there may be error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
Else
vRemarksTC = "The unix command output file is not created, there may be
error or issue with command while executing"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
End Function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
'Decalaration Of variables
Dim varf_TC_UnixBox_HostName, varf_TC_Unix_QA_FolderLocation,
varf_TC_Unix_FileName, varf_TC_QA_TargetFileLocation, varf_TC_Evidence_Location
'Initialisation of variables
varf_TC_UnixBox_HostName = Trim(Obj_Dict_RegTC("UnixBox_HostName"))
varf_TC_Unix_QA_FolderLocation =
Trim(Obj_Dict_RegTC("Unix_QA_FolderLocation"))
varf_TC_Unix_FileName = Trim(Obj_Dict_RegTC("Unix_FileName"))
varf_TC_QA_TargetFileLocation =
Trim(Obj_Dict_RegTC("QA_TargetFile_into_Local"))
varf_TC_Evidence_Location = Trim(Obj_Dict_RegTC("Evidence_Location"))
' Extract the unix details -USN, PWD, Plink location, PSFTP location from Unix
Connection details sheet
If Func_Worksheet_Exist(vTD_UnixCrdnSheet, ObjWB_Result) =1 Then
Set ObjWS_UnixConnection_Sheet =
ObjWB_Result.Worksheets(vTD_UnixCrdnSheet)
vUnixConnection_UsedColCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Columns.Count)
vUnixConnection_UsedRowCnt =
Cint(ObjWS_UnixConnection_Sheet.UsedRange.Rows.Count)
vRowNoUC = 1
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value = vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
End If
Else
vRemarksTC = "Unix Credential sheet "& vTD_UnixCrdnSheet & " not found in
the test data file, Please add the sheet and rerun the regression suite"
ObjWS_ResultTC.Cells(vTC_FuncRowNo_Value,vFuncTC_Remarks_ColNo).Value =
vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC
Obj_ExeLog.WriteLine vRemarksTC & " Test case is failed "
Obj_ExeLog.WriteBlankLines 1
vStatus = "FAIL"
Exit Function
End If
' Output file name with time stamp(static time stamp from function parameter)
If Mid(Trim(varf_TC_Unix_QA_FolderLocation),
len(Trim(varf_TC_Unix_QA_FolderLocation)),1) <> "/" Then
varf_TC_Unix_QA_FolderLocation = Trim(varf_TC_Unix_QA_FolderLocation) & "/"
If Mid(Trim(varf_TC_QA_TargetFileLocation),
len(Trim(varf_TC_QA_TargetFileLocation)),1) <> "\" Then
varf_TC_QA_TargetFileLocation = Trim(varf_TC_QA_TargetFileLocation) & "\"
If Mid(Trim(varf_TC_Evidence_Location), len(Trim(varf_TC_Evidence_Location)),1)
<> "\" Then varf_TC_Evidence_Location = Trim(varf_TC_Evidence_Location) & "\"
vUnix_GETCommand = varf_TC_Evidence_Location & "Unix_GetCommand_" &
vStaticTimestamp_DDMMHHMM & ".txt"
' Write a script to dynamicaly create a hive command file and each line should have
output file
Set vObj_HiveCmd_File_Dynamic = Obj_FSO.OpenTextFile(vUnix_GETCommand,2,True)
vObj_HiveCmd_File_Dynamic.WriteLine "lcd " & varf_TC_QA_TargetFileLocation
vObj_HiveCmd_File_Dynamic.WriteLine "get " & varf_TC_Unix_QA_FolderLocation &
varf_TC_Unix_FileName
vObj_HiveCmd_File_Dynamic.Close
' Create and Execute the Plink command file into Unix
vPsftpExe_Location_Split = Split(vPSFTPExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " & vPsftpExe_Location_Split(0) & ":" & "&cd \
&cd " & Chr(34) & vPsftpExe_Location_Split(1) & Chr(34) & "&psftp " &
vUnixConn_Server_USN
vExecute_CMD_Prompt = vExecute_CMD_Prompt & "@" & varf_TC_UnixBox_HostName & "
-pw " & vUnixConn_Server_PWD & " -b " & vUnix_GETCommand
Wshell.Run vExecute_CMD_Prompt,0,True
End Function
vTD_DbCrdnSheet,vTD_UnixCrdnSheet,vStaticTimestamp_DDMMHHMM,Obj_ExeLog,vFuncTC_Rema
rks_ColNo,vTC_FuncRowNo_Value,vStatus)
vStatus ="PASS"
End Function
'**********************************************************************************
**************************
' GENERIC FUNCTIONS
'**********************************************************************************
**************************
'==================================================================================
==========================
'Generic Function Name : Unix job Verification
'Description :
'==================================================================================
==========================
Public Function f_UnixProcess_Verification (vTC_Name, Obj_Dict_Conf,
Obj_Dict_RegTC, ObjWB_Result, Obj_FSO, ObjXL_Main, vStatus)
vStatus = "PASS"
End Function
'==================================================================================
==========================
'Generic Function Name : Func_Worksheet_Exist
'Description :
'==================================================================================
==========================
'==================================================================================
==========================
'Generic Function Name : Kill Windows Process
'Description :
'==================================================================================
'==================================================================================
==========================
'Generic Function Name : Func_UpdateStatus
'Description :
'==================================================================================
End Function
'==================================================================================
==========================
'Generic Function Name : f_WriteCommand_TextFile
'Description : Write Unix command based on the Unix environment to a text file
'==================================================================================
Public Function
f_WriteCommand_TextFile(vObj_HiveCmd_File_Dynamic,varf_TC_UnixBox_HostName,
command)
For commandcount = 0 to ubound(command)
if(varf_TC_UnixBox_HostName="wupra92a0033.mylocal.com" or
varf_TC_UnixBox_HostName="wupra92a0201.mylocal.com") then
vObj_HiveCmd_File_Dynamic.WriteLine "su - cdhqa -c " & chr(39) &
command(commandcount) &chr(39)
Else
vObj_HiveCmd_File_Dynamic.WriteLine command(commandcount)
End If
Next
vObj_HiveCmd_File_Dynamic.Close
End Function
Public Function SenMail(SendTo, Subject, Body, Attachment)
Set Otl = CreateObject("Outlook.Application")
Set m = otl.CreateItem(0)
m.to = SendTo
m.Subject = subject
m.Body = Body
mail.attachment.Add(Attachment)
m.Send
otl.Quit
End Function
'==================================== End Function
==========================================
'**********************************************************************************
**************************
' QC Driver Script
'**********************************************************************************
**************************
sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
Set dri_FSO = CreateObject("Scripting.FileSystemObject")
Set Dr_ExcelObj = CreateObject("Excel.Application")
If dri_FSO.FileExists(sCurPath & "\QC_Details_Driver.xlsx") Then
Set Dr_Wrbook = Dr_ExcelObj.Workbooks.Open(sCurPath & "\QC_Details_Driver.xlsx")
Set Dr_Wsheet = Dr_Wrbook.Worksheets("QC_Details")
'******** Capturing the column number of the test data sheet ************
vTotColumnUsed = Dr_Wsheet.UserRange.Columns.Count
vTotRowUsed = Dr_Wsheet.UserRange.Rows.Count
vRowNoConf = 2
vQC_Trigger_Flag = Dr_Wsheet.Cells(2,vQC_Trigger_Flag_ColNo).Value
qcServer = Dr_Wsheet.Cells(2,vQC_Server_ColNo).Value
qcUser = Dr_Wsheet.Cells(2,vQC_User_ColNo).Value
qcPassword = Dr_Wsheet.Cells(2,vQC_Password_ColNo).Value
qcDomain = Dr_Wsheet.Cells(2,vQC_Domain_ColNo).Value
qcProject = Dr_Wsheet.Cells(2,vQC_Project_ColNo).Value
HostName = Dr_Wsheet.Cells(2,vHostName_ColNo).Value
RunWhere = Dr_Wsheet.Cells(2,vRunWhere_ColNo).Value
TDFolderPath = Dr_Wsheet.Cells(2,vTDFolder_Path_ColNo).Value
TDAttachmentName = Dr_Wsheet.Cells(2,vTD_AttachmentName_ColNo).Value
TSFolderName = Dr_Wsheet.Cells(2,vTSFolderName_ColNo).Value
TSetName = Dr_Wsheet.Cells(2,vTestSetName_ColNo).Value
ResFolderPath = Dr_Wsheet.Cells(2,vResultFolderPath_ColNo).Value
fldPath_Local = Dr_Wsheet.Cells(2,vFdrPath_Local_ColNo).Value
lclPath = fldPath_Local & "\"
vResult_Folder = fldPath_Local & "\"
vRes_testdata = vResult_Folder & "TestData.xls"
vRes_FA_UI = vResult_Folder & "Result_FA_UI_Auto.xlsx"
'*********** Downloading the Testdata.xls file into local only if not exist
************
If Not (dri_FSO.FileExists(lclPath & TDAttachment)) Then
Set otaSysTreeNode = otaTreeManager.NodeByPath(TDFolderPath)
Set otaAttachmentFactory = otaSysTreeNode.Attachments
Set otaAttachmentFilter = otaAttachmentFactory.Filter
otaAttachmentFilter.Filter("CR_REFERENCE") = "'ALL_LIST_" &
otaSysTreeNode.NodeID & "_" & TDAttachmentName & "'"
otaAttachmentList = otaAttachementFilter.NewList
If otaAttachmentList.Count > 0 Then
Set otaAttachment = otaAttachmentList.Item(1)
otaAttachment.Load True, ""
StrPath = otaAttachment.FileName
If (dri_FSO.FileExists(otaAttachment.FileName)) Then
dri_FSO.CopyFile StrPath, lclPath & "\" & TDAttachmentName
DownloadAttachment = lclPath & "\" & TDAttachmentName
Else
DownloadAttachment = StrPath
End If
End If
End If
'********* Validate if run is completed and sync the script till it get finished
***********
'***** Uploading the results into QC both testdata and application specific
*************
If IsRunning("UFT.exe") Then
KillProcesses("UFT.exe")
End If
If IsRunning("AQTRmtAgent.exe") Then
KillProcesses("UFT.exe")
End If
If IsRunning("TERun.exe") Then
KillProcesses("UFT.exe")
End If
If IsRunning("EXTRA.exe") Then
KillProcesses("UFT.exe")
End If
tdc.ReleaseConnection
'*********** if Required file not exist then below msgbox will pop up and stops
the script **************
Else
Msgbox "QC_Details.xlsx file not in required location " & Chr(10) & "Please
copy the file in below location and ReRun the script" & Chr(10) & Chr(34) &
sCurPath & Chr(34),4160
End If
End Function
'==================================== End Function
==========================================
'**********************************************************************************
**************************
' QTP Automation Object module Script
'**********************************************************************************
**************************
Public Function QTP_AOM(test_path, lib_path, tsr_path, result_path)
Dim qtApp
Dim qtLibraries, qtRepo
Dim qtResultopt
Set qtApp = CreateObject("QuickTest.Application")
vExistAddin_Test = qtApp.GetAssociatedAddinsForTest(test_path)
AddinList = Array("Web", "WPF","ActiveX")
qtApp.SetActiveAddins(AddinList)
qtApp.Launch
qtApp.Visible = True
qtApp.Open test_path, True
qtApp.Test.Settings.Resources.Libraries.RemoveAll
qtApp.Test.Settings.Resources.Libraries.Add(lib_path)
qtApp.Test.Actions.Item(1).ObjectRepositories.RemoveAll
qtApp.Test.Actions.Item(1).ObjectRepositories.Add(tsr_path)
qtApp.Options.Run.RunMode = "Fast"
qtApp.Options.Run.ImageCaptureForTestResults = "Never"
qtApp.Options.Run.MovieCaptureForTestResults = "Never"
'qtApp.Options.ObjectIdentification("WinEdit").MandatoryProperties
'qtApp.Options.ObjectIdentification("WinEdit").AssistiveProperties
'qtApp.Options.ObjectIdentification("WinEdit").BaseFilterProperties
'qtApp.Options.ObjectIdentification("WinEdit").AvailableProperties
'qtApp.Options.ObjectIdentification("WinEdit").OrdinalIdentifier
qtApp.Test.Settings.Run.ObjectSyncTimeOut = 25000
qtApp.Test.Settings.Run.DisableSmartIdentification = False
qtApp.Test.Settings.Run.IterationMode = "rngIterations"
qtApp.Test.Settings.Run.StartIteration = 1
qtApp.Test.Settings.Run.EndIteration = 1
qtApp.Test.Settings.Run.OnError = "Dialog"
qtApp.Test.Run(qtResultOpt)
qtApp.Test.Save
qtApp.Quit
CURD_OPP = "KHADEER"
SERVER_LINK = "http://wupra92a0201.mylocal.com:8086/users/u540458"
'POST_MSG = ""USN = "u403516"
PWD = "QADIr123"
End Function
BZ_DATE = "10/27/2016"
'**********************************************************************************
**************************
'Project Name : <iHub Regression Suite>
'Author : Khadeer
'Creation Date : 2-NOV-2016
'Module Name : Controller
'Description : Regression tool is used to compare iHUB tables with
HIVE and TERADATA. Also provide report about Autosys status and duartion of each
job run
'**********************************************************************************
**************************
'Option Explicit
'==================================================================================
==========================
'Declaration of Variables
'==================================================================================
==========================
Dim varf_TC_UnixBox_HostName, vUnixConn_Server_USN, vUnixConn_Server_PWD,
Log_FileLocation_unix
Dim vAutomationHomeDir_Location,
vPlinkExe_Location,vConfig_File_Loc,vConfig_File_Name,vConfig_SheetName,vExecutionL
og_FileName,vResSummary_FileName
Dim objFSO,Obj_ExeLog,ObjXL_main,Obj_Wsh,Obj_Dict_Conf
'==================================================================================
==========================
'Initialisation of variable whose values will be constant
'==================================================================================
==========================
'Create and define the log file and validate the any Excel files are opened
If Not CreateObject("Scripting.FileSystemObject").FolderExists(vResultFDR_Loc) Then
CreateObject("Scripting.FileSystemObject").CreateFolder vResultFDR_Loc
Set Obj_ExeLog =
CreateObject("Scripting.FileSystemObject").OpenTextFile(vResultFDR_Loc &
vExecutionLog_FileName,2,True)
' Before execution begin close all excel files currently opened or terminate script
Select Case Msgbox("Please Save the excel files opened and click OK" & Chr(10) &
"Cancel will stop execution",1)
Case 1 Call KillProcessor("EXCEL.EXE")
Case 2 vterminate_msg = "Execution stopped " & Chr(10) & "User not save &
close the excel file"
Call Func_TerminateExec(vterminate_msg,Obj_ExeLog)
End Select
'==================================================================================
==========================
'Defining the class objects FSO, Wscript, Excel, Dictionary
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set ObjXL_main = CreateObject("Excel.Application")
Set Obj_Wsh = CreateObject("Wscript.Shell")
Set Obj_WshNet = CreateObject("WScript.Network")
Set Obj_Dict_Conf = CreateObject("Scripting.Dictionary")
Set ObjDict_Config_Dd_Tb = CreateObject("Scripting.Dictionary")
Set ObjDict_iHUB_Dd_Tb = CreateObject("Scripting.Dictionary")
Set ObjDict_OldColumnNames = CreateObject("Scripting.Dictionary")
ObjXL_main.Visible = False
ObjXL_main.DisplayAlerts = False
If Func_FileExists(vConfig_File_Loc,
vConfig_File_Name,vterminate_msg,objFSO,Obj_ExeLog) <> "EXIST" Then Call
Func_TerminateExec(vterminate_msg,Obj_ExeLog)
Obj_ExeLog.WriteLine "Config File Exist : " & vConfig_File_Loc &
vConfig_File_Name
If Func_FileExists(vPlinkExe_Location,
vPlinkExe_Name,vterminate_msg,objFSO,Obj_ExeLog) <> "EXIST" Then Call
Func_TerminateExec(vterminate_msg,Obj_ExeLog)
Obj_ExeLog.WriteLine "Plink File Exist : " & vPlinkExe_Location & vPlinkExe_Namee
Obj_ExeLog.WriteBlankLines 1
Obj_ExeLog.WriteLine String(15,"-") & "Executing the scenarios Defined in Config" &
String(15,"-")
'==================================================================================
==========================
'Create Result File with name as specific to scenario name, data and time stamp
vTDResult_FileName = Replace(Replace(Replace(vConfig_File_Name, " ",
""),"xlsx",""),".","") & "_" & vStaticTimestamp_DDMMHHMM & ".xlsx"
'Create Result File into to result folder and set the result TD object
objFSO.CopyFile (vConfig_File_Loc & vConfig_File_Name), (vResultFDR_Loc &
vTDResult_FileName), True
set ObjWB_Result = ObjXL_main.Workbooks.Open(vResultFDR_Loc & vTDResult_FileName)
'Validate Sheet Exist in config file
vConfigSheet_Found = vConfig_SheetName & " --> Sheet Not Exist in the config file
and Execution is stopped"
For Each vSheet_to_Delete In ObjWB_Result.Sheets
If InStr(1, vSheet_to_Delete.Name, Mid(vConfig_SheetName,1,15)) > 0 Then
ObjWB_Result.Worksheets(vSheet_to_Delete.Name).Visible = True
vConfigSheet_Found = "Found"
Else
vSheet_to_Delete.Delete
End If
Next
'==================================================================================
==========================
'Fetch the column Number from configuration sheet for few attributes
vTotRow_ConfigXL = Cint(ObjWS_main.UsedRange.Rows.Count)
vTotCol_ConfigXL = Cint(ObjWS_main.UsedRange.Columns.Count)
vRowNoConfig_HDR = 2
'==================================================================================
==========================
' Standardize the column names into SQL defined in main sheet second record
Select Case
Replace(Replace(Replace(Trim(vColumnName),vblf,""),vbcr,""),Chr(32),"")
End Select
Next
ObjWB_Result.Save
'==================================================================================
==========================
' Add a column and enter sequence number to identify the issue in actual excel row
number
vTotCol_ConfigXL = vTotCol_ConfigXL + 1
ObjWS_main.cells(vRowNoConfig_HDR, vTotCol_ConfigXL) = "Actual_SeqNo_Config"
ObjWB_Result.Save
'==================================================================================
==========================
' Add a column for identifying any blank values into expected columns
vTotCol_ConfigXL = vTotCol_ConfigXL + 1
ObjWS_main.cells(vRowNoConfig_HDR, vTotCol_ConfigXL) = "Res_BlankValue_Columns"
ObjWB_Result.Save
'==================================================================================
==========================
' Add a column to display the results if there is an issue with Target JobName, it
is not unique
vTotCol_ConfigXL = vTotCol_ConfigXL + 1
ObjWS_main.cells(vRowNoConfig_HDR, vTotCol_ConfigXL) =
"Multiple_TarJobName_1_Schema_Jfrq"
vTotCol_ConfigXL = vTotCol_ConfigXL + 1
ObjWS_main.cells(vRowNoConfig_HDR, vTotCol_ConfigXL) =
"Single_TarJobName_Multi_Schema_Jfrq"
vTotCol_ConfigXL = vTotCol_ConfigXL + 1
ObjWS_main.cells(vRowNoConfig_HDR, vTotCol_ConfigXL) = "Duplicate_entry_Primary"
vTotCol_ConfigXL = vTotCol_ConfigXL + 1
ObjWS_main.cells(vRowNoConfig_HDR, vTotCol_ConfigXL) = "Autosys_Checks"
ObjWB_Result.Save
'==================================================================================
==========================
'Convert the Config file into temp table, to make quick decisions
'Define the database objects
Set Obj_AdodbConnection = CreateObject("ADODB.Connection")
Set Obj_RSGeneric = CreateObject("ADODB.RecordSet")
Set Obj_RSUpdate = CreateObject("ADODB.RecordSet")
If Obj_AdodbConnection.State = 1 Then Obj_AdodbConnection.close
'==================================================================================
==========================
'validation Of Config File using temp table and extra column -->
Actual_SeqNo_Config, Res_BlankValue_Columns
'Check no blank should be available in below columns -->
'Target_JobName_DataSet, SchemaName_iHUB, TableName_iHUB, Autosys_JobName_iHUB,
Autosys_JobFreq_iHUB, Autosy_JobTime_iHUB, Autosy_JobTime_iHUB,
Autosys_RunCalendar_iHUB, Autosys_ExdCalendar_iHUB, Autosy_JobExecDay_iHUB
Query_output = Empty
vQuery_Null_Identification = "select Actual_SeqNo_Config from " &
vConfig_TempTableName & " Where Target_JobName_DataSet is null or SchemaName_iHUB
is null or TableName_iHUB is null or Autosys_JobName_iHUB is null or " &_
"Autosys_JobFreq_iHUB is null or Autosy_JobTime_iHUB is null or
Autosy_JobTime_iHUB is null or (Autosys_RunCalendar_iHUB is null and
Autosys_ExdCalendar_iHUB is null and Autosy_JobExecDay_iHUB is null) "
ObjWB_Result.Save
'==================================================================================
==========================
'validation Of Config File using temp table and extra column -->
Actual_SeqNo_Config, 'Multiple_TarJobName_1_Schema_Jfrq,
Single_TarJobName_Multi_Schema_Jfrq
' Validate is there are any multiple "Target Job Name" for unique combination of
Source schema and Autosys_JobName_iHUB
Query_output=Empty
vQuery_Multiple_TarJobName = "select XYZ.Schema_JFreq from " & _
"(select ABC.Schema_JFreq,count(*) from " & _
"(select distinct
Target_JobName_DataSet,(SchemaName_iHUB & '@' & Autosys_JobName_iHUB) as
Schema_JFreq from " & vConfig_TempTableName & ") ABC "&_
"group by ABC.Schema_JFreq having
count(*) > 1) XYZ"
ObjWB_Result.Save
' Validate if one "Target Job Name" assigned to multplie Source schema and Autosys
Job Name combination
Query_output=Empty
vQuery_Single_TarJobName_MulSchema = "select XYZ.Target_JobName_DataSet from " & _
"(select ABC.Target_JobName_DataSet,count(*)
from " & _
"(select distinct
Target_JobName_DataSet,(SchemaName_iHUB & '@' & Autosys_JobName_iHUB) as
Schema_JFreq from " & vConfig_TempTableName & ") ABC "&_
"group by
ABC.Target_JobName_DataSet having count(*) > 1) XYZ"
'==================================================================================
==========================
'validate if there any duplicate entries in config file and update result in column
Duplicate_entry_Primary
Query_output=Empty
'vQuery_duplicate_record = "select XYZ.Actual_SeqNo_Config from " &_
' "(select Actual_SeqNo_Config, row_number over
(partition by Target_JobName_DataSet, SchemaName_iHUB, Autosys_JobFreq_iHUB) as
rw_num from " & vConfig_TempTableName & ") XYZ where XYZ.rw_num=1"
'
'vQuery_duplicate_record = "select A.Target_JobName_DataSet, A.SchemaName_iHUB,
A.SchemaName_iHUB,A.Autosys_JobFreq_iHUB,count(*) as Rank from " &
vConfig_TempTableName &_
' " as A INNER JOIN " &
vConfig_TempTableName & " as B On
A.Target_JobName_DataSet>=B.Target_JobName_DataSet group by " &_
' "A.Target_JobName_DataSet,
A.SchemaName_iHUB, A.SchemaName_iHUB,A.Autosys_JobFreq_iHUB"
ObjWB_Result.Save
'==================================================================================
==========================
'validation Of Config File - Schema & table against iHUB teradata Database
'Extract Schema name and table name from Tera database into above sheet and store
into dictionary object
'- 2 ways --> Connect teradata extract based on pattern or manual should be
available
vTotRow_iHUB_DB_TB = Cint(ObjWS_iHUB_DB_TB.UsedRange.Rows.Count)
vTotCol_iHUB_DB_TB = Cint(ObjWS_iHUB_DB_TB.UsedRange.Columns.Count)
vRowNoiHUB_HDR = 1
ObjWB_iHUB_DB_TB.Close
'Create new sheet name "config Vs iHUB DB" to store the results
Set ObjWS_Config_Vs_iHUB = ObjWB_Result.Worksheets.Add
ObjWS_Config_Vs_iHUB.Name = vConfig_iHUB_CMP_SheetName
RowCnt_Config_IHUB_Cmp = 1
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp, viHUB_SchemaName_ColNo).value
= "iHUB_SchemaName"
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp, viHUB_TableName_ColNo).value
= "iHUB_TableName"
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp, vConfig_SchemaName_ColNo).value
= "Config_SchemaName"
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp, vConfig_TableName_ColNo).value
= "Config_TableName"
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp, vCMP_Status_ColNo).value
= "CMP_Status"
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp, vCMP_Remarks_ColNo).value
= "CMP_Remarks"
RowCnt_Config_IHUB_Cmp = RowCnt_Config_IHUB_Cmp + 1
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp,
viHUB_SchemaName_ColNo).value = Split(vSchema_TableName,"|")(0)
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp,
viHUB_TableName_ColNo).value = ObjDict_iHUB_Dd_Tb(vSchema_TableName)
If ObjDict_Config_Dd_Tb.Exists(vSchema_TableName) Then
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp,
vConfig_SchemaName_ColNo).value = Split(vSchema_TableName,"|")(0)
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp,
vConfig_TableName_ColNo).value = ObjDict_Config_Dd_Tb(vSchema_TableName)
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp,
vCMP_Status_ColNo).value = "PASS"
ObjDict_Config_Dd_Tb.Remove(vSchema_TableName)
' ElseIf Instr(1,vDBNAME_IHUB,"NPRIV_S0") <= 0 Then
' ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp,
vCMP_Status_ColNo).value = "IGNORE"
' ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp,
vCMP_Remarks_ColNo).value = "Not Available in Config File but ignored"
Else
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp,
vCMP_Status_ColNo).value = "FAIL"
ObjWS_Config_Vs_iHUB.cells(RowCnt_Config_IHUB_Cmp,
vCMP_Remarks_ColNo).value = "Not Available in Config File"
End If
Next
ObjDict_iHUB_Dd_Tb.RemoveAll
ObjDict_Config_Dd_Tb.RemoveAll
ObjWB_Result.Save
ObjWB_Result.Close
If Obj_AdodbConnection.State = 1 Then Obj_AdodbConnection.close
Call KillProcessor("EXCEL.EXE")
ExitTest
'==================================================================================
==========================
'Validate Autosys jobs dependancy available in source --> Autosys_JobName_iHUB,
Autosys_JobFreq_iHUB, Autosy_JobTime_iHUB,
'<Update Code>
'==================================================================================
==========================
'Create New Sheet with Name "STATS_AUTOSYS_JOB_LEVEL" and also create below column
'JobNo --> Dynamic sequence number
'Target Job Name --> Distinct Target Job name to be copied from main sheet
'SourceSchema_Name --> Distinct schema snames to be copied from main sheet
'Probability Job Freq --> Distinct values to be copied from main sheet
'No Of tables --> Extract a value based on the count of tables belongs to each
schema as per main sheet
'Autosys Job Date -->
'Autosys Start Time -->
'Autosys End Time -->
'Job Duartion -->
'No Of records ingested -->
'Job Status -->
'<Update code>
'==================================================================================
==========================
' Create Extra Column in Main sheet to update record count of the tables
'Based on BZ_DATE merge 3 columns in first line and update 2nd line woth below
columns
'1. snap_eff_dt
'2. No of records ingested in HDFS
'3. No Of records source IHUB
'4. Status SU/FA/OI
'Fetch Autosys log file and update the columns in sheet
Set ObjFSO_Write_Temp_GrepFile =
objFileToWrite.OpenTextFile(vTemp_grep_filename,2,True)
ObjFSO_Write_Temp_GrepFile.Writeline "grep 'expectedCount' " &
log_FileName_location & "|grep -v '" & Chr(34) & "expectedCount" & Chr(34) &
":null'" & "|grep -i '" & vTable_Name & "'"
ObjFSO_Write_Temp_GrepFile.Close
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " & vPlinkExe_Location_Split(0) &
":" & "&cd \ &cd " & Chr(34) & vPlinkExe_Location_Split(1) & Chr(34) & "&plink -t "
& varf_TC_UnixBox_HostName & _
" -l " & vUnixConn_Server_USN & " -pw " &
vUnixConn_Server_PWD & " -m " & vTemp_grep_filename & " > " &
vLogOutput_FileLocation & " & exit"
Obj_Wsh.Run vExecute_CMD_Prompt,0,True
If Not objFileToWrite.FileExists(vLogOutput_FileLocation) Then wait 2
If objFileToWrite.FileExists(vLogOutput_FileLocation) Then
Loop
ObjWB.Save
End if
Exit DO
Loop
Next
ObjWB.Save
'==================================================================================
==========================
' Update the results into sheet "STATS_AUTOSYS_JOB_LEVEL" based on Autosys and Log
File. Get count from main sheet
'<Update Code>
ObjWB.Save
ObjWB.Close
ObjXL.Quit
If Obj_AdodbConnection.State = 1 Then Obj_AdodbConnection.close
Call KillProcessor("excel.exe")
'==================================================================================
=
' Generic Functions
'==================================================================================
End Function
' Copy the File as Response body from sharepoint save it into a file
xmlhttp.open "GET",sharepointUrl & filename,false
xmlhttp.send
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write xmlhttp.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
objADOStream.SaveToFile vTempFdrLoc & filename,2
'Check the file existence and extract the XL file from word document
If Cint(xmlhttp.status) = 200 and FSO.FileExists(vTempFdrLoc & filename) Then
FSO.CopyFile vTempFdrLoc & filename, ZipFileLocation,True ' Convert the
DOCX into ZIP file
If FSO.FolderExists(TempExtractLoc)Then FSO.DeleteFile TempExtractLoc &
"\*", true
If FSO.FolderExists(TempExtractLoc)Then FSO.DeleteFolder TempExtractLoc &
"\*", true
If not FSO.FolderExists(TempExtractLoc)Then
FSO.CreateFolder(TempExtractLoc)
Set objSource = objSA.NameSpace(ZipFileLocation).Items ' Collect the ZIP
files
objSA.NameSpace(TempExtractLoc).CopyHere(objSource) ' extract the ZIP file
into temp folder
' Copy the XL files from temp folder where ZIP extracted, folder
location \word\embeddings\
If FSO.FolderExists(Embed_XLFdr)Then
Set EmbdFdr = FSO.GetFolder(Embed_XLFdr)
For Each XLFile in EmbdFdr.Files
vFile_Extension =
Ucase(FSO.GetExtensionName(XLFile.name))
If vFile_Extension = "XLSX" or
vFile_Extension="XLS" then FSO.CopyFile Embed_XLFdr & XLFile.name,
ResultXL_DestLoc, True
XL_Found = true
Next
Else
Msgbox " No XL files inside the document "
End If
If XL_Found <> true then Msgbox "There are no excel files available in
documnet"
FSO.DeleteFile ZipFileLocation,True ' Delete the temp ZIP file which was
converted from word document
FSO.DeleteFolder TempExtractLoc,True ' Delete the temp extrated files
from word document
Else
If Cint(xmlhttp.status) <> 200 Then Msgbox "Unable to copy the file from
sharepoint" & chr(10) & xmlhttp.status & " : " & xmlhttp.statusText
If not FSO.FileExists(vTempFdrLoc & filename) and Cint(xmlhttp.status) =
200 Then Msgbox " File Not Exist in the below location " & Chr(10) & vTempFdrLoc &
filename & chr(10) & xmlhttp.status & " : " & xmlhttp.statusText
End If
xmlhttp.abort
objADOStream.Close
Set FSO = Nothing
Set objSA = Nothing
set xmlHttp = Nothing
Set objADOStream = Nothing
'Option Explicit
'==================================================================================
==========================
'Declaration of Variables
'==================================================================================
==========================
'==================================================================================
==========================
'Initialisation of variable whose values will be constant
vMultiple_XML_CMP = TRUE
vHomeFDR = "C:\temp\"
vHomeFDR =
CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".") & "\"
vXML_PARSED_TXT_FDR = vHomeFDR & "XML_Parsed_TXT\"
vComparison_Reports_FDR = vHomeFDR & "XML_Comparison_Reports\"
vController_XL_FileName = "Galaxy_XML_CMP_Controller.xlsx"
vController_XL_FullPath = vHomeFDR & vController_XL_FileName
Select Case Msgbox("Please Save the excel files opened and click OK" & Chr(10) &
"Cancel will stop execution",1)
Case 1 Call KillProcessor("EXCEL.EXE")
Case 2 Msgbox "Execution is stopped"
Call KillProcessor("wscript.exe")
End Select
'==================================================================================
==========================
'Defining the class objects FSO, Wscript, Excel, Dictionary
Do
If vMultiple_XML_CMP <> True Then
vXMLFile_Path_actual = InputBox("Enter the Actual XML File Location
with Name and format","XML File 1 Location",vXMLFile_Path_actual)
vXMLFile_Path_baseline = InputBox("Enter the Baseline XML File Location
with Name and format","XML File 2 Location",vXMLFile_Path_baseline)
vComparison_Report_Fmt = InputBox("Required in EXCEL / CSV","Result
Format", vComparison_Report_Fmt)
vResultFileName = "XMLCMP_" &
Left(Split(Split(vXMLFile_Path_baseline,".")(0),"\")
(ubound(Split(Split(vXMLFile_Path_baseline,".")(0),"\"))),10) & "_" & Day(Date) &
Month(Date) & Hour(Time) & Minute(Time)
vResultFileNameLoc = vComparison_Reports_FDR & vResultFileName
varf_ScenarioName = Left(Split(Split(vXMLFile_Path_baseline,".")
(0),"\")(ubound(Split(Split(vXMLFile_Path_baseline,".")(0),"\"))),15)
Call
XML_Comparison_Main(vHomeFDR,vXML_PARSED_TXT_FDR,vComparison_Reports_FDR,vXMLFile_P
ath_actual,vXMLFile_Path_baseline,vComparison_Report_Fmt,_
Obj_FSO,Obj_Dict_Actual,Obj_Dict_Baseline,Obj_Wsh,ObjXL_Main,varf_ScenarioName,vRes
ultFileNameLoc,vXMLCMP_Remarks,vXML_ComparisonStatus,varf_DiffCnt)
If vXML_ComparisonStatus = "FAIL" and Instr(1,vXMLCMP_Remarks,"XML
Comparison Failed") > 0 Then vAuto_open_Result_report = "DON'T OPEN"
vFinal_Result_Report = vResultFileNameLoc
Exit Do
End If
'==================================================================================
==========================
'Fetch the column Number from configuration sheet for few attributes
If Not Obj_FSO.FileExists(vController_XL_FullPath) Then
Msgbox "Controller XL File Not exists" & Chr(10) & vController_XL_FullPath
Exit Do
End If
vFinal_Result_Report = vComparison_Reports_FDR & "XML_Result_Report_" &
Day(Date) & Month(Date) & Hour(Time) & Minute(Time) & ".xlsx"
Obj_FSO.CopyFile vController_XL_FullPath, vFinal_Result_Report
Set ObjWB_Main = ObjXL_Main.Workbooks.Open(vFinal_Result_Report)
Set ObjWS_Main = ObjXL_Main.Worksheets("Galaxy_XML_CMP")
vTotCol_Main = Cint(ObjWS_Main.UsedRange.Columns.Count)
vTotRow_Main = Cint(ObjWS_Main.UsedRange.Rows.Count)
vRowNoConf = 1
Obj_FSO,Obj_Dict_Actual,Obj_Dict_Baseline,Obj_Wsh,ObjXL_Main,varf_ScenarioName,vRes
ultFileNameLoc,vXMLCMP_Remarks,vXML_ComparisonStatus,varf_DiffCnt)
ObjWS_Main.Cells(vXLRowNo,Execution_Status_ColNo).Font.Bold =
True
If varf_DiffCnt > 0 Then
ObjWS_Main.Cells(vXLRowNo,Execution_Status_ColNo) =
"FAIL"
ObjWS_Main.Cells(vXLRowNo,Total_No_Diff_ColNo) =
varf_DiffCnt
ObjWS_Main.Cells(vXLRowNo,Execution_Status_ColNo).Interior.ColorIndex = 3
Else
ObjWS_Main.Cells(vXLRowNo,Execution_Status_ColNo) =
"PASS"
ObjWS_Main.Cells(vXLRowNo,Execution_Status_ColNo).Interior.ColorIndex = 4
End If
ObjWS_Main.Cells(vXLRowNo,Execution_Status_ColNo).Interior.ColorIndex = 15
ObjWS_Main.Cells(vXLRowNo,Result_Report_Location_ColNo) =
""
Else
ObjWS_Main.Cells(vXLRowNo,Result_Report_Location_ColNo) =
"Empty Line, Please delete from Main Controller file"
End If
Next
ObjWB_Main.Save
ObjWB_Main.Close
Exit Do
Loop
ObjXL_Main.Quit
Call KillProcessor("Excel.exe")
Public Function
XML_Comparison_Main(vHomeFDR,vXML_PARSED_TXT_FDR,vComparison_Reports_FDR,vXMLFile_P
ath_actual,vXMLFile_Path_baseline,vComparison_Report_Fmt,_
Obj_FSO,Obj_Dict_Actual,Obj_Dict_Baseline,Obj_Wsh,ObjXL_Main,varf_ScenarioName,vRes
ultFileNameLoc,vXMLCMP_Remarks,vXML_ComparisonStatus,varf_DiffCnt)
' Genrate the Result report based on the values present in array varf_diff
Select Case Ucase(vComparison_Report_Fmt)
Case "CSV"
vResultFileNameLoc = vResultFileNameLoc & ".csv"
Call f_ResultReporting_CSV (varf_diff,
varf_ScenarioName,ObjXL_Main,vResultFileNameLoc, vResultReportExcel_Status)
Case "EXCEL"
vResultFileNameLoc = vResultFileNameLoc & ".xlsx"
Call f_ResultReporting_Excel (varf_diff,
varf_ScenarioName,ObjXL_Main,vResultFileNameLoc, vResultReportExcel_Status)
End Select
Obj_Dict_Actual.RemoveAll
Obj_Dict_Baseline.RemoveAll
End Function
' Wait for the XML file to be loaded into DOM object
Do
' "Wscript.sleep 10000" wont work in UFT & "wait" won't work in VBS, an
alternate way to delay script by running the ping cmd in back ground
CreateObject("wscript.Shell").Run "%COMSPEC% /c ping -n " & ctr & "
127.0.0.1>nul",0,1
ctr = ctr + 1
If ctr = 10 Then Msgbox " Unable to load XML" ' Counter help to come
out of loop if XML is loaded in 45 seconds
If Obj_XML.ReadyState = 4 Then Exit Do ' ' ReadyState = 4
indicates XML load into DOM is complete
Loop
' Store all attributes and elements of each node with index value into dictionary
object and also save the same into sample txt file
For PNodeCnt = 1 to Obj_XML.childnodes.length
Set Obj_XMLDOM = Obj_XML.childnodes
PNode_strt = 1
PNode_LevelCnt = 1
vCurLevel = 1
vCurIndex = 1
Execute "vNodeLevel" & PNode_LevelCnt & "_index=" & PNode_strt
currChildNode = Trim(Obj_XMLDOM.item(PNodeCnt-1).NodeName) & "[" &
PNode_strt-1 & "]/"
ObjDict_Index.Add Trim(Obj_XMLDOM.item(PNodeCnt-1).NodeName) & "/",
PNode_strt-1
Execute "vChildNodeIndex" & PNode_LevelCnt & " = " & Chr(34) &
currChildNode & Chr(34)
Execute "vChildNode_With_Index = " & "vChildNodeIndex" &
PNode_LevelCnt
Call func_CheckAttribute_AddDict (Obj_XMLDOM, PNodeCnt-1,
vChildNode_With_Index, Obj_Dict_Map, ObjWrt_XMLparser)
Execute "Node_index = Cint(" & "vNodeLevel" & PNode_LevelCnt &
"_index)"
Execute "vNodeLevel" & PNode_LevelCnt &" = " & Chr(34) & ".item(" &
PNodeCnt-1 & ").ChildNodes" & Chr(34)
Execute "Node_siblings = " & "vNodeLevel" & PNode_LevelCnt
Do
Execute "Set Obj_XMLDOM_CH = " & "Obj_XMLDOM" &
Node_siblings
If Obj_XMLDOM_CH.length > 0 Then
vStartIndex = 1
PNode_LevelCnt = PNode_LevelCnt + 1
Execute "vnum1 = vNodeLevel" & PNode_LevelCnt &
"_index"
vCurIndex = cint(vnum1) + vStartIndex
if Instr(1,Trim(Obj_XMLDOM_CH.item(vCurIndex-
1).NodeName),"#text") > 0 then
' Execute "vCurIndex_tmp = vNodeLevel" &
PNode_LevelCnt-1 & "_index"
Execute "vchild_temp1 = " & "vChildNodeIndex"
& PNode_LevelCnt-2
vNewKey = vchild_temp1 &
Trim(Obj_XMLDOM_CH.item(vCurIndex-1).parentnode.NodeName)
If ObjDict_Index.Exists(vNewKey) Then
ObjDict_Index.Item(vNewKey) = ObjDict_Index(vNewKey) - 1
Else
Execute "vchild_temp1 = " & "vChildNodeIndex"
& PNode_LevelCnt-1
vNewKey = vchild_temp1 &
Trim(Obj_XMLDOM_CH.item(vCurIndex-1).NodeName)
End If
If ObjDict_Index.Exists(vNewKey) Then
New_indexValue = ObjDict_Index(vNewKey) + 1
ObjDict_Index.Item(vNewKey) =
New_indexValue
Else
New_indexValue = 0
ObjDict_Index.Add vNewKey,New_indexValue
End If
currChildNode = vNewKey & "[" & New_indexValue &
"]/"
Execute "vChildNodeIndex" & PNode_LevelCnt & " = "
& Chr(34) & currChildNode & Chr(34)
Execute "vChildNode_With_Index = " &
"vChildNodeIndex" & PNode_LevelCnt
Call func_CheckAttribute_AddDict (Obj_XMLDOM_CH,
vCurIndex-1, vChildNode_With_Index, Obj_Dict_Map, ObjWrt_XMLparser)
Execute "vNodeLevel" & PNode_LevelCnt & "_index ="&
vCurIndex
Set Obj_XMLDOM_temp = Obj_XMLDOM_CH
Execute "Node_index = Cint(" & "vNodeLevel" &
PNode_LevelCnt & "_index)"
Execute "temp_value1 = " & "vNodeLevel" &
PNode_LevelCnt-1
Execute "temp_value2 = " & Chr(34) & ".item(" &
Node_index-1 & ").ChildNodes" & Chr(34)
Execute "vNodeLevel" & PNode_LevelCnt &" = " &
Chr(34) & temp_value1 & temp_value2 & Chr(34)
Execute "Node_siblings = " & "vNodeLevel" &
PNode_LevelCnt
Else
Call
func_WriteXMLElem_ObjDict_TxtFile(vChildNode_With_Index, vCurIndex-1,
Obj_XMLDOM_temp, Obj_Dict_Map, ObjWrt_XMLparser)
Do
If PNode_LevelCnt <= 1 Then
Exit Do
Execute "vnum =
cint(vNodeLevel" & PNode_LevelCnt & "_index)"
vCurIndex = vnum + 1
Execute "vNodeLevel" &
PNode_LevelCnt & "_index ="& vCurIndex
Execute
"Node_siblings_len_chk = " & "vNodeLevel" & PNode_LevelCnt-1
Execute "Set
Obj_XMLDOM_Len_chk = " & "Obj_XMLDOM" & Node_siblings_len_chk
If Obj_XMLDOM_Len_chk.length
>= vCurIndex Then
Exit Do
Else
Execute "vNodeLevel" &
PNode_LevelCnt & "_index = 0"
Execute
"vChildNodeIndex" & PNode_LevelCnt & " = Empty"
PNode_LevelCnt =
PNode_LevelCnt - 1
End If
Loop
If PNode_LevelCnt <= 1 Then Exit Do
Execute "temp_value1 = " & "vNodeLevel" &
PNode_LevelCnt-1
Execute "Set Obj_XMLDOM_CH_temp = " &
"Obj_XMLDOM" & temp_value1
' CurrChildNode =
Trim(Obj_XMLDOM_CH_temp.item(vCurIndex-1).NodeName) & "[" & vCurIndex-1 & "]/"
Execute "vchild_temp1 = " &
"vChildNodeIndex" & PNode_LevelCnt-1
vNewKey = vchild_temp1 &
Trim(Obj_XMLDOM_CH_temp.item(vCurIndex-1).NodeName)
If ObjDict_Index.Exists(vNewKey) Then
New_indexValue =
ObjDict_Index(vNewKey) + 1
ObjDict_Index.Item(vNewKey) =
New_indexValue
Else
New_indexValue = 0
ObjDict_Index.Add
vNewKey,New_indexValue
End If
currChildNode = vNewKey & "[" &
New_indexValue & "]/"
End If
Loop
ObjDict_Index.RemoveAll
Next
Else
vRemarks = "There are no nodes or elements in the XML file"
vStatus = "FAIL"
End If
ObjWrt_XMLparser.close
Else
ReDim Preserve varf_diff(varf_DiffCnt)
vFailure_Cnt = vFailure_Cnt + 1
If Obj_Dict_Baseline(vKey) = "$Broken_XPath/Blank_Value$" Then
varf_diff(varf_DiffCnt) = "Xpath Broken Baseline" & "^$!" &
vKey & "^$!" & " - " & "^$!" & Obj_Dict_Baseline(vKey) & "^$!" & "FAIL"
Else
varf_diff(varf_DiffCnt) = "Xpath Missing Actual" & "^$!" &
vKey & "^$!" & " Not available (Missing) " & "^$!" & Obj_Dict_Baseline(vKey) &
"^$!" & "FAIL"
End If
varf_DiffCnt = varf_DiffCnt + 1
End If
Exit Do
Loop
Next
For each vKey in Obj_Dict_Actual
ReDim Preserve varf_diff(varf_DiffCnt)
vFailure_Cnt = vFailure_Cnt + 1
If Obj_Dict_Actual(vKey) = "$Broken_XPath/Blank_Value$" Then
varf_diff(varf_DiffCnt) = "Xpath Broken Actual" & "^$!" & vKey & "^$!" &
Obj_Dict_Actual(vKey) & "^$!" & " - " & "^$!" & "FAIL"
Else
varf_diff(varf_DiffCnt) = "Xpath Missing Baseline" & "^$!" & vKey & "^$!"
& Obj_Dict_Actual(vKey) & "^$!" & " Not available (Missing) " & "^$!" & "FAIL"
End If
varf_DiffCnt = varf_DiffCnt + 1
Next
varf_DiffCnt = vFailure_Cnt
End Function
vResult_Type_ColNo = 1
vXpath_ColNo = 2
vActual_XML_value_ColNo = 3
vBaseline_XML_value_ColNo = 4
vMatching_Status_ColNo = 5
vTotalNoColUsed_ResultReport = 5
vDiffSheetName = varf_ScenarioName
vStartingRowNo_ResultReport = 3
vTotRow_ResultReport = Cint(ObjWS_ResultReport.UsedRange.Rows.Count)
If vTotRow_ResultReport < 3 Then
ObjWS_ResultReport.Cells(vStartingRowNo_ResultReport-1,
vResult_Type_ColNo).Value = "Result Type"
ObjWS_ResultReport.Cells(vStartingRowNo_ResultReport-1,
vXpath_ColNo).Value = "Xpath With Index"
ObjWS_ResultReport.Cells(vStartingRowNo_ResultReport-1,
vActual_XML_value_ColNo).Value = "Actual XML Value"
ObjWS_ResultReport.Cells(vStartingRowNo_ResultReport-1,
vBaseline_XML_value_ColNo).Value = "Baseline XML Value"
ObjWS_ResultReport.Cells(vStartingRowNo_ResultReport-1,
vMatching_Status_ColNo).Value = "Matching Status"
ObjWS_ResultReport.columns("A:E").select
ObjXL_Main.Selection.NumberFormat = "@"
Else
vStartingRowNo_ResultReport = vTotRow_ResultReport + 1
End If
ObjWS_ResultReport.Activate
ObjXL_Main.Columns(1).columnwidth = 20
ObjXL_Main.Columns(2).columnwidth = 112
ObjXL_Main.Columns(3).columnwidth = 30
ObjXL_Main.Columns(4).columnwidth = 30
ObjXL_Main.Columns(5).columnwidth = 20
vResultReportExcel_Status = "PASS"
ObjWB_Result.Worksheets(vDiffSheetName).Visible = True
ObjWB_Result.SaveAs vResultFileNameLoc
ObjWB_Result.Close
End Function
If Obj_FSO.FileExists(vResultFileNameLoc) Then
Set ObjWrt_ResultReportCSV =
Obj_FSO.OpenTextFile(vResultFileNameLoc , 8 ,True)
Else
Set ObjWrt_ResultReportCSV =
Obj_FSO.OpenTextFile(vResultFileNameLoc , 2 ,True)
ObjWrt_ResultReportCSV.WriteLine "Result Type" & vDelimiter & "Xpath With
Index" & vDelimiter & "Actual XML Value" & vDelimiter & "Baseline XML Value" &
vDelimiter & "Matching Status"
End If
vResultReportExcel_Status = "PASS"
ObjWrt_ResultReportCSV.Close
End Function
'==================================================================================
==========================
'Generic Function Name : Kill Windows Process
'Description :
'==================================================================================
End Function
vPlinkExe_Location = "C:\temp\KRegression_Tool\pTools"
varf_TC_UnixBox_HostName = "wppra93a0201.mylocal.com"
vUnixConn_Server_USN = "u448515"
vUnixConn_Server_PWD = "Apr0417$"
Json_FileLocation_unix = "/opt/cdhprd/daas/cdbo-message-
ingestion/raw_message_store/"
Json_FileName = "messages20170102.json"
'Json_FileName = inputbox("Enter the JSON File Name")
Json_FileName_location = Json_FileLocation_unix & Json_FileName
vGrepJson_Command = Chr(34) & "grep -i 'swap' " & Json_FileName_location
& " |head -10" & Chr(34)
vJsonOutput_FileLocation = "C:\temp\json_output.json"
vTotalRecordCount = 0
keyword_cnt_tot = 0
Jsonlines = 0
TempXMLFile = "C:\temp\tradeSample.xml"
TempKeywordFile = "C:\temp\TradeAttribute.txt"
vTimer_Start = Timer
vPlinkExe_Location_Split = Split(vPlinkExe_Location,":\")
vExecute_CMD_Prompt = "cmd /c " & vPlinkExe_Location_Split(0) & ":" &
"&cd \ &cd " & Chr(34) & vPlinkExe_Location_Split(1) & Chr(34) & "&plink " &
varf_TC_UnixBox_HostName & _
" -l " & vUnixConn_Server_USN & " -pw " &
vUnixConn_Server_PWD & " " & vGrepJson_Command & " > " & vJsonOutput_FileLocation &
" & exit"
'Obj_Wsh.Run vExecute_CMD_Prompt,0,True
Do until ObjFSO_ReadJson.AtEndOfStream
Jsonlines = Jsonlines + 1
vSingleXML = ObjFSO_ReadJson.ReadLine
vSingleXML_split = Split(vSingleXML,Chr(34) & "body" & Chr(34) & ":"
& Chr(34))
No_Of_proxyproductleg = 0
Do
If ubound(vSingleXML_split) <= 0 Then Exit Do
vFinalXML = Replace(Replace(Split(vSingleXML_split(1),Chr(34)
& Chr(44) & Chr(34))(0),"\" & Chr(34),Chr(34)), "\n",Chr(13) & Chr(10))
Set Obj_Write_XML =
objFileToWrite.OpenTextFile(TempXMLFile,2,true)
Obj_Write_XML.WriteLine vFinalXML
Obj_Write_XML.Close
Set frontOfficeSysName_node =
xmlDoc.selectNodes("//req:bo_request/source")
frontOfficeSysName_Val
=frontOfficeSysName_node.item(0).text
Set frontOfficeReferenceID_node =
xmlDoc.selectNodes("//req:bo_request/trade/tradeId")
frontOfficeReferenceID_Val =
frontOfficeReferenceID_node.item(0).text
vFrst_ProxyProduct_Xpath =
"//req:bo_request/trade/proxyProduct/"
Set proxyproductleg_node =
xmlDoc.selectNodes(vFrst_ProxyProduct_Xpath & "proxyType")
No_Of_proxyproductleg = proxyproductleg_node.length - 1
OnlyRefentity_swap = "/refEntity"
Trigger_Run_Main_Script = TRUE
ElseIf ucase(vProxyType) = "SWAP" or
ucase(vProxyType) = "CAP" or ucase(vProxyType) = "FRA" or ucase(vProxyType) =
"TREASURYLOCK" Then
Trigger_Run_Main_Script = TRUE
If No_first_prxprdt_leg_length >=
0 Then
Execute
ExecuteOnly_frst_PrxyPrdt_leg
Execute
Execute_Attribute_type_leg
For
vFrstPrxprdt_leg_cnt = 0 To No_first_prxprdt_leg_length
Set
frst_proxprdt_leg_node = xmlDoc.selectNodes(vFrst_ProxyProduct_Xpath & "leg[" &
vFrstPrxprdt_leg_cnt & "]")
Set
frst_proxprdt_leg_legid =
frst_proxprdt_leg_node.item(0).Getelementsbytagname("legId")
If
frst_proxprdt_leg_legid.length > 0 Then attr_Type_Id_Val =
frst_proxprdt_leg_legid.Item(0).text
vOTC_Val,vAttr_type,attr_Type_Id_Val,attr_class_Val,attr_name_Val,attr_Val_Val,Obj_
Write_Trade)
Set
frst_proxprdt_leg_xmlblob_node = xmlDoc.selectNodes(vFrst_ProxyProduct_Xpath &
"leg[" & vFrstPrxprdt_leg_cnt & "]/xml_blob")
frst_proxprdt_leg_xmlblob_length = frst_proxprdt_leg_xmlblob_node.length-1
If
frst_proxprdt_leg_xmlblob_length>=0 Then
For
frst_proxprdt_leg_xmlblob_length_cnt = 0 To frst_proxprdt_leg_xmlblob_length
Set
frst_proxprdt_leg_xmlblob =
frst_proxprdt_leg_xmlblob_node.item(frst_proxprdt_leg_xmlblob_length_cnt).childNode
s
frst_proxprdt_leg_xmlblob_lenth = frst_proxprdt_leg_xmlblob.length-1
For
Frst_proxprdt_leg_xmbob_cnt = 0 To frst_proxprdt_leg_xmlblob_lenth
attr_class_Val =
frst_proxprdt_leg_xmlblob.item(Frst_proxprdt_leg_xmbob_cnt).nodeName
attr_Name_Val =
frst_proxprdt_leg_xmlblob.item(Frst_proxprdt_leg_xmbob_cnt).nodeName
attr_Val_Val = frst_proxprdt_leg_xmlblob.item(Frst_proxprdt_leg_xmbob_cnt).text
vDelimiter & vProduct_Val & vDelimiter & vCurrency_Val & vDelimiter & vOTC_Val & _
vDelimiter & vAttr_type & vDelimiter & attr_Type_Id_Val & vDelimiter &
attr_class_Val & vDelimiter &_
vRecordCount = vRecordCount + 1
Next
Next
End If
Next
End If
Set frst_proxprdt_xmlblob_node =
xmlDoc.selectNodes(vFrst_ProxyProduct_Xpath & "xml_blob" & OnlyRefentity_swap)
If frst_proxprdt_xmlblob_node.length >
0 Then
Set attr_Type_Id_Elmt =
frst_proxprdt_xmlblob_node.item(0).childnodes
Execute
Execute_Attribute_type_outside
attr_Type_Id_Val = ""
For
frst_xmlblob_childnodes_cnt = 0 To attr_Type_Id_Elmt.length-1
Set
ref_Entity_Elmt = attr_Type_Id_Elmt.item(frst_xmlblob_childnodes_cnt).childNodes
ref_Entitiy_Child_Length = ref_Entity_Elmt.length-1
If
ref_Entitiy_Child_Length = 0 Then
attr_class_Val = ref_Entity_Elmt.item(0).parentNode.nodeName
attr_Name_Val = ref_Entity_Elmt.item(0).parentNode.nodeName
attr_Val_Val = ref_Entity_Elmt.item(0).text
vDelimiter & vProduct_Val & vDelimiter & vCurrency_Val & vDelimiter & vOTC_Val &_
vDelimiter & vAttr_type & vDelimiter & attr_Type_Id_Val & vDelimiter &
attr_class_Val & vDelimiter &_
vRecordCount = vRecordCount + 1
ElseIf
ref_Entitiy_Child_Length >= 1 Then
For
refEntityIterator = 0 To ref_Entitiy_Child_Length
attr_class_Val = ref_Entity_Elmt.item(refEntityIterator).parentNode.nodeName
attr_Name_Val = ref_Entity_Elmt.item(refEntityIterator).nodeName
attr_Val_Val = ref_Entity_Elmt.item(refEntityIterator).text
vDelimiter & vProduct_Val & vDelimiter & vCurrency_Val & vDelimiter & vOTC_Val &_
vDelimiter & vAttr_type & vDelimiter & attr_Type_Id_Val & vDelimiter &
attr_class_Val & vDelimiter &_
Set second_prxprdt_main =
xmlDoc.selectNodes(vFrst_ProxyProduct_Xpath & "proxyProduct")
No_secnd_prxprdt_length =
second_prxprdt_main.length-1
If No_secnd_prxprdt_length >= 0 Then
For vsecndPrxprdt_cnt = 0 To
No_secnd_prxprdt_length
second_prxprdt_xpath =
vFrst_ProxyProduct_Xpath & "proxyProduct[" & vsecndPrxprdt_cnt & "]"
Set second_prxprdt =
xmlDoc.selectNodes(second_prxprdt_xpath)
If
vProd_OTC_CURR_Non_STRUC = TRUE Then Call
vProduct_OTC_Currency(second_prxprdt_xpath & "/", vProduct_Val, vCurrency_Val,
vOTC_Val)
Set second_proxprdt_leg
= xmlDoc.selectNodes(second_prxprdt_xpath & "/leg")
No_secnd_prxprdt_leg_length = second_proxprdt_leg.length-1
If
No_secnd_prxprdt_leg_length >= 0 Then
Execute ExecuteOnly_Secnd_PrxyPrdt_leg
Execute Execute_Attribute_type_leg
For
vsecndPrxprdt_leg_cnt = 0 To No_secnd_prxprdt_leg_length
Set secnd_proxprdt_leg_legid =
secnd_proxprdt_leg_node.item(0).Getelementsbytagname("legId")
Call
CashFlow_XMLBLOB_Extract(vProductTypeNode_Xpath,vEffdate,frontOfficeSysName_Val,vSo
urceSubsystemName,frontOfficeReferenceID_Val,vProduct_Val,vCurrency_Val,_
vOTC_Val,vAttr_type,attr_Type_Id_Val,attr_class_Val,attr_name_Val,attr_Val_Val,Obj_
Write_Trade)
Set secnd_proxprdt_leg_xmlblob_node = xmlDoc.selectNodes(second_prxprdt_xpath &
"/leg[" & vsecndPrxprdt_leg_cnt & "]/xml_blob")
secnd_proxprdt_leg_xmlblob_length = secnd_proxprdt_leg_xmlblob_node.length-1
If secnd_proxprdt_leg_xmlblob_length>=0 Then
Set secnd_proxprdt_leg_xmlblob_child =
secnd_proxprdt_leg_xmlblob_node.item(secnd_proxprdt_leg_xmlblob_length_cnt).childNo
des
secnd_proxprdt_leg_xmlblob_lenth = secnd_proxprdt_leg_xmlblob_child.length-1
attr_class_Val =
secnd_proxprdt_leg_xmlblob_child.item(secnd_proxprdt_leg_xmbob_cnt).nodeName
attr_Name_Val =
secnd_proxprdt_leg_xmlblob_child.item(secnd_proxprdt_leg_xmbob_cnt).nodeName
attr_Val_Val =
secnd_proxprdt_leg_xmlblob_child.item(secnd_proxprdt_leg_xmbob_cnt).text
vDelimiter & vProduct_Val & vDelimiter & vCurrency_Val & vDelimiter & vOTC_Val &_
vDelimiter & vAttr_type & vDelimiter & attr_Type_Id_Val & vDelimiter &
attr_class_Val & vDelimiter &_
vRecordCount = vRecordCount + 1
Next
Next
End If
Next
End If
Set
secnd_proxprdt_xmlblob_node = xmlDoc.selectNodes(second_prxprdt_xpath & "/xml_blob"
& OnlyRefentity_swap)
If
secnd_proxprdt_xmlblob_node.length > 0 Then
Set
attr_Type_Id_Elmt = secnd_proxprdt_xmlblob_node.item(0).childnodes
Execute
Execute_Attribute_type_outside
attr_Type_Id_Val = ""
For
secnd_xmlblob_childnodes_cnt = 0 To attr_Type_Id_Elmt.length-1
Set
ref_Entity_Elmt = attr_Type_Id_Elmt.item(secnd_xmlblob_childnodes_cnt).childNodes
ref_Entitiy_Child_Length = ref_Entity_Elmt.length-1
If
ref_Entitiy_Child_Length = 0 Then
attr_class_Val = ref_Entity_Elmt.item(0).parentNode.nodeName
attr_Name_Val = ref_Entity_Elmt.item(0).parentNode.nodeName
attr_Val_Val = ref_Entity_Elmt.item(0).text
vDelimiter & vProduct_Val & vDelimiter & vCurrency_Val & vDelimiter & vOTC_Val &_
vDelimiter & vAttr_type & vDelimiter & attr_Type_Id_Val & vDelimiter &
attr_class_Val & vDelimiter &_
vRecordCount = vRecordCount + 1
ElseIf
ref_Entitiy_Child_Length >= 1 Then
attr_class_Val = ref_Entity_Elmt.item(refEntityIterator).parentNode.nodeName
attr_Name_Val = ref_Entity_Elmt.item(refEntityIterator).nodeName
attr_Val_Val = ref_Entity_Elmt.item(refEntityIterator).text
vDelimiter & vProduct_Val & vDelimiter & vCurrency_Val & vDelimiter & vOTC_Val &_
vDelimiter & vAttr_type & vDelimiter & attr_Type_Id_Val & vDelimiter &
attr_class_Val & vDelimiter &_
vRecordCount = vRecordCount + 1
Next
End If
Next
End If
Set third_prxprdt_main
= xmlDoc.selectNodes(second_prxprdt_xpath & "/proxyProduct")
No_third_prxprdt_length
= third_prxprdt_main.length-1
If
No_third_prxprdt_length >= 0 Then
For
vthirdPrxprdt_cnt = 0 To No_third_prxprdt_length
No_third_prxprdt_leg_length = third_proxprdt_leg.length-1
If
No_third_prxprdt_leg_length >= 0 Then
Execute ExecuteOnly_third_PrxyPrdt_leg
Execute Execute_Attribute_type_leg
Set third_proxprdt_leg_legid =
third_proxprdt_leg_node.item(0).Getelementsbytagname("legId")
Call
CashFlow_XMLBLOB_Extract(vProductTypeNode_Xpath,vEffdate,frontOfficeSysName_Val,vSo
urceSubsystemName,frontOfficeReferenceID_Val,vProduct_Val,vCurrency_Val,_
vOTC_Val,vAttr_type,attr_Type_Id_Val,attr_class_Val,attr_name_Val,attr_Val_Val,Obj_
Write_Trade)
third_proxprdt_leg_xmlblob_length = third_proxprdt_leg_xmlblob_node.length-1
If third_proxprdt_leg_xmlblob_length>=0 Then
Set third_proxprdt_leg_xmlblob_child =
third_proxprdt_leg_xmlblob_node.item(third_proxprdt_leg_xmlblob_length_cnt).childNo
des
third_proxprdt_leg_xmlblob_lenth = third_proxprdt_leg_xmlblob_child.length-1
attr_class_Val =
third_proxprdt_leg_xmlblob_child.item(third_proxprdt_leg_xmbob_cnt).nodeName
attr_Name_Val =
third_proxprdt_leg_xmlblob_child.item(third_proxprdt_leg_xmbob_cnt).nodeName
attr_Val_Val =
third_proxprdt_leg_xmlblob_child.item(third_proxprdt_leg_xmbob_cnt).text
vDelimiter & vProduct_Val & vDelimiter & vCurrency_Val & vDelimiter & vOTC_Val &_
vDelimiter & vAttr_type & vDelimiter & attr_Type_Id_Val & vDelimiter &
attr_class_Val & vDelimiter &_
vRecordCount = vRecordCount + 1
Next
Next
End If
Next
End If
Set
third_proxprdt_xmlblob_node = xmlDoc.selectNodes(third_prxprdt_xpath & "/xml_blob"
& OnlyRefentity_swap)
If
third_proxprdt_xmlblob_node.length > 0 Then
Set
attr_Type_Id_Elmt = third_proxprdt_xmlblob_node.item(0).childnodes
Execute Execute_Attribute_type_outside
attr_Type_Id_Val = ""
For
third_xmlblob_childnodes_cnt = 0 To attr_Type_Id_Elmt.length-1
Set ref_Entity_Elmt =
attr_Type_Id_Elmt.item(third_xmlblob_childnodes_cnt).childNodes
ref_Entitiy_Child_Length = ref_Entity_Elmt.length-1
If ref_Entitiy_Child_Length = 0 Then
attr_class_Val = ref_Entity_Elmt.item(0).parentNode.nodeName
attr_Name_Val = ref_Entity_Elmt.item(0).parentNode.nodeName
attr_Val_Val = ref_Entity_Elmt.item(0).text
vDelimiter & vProduct_Val & vDelimiter & vCurrency_Val & vDelimiter & vOTC_Val &_
vDelimiter & vAttr_type & vDelimiter & attr_Type_Id_Val & vDelimiter &
attr_class_Val & vDelimiter &_
vRecordCount = vRecordCount + 1
attr_class_Val = ref_Entity_Elmt.item(refEntityIterator).parentNode.nodeName
attr_Name_Val = ref_Entity_Elmt.item(refEntityIterator).nodeName
attr_Val_Val = ref_Entity_Elmt.item(refEntityIterator).text
vDelimiter & vProduct_Val & vDelimiter & vCurrency_Val & vDelimiter & vOTC_Val &_
vDelimiter & vAttr_type & vDelimiter & attr_Type_Id_Val & vDelimiter &
attr_class_Val & vDelimiter &_
vRecordCount = vRecordCount + 1
Next
End If
Next
End If
Next
End If
Next
End If
End If
End If
Exit Do
Loop
Loop
vTotal_ExecTime = Timer - vTimer_Start
Msgbox " Trade count completed" & Chr(10) & " Execution Time = " &
Round(vTotal_ExecTime,2) & " Sec" & Chr(10) & "Total Number of Trade records in --
" & vRecordCount
Obj_Write_Trade.Close
Else
Msgbox "Unable to fetch result from unix box"
End If
vProduct_Val = Empty
vCurrency_Val = Empty
vOTC_Val = Empty
End Function
Public Function
CashFlow_XMLBLOB_Extract(fProxyProduct_Xpath,vEffdate,frontOfficeSysName_Val,vSourc
eSubsystemName,frontOfficeReferenceID_Val,vProduct_Val,_
vCurrency_Val,vOTC_Val,vAttr_type,attr_Type_Id_Val,attr_class_Val,attr_name_Val,att
r_Val_Val,Obj_Write_Trade)
vRecordCount = vRecordCount + 1
Next
Next
End If
End If
End Function
End Function