Skip to content

Commit 1a9ff0b

Browse files
committed
github_actions: use the latest test resources
Signed-off-by: Adrian Vladu <avladu@cloudbasesolutions.com>
1 parent 798df5e commit 1a9ff0b

1 file changed

Lines changed: 33 additions & 44 deletions

File tree

.github/workflows/build_test_cbsinit.yml

Lines changed: 33 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Cloudbase-Init - build and functionally test MSI
22

33
on: [push, pull_request]
44

5+
env:
6+
TEST_RESOURCES: "https://github.com/cloudbase/cloudbase-init-test-resources"
7+
TEST_RESOURCES_BRANCH: "master"
8+
59
jobs:
610
build:
711
runs-on: ${{ matrix.os }}
@@ -41,15 +45,7 @@ jobs:
4145
with:
4246
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"
4347
path: 'CloudbaseInitSetup/bin/release/${{ matrix.platform }}/CloudbaseInitSetup.msi'
44-
- name: Download external dependencies
45-
shell: powershell
46-
run: |
47-
try { git clone "https://github.com/ader1990/cloudbase-init-test-resources-1" -b "add_openstack_packet_check" cbs-test-res }catch{}
48-
pushd "cbs-test-res/${{ matrix.cloud }}"
49-
try {
50-
& "../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 | %{ "$_" }
51-
} catch {}
52-
popd
48+
5349
- name: Install MSI and functionally test Cloudbase-Init
5450
shell: powershell
5551
run: |
@@ -63,45 +59,38 @@ jobs:
6359
$procLog = Start-Process "powershell" "Get-Content -Path `"$log`" -Wait" -NoNewWindow -PassThru
6460
$procMain.WaitForExit()
6561
$procLog.Kill()
66-
Mount-DiskImage -ImagePath (Resolve-Path ./cloudbase-init-config-drive.iso) | Out-Null
67-
Get-PSDrive | Out-Null
68-
mkdir "./metadata" | Out-Null
69-
cp -recurse -force "$((Get-DiskImage (Resolve-Path './cloudbase-init-config-drive.iso') | Get-Volume).DriveLetter):\*" "./metadata";
70-
if (Test-path ".\metadata\openstack\latest\network_data.json.template") {
71-
(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
72-
}
73-
$pythonPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\python.exe"
74-
Write-Output "Python version:"
75-
& $pythonPath --version
76-
$cloudbaseInitPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\cloudbase-init.exe"
77-
$pipAuditPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip-audit.exe"
78-
if (!(Test-Path $pythonPath)) {
79-
$pythonPath = "C:\\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python\python.exe"
80-
$cloudbaseInitPath = "C:\\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\cloudbase-init.exe"
81-
$pipAuditPath = "C:\\Program Files (x86)\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip-audit.exe"
82-
}
83-
Start-Process -FilePath $pythonPath -ArgumentList "-m http.server" -NoNewWindow -WorkingDirectory (Resolve-Path("./metadata")) 2>&1 >> http_server.log
84-
cd "cbs-test-res/${{ matrix.cloud }}/"
62+
63+
- name: Download external dependencies
64+
shell: cmd
65+
run: |
66+
git clone %TEST_RESOURCES% -b %TEST_RESOURCES_BRANCH% test-resources
67+
68+
- name: Run Cloudbase-Init functional tests
69+
shell: powershell
70+
run: |
71+
Install-Module -Force -AllowClobber -Confirm:$false "Pester"
72+
$ENV:CLOUD = "${{ matrix.cloud }}"
73+
$ENV:TEST_ARCHITECTURE = "${{ matrix.architecture }}"
74+
Invoke-Pester test-resources/functional-tests -Output Detailed -FullNameFilter TestVerifyBeforeAllPlugins
75+
8576
try {
86-
$logs = & $cloudbaseInitPath --noreset_service_password --config-file ./cloudbase-init.conf
77+
& 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
8778
} catch {}
88-
echo $logs
89-
$errors = $($logs | Where-Object {$_ -like "*error*"})
90-
$pluginExecution = $($logs | Where-Object {$_ -like "*Plugins execution done*"})
79+
$errors = $(cat ./cloudbase-init.log | Where-Object {$_ -like "*error*"})
80+
$pluginExecution = $(cat ./cloudbase-init.log | Where-Object {$_ -like "*Plugins execution done*"})
9181
if ($errors -or !$pluginExecution) {
92-
Write-Output $logs
93-
Write-Output "Errors found in the execution $($errors.Length)"
94-
Write-Output $errors
95-
$userPass501Err = "plugin 'SetUserPasswordPlugin' failed with error '501 Server Error: Unsupported method ('POST') for url"
96-
if ($errors.Length -gt 20 -and $errors.length -lt 34 -and $errors[0].indexOf($userPass501Err) -gt -1) {
97-
Write-Output "Expected errors"
98-
} else {
99-
Write-Output $("Unexpected error lines: " + $errors.Length + " and found: " + $errors[0].indexOf($userPass501Err))
100-
exit 1
101-
}
82+
exit 1
10283
}
103-
& $pythonPath -m pip install pip-audit
104-
$pipAuditLogs = & $pipAuditPath
84+
85+
Invoke-Pester test-resources/functional-tests -Output Detailed -FullNameFilter TestVerifyAfterAllPlugins
86+
87+
- name: Audit Cloudbase-Init pip packages
88+
shell: powershell
89+
run: |
90+
$pythonPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\python.exe"
91+
$pipAuditPath = "C:\\Program Files\Cloudbase Solutions\Cloudbase-Init\Python\Scripts\pip-audit.exe"
92+
& "${pythonPath}" -m pip install pip-audit
93+
$pipAuditLogs = & "${pipAuditPath}"
10594
Write-Output "$pipAuditLogs"
10695
if ($LASTEXITCODE) {
10796
throw "pip audit failed"

0 commit comments

Comments
 (0)