|
1 | | -# cloudbase-init-test-resources |
2 | | -Cloudbase-Init example configurations and config-drives used for functional tests |
| 1 | +## cloudbase-init-test-resources repostitory contains Pester based functional tests for: |
| 2 | + |
| 3 | + * cloudbase-init https://github.com/cloudbase/cloudbase-init. |
| 4 | + |
| 5 | +For Pester, see: https://pester.dev. |
| 6 | + |
| 7 | + |
| 8 | +## How to run |
| 9 | + |
| 10 | +### Install Pester |
| 11 | + |
| 12 | +```powershell |
| 13 | +# run from an administrative powershell |
| 14 | +Install-Module -Force -AllowClobber -Confirm:$false "Pester" -SkipPublisherCheck |
| 15 | +``` |
| 16 | + |
| 17 | +### Run functional tests for OpenStack |
| 18 | + |
| 19 | +### DO NOT RUN ON A LIVE PRODUCTION ENVIRONMENT, AS IT CAN DESTROY DATA OR, REBOOT MACHINE!!! |
| 20 | + |
| 21 | +### These functional tests are meant to be run in short lived execution environments, like Github Actions sandboxes/containers |
| 22 | + |
| 23 | +See a real world example here: https://github.com/cloudbase/cloudbase-init/blob/master/.github/workflows/cloudbase_init_tests.yml#L85. |
| 24 | + |
| 25 | +```powershell |
| 26 | +$ENV:CLOUD = "openstack" |
| 27 | +
|
| 28 | +# Run functional tests before cloudbase-init is run |
| 29 | +# These tests make sure that the environment is clean |
| 30 | +# Also, this invocation sets up the correct metadata setup |
| 31 | +Invoke-Pester functional-tests -Output Detailed -FullNameFilter TestVerifyBeforeAllPlugins |
| 32 | +
|
| 33 | +# Run cloudbase-init using a config drive based approach |
| 34 | +try { |
| 35 | + & cmd /c "cloudbase-init.exe --noreset_service_password --config-file ./test-resources/openstack/cloudbase-init.conf 2>&1" | Tee-Object -FilePath cloudbase-init.log |
| 36 | +} catch {} |
| 37 | + |
| 38 | +# Ensure there are no plugin errors |
| 39 | +$errors = $(cat ./cloudbase-init.log | Where-Object {$_ -like "*error*"}) |
| 40 | +$pluginExecution = $(cat ./cloudbase-init.log | Where-Object {$_ -like "*Plugins execution done*"}) |
| 41 | +if ($errors -or !$pluginExecution) { |
| 42 | + exit 1 |
| 43 | +} |
| 44 | +
|
| 45 | +# Run functional tests after cloudbase-init is run |
| 46 | +# These tests make sure that the environment is changed according to the specifications |
| 47 | +Invoke-Pester test-resources/functional-tests -Output Detailed -FullNameFilter TestVerifyAfterAllPlugins |
| 48 | +``` |
0 commit comments