diff --git a/.github/workflows/build_test_cbsinit.yml b/.github/workflows/build_test_cbsinit.yml index 88258c05..e711373e 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 }} @@ -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,38 @@ 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" - } - Start-Process -FilePath $pythonPath -ArgumentList "-m http.server" -NoNewWindow -WorkingDirectory (Resolve-Path("./metadata")) 2>&1 >> http_server.log - cd "cbs-test-res/${{ matrix.cloud }}/" + + - 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 + try { - $logs = & $cloudbaseInitPath --noreset_service_password --config-file ./cloudbase-init.conf + & cmd /c "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\cloudbase-init.exe" "--noreset_service_password" "--config-file $(pwd)/test-resources/${{ matrix.cloud }}/cloudbase-init.conf" 2>&1 | Tee-Object -FilePath cloudbase-init.log } catch {} - echo $logs - $errors = $($logs | Where-Object {$_ -like "*error*"}) - $pluginExecution = $($logs | Where-Object {$_ -like "*Plugins execution done*"}) + $errors = $(cat ./cloudbase-init.log | Where-Object {$_ -like "*error*"}) + $pluginExecution = $(cat ./cloudbase-init.log | 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"