Skip to content

Commit

Permalink
CRAYSAT-1939: add testing for sat status
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanholen-hpe committed Dec 16, 2024
1 parent d1baa99 commit 1bc27f8
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
Empty file.
54 changes: 54 additions & 0 deletions src/csm_testing/tests/sat_functional/status/test_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# MIT License
#
# (C) Copyright 2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
"""
Simple test for the functionality of the `sat --version` command. This should
just print the semantic version of the `sat` command.
"""
import shlex
import subprocess
from typing import Optional
import unittest

SAT_VERSION_FILE = '/opt/cray/etc/sat/version'


SAT_STATUS_HEADER = """+----------------+-----------+------+----------+---------+-------+---------+------+-------+-------------+------------+----------+------------------------------------+----------------------+-------------+-------------+--------------------------------------+----------------------------------------+--------------------------------------+
| xname | Aliases | Type | NID | State | Flag | Enabled | Arch | Class | Role | SubRole | Net Type | Desired Config | Configuration Status | Error Count | Boot Status | Most Recent BOS Session | Most Recent Session Template | Most Recent Image |
+----------------+-----------+------+----------+---------+-------+---------+------+-------+-------------+------------+----------+------------------------------------+----------------------+-------------+-------------+--------------------------------------+----------------------------------------+--------------------------------------+ """

class TestVersion(unittest.TestCase):
"""Test the `sat --version` command."""

def test_version_command(self):
"""Test that `sat status` returns the proper header."""
command = 'sat status'

# Use stdout and stderr instead of capture_output=True for Python 3.6 compatibility
proc = subprocess.run(shlex.split(command), stdout=subprocess.PIPE, stderr=subprocess.PIPE,
check=True)
status_output = proc.stdout.decode().strip()

status_output_header = '\n'.join(status_output.splitlines()[:3])

self.assertEqual(SAT_STATUS_HEADER, status_output_header)

0 comments on commit 1bc27f8

Please sign in to comment.