mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-08-10 06:16:53 +00:00
12874d168d
Split the 1544-line Integration.Tests.ps1 into 18 focused test files with numeric prefixes for execution ordering. New shared helper (_IntegrationHelper.ps1): - Credential-based auth (root@pam) instead of API tokens - Skip helpers for env var checks - Resource discovery (Find-TestVm) for cross-file dependencies - Register-TestResource for env-var state passing between files Files created: 00_Connection, 01_Nodes, 02_Users, 03_Storage, 03a_SharedStorage, 04_Network, 05_SDN, 06_VMs, 07_Snapshots, 08_Templates, 09_CloudInit, 10_Containers, 11_LinuxVM, 12_OVA, 13_Firewall, 14_Backup, 15_Tasks, 99_Cleanup Key changes: - All tests use root@pam credentials (not API tokens) - Each file self-contained with own BeforeAll/AfterAll cleanup - Token CRUD tests now idempotent (remove-before-create) - 99_Cleanup is safety-net for any leftover pester-* resources - SharedStorage renamed to 03a_SharedStorage Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
88 lines
2.7 KiB
PowerShell
88 lines
2.7 KiB
PowerShell
#Requires -Module Pester
|
|
|
|
BeforeAll {
|
|
. $PSScriptRoot/_IntegrationHelper.ps1
|
|
Connect-TestPve
|
|
}
|
|
|
|
AfterAll {
|
|
if (-not $script:SkipReason) {
|
|
# Clean up pester network bridge if it still exists
|
|
try { Remove-PveNetwork -Node $script:Node -Iface 'vmbr99' -Confirm:$false -ErrorAction SilentlyContinue } catch { }
|
|
try { Invoke-PveNetworkApply -Node $script:Node -Wait -ErrorAction SilentlyContinue } catch { }
|
|
}
|
|
Disconnect-TestPve
|
|
}
|
|
|
|
Describe 'Network — Integration' -Tag 'Integration' {
|
|
Context 'Network — Read' {
|
|
It 'Should list networks' {
|
|
if (Skip-IfNoTarget) { return }
|
|
|
|
$networks = Get-PveNetwork -Node $script:Node
|
|
$networks | Should -Not -BeNullOrEmpty
|
|
}
|
|
|
|
It 'Should filter by interface type' {
|
|
if (Skip-IfNoTarget) { return }
|
|
|
|
# Filter for bridges — every PVE node has at least vmbr0
|
|
$bridges = Get-PveNetwork -Node $script:Node -Type 'bridge'
|
|
$bridges | Should -Not -BeNullOrEmpty
|
|
$bridges | ForEach-Object { $_.Type | Should -Be 'bridge' }
|
|
}
|
|
}
|
|
|
|
Context 'Network — CRUD' {
|
|
It 'Should create a Linux bridge' {
|
|
if (Skip-IfNoTarget) { return }
|
|
|
|
{ New-PveNetwork `
|
|
-Node $script:Node `
|
|
-Iface 'vmbr99' `
|
|
-Type 'bridge' `
|
|
-Autostart `
|
|
-ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
|
|
It 'Should find the new bridge in pending changes' {
|
|
if (Skip-IfNoTarget) { return }
|
|
|
|
$networks = Get-PveNetwork -Node $script:Node
|
|
$networks | Where-Object { $_.Iface -eq 'vmbr99' } |
|
|
Should -Not -BeNullOrEmpty
|
|
}
|
|
|
|
It 'Should update bridge comments' {
|
|
if (Skip-IfNoTarget) { return }
|
|
|
|
{ Set-PveNetwork `
|
|
-Node $script:Node `
|
|
-Iface 'vmbr99' `
|
|
-Type 'bridge' `
|
|
-Comments 'Created by Pester integration test' `
|
|
-ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
|
|
It 'Should remove the bridge' {
|
|
if (Skip-IfNoTarget) { return }
|
|
|
|
{ Remove-PveNetwork `
|
|
-Node $script:Node `
|
|
-Iface 'vmbr99' `
|
|
-Confirm:$false `
|
|
-ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
|
|
It 'Should revert pending changes (apply to baseline)' {
|
|
if (Skip-IfNoTarget) { return }
|
|
|
|
# Apply reverts any pending changes back to the running config
|
|
{ Invoke-PveNetworkApply `
|
|
-Node $script:Node `
|
|
-Wait `
|
|
-ErrorAction Stop } | Should -Not -Throw
|
|
}
|
|
}
|
|
}
|