-
Notifications
You must be signed in to change notification settings - Fork 4
BITMAG-1266-prevent-permanent-test-files #96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,25 +33,23 @@ | |
| import org.bitrepository.pillar.integration.perf.metrics.Metrics; | ||
| import org.bitrepository.pillar.messagefactories.GetFileMessageFactory; | ||
| import org.bitrepository.protocol.bus.MessageReceiver; | ||
| import org.junit.jupiter.api.AfterAll; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Tag; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.condition.DisabledIf; | ||
| import org.junit.jupiter.api.condition.EnabledIfSystemProperty; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| import java.io.IOException; | ||
| import java.nio.file.DirectoryStream; | ||
| import java.net.URL; | ||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
| import java.nio.file.Paths; | ||
|
|
||
| import static org.bitrepository.common.utils.AllureTestUtils.addDescription; | ||
| import static org.bitrepository.common.utils.AllureTestUtils.addStep; | ||
|
|
||
| @EnabledIfSystemProperty(named = "runStressTests", matches = "true") | ||
| public class GetFileStressIT extends PillarPerformanceIT { | ||
| public static final String FOLDER_NAME = "src/test/resources"; | ||
| @TempDir | ||
| static Path tempDir; | ||
| protected GetFileClient getFileClient; | ||
|
|
||
| @BeforeEach | ||
|
|
@@ -61,22 +59,6 @@ settingsForTestClient, createSecurityManager(), settingsForTestClient.getCompone | |
| ); | ||
| } | ||
|
|
||
| @AfterAll | ||
| static void removeUnnecessaryFiles() throws IOException { | ||
| removeFiles("noIdentfy", FOLDER_NAME); | ||
| removeFiles("parallel", FOLDER_NAME); | ||
| removeFiles("single", FOLDER_NAME); | ||
| } | ||
|
|
||
| private static void removeFiles(String fileStartsWith, String folderName) throws IOException { | ||
| Path directory = Paths.get(folderName); | ||
| try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory, fileStartsWith + "*")) { | ||
| for (Path entry : stream) { | ||
| Files.delete(entry); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| @Tag(PillarTestGroups.PILLAR_STRESS_TEST) | ||
| void singleGetFilePerformanceTest() throws Exception { | ||
|
|
@@ -116,6 +98,7 @@ void parallelGetFilePerformanceTest() throws Exception { | |
| EventHandler eventHandler = new OperationEventHandlerForMetrics(metrics, getLimiter); | ||
| for (int i = 1; i <= numberOfFiles; i++) { | ||
| getLimiter.addJob(defaultFileId); | ||
| URL testUrl = httpServerConfiguration.getURL(nonDefaultFileId + "-" + i); | ||
| getFileClient.getFileFromSpecificPillar( | ||
| collectionID, defaultFileId, null, httpServerConfiguration.getURL(nonDefaultFileId + "-" + i), | ||
| getPillarID(), eventHandler, " performing parallelGetFilePerformance"); | ||
|
|
@@ -146,11 +129,23 @@ void noIdentfyGetFilePerformanceTest() throws Exception { | |
| for (int i = 1; i <= numberOfFiles; i++) { | ||
| String correlationID = msgFactory.getNewCorrelationID(); | ||
| getLimiter.addJob(correlationID); | ||
| String fileName = nonDefaultFileId + "-" + i; | ||
|
|
||
| // Ensure the source file exists in the temp directory so the server can serve it | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? The test is also green without it. |
||
| Path sourceFile = tempDir.resolve(fileName); | ||
| if (!Files.exists(sourceFile)) { | ||
| Files.createFile(sourceFile); | ||
| } | ||
|
|
||
| // Create a unique destination path for each file within the temp directory | ||
| Path destinationFile = tempDir.resolve("noIdentfy-dest-" + i); | ||
| GetFileRequest getRequest = | ||
| msgFactory.createGetFileRequest("noIdentfyGetFilePerformanceTest", correlationID, | ||
| httpServerConfiguration.getURL(nonDefaultFileId + "-" + i).toExternalForm(), | ||
| msgFactory.createGetFileRequest(destinationFile.toAbsolutePath().toString(), | ||
| correlationID, | ||
| httpServerConfiguration.getURL(fileName).toExternalForm(), | ||
| defaultFileId, null, getPillarID(), getPillarID(), | ||
| settingsForTestClient.getReceiverDestinationID(), pillarDestination); | ||
| getRequest.setFileAddress("file:" + tempDir.toAbsolutePath().toString()+"/"+fileName); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this necessary? The test is also green without it. If we want it (for one reason or another), conventions say to put a space before and after each Matter of taste, we don’t need the |
||
| messageBus.sendMessage(getRequest); | ||
| } | ||
|
|
||
|
|
@@ -171,4 +166,4 @@ public String lookupGetFileDestination() { | |
| } | ||
| return pillarDestination; | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than a field here would we want to reduce the scope by making it a parameter to the method that uses it? See my comment to the method header.