' Copyright (c) 2023, Perforce Software, Inc. All rights reserved. ' ' Redistribution and use in source and binary forms, with or without ' modification, are permitted provided that the following conditions are met: ' ' 1. Redistributions of source code must retain the above copyright ' notice, this list of conditions and the following disclaimer. ' ' 2. Redistributions in binary form must reproduce the above copyright ' notice, this list of conditions and the following disclaimer in the ' documentation and/or other materials provided with the distribution. ' ' THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE ' IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ' ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY ' DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ' (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ' LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ' ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ' (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ' THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Option Explicit Dim BENCHMARK, P4CLIENT, P4CLIENTdir, P4PORT, P4ROOT, P4USER, BRANCHCMDS Dim P4JOURNALdir, P4JOURNAL, P4LOGdir, P4LOG, ZCKP, intPrintDebug Dim p4, p4d, RCSCHANGE, RCSDATE, DATETIME, YAMLFILE, YAMLINDENT RCSCHANGE = "$Change: 2518612 $" RCSDATE = "$Date: 2023/11/13 $" p4 = "C:\Program Files\Perforce\p4.exe" p4d = "C:\Program Files\Perforce\Server\p4d.exe" BENCHMARK = Split(Wscript.Scriptname, ".") (0) ' See branchsubmit.vbs.txt to learn how to extend test scenario BRANCHCMDS = array("integrate -v //depot/main/0... //depot/r36.0.0/0...") DATETIME = GetDateStr P4CLIENT = BENCHMARK & "-client" P4CLIENTdir = "C:\p4clients\" & BENCHMARK & "\" & P4CLIENT ' must NOT be an existing server! P4PORT = "127.0.0.1:31696" ' must NOT be an existing installation! P4ROOT = "C:\p4dbs\" & BENCHMARK P4JOURNALdir = "C:\p4journals\" & BENCHMARK ' must NOT be an existing journal! P4JOURNAL = P4JOURNALdir & "\journal" P4LOGdir = "C:\p4logs\" & BENCHMARK P4LOG = P4LOGdir & "\log" YAMLFILE = BENCHMARK & "." & DATETIME & ".yml" YAMLINDENT = " " ZCKP = "C:\p4ckps\reference01.2023.2.ckp.gz" 'intPrintDebug = "1" Sub LogMessage(msg) WScript.Stdout.Write(msg) End Sub Sub DebugMessage(msg) If (intPrintDebug) Then WScript.Stdout.Write(VbCrLf & "DEBUG: " & msg) End If End Sub Function GetRCSValue(strRCS) Dim objRegExRCS ' ' Return an RCS value from a string. The RCS value is the ' substring between the first and last space characters. ' ' Create a Regexp object to search and replace spec lines Set objRegExRCS = CreateObject("VBScript.RegExp") objRegExRCS.Pattern = "^[^ ]* (.*) [^ ]*$" GetRCSValue = objRegExRCS.Replace(strRCS, "$1") Set objRegExRCS = nothing End Function Function GetDateStr() Dim intDate, intTime, intYear, intMonth, intDay, intHour, intMin, intSec ' Create a date string that will be used with the logfile name. intDate = Date() intTime = Time() intYear = Year(intDate) intMonth = Month(intDate) intDay = Day(intDate) intHour = Hour(intTime) intMin = Minute(intTime) intSec = Second(intTime) 'Get the month : parse method if Len(intMonth)=1 Then intMonth = "0" & intMonth 'Get the day : parse method if Len(intDay)=1 Then intDay = "0" & intDay 'Get the hour : parse method if Len(intHour)=1 Then intHour = "0" & intHour 'Get the Minute : parse method if Len(intMin)=1 Then intMin = "0" & intMin 'Get the second : parse method if Len(intSec)=1 Then intSec = "0" & intSec GetDateStr = intYear & intMonth & intDay & intHour & intMin & intSec End Function Sub SetEnvironment Dim WshShell ' P4USER is the current USERNAME Set WshShell = WScript.CreateObject("WScript.Shell") P4USER = WshShell.ExpandEnvironmentStrings("%USERNAME%") ' Create Environment variables for the following. WshShell.Environment("PROCESS").Item("P4CLIENT") = P4CLIENT WshShell.Environment("PROCESS").Item("P4PORT") = P4PORT WshShell.Environment("PROCESS").Item("P4USER") = P4USER WshShell.Environment("PROCESS").Item("P4CONFIG") = "" Set WshShell = nothing End Sub Function CreateYamlFile() Dim objFSO, objOutfile Set objFSO = CreateObject("Scripting.FileSystemObject") objOutfile = objFSO.GetFolder(".") & "\" & YAMLFILE objFSO.CreateTextFile (objOutfile) CreateYamlFile = objOutfile Set objFSO = nothing End Function Sub WriteYamlFile (objOutfile, intYamlLevel, strText) Dim objFSO, objFile, i ' ' Indent the number of YAML levels desired. ' i = intYamlLevel Const ForAppending = 8 Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile(objOutfile, ForAppending, True) Do While i <> 0 objFile.Write(YAMLINDENT) i = i - 1 Loop objFile.WriteLine(strText) objFile.Close End Sub Function MakeDir (strPath) Dim strParentPath, objFSO DebugMessage("Creating: " & strPath) Set objFSO = CreateObject("Scripting.FileSystemObject") On Error Resume Next strParentPath = objFSO.GetParentFolderName(strPath) ' Create the folder if it doesn't exist If Not objFSO.FolderExists(strParentPath) Then MakeDir strParentPath End If If Not objFSO.FolderExists(strPath) Then objFSO.CreateFolder strPath End If On Error Goto 0 MakeDir = objFSO.FolderExists(strPath) Set objFSO = nothing End Function Function GetSeconds GetSeconds = Timer() End Function Function GetElapsed(intTimeStart) Dim intTimeEnd intTimeEnd = GetSeconds() If intTimeEnd < intTimeStart Then intTimeEnd = intTimeEnd + 86400 End If GetElapsed = Int(intTimeEnd - intTimeStart) End Function Function CheckProcess(strP4Process) Dim objWMIService, objProcess, colProcess, objRegExProcess Dim strComputer, intProcessStatus, strList intProcessStatus = 1 ' This is the localmachine strComputer = "." ' Create an object of the WMI services Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") ' Select all the Win32 processes Set colProcess = objWMIService.ExecQuery _ ("Select * from Win32_Process") Set objRegExProcess = CreateObject("VBScript.RegExp") objRegExProcess.Pattern = strP4Process ' If the process matches the "passed in" process, set to 0 For Each objProcess in colProcess If objRegExProcess.Test(objProcess.Name) Then intProcessStatus = 0 End If Next CheckProcess = intProcessStatus Set objRegExProcess = nothing End Function Function WaitListener Dim WshShell, objExec ' Run "p4 info" to make sure the p4d process is accepting requests Set WshShell = WScript.CreateObject("WScript.Shell") Set objExec = WshShell.Exec(chr(34) & p4 & chr(34) & " -p " _ & P4PORT & " info") If objExec.ProcessID = 0 And objExec.Status = 1 Then Err.Raise vbObjectError,,"WshShell.Exec failed." End If ' Wait until "p4 info" is completed until checking ExitCode Do While objExec.Status = 0 DebugMessage objExec.StdOut.ReadAll() DebugMessage objExec.StdErr.ReadAll() WScript.Sleep 100 Loop Waitlistener = objExec.ExitCode Set WshShell = nothing End Function Sub StartP4d Dim intWaitListener, intCount, strP4dArgs, objExec, WshShell intWaitListener = 1 Set WshShell = WScript.CreateObject("WScript.Shell") strP4dArgs = " -d -p " & P4PORT & " -r " & P4ROOT & " -J " _ & P4JOURNAL & " -q -L " & P4LOG & " -v server=3 -v track=1" ' This command can be redirected to a file for debug purposes Set objExec = WshShell.Exec("%ComSpec% /c " & chr(34) & p4d _ & chr(34) & " " & strP4dArgs & " > NUL:") Do Until intWaitListener = 0 intWaitListener = WaitListener() WScript.Sleep 1000 Loop LogMessage(" sleeping...") ' We are sleeping for 10 seconds before starting the test WScript.Sleep 10000 Set WshShell = nothing End Sub Sub StopP4d Dim intProcessStatus, intCount, objExec, WshShell intProcessStatus = 0 Set WshShell = WScript.CreateObject("WScript.Shell") Set objExec = WshShell.Exec(chr(34) & p4 & chr(34) & " -p " _ & P4PORT & " admin stop") Do While objExec.Status = 0 WScript.Sleep 1000 Loop Do Until intProcessStatus = 1 intProcessStatus = CheckProcess("p4d.exe") WScript.Sleep 1000 Loop LogMessage(" sleeping...") WScript.Sleep 10000 Set WshShell = nothing End Sub Function BuildSpec(strSpecType,strSpecSearchStr, strSpecReplaceStr) Dim strSpecString, strSpecReturn, objRegExSpec, objExec Dim strP4InputCmd, strP4OutputCmd, objOutput, objInput DebugMessage("Passing in: " & strSpecType & " " & strSpecSearchStr _ & " " & strSpecReplaceStr & VbCrLf) ' Setup the output and input commands strP4OutputCmd = chr(34) & p4 & chr(34) & " " & strSpecType & " -o" strP4InputCmd = chr(34) & p4 & chr(34) & " " & strSpecType & " -i " LogMessage(" executing...") Set WshShell = CreateObject("WScript.Shell") Set objOutput = WshShell.Exec(strP4OutputCmd) Set objInput = WshShell.Exec(strP4InputCmd) ' Create a Regexp object to search and replace spec lines Set objRegExSpec = CreateObject("VBScript.RegExp") objRegExSpec.Pattern = strSpecSearchStr Do Until objOutput.Stdout.AtEndOfStream strSpecString = objOutput.Stdout.ReadLine If objRegExSpec.Test(strSpecString) Then strSpecString = objRegExSpec.Replace(strSpecString, strSpecReplaceStr) End If objInput.Stdin.Write strSpecString & VbCrLf Loop ' Add a Control Z at the end of input to terminate objInput.Stdin.Write chr(26) ' Read STDOUT from the spec submission strSpecReturn = objInput.StdOut.ReadAll() BuildSpec = strSpecReturn Set objRegExSpec = nothing Set WshShell = nothing End Function Function GetVersion(prog) Dim objOutput, strVersion, objRegExVersion Dim WshShell, strP4Cmd Set WshShell = CreateObject("WScript.Shell") strP4Cmd = prog & " -V" Set objOutput = WshShell.Exec(strP4Cmd) Set objRegExVersion = CreateObject("VBScript.RegExp") objRegExVersion.Pattern = "^Rev. (.*)$" ' Read the version string output and peal out everything after Rev Do Until objOutput.Stdout.AtEndOfStream strVersion = objOutput.Stdout.ReadLine If objRegExVersion.Test(strVersion) Then GetVersion = objRegExVersion.Replace(strVersion,"$1") End If Loop Set WshShell = nothing Set objRegExVersion = nothing End Function Function GetArgs() Dim args For Each phaseArg in phaseArray args = args & " " & phaseArg Next GetArgs = args End Function Sub ExtractLog(logFile, dbOperation, extract) ' ' Extract the last occurrence of an operation from the server log. ' Dim FSO, logTS, dbOperationRE, logLast, logCurrent, line, extractTS Const ForReading = 1 Set FSO = CreateObject("Scripting.FileSystemObject") Set logTS = FSO.OpenTextFile(logFile, ForReading) Set dbOperationRE = CreateObject("VBScript.RegExp") dbOperationRE.Pattern = dbOperation ' ' Find the last occurrence of the desired operation in the server log. ' LogLast = -1 LogCurrent = 0 Do Until logTS.AtEndOfStream line = logTS.ReadLine If dbOperationRE.Test(line) Then ' ' An occurrence of the desired operation was found; ' record the position. The last position recorded ' will be for the last occurrence. ' logLast = logCurrent End If logCurrent = logCurrent + Len(line) + 2 ' lines end with CrLf Loop logTS.Close Set logTS = nothing Set dbOperationRE = nothing Set logTS = FSO.OpenTextFile(logFile, ForReading) Set extractTS = FSO.CreateTextFile(extract) ' ' Position to the last occurence of the desired operation. ' logTS.Skip(logLast) ' ' Extract the last occurrence of the desired operation. ' Do Until logTS.AtEndOfStream line = logTS.ReadLine If line = Empty Then ' ' The tracking information has been exhausted; there is ' no further information for the desired operation. ' Exit Do End If extractTS.WriteLine(line) Loop logTS.Close extractTS.Close Set logTS = nothing Set extractTS = nothing Set FSO = nothing End Sub Sub GetTable(extract, dbTable, table) ' ' Extract the tracking information for a table ' from an operation in the server log. ' Dim FSO, extractTS, tableTS, dbTableRE, seen, line Const ForReading = 1 Set FSO = CreateObject("Scripting.FileSystemObject") Set extractTS = FSO.OpenTextFile(extract, ForReading) Set tableTS = FSO.CreateTextFile(table) Set dbTableRE = CreateObject("VBScript.RegExp") ' ' Extract the tracking information for the desired table. ' seen = False dbTableRE.Pattern = "^--- " & dbTable & "$" ' look for desired table Do Until extractTS.AtEndOfStream line = extractTS.ReadLine If dbTableRE.Test(line) Then If Not seen Then ' ' Encountered the desired table. ' seen = True dbTableRE.Pattern = "^--- db\.|^$" ' look for next table Else ' ' Encountered the next table (or the end of the ' tracking information); there is nothing ' further for the desired table. ' Exit Do End If End If If seen Then tableTS.WriteLine(line) End If Loop Set dbTableRE = nothing extractTS.Close tableTS.Close Set extractTS = nothing Set tableTS = nothing Set FSO = nothing End Sub Function GetHeld(table, lockType) ' ' Get a held time for a table from an operation in the server log. ' Dim FSO, tableTS, lockRE, peekRE, line, matches, i Const ForReading = 1 Set FSO = CreateObject("Scripting.FileSystemObject") Set tableTS = FSO.OpenTextFile(table, ForReading) Set lockRE = CreateObject("VBScript.RegExp") lockRE.Pattern = "^--- (total\s)?lock(s)? wait\+held read\/write \d+ms\+(\d+)ms\/\d+ms\+(\d+)ms" Set peekRE = CreateObject("VBScript.RegExp") peekRE.Pattern = "^--- peek count \d+ wait\+held total\/max \d+ms\+(\d+)ms\/\d+ms\+\d+ms" GetHeld = "" Do Until tableTS.AtEndOfStream line = tableTS.ReadLine ' ' Attempt to match the line containing the desired held time. ' If lockType <> "peek" Then Set matches = lockRE.Execute(line) Else Set matches = peekRE.Execute(line) End If If matches.Count Then ' ' Line contains the desired held time; set an index for ' the submatch corresponding to the desired held time. ' If lockType = "read" Then i = 2 ElseIf lockType = "write" Then i = 3 Else i = 0 End If GetHeld = matches(0).SubMatches(i) Exit Do End If Loop Set matches = nothing Set lockRE = nothing Set peekRE = nothing tableTS.Close Set tableTS = nothing Set FSO = nothing End Function Sub Setup(objOutFile, intYamlLevel) Dim strSpecString, strSpecSearchStr, strSpecReplaceStr, strSpecRet Dim intTimeStart, intElapsed, intResult, dirList(3), objSubfolders Dim strP4Cmd, objExec, WshShell, strCkpName dirList(0) = P4CLIENTdir dirList(1) = P4ROOT dirList(2) = P4JOURNALdir dirList(3) = P4LOGdir LogMessage("Creating directories as needed...") For Each objSubfolders in dirList intResult = MakeDir(objSubfolders) Next LogMessage(" done." & VbCrLf) LogMessage("Replaying checkpoint...") ' Start the timer to determine archive uncompress duration intTimeStart = GetSeconds() ' Uncompress the reference archive strP4Cmd = (chr(34) & p4d & chr(34) & " -r " & P4ROOT & " -z -jr " & ZCKP) DebugMessage(strP4Cmd) Set WshShell = WScript.CreateObject("WScript.Shell") ' This command can be redirected to a file for debug purposes Set objExec = WshShell.Exec("%ComSpec% /c " & strP4Cmd) Do While objExec.Status = 0 WScript.Sleep 100 Loop ' Check the elapsed time intElapsed = GetElapsed(intTimeStart) LogMessage(" done." & VbCrLf) LogMessage(" checkpoint replay duration: " & intElapsed & " seconds" & VbCrLf) strCkpName = split(ZCKP,"\") WriteYamlFile objOutfile, intYamlLevel, "checkpointName: " & _ strCkpName(ubound(strCkpName)) WriteYamlFile objOutfile, intYamlLevel, "checkpointReplay: " & intElapsed LogMessage("Creating client...") StartP4d() ' About to replace the Root: entry in the client spec strSpecSearchStr = "^Root:(.*)$" strSpecReplaceStr = "Root: " & P4CLIENTdir strSpecRet = BuildSpec("client", strSpecSearchStr, strSpecReplaceStr) StopP4d() LogMessage(" done." & VbCrLf) Set WshShell = nothing End Sub Sub Runme(objOutfile, intYamlLevel) Dim FSO, TMP, EXTRACT, TABLE Dim strBranchStr, intHeld, cmdOutput, intChangeNumber Dim strSpecString, strSpecSearchStr, strSpecReplaceStr Dim dirList(3), objShell, strP4Cmd, objExec, strBranchCmd Dim intNumFiles, intCommitRate, strChangeStr, intTotalFiles, intBranch Const TemporaryFolder = 2 WriteYamlFile objOutfile, intYamlLevel, "numberOfBranches: " & _ UBound( BRANCHCMDS ) + 1 WriteYamlFile objOutfile, intYamlLevel, "branches:" intYamlLevel = intYamlLevel + 1 Set FSO = CreateObject("Scripting.FileSystemObject") TMP = FSO.GetSpecialFolder(TemporaryFolder) EXTRACT = TMP & "\" & FSO.GetTempName TABLE = TMP & "\" & FSO.GetTempName ' This object is created for the branch commands execution Set objShell = CreateObject("WScript.Shell") ' For each branch command execute intBranch = 0 For Each strBranchCmd in BRANCHCMDS intBranch = intBranch + 1 WriteYamlFile objOutFile, intYamlLevel, intBranch & ":" intYamlLevel = intYamlLevel + 1 ' Initialize number of files for each iteration intNumFiles = 0 LogMessage("Branching files...") StartP4d LogMessage(" executing...") ' Run the branch command strP4Cmd = (chr(34) & p4 & chr(34) & " " & strBranchCmd) DebugMessage(strP4Cmd) ' This command can be redirected to a file for debug purposes Set cmdOutput = objShell.Exec("%ComSpec% /c " & strP4Cmd ) Do Until cmdOutput.Stdout.AtEndOfStream strBranchStr = cmdOutput.Stdout.ReadLine ' increment the count to get number of files intNumFiles = intNumFiles + 1 Loop DebugMessage("intNumFiles = " & intNumFiles) StopP4d LogMessage(" done." & VbCrLf) ' Get the "user-integrate -v" tracking information for db.rev ExtractLog P4LOG, "user-integrate -v", EXTRACT GetTable EXTRACT, "db.rev", TABLE intHeld = GetHeld(TABLE, "read") If intHeld = "" Then ' ' No read lock held time was recorded; ' get the peek held time if it was recorded. ' intHeld = GetHeld(TABLE, "peek") End If If intHeld <> "" Then LogMessage(" compute phase duration: " & intHeld & " milliseconds" & VbCrLf) WriteYamlFile objOutfile, intYamlLevel, "branchComputeTime: " & intHeld End If LogMessage(" files opened: " & intNumFiles & VbCrLf) WriteYamlFile objOutfile, intYamlLevel, "filesOpened: " & intNumFiles FSO.DeleteFile(EXTRACT) FSO.DeleteFile(TABLE) ' Store file total for final changelist submission calculation intTotalFiles = intTotalFiles + intNumFiles intYamlLevel = intYamlLevel - 1 Next intYamlLevel = intYamlLevel - 1 LogMessage("Creating changelist...") StartP4d ' Here's the search and replace string for the change spec strSpecSearchStr = "\t+ NUL: 2>&1") DebugMessage(strP4Cmd & VbCrLf) Set WshShell = WScript.createobject("WScript.Shell") ' This command can be redirected to a file for debug purposes Set objExec = WshShell.Exec("%ComSpec% /c " & strP4Cmd) Do While objExec.Status = 0 WScript.Sleep 100 Loop StopP4d LogMessage(" done." & VbCrLf) ' Get the "dm-CommitSubmit" tracking information for db.integed ExtractLog P4LOG, "dm-CommitSubmit", EXTRACT GetTable EXTRACT, "db.integed", TABLE ' Get the write lock held time and use it to compute the commit rate intHeld = GetHeld(TABLE, "write") intCommitRate = Int(intTotalFiles * 1000/ intHeld) LogMessage(" commit duration: " & intHeld & " milliseconds" & VbCrLf) LogMessage(" commit rate: " & intCommitRate & " files/second" & VbCrLf) WriteYamlFile objOutfile, intYamlLevel, "totalFilesOpened: " & intTotalFiles WriteYamlFile objOutfile, intYamlLevel, "submitCommitTime: " & intHeld WriteYamlFile objOutfile, intYamlLevel, "submitCommitRate: " & intCommitRate FSO.DeleteFile(EXTRACT) FSO.DeleteFile(TABLE) LogMessage("Obliterating changelist...") StartP4d LogMessage(" executing...") strP4Cmd = (chr(34) & p4 & chr(34) & " obliterate -y @" & intChangeNumber & ",@" & intChangeNumber & " > NUL: 2>&1") DebugMessage(strP4Cmd & VbCrLf) ' Obliterate the changenumber Set WshShell = WScript.CreateObject("WScript.Shell") ' This command can be redirected to a file for debug purposes Set objExec = WshShell.Exec("%ComSpec% /c " & strP4Cmd) Do While objExec.Status = 0 WScript.Sleep 100 Loop StopP4d LogMessage(" done." & VbCrLf) LogMessage("Deleting changelist...") StartP4d Set objShell = CreateObject("WScript.Shell") strP4Cmd = (chr(34) & p4 & chr(34) & " change -d -f " & intChangeNumber & " > NUL: 2>&1") DebugMessage(strP4Cmd & VbCrLf) LogMessage(" executing...") Set WshShell = WScript.CreateObject("WScript.Shell") Set objExec = WshShell.Exec("%ComSpec% /c " & strP4Cmd) Do While objExec.Status = 0 WScript.Sleep 100 Loop StopP4d LogMessage(" done." & VbCrLf) If 1 = 0 Then ' Required for strict repeatability, but too dangereous ' to execute unless potential ramifications have been ' mitigated (i.e. this cannot be executed against a ' production server) LogMessage("Resetting changelist counter...") ' Restart Server StartP4d intChangeNumber = intChangeNumber - 1 LogMessage(" executing...") strP4Cmd = chr(34) & p4 & chr(34) & " counter -f change " _ & intChangeNumber Set WshShell = WScript.CreateObject("WScript.Shell") Set objExec = WshShell.Exec("%ComSpec% /c " & strP4Cmd & " > NUL:") Do While objExec.Status = 0 WScript.Sleep 100 Loop ' Stop the server and wait for it to quiesce. StopP4d LogMessage(" done." & VbCrLf) End If Set WshShell = nothing Set FSO = nothing End Sub Sub RemoveFolder(objFSO, folder) Dim subFolder, objFolder, colFiles, objFile Set objFolder = objFSO.GetFolder(folder) For Each subFolder in objFolder.Subfolders Set colFiles = objFolder.Files For Each objFile in colFiles DebugMessage("Deleting File: " & objFile.name) objFile.Delete(TRUE) Next DebugMessage("Deleting Folder: " & subFolder.name) subFolder.Delete(TRUE) Next objFolder.Delete(TRUE) End Sub Sub Cleanup() Dim LogFileDestination, strCurrentPath, objFileCopy, objRegExFile Dim objFolder, objFileCollection, objFile, objFSO, objJournal Set objFSO = CreateObject("Scripting.FileSystemObject") LogFileDestination = objFSO.GetFolder(".") & "\" & BENCHMARK _ & "." & DATETIME & ".log" If objFSO.FileExists(P4LOG) Then LogMessage("Moving server log to " & LogFileDestination) Set objFileCopy = objFSO.GetFile(P4LOG) ' Move the file destination objFileCopy.Move (LogFileDestination) End If LogMessage(" done. " & VbCrLf) LogMessage("Removing db.* files and journal file... ") ' Delete only files that are named db.* Set objFolder = objFSO.GetFolder(P4ROOT) Set objFileCollection = objFolder.Files For Each objFile in objFileCollection If instr(objFile,"db.") Then DebugMessage(objFile.name) objFile.Delete(TRUE) End If Next ' single the journal to be deleted If objFSO.FileExists(P4JOURNAL) Then Set objJournal = objFSO.GetFile(P4JOURNAL) DebugMessage(objJournal.name) objJournal.Delete(TRUE) End If LogMessage(" done." & VbCrLf) If objFSO.FolderExists(P4ROOT & "\server.locks") Then LogMessage("Removing server.locks subdirectory...") call RemoveFolder(objFSO, P4ROOT & "\server.locks") LogMessage(" done." & VbCrLf) End If Set objFSO = nothing End Sub Dim strUname, strOs, strUser, strArch, phaseArg, intProcessStatus Dim strP4dVersion, strP4Version, WshShell, intRunme, objOutfile Dim objFSO, strFname, intYamlLevel, strMachInfo ' check to make sure p4d isn't running before starting test intProcessStatus = CheckProcess("p4d.exe") If (intProcessStatus = 0) Then LogMessage("p4d.exe should be stopped before running test" & VbCrLf) WScript.Quit(1) End If ' If no arguments are given use "setup runme runme cleanup" If WScript.Arguments.Count = 0 Then phaseArray = Array("setup", "runme", "runme", "cleanup") Else Dim phaseArray(0) phaseArray(0) = WScript.Arguments(0) End If strP4dVersion = GetVersion(p4d) strP4Version = GetVersion(p4) Set WshShell = CreateObject("WScript.Shell") strUname = WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%") strUname=Split(strUname,".") (0) strUser = WshShell.ExpandEnvironmentStrings("%USERNAME%") strOs = WshShell.ExpandEnvironmentStrings("%OS%") strArch = WshShell.ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%") strMachInfo = strUname & " " & strUser & " " & strOs & " " & strArch LogMessage("Using versions:" & VbCrLf) LogMessage(" BRANCHSUBMIT.VBS/" & GetRCSValue(RCSCHANGE) _ & " (" & GetRCSValue(RCSDATE) & ")" & VbCrLf) LogMessage(" " & strP4dVersion & VbCrLf) LogMessage(" " & strP4Version & VbCrLf) LogMessage("On machine:" & VbCrLf) LogMessage(" " & strMachInfo & VbCrLf) objOutfile = CreateYamlFile() LogMessage("BRDB file:" & VbCrLf) LogMessage(" " & objOutfile & VbCrLf) intYamlLevel = 0 WriteYamlFile objOutfile, intYamlLevel, "benchmark: " & BENCHMARK WriteYamlFile objOutfile, intYamlLevel, "args:" & GetArgs() WriteYamlFile objOutfile, intYamlLevel, "testInfo:" intYamlLevel = intYamlLevel + 1 WriteYamlFile objOutfile, intYamlLevel, "rcsChange: " & GetRCSValue(RCSCHANGE) WriteYamlFile objOutfile, intYamlLevel, "rcsDate: " & GetRCSValue(RCSDATE) intYamlLevel = intYamlLevel - 1 WriteYamlFile objOutfile, intYamlLevel, "versions:" intYamlLevel = intYamlLevel + 1 WriteYamlFile objOutfile, intYamlLevel, "p4d: " & strP4dVersion WriteYamlFile objOutfile, intYamlLevel, "p4: " & strP4Version intYamlLevel = intYamlLevel - 1 WriteYamlFile objOutfile, intYamlLevel, "uname: " & chr(34) & strMachInfo & chr(34) ' Set the environment variables for the server. SetEnvironment intRunme = 0 For Each phaseArg in phaseArray LogMessage(VbCrLf & "Starting " & phaseArg & " phase..." & VbCrLf) Select Case phaseArg Case "setup" call Setup(objOutFile, intYamlLevel) Case "runme" If (intRunme = 0) Then WriteYamlFile objOutfile, intYamlLevel, "runme:" intYamlLevel = intYamlLevel + 1 End If intRunme = intRunme + 1 WriteYamlFile objOutfile, intYamlLevel, intRunme & ":" intYamlLevel = intYamlLevel + 1 call Runme(objOutfile, intYamlLevel) intYamlLevel = intYamlLevel - 1 Case "cleanup" call Cleanup() Case Else LogMessage(VbCrLf & "Phase " & phaseArg & " unknown! Terminating." & VbCrLf) WScript.Quit(1) End Select Next Set WshShell = nothing