summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-04-20 15:26:37 +0200
committerRobin Appelman <robin@icewind.nl>2023-04-28 15:37:57 +0200
commite7ab30f5d8da574979f4c5b233f0cbd6827ecd90 (patch)
treedfdc5aabfdd50e81d4617ec96c9c504a22bf3687 /tests
parent74f31bac8c0473f3dc92fcb54967f4cf977c413f (diff)
downloadnextcloud-server-e7ab30f5d8da574979f4c5b233f0cbd6827ecd90.tar.gz
nextcloud-server-e7ab30f5d8da574979f4c5b233f0cbd6827ecd90.zip
log performance events for http requests
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Http/Client/ClientServiceTest.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/tests/lib/Http/Client/ClientServiceTest.php b/tests/lib/Http/Client/ClientServiceTest.php
index ed1165236aa..72281a0453c 100644
--- a/tests/lib/Http/Client/ClientServiceTest.php
+++ b/tests/lib/Http/Client/ClientServiceTest.php
@@ -14,12 +14,15 @@ namespace Test\Http\Client;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Handler\CurlHandler;
+use GuzzleHttp\Middleware;
use OC\Http\Client\Client;
use OC\Http\Client\ClientService;
use OC\Http\Client\DnsPinMiddleware;
+use OCP\Diagnostics\IEventLogger;
use OCP\ICertificateManager;
use OCP\IConfig;
use OCP\Security\IRemoteHostValidator;
+use Psr\Http\Message\RequestInterface;
/**
* Class ClientServiceTest
@@ -37,17 +40,24 @@ class ClientServiceTest extends \Test\TestCase {
->willReturn(function () {
});
$remoteHostValidator = $this->createMock(IRemoteHostValidator::class);
+ $eventLogger = $this->createMock(IEventLogger::class);
$clientService = new ClientService(
$config,
$certificateManager,
$dnsPinMiddleware,
- $remoteHostValidator
+ $remoteHostValidator,
+ $eventLogger
);
$handler = new CurlHandler();
$stack = HandlerStack::create($handler);
$stack->push($dnsPinMiddleware->addDnsPinning());
+ $stack->push(Middleware::tap(function (RequestInterface $request) use ($eventLogger) {
+ $eventLogger->start('http:request', $request->getMethod() . " request to " . $request->getRequestTarget());
+ }, function () use ($eventLogger) {
+ $eventLogger->end('http:request');
+ }), 'event logger');
$guzzleClient = new GuzzleClient(['handler' => $stack]);
$this->assertEquals(