Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INFRA-388 Converting smartmon into python and adding mock tests #1327

Draft
wants to merge 2 commits into
base: stackhpc/2024.1
Choose a base branch
from

Conversation

technowhizz
Copy link
Contributor

No description provided.

@technowhizz technowhizz self-assigned this Oct 11, 2024
Copy link
Member

@dougszumski dougszumski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great start, many thanks. It would be good to investigate external libraries for the smart data collection / parsing.

def parse_smartctl_attributes(disk, disk_type, serial, json_data):
labels = f'disk="{disk}",type="{disk_type}",serial_number="{serial}"'
metrics = []
smartmon_attrs = set([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: It would be helpful to move these to a 'constant' eg. SMARTMON_ATTRS = set(.. and put each attribute on a new line.

try:
version_output = run_command([SMARTCTL_PATH, '-j'], parse_json=True)
smartctl_version_list = version_output.get('smartctl', {}).get('version', [])
if smartctl_version_list:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you looked at Python libraries for doing this?

Eg. This one looks reasonable: https://pypi.org/project/pySMART/

It can handle loading all the device metrics in via smartctl as you are doing here.

It seems to provide some abstraction over the health state as well.

The work you've put into the tests should be directly usable

class TestSmartMon(unittest.TestCase):
@patch('smartmon.run_command')
def test_parse_smartctl_info(self, mock_run_command):
devices_info = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to factor this example data out into a dedicated file. Then we can have a file for each HW profile, and loop over them.

@Alex-Welsh Alex-Welsh added stackhpc-ci Automated action performed by stackhpc-ci Caracal Targets the Caracal OpenStack release labels Nov 15, 2024
@Alex-Welsh Alex-Welsh added enhancement New feature or request and removed stackhpc-ci Automated action performed by stackhpc-ci labels Nov 22, 2024
@technowhizz technowhizz changed the title Converting smartmon into python and adding mock tests INFRA-388 Converting smartmon into python and adding mock tests Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Caracal Targets the Caracal OpenStack release enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants