Skip to content

cloudbase/cloudbase-init-test-resources

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cloudbase-init-test-resources repostitory contains Pester based functional tests for:

For Pester, see: https://pester.dev.

How to run

Install Pester

# run from an administrative powershell
Install-Module -Force -AllowClobber -Confirm:$false "Pester" -SkipPublisherCheck

Run functional tests for OpenStack

DO NOT RUN ON A LIVE PRODUCTION ENVIRONMENT, AS IT CAN DESTROY DATA OR, REBOOT MACHINE!!!

These 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 TestVerifyAfterAllPlugins

Oracle Cloud IMDSv2

The 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages