76 lines
2.8 KiB
Bash
Executable File
76 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -u -o pipefail
|
|
|
|
TEST_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
source "${TEST_ROOT}/tests/testlib.sh"
|
|
source "${TEST_ROOT}/inc/deploy-iso-nfs-lxc.sh"
|
|
|
|
assert_success "LXC creation uses the compatible cpuunits option" \
|
|
grep -q -- '--cpuunits 100' "${TEST_ROOT}/inc/deploy-iso-nfs-lxc.sh"
|
|
assert_failure "misspelled cpunits option is absent" \
|
|
grep -q -- '--cpunits' "${TEST_ROOT}/inc/deploy-iso-nfs-lxc.sh"
|
|
|
|
assert_success "valid storage ID" TAPM_ISO_NFS_VALID_ID PVE-Shared-Storage
|
|
assert_failure "storage ID cannot start with a number" TAPM_ISO_NFS_VALID_ID 1-storage
|
|
assert_failure "storage ID rejects spaces" TAPM_ISO_NFS_VALID_ID 'shared storage'
|
|
|
|
assert_success "valid CTID" TAPM_ISO_NFS_VALID_CTID 210
|
|
assert_failure "reserved two-digit CTID" TAPM_ISO_NFS_VALID_CTID 99
|
|
assert_failure "CTID rejects text" TAPM_ISO_NFS_VALID_CTID ct210
|
|
|
|
assert_success "valid hostname" TAPM_ISO_NFS_VALID_HOSTNAME PVE-Shared-Storage
|
|
assert_success "valid FQDN hostname" TAPM_ISO_NFS_VALID_HOSTNAME iso-nfs.example.net
|
|
assert_failure "hostname rejects spaces" TAPM_ISO_NFS_VALID_HOSTNAME 'ISO Storage'
|
|
|
|
assert_success "valid IPv4 CIDR" TAPM_ISO_NFS_VALID_IPV4_CIDR 10.10.2.45/16
|
|
assert_failure "IPv4 octet out of range" TAPM_ISO_NFS_VALID_IPV4_CIDR 10.10.2.256/24
|
|
assert_failure "IPv4 prefix out of range" TAPM_ISO_NFS_VALID_IPV4_CIDR 10.10.2.45/33
|
|
assert_failure "IPv4 prefix required" TAPM_ISO_NFS_VALID_IPV4_CIDR 10.10.2.45
|
|
|
|
pvesm() {
|
|
[[ "${1:-}" == status ]] || return 1
|
|
printf '%s\n' \
|
|
'Name Type Status Total Used Available %' \
|
|
'local-lvm lvmthin active 100 10 90 10%' \
|
|
'iSCSI-Datastore1 lvm active 200 20 180 10%' \
|
|
'iSCSI-Datastore1-2 lvm active 200 20 180 10%' \
|
|
'offline-store dir inactive 100 0 100 0%'
|
|
}
|
|
|
|
SELECT_MENU() {
|
|
local title="$1"
|
|
|
|
assert_equal "Root filesystem storage" "$title" "storage menu title"
|
|
assert_equal \
|
|
'iSCSI-Datastore1-2 (lvm) — default' \
|
|
"${labels[0]}" \
|
|
"default storage placed first"
|
|
assert_equal 3 "${#labels[@]}" "only active storages offered"
|
|
MENU_SELECTION="${values[0]}"
|
|
}
|
|
|
|
test_default_storage_selection() {
|
|
local selected_storage=''
|
|
|
|
TAPM_ISO_NFS_SELECT_STORAGE selected_storage \
|
|
"Root filesystem storage" "iSCSI-Datastore1-2" || return 1
|
|
assert_equal iSCSI-Datastore1-2 "$selected_storage" \
|
|
"pressing Enter retains default storage"
|
|
}
|
|
|
|
assert_success "default storage menu selection" test_default_storage_selection
|
|
|
|
pveam() {
|
|
[[ "${1:-}" == list && "${2:-}" == local ]] || return 1
|
|
printf '%s\n' \
|
|
'NAME VOLID FORMAT TYPE SIZE VMID' \
|
|
'local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst 0 0 0 0 0' \
|
|
'local:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst 0 0 0 0 0'
|
|
}
|
|
assert_equal \
|
|
'local:vztmpl/debian-13-standard_13.1-2_amd64.tar.zst' \
|
|
"$(TAPM_ISO_NFS_LOCAL_TEMPLATE local)" \
|
|
"newest local Debian template avoids catalog refresh"
|
|
|
|
finish_tests
|