From d5e70a4835b6d4e8f571c41a8c632457518deda5 Mon Sep 17 00:00:00 2001 From: Adrian Vladu Date: Tue, 12 May 2026 17:10:17 +0300 Subject: [PATCH] github_actions: use the latest test resources Signed-off-by: Adrian Vladu --- .github/workflows/build_test_cbsinit.yml | 95 ++++++++++++------------ 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/.github/workflows/build_test_cbsinit.yml b/.github/workflows/build_test_cbsinit.yml index 88258c05..9ed555d6 100644 --- a/.github/workflows/build_test_cbsinit.yml +++ b/.github/workflows/build_test_cbsinit.yml @@ -2,6 +2,10 @@ name: Cloudbase-Init - build and functionally test MSI on: [push, pull_request] +env: + TEST_RESOURCES: "https://github.com/cloudbase/cloudbase-init-test-resources" + TEST_RESOURCES_BRANCH: "master" + jobs: build: runs-on: ${{ matrix.os }} @@ -14,7 +18,7 @@ jobs: install_with_pymanager: ["true"] cbsinit_repo: ['https://github.com/cloudbase/cloudbase-init'] cbsinit_branch: ['master'] - python_version: ['3.14_4'] + python_version: ['3.14_6'] platform: ['x64'] cloud: [openstack] @@ -41,15 +45,7 @@ jobs: with: name: "CloudbaseInit_platform-${{ matrix.platform }}_build-env-os-${{ matrix.os }}_download-official-msi-${{ matrix.download_official_python_msi }}_remove-pycs-${{ matrix.remove_python_pycs }}_install-with-pymanager${{ matrix.install_with_pymanager }}_cbs-init-branch-${{ matrix.cbsinit_branch }}_MSI" path: 'CloudbaseInitSetup/bin/release/${{ matrix.platform }}/CloudbaseInitSetup.msi' - - name: Download external dependencies - shell: powershell - run: | - try { git clone "https://github.com/ader1990/cloudbase-init-test-resources-1" -b "add_openstack_packet_check" cbs-test-res }catch{} - pushd "cbs-test-res/${{ matrix.cloud }}" - try { - & "../bin/mkisofs.exe" -o "../../cloudbase-init-config-drive.iso" -ignore-error -ldots -allow-lowercase -allow-multidot -l -publisher "cbsl" -quiet -J -r -V "config-2" "cloudbase-init-metadata" 2>&1 | %{ "$_" } - } catch {} - popd + - name: Install MSI and functionally test Cloudbase-Init shell: powershell run: | @@ -63,45 +59,52 @@ jobs: $procLog = Start-Process "powershell" "Get-Content -Path `"$log`" -Wait" -NoNewWindow -PassThru $procMain.WaitForExit() $procLog.Kill() - Mount-DiskImage -ImagePath (Resolve-Path ./cloudbase-init-config-drive.iso) | Out-Null - Get-PSDrive | Out-Null - mkdir "./metadata" | Out-Null - cp -recurse -force "$((Get-DiskImage (Resolve-Path './cloudbase-init-config-drive.iso') | Get-Volume).DriveLetter):\*" "./metadata"; - if (Test-path ".\metadata\openstack\latest\network_data.json.template") { - (Get-Content ".\metadata\openstack\latest\network_data.json.template").Replace("REPLACE_MAC_ADDRESS", ((Get-NetAdapter Ethernet).macaddress).Replace("-",":")) | Set-Content ".\metadata\openstack\latest\network_data.json" -Encoding Ascii - } - $pythonPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\python.exe" - Write-Output "Python version:" - & $pythonPath --version - $cloudbaseInitPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\cloudbase-init.exe" - $pipAuditPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip-audit.exe" - if (!(Test-Path $pythonPath)) { - $pythonPath = "C:\\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python\python.exe" - $cloudbaseInitPath = "C:\\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\cloudbase-init.exe" - $pipAuditPath = "C:\\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip-audit.exe" + + - name: Download external dependencies + shell: cmd + run: | + git clone %TEST_RESOURCES% -b %TEST_RESOURCES_BRANCH% test-resources + + - name: Run Cloudbase-Init functional tests + shell: powershell + run: | + Install-Module -Force -AllowClobber -Confirm:$false "Pester" + $ENV:CLOUD = "${{ matrix.cloud }}" + $ENV:TEST_ARCHITECTURE = "${{ matrix.architecture }}" + Invoke-Pester test-resources/functional-tests -Output Detailed -FullNameFilter TestVerifyBeforeAllPlugins + + $baseDir = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\" + Copy-Item -Force "$(pwd)/test-resources/${{ matrix.cloud }}/cloudbase-init.conf" "${baseDir}/conf/cloudbase-init.conf" + + $confFileData = Get-Content "${baseDir}/conf/cloudbase-init.conf" -Raw + $confFileData = $confFileData.Replace("logfile =","logfile = ${baseDir}/log/cloudbase-init.log") + $confFileData | Out-File -encoding ASCII "${baseDir}/conf/cloudbase-init.conf" + Start-Service cloudbase-init + while ($true) { + $cloudbaseInitSvcStatus = (Get-Service "cloudbase-init").Status + if ($cloudbaseInitSvcStatus -ne "Running") { + break + } + Write-Output "cloudbase-init service is still running" + Start-Sleep 1 } - Start-Process -FilePath $pythonPath -ArgumentList "-m http.server" -NoNewWindow -WorkingDirectory (Resolve-Path("./metadata")) 2>&1 >> http_server.log - cd "cbs-test-res/${{ matrix.cloud }}/" - try { - $logs = & $cloudbaseInitPath --noreset_service_password --config-file ./cloudbase-init.conf - } catch {} - echo $logs - $errors = $($logs | Where-Object {$_ -like "*error*"}) - $pluginExecution = $($logs | Where-Object {$_ -like "*Plugins execution done*"}) + $logs = Get-Content -Raw "${baseDir}/log/cloudbase-init.log" + Write-Output $logs + $errors = $logs | Where-Object {$_ -like "*error*"} + $pluginExecution = $logs | Where-Object {$_ -like "*Plugins execution done*"} if ($errors -or !$pluginExecution) { - Write-Output $logs - Write-Output "Errors found in the execution $($errors.Length)" - Write-Output $errors - $userPass501Err = "plugin 'SetUserPasswordPlugin' failed with error '501 Server Error: Unsupported method ('POST') for url" - if ($errors.Length -gt 20 -and $errors.length -lt 34 -and $errors[0].indexOf($userPass501Err) -gt -1) { - Write-Output "Expected errors" - } else { - Write-Output $("Unexpected error lines: " + $errors.Length + " and found: " + $errors[0].indexOf($userPass501Err)) - exit 1 - } + exit 1 } - & $pythonPath -m pip install pip-audit - $pipAuditLogs = & $pipAuditPath + + Invoke-Pester test-resources/functional-tests -Output Detailed -FullNameFilter TestVerifyAfterAllPlugins + + - name: Audit Cloudbase-Init pip packages + shell: powershell + run: | + $pythonPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\python.exe" + $pipAuditPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip-audit.exe" + & "${pythonPath}" -m pip install pip-audit + $pipAuditLogs = & "${pipAuditPath}" Write-Output "$pipAuditLogs" if ($LASTEXITCODE) { throw "pip audit failed"