- cloudbase-init https://github.com/cloudbase/cloudbase-init.
For Pester, see: https://pester.dev.
# run from an administrative powershell
Install-Module -Force -AllowClobber -Confirm:$false "Pester" -SkipPublisherCheckThese functional tests are meant to be run in short lived execution environments, like Github Actions sandboxes/containers
See a real world example here: https://github.com/cloudbase/cloudbase-init/blob/master/.github/workflows/cloudbase_init_tests.yml#L85.
$ENV:CLOUD = "openstack"
# Run functional tests before cloudbase-init is run
# These tests make sure that the environment is clean
# Also, this invocation sets up the correct metadata setup
Invoke-Pester functional-tests -Output Detailed -FullNameFilter TestVerifyBeforeAllPlugins
# Run cloudbase-init using a config drive based approach
try {
& cmd /c "cloudbase-init.exe --noreset_service_password --config-file ./test-resources/openstack/cloudbase-init.conf 2>&1" | Tee-Object -FilePath cloudbase-init.log
} catch {}
# Ensure there are no plugin errors
$errors = $(cat ./cloudbase-init.log | Where-Object {$_ -like "*error*"})
$pluginExecution = $(cat ./cloudbase-init.log | Where-Object {$_ -like "*Plugins execution done*"})
if ($errors -or !$pluginExecution) {
exit 1
}
# Run functional tests after cloudbase-init is run
# These tests make sure that the environment is changed according to the specifications
Invoke-Pester test-resources/functional-tests -Output Detailed -FullNameFilter TestVerifyAfterAllPluginsThe oracle fixture runs a local metadata server on 127.0.0.1:18080 and
serves example OCI metadata from oracle/metadata/opc/v2. The server returns
HTTP 401 unless every request includes the IMDSv2 header:
Authorization: Bearer Oracle
The precondition tests explicitly verify that a request without this header is
rejected with HTTP 401 and that a request with the header returns the expected
instance ID. The end-to-end execution then verifies that OracleCloudService
adds the header itself and successfully processes the returned user data.
Run it through the Cloudbase-Init functional-test workflow with:
$ENV:CLOUD = "oracle"
$ENV:TEST_ARCHITECTURE = "x64"
Invoke-Pester functional-tests -Output Detailed -FullNameFilter TestVerifyBeforeAllPlugins
& cloudbase-init.exe `
--noreset_service_password `
--config-file ./oracle/cloudbase-init.conf
Invoke-Pester functional-tests -Output Detailed -FullNameFilter TestVerifyAfterAllPlugins