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

CRAYSAT-1937: Add the first functional test for SAT #648

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

haasken-hpe
Copy link
Contributor

Summary and Scope

Add the first functional test for the System Admin Toolkit (SAT). This is a proof of concept for future tests for SAT.

This test simply executes the sat --version command on the NCN and verifies that the output matches the value in the file used to set the version.

SAT tests are implemented in Python using the unittest standard library package. This provides an easy way to structure tests, add set up and tear down logic for each test, and run the tests from a script. The Python code for the SAT tests is all under a sat_functional subpackage, and individual subpackages and modules beneath that subpackage will implement tests for specific SAT functionality. Tests will be organized by the sat command they are testing.

The __main__.py in the sat_testing module simply passes along the arguments, which should be a list of relative test paths, to the unittest.TextTestRunner, which then runs the tests.

SAT tests are added in Gossfiles. Currently a single test file for SAT tests, goss-sat-version.yaml, is created. A test suite is created in the goss file ncn-sat-functional-tests.yaml. This test suite is limited to run on only ncn-m001. It will eventually include all SAT functional tests.

Issues and Related PRs

Testing

Tested on:

  • drax

Test description:

Downloaded the RPM built on Jenkins to drax. Extracted the RPM using rpm2cpio $RPM_FILE | cpio -idvmu. Modified the path to the Python virtual environment in the test_sat_functional script in the bin directory of the virtualenv to match the extraction path, set GOSS_BASE to the extracted Goss base directory, and then ran the Goss test file and test suite using goss -g $GOSS_FILE validate.

Risks and Mitigations

Pretty low risk. It's possible the test could not work as I'm expecting in the vshasta jenkins jobs, but if that's the case, we can fix it. I'm not sure how to test beyond what I described above.

Pull Request Checklist

  • Version number(s) incremented, if applicable
  • Copyrights updated
  • License file intact
  • Target branch correct
  • CHANGELOG.md updated
  • Testing is appropriate and complete, if applicable
  • HPC Product Announcement prepared, if applicable

@haasken-hpe
Copy link
Contributor Author

Test output:

ncn-m001:~/haasken/opt/cray/tests/install/ncn/suites # goss -g ncn-sat-functional-tests.yaml validate
..

Total Duration: 1.796s
Count: 2, Failed: 0, Skipped: 0

And the detailed logs for this test show the individual Python test method being run via unittest:

ncn-m001:/opt/cray/tests/install/logs/sat_version # cat 20241212_222505_096447746_3924799.log
log_run argument(s): -l sat_version
Executable: '/root/haasken/opt/cray/tests/install/ncn/scripts/python/sat_functional'
1 argument(s) to executable: 'version.test_version'

## 20241212_222505_109987914 ##                      executable starting ##
###########################################################################
test_version_command (csm_testing.tests.sat_functional.version.test_version.TestVersion)
Test that `sat --version` returns the semantic version. ... ok

----------------------------------------------------------------------
Ran 1 test in 1.689s

OK
###########################################################################
## 20241212_222506_875399675 ##       executable completed (exit code=0) ##

@mharding-hpe mharding-hpe force-pushed the CRAYSAT-1937-add-sat-version-test branch from 18e12f5 to d1baa99 Compare December 12, 2024 22:39
Add the first functional test for the System Admin Toolkit (SAT).  This
is a proof of concept for future tests for SAT.

This test simply executes the `sat --version` command on the NCN and
verifies that the output matches the value in the file used to set the
version.

SAT tests are implemented in Python using the `unittest` standard
library package.  This provides an easy way to structure tests, add set
up and tear down logic for each test, and run the tests from a script.
The Python code for the SAT tests is all under a `sat_functional`
subpackage, and individual subpackages and modules beneath that
subpackage will implement tests for specific SAT functionality. Tests
will be organized by the `sat` command they are testing.

The `__main__.py` in the `sat_testing` module simply passes along the
arguments, which should be a list of relative test paths, to the
`unittest.TextTestRunner`, which then runs the tests.

SAT tests are added in Gossfiles. Currently a single test file for SAT
tests, `goss-sat-version.yaml`, is created. A test suite is created in
the goss file `ncn-sat-functional-tests.yaml`. This test suite is
limited to run on only `ncn-m001`. It will eventually include all SAT
functional tests.

Test Description:
Downloaded the RPM built on Jenkins to drax. Extracted the RPM using
`rpm2cpio $RPM_FILE | cpio -idvmu`. Modified the path to the Python
virtual environment in the `test_sat_functional` script in the `bin`
directory of the virtualenv to match the extraction path, set
`GOSS_BASE` to the extracted Goss base directory, and then ran the Goss
test file and test suite using `goss -g $GOSS_FILE validate`.
@haasken-hpe
Copy link
Contributor Author

@rajeshranganathan-hpe, @Pankhuri-Rajesh, @Srinivas-Anand-HPE, I added you all for awareness per our meeting today. We'll keep you in the loop on further SAT automated testing PRs as well.

@haasken-hpe haasken-hpe merged commit a8ef960 into release/1.6 Dec 17, 2024
3 checks passed
@haasken-hpe haasken-hpe deleted the CRAYSAT-1937-add-sat-version-test branch December 17, 2024 22:49
@haasken-hpe
Copy link
Contributor Author

/backport release/1.7

Copy link
Contributor

github-actions bot commented Jan 7, 2025

Backporting into branch release/1.7 was successful. New PR: #654

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants