-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(self-test): add selftest and integration tests
Add selftest.py, a standalone script meant to validate a the functionality of azure-vm-utils when installed in Azure VM. Add test_images.py, a pytest-based set of tests which tests marketplace and community images which feature azure-vm-utils baked in (e.g. debian 13, fedora 41) across a variety of vm sizes and types. It also features a test_custom() to allow for easy testing of any image & vm size combination via environment TEST_CUSTOM_IMAGES=image1,image2,... and TEST_CUSTOM_VM_SIZES=size1,size2... Instructions for usage added to README.md. Add python-autoformat and python-lint targets to cmake and update CI to use linters. Signed-off-by: Chris Patterson <[email protected]>
- Loading branch information
Showing
8 changed files
with
1,289 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,55 @@ DEVNAME=/dev/nvme0n1 azure-nvme-id --udev | |
|
||
Provides helpful symlinks in /dev/disk/azure for local, data, and os disks. | ||
|
||
# Testing | ||
|
||
## selfcheck | ||
|
||
selfcheck is provided to validate the runtime environment of a VM. | ||
|
||
With azure-vm-utils installed in a VM on Azure, simply copy the selfcheck.py executable to the target and | ||
execute with sudo. | ||
|
||
``` | ||
scp selfcheck/selftest.py $ip: && ssh $ip -- sudo ./selftest.py | ||
``` | ||
|
||
## test_images | ||
|
||
To help automate a spread of tests, test_images provides functional testing for a set of pre-existing images, | ||
assuming azure-vm-utils is already installed. It depends on az-cli, ssh, and ssh-keygen to create VMs | ||
and ssh into them to run the tests. | ||
|
||
To run tests against marketplace and community images with azure-vm-utils: | ||
|
||
``` | ||
AZURE_SUBSCRIPTION=<subscription id> \ | ||
AZURE_LOCATION=eastus2 \ | ||
pytest -v selftest | ||
``` | ||
|
||
To run tests for custom images and vm sizes, test_custom() is provided and can be configured via environment. | ||
TEST_CUSTOM_IMAGES and TEST_CUSTOM_VM_SIZES are comma-separated so multiple may be tested at a time. | ||
|
||
For example: | ||
|
||
``` | ||
AZURE_SUBSCRIPTION=<subscription id> \ | ||
AZURE_LOCATION=eastus2 \ | ||
TEST_CUSTOM_IMAGES=/my/image1,/my/image2,... \ | ||
TEST_CUSTOM_VM_SIZES=Standard_D2ds_v5,Standard_D2ds_v6,... \ | ||
pytest -v -k test_custom | ||
``` | ||
|
||
For convenience, the default spread of VM sizes can be re-used for custom tests by setting one of the | ||
following that are appropriate for the image(s) under test: | ||
|
||
``` | ||
TEST_CUSTOM_VM_SIZES=DEFAULT_GEN1_VM_SIZES | ||
TEST_CUSTOM_VM_SIZES=DEFAULT_GEN2_VM_SIZES | ||
TEST_CUSTOM_VM_SIZES=DEFAULT_ARM64_VM_SIZES | ||
``` | ||
|
||
# Contributing | ||
|
||
This project welcomes contributions and suggestions. Most contributions require you to agree to a | ||
|
@@ -57,8 +106,8 @@ contact [[email protected]](mailto:[email protected]) with any additio | |
|
||
## Trademarks | ||
|
||
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft | ||
trademarks or logos is subject to and must follow | ||
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft | ||
trademarks or logos is subject to and must follow | ||
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). | ||
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. | ||
Any use of third-party trademarks or logos are subject to those third-party's policies. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
file(GLOB PYTHON_SOURCES */*.py) | ||
|
||
add_custom_target( | ||
python-autoformat | ||
COMMAND isort ${PYTHON_SOURCES} | ||
COMMAND black ${PYTHON_SOURCES} | ||
COMMAND autoflake -r --in-place --remove-unused-variables --remove-all-unused-imports --ignore-init-module-imports ${PYTHON_SOURCES} | ||
COMMENT "Running autoformatting tools" | ||
) | ||
|
||
add_custom_target( | ||
python-lint | ||
COMMAND isort --check-only ${PYTHON_SOURCES} | ||
COMMAND black --check --diff ${PYTHON_SOURCES} | ||
COMMAND mypy --ignore-missing-imports ${PYTHON_SOURCES} | ||
COMMAND flake8 --ignore=W503,E501,E402 ${PYTHON_SOURCES} | ||
COMMAND pylint ${PYTHON_SOURCES} | ||
COMMENT "Running Python lint checks and formatting checks" | ||
) |
Empty file.
Oops, something went wrong.