mirror of
https://github.com/goharbor/harbor.git
synced 2025-01-26 01:21:22 +01:00
Add e2e test for harbor metrics
Signed-off-by: DQ <dengq@vmware.com>
This commit is contained in:
parent
0271efd3f7
commit
27a9f71e26
36
tests/apitests/python/test_verify_metrics_enabled.py
Normal file
36
tests/apitests/python/test_verify_metrics_enabled.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import requests
|
||||||
|
import testutils
|
||||||
|
|
||||||
|
class TestMetricsExist(unittest.TestCase):
|
||||||
|
golang_basic_metrics = ["go_gc_duration_seconds", "go_goroutines", "go_info", "go_memstats_alloc_bytes"]
|
||||||
|
|
||||||
|
eigen_metrics = {
|
||||||
|
'core': golang_basic_metrics + ["harbor_core_http_request", "harbor_core_http_request_duration_seconds",
|
||||||
|
"harbor_core_http_request_inflight"],
|
||||||
|
'registry': golang_basic_metrics + ["registry_http_in_flight_requests"],
|
||||||
|
'exporter': golang_basic_metrics + ["harbor_image_pulled",
|
||||||
|
"harbor_project_artifact_total", "harbor_project_member_total", "harbor_project_quota_byte",
|
||||||
|
"harbor_project_repo_total", "harbor_project_total"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_metrics(self):
|
||||||
|
metrics_url = testutils.METRIC_URL+'/metrics'
|
||||||
|
exporter_res = requests.get(metrics_url)
|
||||||
|
core_res = requests.get(metrics_url, params={'comp': 'core'})
|
||||||
|
reg_res = requests.get(metrics_url, params={'comp': 'registry'})
|
||||||
|
return [('exporter', exporter_res.text), ('core', core_res.text), ('registry', reg_res.text)]
|
||||||
|
|
||||||
|
def testMetricsExist(self):
|
||||||
|
for k, metric_text in self.get_metrics():
|
||||||
|
for metric_name in self.eigen_metrics[k]:
|
||||||
|
print("Metric {} should exist in {} ".format(metric_name, k))
|
||||||
|
self.assertTrue(metric_name in metric_text)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
@ -31,6 +31,7 @@ TEARDOWN = os.environ.get('TEARDOWN', 'true').lower() in ('true', 'yes')
|
|||||||
notary_url = os.environ.get('NOTARY_URL', 'https://'+harbor_server+':4443')
|
notary_url = os.environ.get('NOTARY_URL', 'https://'+harbor_server+':4443')
|
||||||
DOCKER_USER = os.environ.get('DOCKER_USER', '')
|
DOCKER_USER = os.environ.get('DOCKER_USER', '')
|
||||||
DOCKER_PWD = os.environ.get('DOCKER_PWD', '')
|
DOCKER_PWD = os.environ.get('DOCKER_PWD', '')
|
||||||
|
METRIC_URL = os.environ.get('METRIC_URL', 'http://'+harbor_server+':9090')
|
||||||
|
|
||||||
def GetProductApi(username, password, harbor_server= os.environ.get("HARBOR_HOST", '')):
|
def GetProductApi(username, password, harbor_server= os.environ.get("HARBOR_HOST", '')):
|
||||||
|
|
||||||
|
@ -22,6 +22,11 @@ then
|
|||||||
sed "s/# github_token: xxx/github_token: $GITHUB_TOKEN/" -i make/harbor.yml
|
sed "s/# github_token: xxx/github_token: $GITHUB_TOKEN/" -i make/harbor.yml
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sed "s|# metric:|metric:|" -i make/harbor.yml
|
||||||
|
sed "s|# enabled: false| enabled: true|" -i make/harbor.yml
|
||||||
|
sed "s|# port: 9090| port: 9090|" -i make/harbor.yml
|
||||||
|
sed "s|# path: /metrics| path: /metrics|" -i make/harbor.yml
|
||||||
|
|
||||||
sudo make build_base_docker compile build prepare COMPILETAG=compile_golangimage GOBUILDTAGS="include_oss include_gcs" NOTARYFLAG=true TRIVYFLAG=true CHARTFLAG=true GEN_TLS=true
|
sudo make build_base_docker compile build prepare COMPILETAG=compile_golangimage GOBUILDTAGS="include_oss include_gcs" NOTARYFLAG=true TRIVYFLAG=true CHARTFLAG=true GEN_TLS=true
|
||||||
|
|
||||||
# set the debugging env
|
# set the debugging env
|
||||||
|
@ -156,3 +156,7 @@ Test Case - Tag Immutability
|
|||||||
Test Case - P2P
|
Test Case - P2P
|
||||||
[Tags] p2p
|
[Tags] p2p
|
||||||
Harbor API Test ./tests/apitests/python/test_p2p.py
|
Harbor API Test ./tests/apitests/python/test_p2p.py
|
||||||
|
|
||||||
|
Test Case - Metrics
|
||||||
|
[Tags] metrics
|
||||||
|
Harbor API Test ./tests/apitests/python/test_verify_metrics_enabled.py
|
||||||
|
Loading…
Reference in New Issue
Block a user