Radar
13 years agoOccasional Contributor
Unable To Delete File After Opening
I am testing a system in a VM environment.
TC resides on a Win7 VM and SUT resides across 8 VM's (some Linux, some Server 2003) in this environment.
As part of testing, I prepare the test data in JADE and Oracle databases.
This involves executing some JADE code on an application server which then calls Java code.
This code can either "Validate" the data input files (CSV files), "Delete" or "Update" data in the databases.
The Delete/Update process first delete/add data to/from the JADE system which then triggers the process to delete/add data to/from the Oracle database.
As part of the routines, log files are produced that contains information about the process progress and state.
I monitor the Jade log file to determine when the process is complete.
An entry is made when the process starts, when the task is passed to the Java process and then return codes when the Java process is completed, which indicates that the entire process is completed.
The process I follow is to Delete to test data followed by Update to add test data.
The process I follow is:
1. Delete log files
2. Delete test data
a) trigger task
b) monitor Jade log file
3. Copy log file to result directory on TC VM
4. Delete log files
5. Update test data
a) trigger task
b) monitor Jade log file
6. Copy log file to result directory on TC VM
The problem I have is that I am unable to "Delete log files" in step 4 as the file is being used by another process.
When I add a break point in the code that performs the delete, I attempt to delete the file manually (via command line) I get the same message.
Only when I stop the TC test run am I able to delete the log file.
I suspect the issue is when I open the file to read the contents, and when I find the content I am looking for, I close the file, however TC does not release the handle on the log file until the test run is completed.
Can you assist with the problem?
CODE SNIPPET - to examine log file
while ((!textFound)&&(i<(timeLimit*timeMultiplier)))
{
logFile = aqFile.OpenTextFile(fullFileName, aqFile.faRead, aqFile.ctANSI)
totalLines = logFile.LinesCount;
logFile.SetPosition(totalLines-lastLineOffset, columnPosition);
lineText = logFile.ReadString(readStringLength);
if(lineText == lineTextSearch)
{
textFound = true;
totalLines = logFile.LinesCount;
logFile.SetPosition(totalLines-lastLineOffset, columnPosition);
lineText = logFile.ReadLine();
logResultObject = {textFound:textFound, lineText:lineText};
logFile.Close();
}
Delay(timeDelay);
i++;
}
CODE SNIPPET - to delete log file
while ((!successFlag) && (i < failAttempt))
{
//successFlag = aqFile.Delete(fullFileName);
successFlag = aqFileSystem.DeleteFile(fullFileName);
i++
Delay(timeDelay);
}
TC resides on a Win7 VM and SUT resides across 8 VM's (some Linux, some Server 2003) in this environment.
As part of testing, I prepare the test data in JADE and Oracle databases.
This involves executing some JADE code on an application server which then calls Java code.
This code can either "Validate" the data input files (CSV files), "Delete" or "Update" data in the databases.
The Delete/Update process first delete/add data to/from the JADE system which then triggers the process to delete/add data to/from the Oracle database.
As part of the routines, log files are produced that contains information about the process progress and state.
I monitor the Jade log file to determine when the process is complete.
An entry is made when the process starts, when the task is passed to the Java process and then return codes when the Java process is completed, which indicates that the entire process is completed.
The process I follow is to Delete to test data followed by Update to add test data.
The process I follow is:
1. Delete log files
2. Delete test data
a) trigger task
b) monitor Jade log file
3. Copy log file to result directory on TC VM
4. Delete log files
5. Update test data
a) trigger task
b) monitor Jade log file
6. Copy log file to result directory on TC VM
The problem I have is that I am unable to "Delete log files" in step 4 as the file is being used by another process.
When I add a break point in the code that performs the delete, I attempt to delete the file manually (via command line) I get the same message.
Only when I stop the TC test run am I able to delete the log file.
I suspect the issue is when I open the file to read the contents, and when I find the content I am looking for, I close the file, however TC does not release the handle on the log file until the test run is completed.
Can you assist with the problem?
CODE SNIPPET - to examine log file
while ((!textFound)&&(i<(timeLimit*timeMultiplier)))
{
logFile = aqFile.OpenTextFile(fullFileName, aqFile.faRead, aqFile.ctANSI)
totalLines = logFile.LinesCount;
logFile.SetPosition(totalLines-lastLineOffset, columnPosition);
lineText = logFile.ReadString(readStringLength);
if(lineText == lineTextSearch)
{
textFound = true;
totalLines = logFile.LinesCount;
logFile.SetPosition(totalLines-lastLineOffset, columnPosition);
lineText = logFile.ReadLine();
logResultObject = {textFound:textFound, lineText:lineText};
logFile.Close();
}
Delay(timeDelay);
i++;
}
CODE SNIPPET - to delete log file
while ((!successFlag) && (i < failAttempt))
{
//successFlag = aqFile.Delete(fullFileName);
successFlag = aqFileSystem.DeleteFile(fullFileName);
i++
Delay(timeDelay);
}