From d07247f0289a0355f21e670fcdc49e7e3aaf1d71 Mon Sep 17 00:00:00 2001 From: Massimiliano Giovagnoli Date: Thu, 21 Nov 2024 22:36:33 +0100 Subject: [PATCH 1/6] chore(nvml/datadog_checks/nvml): regenerate protobuf code The current generated protobuf code is no longer compatible with the version of runtime protobuf implementation bundled with the Datadog Agent. This api protobuf code is regenerated using Python protobuf 5.27.2. It should be compatible with Agent >= 7.56.0. Signed-off-by: Massimiliano Giovagnoli --- nvml/datadog_checks/nvml/README.md | 15 + nvml/datadog_checks/nvml/api_pb2.py | 380 ++-------------------- nvml/datadog_checks/nvml/requirements.txt | 4 + 3 files changed, 51 insertions(+), 348 deletions(-) create mode 100644 nvml/datadog_checks/nvml/README.md create mode 100644 nvml/datadog_checks/nvml/requirements.txt diff --git a/nvml/datadog_checks/nvml/README.md b/nvml/datadog_checks/nvml/README.md new file mode 100644 index 0000000000..55bcb83096 --- /dev/null +++ b/nvml/datadog_checks/nvml/README.md @@ -0,0 +1,15 @@ +# NVML Datadog check + +## Development + +### Regenerate API protobuf code + +```shell +$ python3 -m venv .venv +$ . .venv/bin/activate +(venv) $ python3 -m pip install -r requirements.txt +(venv) $ python3 -m grpc_tools.protoc --python_out=. --proto_path=. api.proto +(venv) $ deactivate +$ +``` + diff --git a/nvml/datadog_checks/nvml/api_pb2.py b/nvml/datadog_checks/nvml/api_pb2.py index 2680fbf99d..657429bd23 100644 --- a/nvml/datadog_checks/nvml/api_pb2.py +++ b/nvml/datadog_checks/nvml/api_pb2.py @@ -1,362 +1,46 @@ # -*- coding: utf-8 -*- # Generated by the protocol buffer compiler. DO NOT EDIT! +# NO CHECKED-IN PROTOBUF GENCODE # source: api.proto -# flake8: noqa - +# Protobuf Python Version: 5.27.2 +"""Generated protocol buffer code.""" from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import runtime_version as _runtime_version from google.protobuf import symbol_database as _symbol_database - +from google.protobuf.internal import builder as _builder +_runtime_version.ValidateProtobufRuntimeVersion( + _runtime_version.Domain.PUBLIC, + 5, + 27, + 2, + '', + 'api.proto' +) # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() -DESCRIPTOR = _descriptor.FileDescriptor( - name='api.proto', - package='v1alpha1', - syntax='proto3', - serialized_options=None, - serialized_pb=b'\n\tapi.proto\x12\x08v1alpha1\"\x19\n\x17ListPodResourcesRequest\"I\n\x18ListPodResourcesResponse\x12-\n\rpod_resources\x18\x01 \x03(\x0b\x32\x16.v1alpha1.PodResources\"a\n\x0cPodResources\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x30\n\ncontainers\x18\x03 \x03(\x0b\x32\x1c.v1alpha1.ContainerResources\"O\n\x12\x43ontainerResources\x12\x0c\n\x04name\x18\x01 \x01(\t\x12+\n\x07\x64\x65vices\x18\x02 \x03(\x0b\x32\x1a.v1alpha1.ContainerDevices\"=\n\x10\x43ontainerDevices\x12\x15\n\rresource_name\x18\x01 \x01(\t\x12\x12\n\ndevice_ids\x18\x02 \x03(\t2e\n\x12PodResourcesLister\x12O\n\x04List\x12!.v1alpha1.ListPodResourcesRequest\x1a\".v1alpha1.ListPodResourcesResponse\"\x00\x62\x06proto3', -) - - -_LISTPODRESOURCESREQUEST = _descriptor.Descriptor( - name='ListPodResourcesRequest', - full_name='v1alpha1.ListPodResourcesRequest', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[], - serialized_start=23, - serialized_end=48, -) - - -_LISTPODRESOURCESRESPONSE = _descriptor.Descriptor( - name='ListPodResourcesResponse', - full_name='v1alpha1.ListPodResourcesResponse', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='pod_resources', - full_name='v1alpha1.ListPodResourcesResponse.pod_resources', - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[], - serialized_start=50, - serialized_end=123, -) - - -_PODRESOURCES = _descriptor.Descriptor( - name='PodResources', - full_name='v1alpha1.PodResources', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='name', - full_name='v1alpha1.PodResources.name', - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode('utf-8'), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name='namespace', - full_name='v1alpha1.PodResources.namespace', - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode('utf-8'), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name='containers', - full_name='v1alpha1.PodResources.containers', - index=2, - number=3, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[], - serialized_start=125, - serialized_end=222, -) - - -_CONTAINERRESOURCES = _descriptor.Descriptor( - name='ContainerResources', - full_name='v1alpha1.ContainerResources', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='name', - full_name='v1alpha1.ContainerResources.name', - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode('utf-8'), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name='devices', - full_name='v1alpha1.ContainerResources.devices', - index=1, - number=2, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[], - serialized_start=224, - serialized_end=303, -) - - -_CONTAINERDEVICES = _descriptor.Descriptor( - name='ContainerDevices', - full_name='v1alpha1.ContainerDevices', - filename=None, - file=DESCRIPTOR, - containing_type=None, - fields=[ - _descriptor.FieldDescriptor( - name='resource_name', - full_name='v1alpha1.ContainerDevices.resource_name', - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode('utf-8'), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - _descriptor.FieldDescriptor( - name='device_ids', - full_name='v1alpha1.ContainerDevices.device_ids', - index=1, - number=2, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax='proto3', - extension_ranges=[], - oneofs=[], - serialized_start=305, - serialized_end=366, -) - -_LISTPODRESOURCESRESPONSE.fields_by_name['pod_resources'].message_type = _PODRESOURCES -_PODRESOURCES.fields_by_name['containers'].message_type = _CONTAINERRESOURCES -_CONTAINERRESOURCES.fields_by_name['devices'].message_type = _CONTAINERDEVICES -DESCRIPTOR.message_types_by_name['ListPodResourcesRequest'] = _LISTPODRESOURCESREQUEST -DESCRIPTOR.message_types_by_name['ListPodResourcesResponse'] = _LISTPODRESOURCESRESPONSE -DESCRIPTOR.message_types_by_name['PodResources'] = _PODRESOURCES -DESCRIPTOR.message_types_by_name['ContainerResources'] = _CONTAINERRESOURCES -DESCRIPTOR.message_types_by_name['ContainerDevices'] = _CONTAINERDEVICES -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -ListPodResourcesRequest = _reflection.GeneratedProtocolMessageType( - 'ListPodResourcesRequest', - (_message.Message,), - { - 'DESCRIPTOR': _LISTPODRESOURCESREQUEST, - '__module__': 'api_pb2', - # @@protoc_insertion_point(class_scope:v1alpha1.ListPodResourcesRequest) - }, -) -_sym_db.RegisterMessage(ListPodResourcesRequest) - -ListPodResourcesResponse = _reflection.GeneratedProtocolMessageType( - 'ListPodResourcesResponse', - (_message.Message,), - { - 'DESCRIPTOR': _LISTPODRESOURCESRESPONSE, - '__module__': 'api_pb2', - # @@protoc_insertion_point(class_scope:v1alpha1.ListPodResourcesResponse) - }, -) -_sym_db.RegisterMessage(ListPodResourcesResponse) - -PodResources = _reflection.GeneratedProtocolMessageType( - 'PodResources', - (_message.Message,), - { - 'DESCRIPTOR': _PODRESOURCES, - '__module__': 'api_pb2', - # @@protoc_insertion_point(class_scope:v1alpha1.PodResources) - }, -) -_sym_db.RegisterMessage(PodResources) - -ContainerResources = _reflection.GeneratedProtocolMessageType( - 'ContainerResources', - (_message.Message,), - { - 'DESCRIPTOR': _CONTAINERRESOURCES, - '__module__': 'api_pb2', - # @@protoc_insertion_point(class_scope:v1alpha1.ContainerResources) - }, -) -_sym_db.RegisterMessage(ContainerResources) - -ContainerDevices = _reflection.GeneratedProtocolMessageType( - 'ContainerDevices', - (_message.Message,), - { - 'DESCRIPTOR': _CONTAINERDEVICES, - '__module__': 'api_pb2', - # @@protoc_insertion_point(class_scope:v1alpha1.ContainerDevices) - }, -) -_sym_db.RegisterMessage(ContainerDevices) - -_PODRESOURCESLISTER = _descriptor.ServiceDescriptor( - name='PodResourcesLister', - full_name='v1alpha1.PodResourcesLister', - file=DESCRIPTOR, - index=0, - serialized_options=None, - serialized_start=368, - serialized_end=469, - methods=[ - _descriptor.MethodDescriptor( - name='List', - full_name='v1alpha1.PodResourcesLister.List', - index=0, - containing_service=None, - input_type=_LISTPODRESOURCESREQUEST, - output_type=_LISTPODRESOURCESRESPONSE, - serialized_options=None, - ), - ], -) -_sym_db.RegisterServiceDescriptor(_PODRESOURCESLISTER) -DESCRIPTOR.services_by_name['PodResourcesLister'] = _PODRESOURCESLISTER +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tapi.proto\x12\x08v1alpha1\"\x19\n\x17ListPodResourcesRequest\"I\n\x18ListPodResourcesResponse\x12-\n\rpod_resources\x18\x01 \x03(\x0b\x32\x16.v1alpha1.PodResources\"a\n\x0cPodResources\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x30\n\ncontainers\x18\x03 \x03(\x0b\x32\x1c.v1alpha1.ContainerResources\"O\n\x12\x43ontainerResources\x12\x0c\n\x04name\x18\x01 \x01(\t\x12+\n\x07\x64\x65vices\x18\x02 \x03(\x0b\x32\x1a.v1alpha1.ContainerDevices\"=\n\x10\x43ontainerDevices\x12\x15\n\rresource_name\x18\x01 \x01(\t\x12\x12\n\ndevice_ids\x18\x02 \x03(\t2e\n\x12PodResourcesLister\x12O\n\x04List\x12!.v1alpha1.ListPodResourcesRequest\x1a\".v1alpha1.ListPodResourcesResponse\"\x00\x62\x06proto3') +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'api_pb2', _globals) +if not _descriptor._USE_C_DESCRIPTORS: + DESCRIPTOR._loaded_options = None + _globals['_LISTPODRESOURCESREQUEST']._serialized_start=23 + _globals['_LISTPODRESOURCESREQUEST']._serialized_end=48 + _globals['_LISTPODRESOURCESRESPONSE']._serialized_start=50 + _globals['_LISTPODRESOURCESRESPONSE']._serialized_end=123 + _globals['_PODRESOURCES']._serialized_start=125 + _globals['_PODRESOURCES']._serialized_end=222 + _globals['_CONTAINERRESOURCES']._serialized_start=224 + _globals['_CONTAINERRESOURCES']._serialized_end=303 + _globals['_CONTAINERDEVICES']._serialized_start=305 + _globals['_CONTAINERDEVICES']._serialized_end=366 + _globals['_PODRESOURCESLISTER']._serialized_start=368 + _globals['_PODRESOURCESLISTER']._serialized_end=469 # @@protoc_insertion_point(module_scope) diff --git a/nvml/datadog_checks/nvml/requirements.txt b/nvml/datadog_checks/nvml/requirements.txt new file mode 100644 index 0000000000..67c8a99839 --- /dev/null +++ b/nvml/datadog_checks/nvml/requirements.txt @@ -0,0 +1,4 @@ +grpcio==1.67.1 +grpcio-tools==1.67.1 +protobuf==5.27.3 +setuptools==75.4.0 From b8f31b3b02be30014264acec43254f41fc531d25 Mon Sep 17 00:00:00 2001 From: Massimiliano Giovagnoli Date: Thu, 21 Nov 2024 22:46:41 +0100 Subject: [PATCH 2/6] chore(nvml): format check protobuf code Signed-off-by: Massimiliano Giovagnoli --- nvml/datadog_checks/nvml/api_pb2.py | 42 +++++++++++++---------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/nvml/datadog_checks/nvml/api_pb2.py b/nvml/datadog_checks/nvml/api_pb2.py index 657429bd23..1f4a6f382d 100644 --- a/nvml/datadog_checks/nvml/api_pb2.py +++ b/nvml/datadog_checks/nvml/api_pb2.py @@ -9,38 +9,32 @@ from google.protobuf import runtime_version as _runtime_version from google.protobuf import symbol_database as _symbol_database from google.protobuf.internal import builder as _builder -_runtime_version.ValidateProtobufRuntimeVersion( - _runtime_version.Domain.PUBLIC, - 5, - 27, - 2, - '', - 'api.proto' -) + +_runtime_version.ValidateProtobufRuntimeVersion(_runtime_version.Domain.PUBLIC, 5, 27, 2, '', 'api.proto') # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() - - -DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tapi.proto\x12\x08v1alpha1\"\x19\n\x17ListPodResourcesRequest\"I\n\x18ListPodResourcesResponse\x12-\n\rpod_resources\x18\x01 \x03(\x0b\x32\x16.v1alpha1.PodResources\"a\n\x0cPodResources\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x30\n\ncontainers\x18\x03 \x03(\x0b\x32\x1c.v1alpha1.ContainerResources\"O\n\x12\x43ontainerResources\x12\x0c\n\x04name\x18\x01 \x01(\t\x12+\n\x07\x64\x65vices\x18\x02 \x03(\x0b\x32\x1a.v1alpha1.ContainerDevices\"=\n\x10\x43ontainerDevices\x12\x15\n\rresource_name\x18\x01 \x01(\t\x12\x12\n\ndevice_ids\x18\x02 \x03(\t2e\n\x12PodResourcesLister\x12O\n\x04List\x12!.v1alpha1.ListPodResourcesRequest\x1a\".v1alpha1.ListPodResourcesResponse\"\x00\x62\x06proto3') +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile( + b'\n\tapi.proto\x12\x08v1alpha1\"\x19\n\x17ListPodResourcesRequest\"I\n\x18ListPodResourcesResponse\x12-\n\rpod_resources\x18\x01 \x03(\x0b\x32\x16.v1alpha1.PodResources\"a\n\x0cPodResources\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x11\n\tnamespace\x18\x02 \x01(\t\x12\x30\n\ncontainers\x18\x03 \x03(\x0b\x32\x1c.v1alpha1.ContainerResources\"O\n\x12\x43ontainerResources\x12\x0c\n\x04name\x18\x01 \x01(\t\x12+\n\x07\x64\x65vices\x18\x02 \x03(\x0b\x32\x1a.v1alpha1.ContainerDevices\"=\n\x10\x43ontainerDevices\x12\x15\n\rresource_name\x18\x01 \x01(\t\x12\x12\n\ndevice_ids\x18\x02 \x03(\t2e\n\x12PodResourcesLister\x12O\n\x04List\x12!.v1alpha1.ListPodResourcesRequest\x1a\".v1alpha1.ListPodResourcesResponse\"\x00\x62\x06proto3' # noqa: E501 +) _globals = globals() _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'api_pb2', _globals) if not _descriptor._USE_C_DESCRIPTORS: - DESCRIPTOR._loaded_options = None - _globals['_LISTPODRESOURCESREQUEST']._serialized_start=23 - _globals['_LISTPODRESOURCESREQUEST']._serialized_end=48 - _globals['_LISTPODRESOURCESRESPONSE']._serialized_start=50 - _globals['_LISTPODRESOURCESRESPONSE']._serialized_end=123 - _globals['_PODRESOURCES']._serialized_start=125 - _globals['_PODRESOURCES']._serialized_end=222 - _globals['_CONTAINERRESOURCES']._serialized_start=224 - _globals['_CONTAINERRESOURCES']._serialized_end=303 - _globals['_CONTAINERDEVICES']._serialized_start=305 - _globals['_CONTAINERDEVICES']._serialized_end=366 - _globals['_PODRESOURCESLISTER']._serialized_start=368 - _globals['_PODRESOURCESLISTER']._serialized_end=469 + DESCRIPTOR._loaded_options = None + _globals['_LISTPODRESOURCESREQUEST']._serialized_start = 23 + _globals['_LISTPODRESOURCESREQUEST']._serialized_end = 48 + _globals['_LISTPODRESOURCESRESPONSE']._serialized_start = 50 + _globals['_LISTPODRESOURCESRESPONSE']._serialized_end = 123 + _globals['_PODRESOURCES']._serialized_start = 125 + _globals['_PODRESOURCES']._serialized_end = 222 + _globals['_CONTAINERRESOURCES']._serialized_start = 224 + _globals['_CONTAINERRESOURCES']._serialized_end = 303 + _globals['_CONTAINERDEVICES']._serialized_start = 305 + _globals['_CONTAINERDEVICES']._serialized_end = 366 + _globals['_PODRESOURCESLISTER']._serialized_start = 368 + _globals['_PODRESOURCESLISTER']._serialized_end = 469 # @@protoc_insertion_point(module_scope) From b01452645789899fcda42c54c265ad28a7bd652a Mon Sep 17 00:00:00 2001 From: Massimiliano Giovagnoli Date: Fri, 22 Nov 2024 10:10:04 +0100 Subject: [PATCH 3/6] deps(nvml): bump pynvml and grpcio Bump pynvml patch version to 11.5.3 and grpcio minor to 1.68.0. Signed-off-by: Massimiliano Giovagnoli --- nvml/pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvml/pyproject.toml b/nvml/pyproject.toml index c843927613..ad39782640 100644 --- a/nvml/pyproject.toml +++ b/nvml/pyproject.toml @@ -37,8 +37,8 @@ dynamic = [ [project.optional-dependencies] deps = [ - "grpcio==1.57.0", - "pynvml==11.5.0", + "grpcio==1.68.0", + "pynvml==11.5.3", ] [project.urls] From 96c3891611cee526810be714d3dd80d58bd51aca Mon Sep 17 00:00:00 2001 From: Massimiliano Giovagnoli Date: Fri, 22 Nov 2024 10:21:34 +0100 Subject: [PATCH 4/6] wip(.codecov/nvml): accept 0.71 code coverage Signed-off-by: Massimiliano Giovagnoli --- .codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codecov.yml b/.codecov.yml index c710934efe..139317faac 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -288,7 +288,7 @@ coverage: flags: - hikaricp nvml: - target: 75 + target: 71 flags: - nvml open_policy_agent: From 2e5f18361da38e57a3be751fa7b3d6748c345174 Mon Sep 17 00:00:00 2001 From: Massimiliano Giovagnoli Date: Fri, 22 Nov 2024 10:59:49 +0100 Subject: [PATCH 5/6] revert(.codecov/nvml): accept 0.71 code coverage" This reverts commit 96c3891611cee526810be714d3dd80d58bd51aca. --- .codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.codecov.yml b/.codecov.yml index 139317faac..c710934efe 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -288,7 +288,7 @@ coverage: flags: - hikaricp nvml: - target: 71 + target: 75 flags: - nvml open_policy_agent: From 2d46e2c7b9455c737ccb5ee9d23ec7fa491aabcb Mon Sep 17 00:00:00 2001 From: Massimiliano Giovagnoli Date: Fri, 22 Nov 2024 11:04:40 +0100 Subject: [PATCH 6/6] tests(nvml/check): add unit tests Signed-off-by: Massimiliano Giovagnoli --- nvml/tests/test_nvml.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nvml/tests/test_nvml.py b/nvml/tests/test_nvml.py index bda3b175cc..18574513f9 100644 --- a/nvml/tests/test_nvml.py +++ b/nvml/tests/test_nvml.py @@ -104,3 +104,19 @@ def test_check(aggregator, instance): aggregator.assert_metric('nvml.compute_running_process', tags=expected_tags + ["pid:1"], count=1) aggregator.assert_all_metrics_covered() + + +@pytest.mark.unit +def test_is_nvml_library_available(instance): + check = NvmlCheck('nvml', {}, [instance]) + res = check.is_nvml_library_available() + assert res is False + + +@pytest.mark.unit +def test_discover_instances(instance): + check = NvmlCheck('nvml', {}, [instance]) + try: + check.discover_instances('1s') + except Exception as e: + pytest.Fail(f"Unexpected exception raised: {e}")