summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2022-03-23 09:15:51 +0000
committerGerrit Code Review <review@openstack.org>2022-03-23 09:15:51 +0000
commit3eae2582d6c2c04ef6054f12015929a1a8f44cd3 (patch)
treef722c7ae14c4f6a33e1bf971da26cfce6e08588e /tests
parent4976fc2d690247a259b7907ab8915ca883330166 (diff)
parenteac322d252e39c3ca68fb11c91f60e6e2e2a396d (diff)
downloadzuul-3eae2582d6c2c04ef6054f12015929a1a8f44cd3.tar.gz
Merge "Report gross/total tenant resource usage stats"
Diffstat (limited to 'tests')
-rw-r--r--tests/base.py6
-rw-r--r--tests/unit/test_scheduler.py50
-rw-r--r--tests/unit/test_web.py6
3 files changed, 40 insertions, 22 deletions
diff --git a/tests/base.py b/tests/base.py
index 51149adbd..d5737f326 100644
--- a/tests/base.py
+++ b/tests/base.py
@@ -3675,7 +3675,7 @@ class FakeNodepool(object):
nodes.append(data)
return nodes
- def makeNode(self, request_id, node_type):
+ def makeNode(self, request_id, node_type, request):
now = time.time()
path = '/nodepool/nodes/'
remote_ip = os.environ.get('ZUUL_REMOTE_IPV4', '127.0.0.1')
@@ -3734,6 +3734,8 @@ class FakeNodepool(object):
if 'fedora-pod' in node_type:
data['connection_type'] = 'kubectl'
data['connection_port']['pod'] = 'fedora-abcdefg'
+ data['tenant_name'] = request['tenant_name']
+ data['requestor'] = request['requestor']
data = json.dumps(data).encode('utf8')
path = self.client.create(path, data,
@@ -3762,7 +3764,7 @@ class FakeNodepool(object):
request['state'] = 'fulfilled'
nodes = request.get('nodes', [])
for node in request['node_types']:
- nodeid = self.makeNode(oid, node)
+ nodeid = self.makeNode(oid, node, request)
nodes.append(nodeid)
request['nodes'] = nodes
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 4b84f7fda..c596028de 100644
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -2038,8 +2038,9 @@ class TestScheduler(ZuulTestCase):
self.assertEqual([], request.nodes)
# Some convenience variables for checking the stats.
- tenant_ram_stat = 'zuul.nodepool.resources.tenant.tenant-one.ram'
- project_ram_stat = ('zuul.nodepool.resources.project.'
+ tenant_ram_stat =\
+ 'zuul.nodepool.resources.in_use.tenant.tenant-one.ram'
+ project_ram_stat = ('zuul.nodepool.resources.in_use.project.'
'review_example_com/org/project.ram')
# Test that we zeroed the gauges
self.scheds.first.sched._runStats()
@@ -5701,45 +5702,54 @@ For CI problems and help debugging, contact ci@example.org"""
self.assertHistory([
dict(name='project-merge', result='SUCCESS', changes='1,1'),
])
+ self.assertReportedStat(
+ 'zuul.nodepool.resources.total.tenant.tenant-one.cores',
+ value='6', kind='g')
+ self.assertReportedStat(
+ 'zuul.nodepool.resources.total.tenant.tenant-one.ram',
+ value='3072', kind='g')
+ self.assertReportedStat(
+ 'zuul.nodepool.resources.total.tenant.tenant-one.instances',
+ value='3', kind='g')
# All 3 nodes are in use
self.assertReportedStat(
- 'zuul.nodepool.resources.tenant.tenant-one.cores',
+ 'zuul.nodepool.resources.in_use.tenant.tenant-one.cores',
value='6', kind='g')
self.assertReportedStat(
- 'zuul.nodepool.resources.tenant.tenant-one.ram',
+ 'zuul.nodepool.resources.in_use.tenant.tenant-one.ram',
value='3072', kind='g')
self.assertReportedStat(
- 'zuul.nodepool.resources.tenant.tenant-one.instances',
+ 'zuul.nodepool.resources.in_use.tenant.tenant-one.instances',
value='3', kind='g')
self.assertReportedStat(
- 'zuul.nodepool.resources.project.review_example_com/org/project.'
- 'cores', value='6', kind='g')
+ 'zuul.nodepool.resources.in_use.project.review_example_com/org/'
+ 'project.cores', value='6', kind='g')
self.assertReportedStat(
- 'zuul.nodepool.resources.project.review_example_com/org/project.'
- 'ram', value='3072', kind='g')
+ 'zuul.nodepool.resources.in_use.project.review_example_com/org/'
+ 'project.ram', value='3072', kind='g')
self.assertReportedStat(
- 'zuul.nodepool.resources.project.review_example_com/org/project.'
- 'instances', value='3', kind='g')
+ 'zuul.nodepool.resources.in_use.project.review_example_com/org/'
+ 'project.instances', value='3', kind='g')
# Check that resource usage counters are reported
self.assertReportedStat(
- 'zuul.nodepool.resources.tenant.tenant-one.cores',
+ 'zuul.nodepool.resources.in_use.tenant.tenant-one.cores',
kind='c')
self.assertReportedStat(
- 'zuul.nodepool.resources.tenant.tenant-one.ram',
+ 'zuul.nodepool.resources.in_use.tenant.tenant-one.ram',
kind='c')
self.assertReportedStat(
- 'zuul.nodepool.resources.tenant.tenant-one.instances',
+ 'zuul.nodepool.resources.in_use.tenant.tenant-one.instances',
kind='c')
self.assertReportedStat(
- 'zuul.nodepool.resources.project.review_example_com/org/project.'
- 'cores', kind='c')
+ 'zuul.nodepool.resources.in_use.project.review_example_com/org/'
+ 'project.cores', kind='c')
self.assertReportedStat(
- 'zuul.nodepool.resources.project.review_example_com/org/project.'
- 'ram', kind='c')
+ 'zuul.nodepool.resources.in_use.project.review_example_com/org/'
+ 'project.ram', kind='c')
self.assertReportedStat(
- 'zuul.nodepool.resources.project.review_example_com/org/project.'
- 'instances', kind='c')
+ 'zuul.nodepool.resources.in_use.project.review_example_com/org/'
+ 'project.instances', kind='c')
self.executor_server.hold_jobs_in_build = False
self.executor_server.release()
diff --git a/tests/unit/test_web.py b/tests/unit/test_web.py
index 98bbd5f77..0d0a6916d 100644
--- a/tests/unit/test_web.py
+++ b/tests/unit/test_web.py
@@ -387,7 +387,9 @@ class TestWeb(BaseTestWeb):
'label': 'label1',
'name': 'controller',
'aliases': [],
+ 'requestor': None,
'state': 'unknown',
+ 'tenant_name': None,
'user_data': None}],
},
'override_checkout': None,
@@ -435,7 +437,9 @@ class TestWeb(BaseTestWeb):
'label': 'label2',
'name': 'controller',
'aliases': [],
+ 'requestor': None,
'state': 'unknown',
+ 'tenant_name': None,
'user_data': None}],
},
'override_checkout': None,
@@ -1057,7 +1061,9 @@ class TestWeb(BaseTestWeb):
'id': None,
'label': 'label1',
'name': 'controller',
+ 'requestor': None,
'state': 'unknown',
+ 'tenant_name': None,
'user_data': None}]},
'override_branch': None,
'override_checkout': None,