mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-12-16 08:14:15 -05:00
Rename "temporary" to "test data" directory in network stress test
This commit is contained in:
parent
b02c5bf2be
commit
6c5c3371e6
1 changed files with 12 additions and 12 deletions
|
|
@ -45,8 +45,8 @@ public class NetworkStressTest {
|
||||||
|
|
||||||
// Instance fields
|
// Instance fields
|
||||||
|
|
||||||
/** A directory to temporarily hold seed and normal nodes' configuration and state files. */
|
/** A directory to (temporarily) hold seed and normal nodes' configuration and state files. */
|
||||||
private Path tempDir;
|
private Path testDataDir;
|
||||||
/** A single seed node that other nodes will contact to request initial data. */
|
/** A single seed node that other nodes will contact to request initial data. */
|
||||||
private SeedNode seedNode;
|
private SeedNode seedNode;
|
||||||
/** A list of peer nodes represented as P2P services. */
|
/** A list of peer nodes represented as P2P services. */
|
||||||
|
|
@ -67,11 +67,11 @@ public class NetworkStressTest {
|
||||||
// Set a security provider to allow key generation.
|
// Set a security provider to allow key generation.
|
||||||
Security.addProvider(new BouncyCastleProvider());
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
|
|
||||||
// Create the temporary directory.
|
// Create the test data directory.
|
||||||
tempDir = createTempDirectory();
|
testDataDir = createTestDataDirectory();
|
||||||
|
|
||||||
// Create and start the seed node.
|
// Create and start the seed node.
|
||||||
seedNode = new SeedNode(tempDir.toString());
|
seedNode = new SeedNode(testDataDir.toString());
|
||||||
final NodeAddress seedNodeAddress = getSeedNodeAddress();
|
final NodeAddress seedNodeAddress = getSeedNodeAddress();
|
||||||
final boolean useLocalhost = seedNodeAddress.hostName.equals("localhost");
|
final boolean useLocalhost = seedNodeAddress.hostName.equals("localhost");
|
||||||
final Set<NodeAddress> seedNodes = new HashSet<>(1);
|
final Set<NodeAddress> seedNodes = new HashSet<>(1);
|
||||||
|
|
@ -89,7 +89,7 @@ public class NetworkStressTest {
|
||||||
}
|
}
|
||||||
for (int p = 0; p < NPEERS; p++) {
|
for (int p = 0; p < NPEERS; p++) {
|
||||||
final int peerPort = Utils.findFreeSystemPort();
|
final int peerPort = Utils.findFreeSystemPort();
|
||||||
final File peerDir = new File(tempDir.toFile(), String.format("peer-%06d", p));
|
final File peerDir = new File(testDataDir.toFile(), String.format("peer-%06d", p));
|
||||||
final File peerTorDir = new File(peerDir, "tor");
|
final File peerTorDir = new File(peerDir, "tor");
|
||||||
final File peerStorageDir = new File(peerDir, "db");
|
final File peerStorageDir = new File(peerDir, "db");
|
||||||
final File peerKeysDir = new File(peerDir, "keys");
|
final File peerKeysDir = new File(peerDir, "keys");
|
||||||
|
|
@ -140,9 +140,9 @@ public class NetworkStressTest {
|
||||||
// Wait for concurrent tasks to finish.
|
// Wait for concurrent tasks to finish.
|
||||||
shutdownLatch.await();
|
shutdownLatch.await();
|
||||||
|
|
||||||
// Cleanup temporary directory.
|
// Cleanup test data directory.
|
||||||
if (tempDir != null) {
|
if (testDataDir != null) {
|
||||||
deleteTempDirectory();
|
deleteTestDataDirectory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,7 +156,7 @@ public class NetworkStressTest {
|
||||||
bootstrapLatch.await(30, TimeUnit.SECONDS));
|
bootstrapLatch.await(30, TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path createTempDirectory() throws IOException {
|
private Path createTestDataDirectory() throws IOException {
|
||||||
Path stressTestDirPath;
|
Path stressTestDirPath;
|
||||||
|
|
||||||
String stressTestDir = System.getenv(TEST_DIR_ENVVAR);
|
String stressTestDir = System.getenv(TEST_DIR_ENVVAR);
|
||||||
|
|
@ -173,11 +173,11 @@ public class NetworkStressTest {
|
||||||
return stressTestDirPath;
|
return stressTestDirPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteTempDirectory() throws IOException {
|
private void deleteTestDataDirectory() throws IOException {
|
||||||
// Based on <https://stackoverflow.com/a/27917071/6239236> by Tomasz Dzięcielewski.
|
// Based on <https://stackoverflow.com/a/27917071/6239236> by Tomasz Dzięcielewski.
|
||||||
if (System.getenv(TEST_DIR_ENVVAR) != null)
|
if (System.getenv(TEST_DIR_ENVVAR) != null)
|
||||||
return; // do not remove if given explicitly
|
return; // do not remove if given explicitly
|
||||||
Files.walkFileTree(tempDir, new SimpleFileVisitor<Path>() {
|
Files.walkFileTree(testDataDir, new SimpleFileVisitor<Path>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||||
Files.delete(file);
|
Files.delete(file);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue