From b61e6e0d5aec328f3e0423f66096e186bba0665f Mon Sep 17 00:00:00 2001 From: shimon Date: Thu, 12 Jan 2023 19:41:14 +0200 Subject: [PATCH] usage test --- app/workers/usage.php | 18 +++++++++++++++++- tests/e2e/General/UsageTest.php | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/app/workers/usage.php b/app/workers/usage.php index 0d2f5d05bc..127f58a7cf 100644 --- a/app/workers/usage.php +++ b/app/workers/usage.php @@ -61,6 +61,7 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools 'value' => ($collections['value'] * -1), ]; } + if (!empty($documents['value'])) { $metrics[] = [ 'key' => 'documents', @@ -94,6 +95,9 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools 'key' => 'files', 'value' => ($files['value'] * -1), ]; + } + + if (!empty($storage['value'])) { $metrics[] = [ 'key' => 'files.storage', 'value' => ($storage['value'] * -1), @@ -115,6 +119,9 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools 'key' => 'deployments', 'value' => ($deployments['value'] * -1), ]; + } + + if (!empty($deploymentsStorage['value'])) { $metrics[] = [ 'key' => 'deployments.storage', 'value' => ($deploymentsStorage['value'] * -1), @@ -126,10 +133,16 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools 'key' => 'builds', 'value' => ($builds['value'] * -1), ]; + } + + if (!empty($buildsStorage['value'])) { $metrics[] = [ 'key' => 'builds.storage', 'value' => ($buildsStorage['value'] * -1), ]; + } + + if (!empty($buildsCompute['value'])) { $metrics[] = [ 'key' => 'builds.compute', 'value' => ($buildsCompute['value'] * -1), @@ -139,8 +152,11 @@ Server::setResource('reduce', function (Cache $cache, Registry $register, $pools if (!empty($executions['value'])) { $metrics[] = [ 'key' => 'executions', - 'value' => ($executions['value'] * -1), + 'value' => ($executionsCompute['value'] * -1), ]; + } + + if (!empty($executionsCompute['value'])) { $metrics[] = [ 'key' => 'executions.compute', 'value' => ($executionsCompute['value'] * -1), diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 67e911b1e6..6fffb037ab 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -18,7 +18,7 @@ class UsageTest extends Scope use SideServer; use FunctionsBase; - private const WAIT = 30; + private const WAIT = 35; private const CREATE = 20; protected string $projectId;