-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop' into fb_browserTimeZone
- Loading branch information
Showing
9 changed files
with
196 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.labkey.test.stress; | ||
|
||
import org.labkey.remoteapi.CommandException; | ||
import org.labkey.remoteapi.Connection; | ||
import org.labkey.remoteapi.miniprofiler.RequestInfo; | ||
import org.labkey.test.util.LogMethod; | ||
import org.labkey.test.util.LoggedParam; | ||
import org.labkey.test.util.TestLogger; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.function.Supplier; | ||
|
||
public class ActivityRecorder | ||
{ | ||
private final RecentRequestsCollector recentRequestsCollector; | ||
|
||
public ActivityRecorder(Connection connection) throws IOException, CommandException | ||
{ | ||
recentRequestsCollector = new RecentRequestsCollector(connection); | ||
} | ||
|
||
@LogMethod | ||
public <R> R recordActivity(@LoggedParam String description, Supplier<R> activity) throws IOException, CommandException | ||
{ | ||
R result = activity.get(); | ||
|
||
List<RequestInfo> recentRequests = recentRequestsCollector.getRecentRequests(); | ||
TestLogger.log("%s triggered %s requests".formatted(description, recentRequests.size())); | ||
|
||
return result; | ||
} | ||
|
||
public void recordActivity(String description, Runnable activity) throws IOException, CommandException | ||
{ | ||
recordActivity(description, () -> { | ||
activity.run(); | ||
return null; | ||
}); | ||
} | ||
|
||
public List<RequestInfo> skipRecentRequests() throws IOException, CommandException | ||
{ | ||
List<RequestInfo> recentRequests = recentRequestsCollector.getRecentRequests(); | ||
TestLogger.log("Skipping %s requests".formatted(recentRequests.size())); | ||
|
||
return recentRequests; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package org.labkey.test.stress; | ||
|
||
import org.labkey.remoteapi.CommandException; | ||
import org.labkey.remoteapi.Connection; | ||
import org.labkey.remoteapi.miniprofiler.RecentRequestsCommand; | ||
import org.labkey.remoteapi.miniprofiler.RequestInfo; | ||
import org.labkey.test.util.Crawler; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class RecentRequestsCollector | ||
{ | ||
private final Connection _connection; | ||
private long lastRequestId = 0L; | ||
|
||
public RecentRequestsCollector(Connection connection) throws IOException, CommandException | ||
{ | ||
_connection = connection; | ||
getRecentRequests(); // Prime 'lastRequestId' | ||
} | ||
|
||
public List<RequestInfo> getRecentRequests() throws IOException, CommandException | ||
{ | ||
List<RequestInfo> requestInfos = new RecentRequestsCommand(lastRequestId).execute(_connection, null).getRequestInfos(); | ||
lastRequestId = requestInfos.get(requestInfos.size() - 1).getId(); | ||
return requestInfos.stream().filter(requestInfo -> HarConverter.EXCLUDED_ACTIONS.contains(new Crawler.ControllerActionId(requestInfo.getUrl()))).toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.