summaryrefslogtreecommitdiff
path: root/src/PVE/API2/Network/SDN/Controllers.pm
diff options
context:
space:
mode:
authorStefan Lendl <s.lendl@proxmox.com>2024-04-05 15:18:04 +0200
committerThomas Lamprecht <t.lamprecht@proxmox.com>2024-04-08 17:57:18 +0200
commite4914916bc5e9927d56577c5eaf579ef5ef9ab5d (patch)
tree177be3283bd1bc42ff4d4a39e7551cf78313ee10 /src/PVE/API2/Network/SDN/Controllers.pm
parent0f6bc593aa632b0743bbadb98c4ca708e184918b (diff)
tests: test VNets functionality as a blackbox
Add several tests for Vnets in test_vnets_blackbox. State setup as well as testing results is done only via the API to test on the API boundaries not not against the internal state. Internal state is mocked to avoid requiring access to system files or pmxcfs. Mocking is done by reading and writing to a hash that holds the entire state of SDN. The state is reset after every test run. Testing is done via helper functions: nic_join and nic_start. When a nic joins a Vnet, currently it always - and only - calls add_next_free_cidr(). The same is true if a nic starts on Vnet, which only calles add_dhcp_mapping. These test functions homogenize the parameter list in contrast to the current calls to the current functions. The intention for the functions is that they can be moved to Vnets.pm to be called from QemuServer and LXC! The tests are composed of a test function which can be parameterized. To call the test function, the run_test function takes the function pointer and passes the rest of the arguments to the test functions. It also takes care of resetting the test state. This allows fine-grained parameterization per-test directly in the code instead of separated files that require the entire state to be passed in. The tests setup the SDN by creating a simple zone and a simple vnet. The nic_join and nic_start function is called with different subnet configuration wiht and without a dhcp-range configured and with or without an already present IP in the IPAM. Signed-off-by: Stefan Lendl <s.lendl@proxmox.com> Reviewed-by: Max Carrara <m.carrara@proxmox.com> Tested-by: Max Carrara <m.carrara@proxmox.com> Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
Diffstat (limited to 'src/PVE/API2/Network/SDN/Controllers.pm')
0 files changed, 0 insertions, 0 deletions