Devserver: measure the PRC usage
This CL gives us the metric of how the devserver RPCs are used in lab.
BUG=None
TEST=Ran the unit test.
Change-Id: Ied1ba736ab7d2bfc7af7bb346dcdc0e3c7b665aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/1793719
Reviewed-by: C Shapiro <shapiroc@chromium.org>
Reviewed-by: Congbin Guo <guocb@chromium.org>
Tested-by: Congbin Guo <guocb@chromium.org>
Commit-Queue: Congbin Guo <guocb@chromium.org>
Auto-Submit: Congbin Guo <guocb@chromium.org>
diff --git a/apache_log_metrics_unittest.py b/apache_log_metrics_unittest.py
index 531142b..17c582a 100755
--- a/apache_log_metrics_unittest.py
+++ b/apache_log_metrics_unittest.py
@@ -21,6 +21,14 @@
' HTTP/1.1" 200 13805917 "-" "Wget/1.15 (linux-gnu)'
)
+RPC_REQUEST_LINE = (
+ '100.115.245.193 - - [08/Sep/2019:07:30:29 -0700] '
+ '"GET /list_suite_controls?suite_name=cros_test_platform'
+ '&build=candy-release/R78-12493.0.0 HTTP/1.1" 200 2724761 "-" "curl/7.35"',
+ '100.115.196.119 - - [08/Sep/2019:07:14:38 -0700] '
+ '"POST /update/nyan_big-release/R77-12371.46.0 HTTP/1.1" 200 416 "-" "-"',
+)
+
class TestParsers(unittest.TestCase):
"""Tests the parsing functions in apache_log_metrics."""
@@ -48,6 +56,12 @@
with mock.patch.object(apache_log_metrics, 'metrics'):
apache_log_metrics.EmitStaticRequestMetric(match)
+ def testEmitRpcUsageMetric(self):
+ for line in RPC_REQUEST_LINE:
+ match = apache_log_metrics.RPC_USAGE_MATCHER.match(line)
+ with mock.patch.object(apache_log_metrics, 'metrics'):
+ apache_log_metrics.EmitRpcUsageMetric(match)
+
if __name__ == '__main__':
unittest.main()