ReplayRecordsFromFeeder: Refactor the after method

While aligning it with CloneUsingBothProtocols, i.e.:

- Extract the duplicated path into a reused local value.
- Move the Thread.sleep out of the try block.
- Remove the comment as it will come back in case of failure.

Next refactoring step(s) then: to extract duplication from these two
sibling scenario classes. Likely by means of introducing a common parent
class, as an intermediary between these two and their Simulation parent.
This is so the framework becomes more and more reusable and extensible.

Change-Id: I20eab87b4b533c356b1831fa346a1df4fce14729
This commit is contained in:
Marco Miller
2020-02-03 19:16:20 -05:00
parent b416ab0db5
commit 561560a891

View File

@@ -55,14 +55,13 @@ class ReplayRecordsFromFeeder extends Simulation {
.maxDuration(60 seconds)
after {
Thread.sleep(5000)
val path = conf.tmpBasePath
try {
//After is often called too early. Some retries should be implemented.
Thread.sleep(5000)
FileUtils.deleteDirectory(new File(conf.tmpBasePath))
FileUtils.deleteDirectory(new File(path))
} catch {
case e: IOException =>
System.err.println(
"Unable to delete temporary directory: " + conf.tmpBasePath)
System.err.println("Unable to delete temporary directory " + path)
e.printStackTrace()
}
}