Revamp cluster test script

This commit is contained in:
Joshua Boniface 2023-08-17 23:01:38 -04:00
parent ae7950e9b7
commit dcda7b5748
1 changed files with 53 additions and 22 deletions

View File

@ -1,31 +1,48 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o errexit
if [[ -z ${1} ]]; then if [[ -z ${1} ]]; then
echo "Please specify a cluster to run tests against." echo "Please specify a cluster to run tests against."
exit 1 exit 1
fi fi
test_cluster="${1}" test_cluster="${1}"
shift
if [[ ${1} == "--test-dangerously" ]]; then
test_dangerously="y"
else
test_dangerously=""
fi
_pvc() { _pvc() {
echo "> pvc --cluster ${test_cluster} $@" echo "> pvc --connection ${test_cluster} $@"
pvc --quiet --cluster ${test_cluster} "$@" pvc --quiet --connection ${test_cluster} "$@"
sleep 1 sleep 1
} }
time_start=$(date +%s) time_start=$(date +%s)
pushd $( git rev-parse --show-toplevel ) &>/dev/null
# Cluster tests # Cluster tests
_pvc maintenance on _pvc cluster maintenance on
_pvc maintenance off _pvc cluster maintenance off
backup_tmp=$(mktemp) backup_tmp=$(mktemp)
_pvc task backup --file ${backup_tmp} _pvc cluster backup --file ${backup_tmp}
_pvc task restore --yes --file ${backup_tmp} if [[ -n ${test_dangerously} ]]; then
# This is dangerous, so don't test it unless option given
_pvc cluster restore --yes --file ${backup_tmp}
fi
rm ${backup_tmp} || true rm ${backup_tmp} || true
# Provisioner tests # Provisioner tests
_pvc provisioner profile list test _pvc provisioner profile list test || true
_pvc provisioner template system add --vcpus 1 --vram 1024 --serial --vnc --vnc-bind 0.0.0.0 --node-limit hv1 --node-selector mem --node-autostart --migration-method live system-test || true
_pvc provisioner template network add network-test || true
_pvc provisioner template network vni add network-test 10000 || true
_pvc provisioner template storage add storage-test || true
_pvc provisioner template storage disk add --pool vms --size 8 --filesystem ext4 --mountpoint / storage-test sda || true
_pvc provisioner script add script-test $( find . -name "3-debootstrap.py" ) || true
_pvc provisioner profile add --profile-type provisioner --system-template system-test --network-template network-test --storage-template storage-test --userdata empty --script script-test --script-arg deb_release=bullseye test || true
_pvc provisioner create --wait testx test _pvc provisioner create --wait testx test
sleep 30 sleep 30
@ -36,7 +53,7 @@ _pvc vm shutdown --yes --wait testx
_pvc vm start testx _pvc vm start testx
sleep 30 sleep 30
_pvc vm stop --yes testx _pvc vm stop --yes testx
_pvc vm disable testx _pvc vm disable --yes testx
_pvc vm undefine --yes testx _pvc vm undefine --yes testx
_pvc vm define --target hv3 --tag pvc-test ${vm_tmp} _pvc vm define --target hv3 --tag pvc-test ${vm_tmp}
_pvc vm start testx _pvc vm start testx
@ -49,21 +66,21 @@ _pvc vm unmigrate --wait testx
sleep 5 sleep 5
_pvc vm move --wait --target hv1 testx _pvc vm move --wait --target hv1 testx
sleep 5 sleep 5
_pvc vm meta testx --limit hv1 --selector vms --method live --profile test --no-autostart _pvc vm meta testx --limit hv1 --node-selector vms --method live --profile test --no-autostart
_pvc vm tag add testx mytag _pvc vm tag add testx mytag
_pvc vm tag get testx _pvc vm tag get testx
_pvc vm list --tag mytag _pvc vm list --tag mytag
_pvc vm tag remove testx mytag _pvc vm tag remove testx mytag
_pvc vm network get testx _pvc vm network get testx
_pvc vm vcpu set testx 4 _pvc vm vcpu set --no-restart testx 4
_pvc vm vcpu get testx _pvc vm vcpu get testx
_pvc vm memory set testx 4096 _pvc vm memory set --no-restart testx 4096
_pvc vm memory get testx _pvc vm memory get testx
_pvc vm vcpu set testx 2 _pvc vm vcpu set --no-restart testx 2
_pvc vm memory set testx 2048 --restart --yes _pvc vm memory set testx 2048 --restart --yes
sleep 5 sleep 5
_pvc vm list testx _pvc vm list testx
_pvc vm info --long testx _pvc vm info --format long testx
rm ${vm_tmp} || true rm ${vm_tmp} || true
# Node tests # Node tests
@ -78,6 +95,9 @@ _pvc node ready --wait hv1
_pvc node list hv1 _pvc node list hv1
_pvc node info hv1 _pvc node info hv1
_pvc vm start testx
sleep 30
# Network tests # Network tests
_pvc network add 10001 --description testing --type managed --domain testing.local --ipnet 10.100.100.0/24 --gateway 10.100.100.1 --dhcp --dhcp-start 10.100.100.100 --dhcp-end 10.100.100.199 _pvc network add 10001 --description testing --type managed --domain testing.local --ipnet 10.100.100.0/24 --gateway 10.100.100.1 --dhcp --dhcp-start 10.100.100.100 --dhcp-end 10.100.100.199
sleep 5 sleep 5
@ -95,7 +115,7 @@ _pvc network dhcp remove --yes 10001 12:34:56:78:90:ab
_pvc network modify --domain test10001.local 10001 _pvc network modify --domain test10001.local 10001
_pvc network list _pvc network list
_pvc network info --long 10001 _pvc network info --format long 10001
# Network-VM interaction tests # Network-VM interaction tests
_pvc vm network add testx 10001 --model virtio --restart --yes _pvc vm network add testx 10001 --model virtio --restart --yes
@ -109,17 +129,20 @@ _pvc network remove --yes 10001
# Storage tests # Storage tests
_pvc storage status _pvc storage status
_pvc storage util _pvc storage util
if [[ -n ${test_dangerously} ]]; then
# This is dangerous, so don't test it unless option given
_pvc storage osd set noout _pvc storage osd set noout
_pvc storage osd out 0 _pvc storage osd out 0
_pvc storage osd in 0 _pvc storage osd in 0
_pvc storage osd unset noout _pvc storage osd unset noout
fi
_pvc storage osd list _pvc storage osd list
_pvc storage pool add testing 64 --replcfg "copies=3,mincopies=2" _pvc storage pool add testing 64 --replcfg "copies=3,mincopies=2"
sleep 5 sleep 5
_pvc storage pool list _pvc storage pool list
_pvc storage volume add testing testx 1G _pvc storage volume add testing testx 1G
_pvc storage volume resize testing testx 2G _pvc storage volume resize --yes testing testx 2G
_pvc storage volume rename testing testx testerX _pvc storage volume rename --yes testing testx testerX
_pvc storage volume clone testing testerX testerY _pvc storage volume clone testing testerX testerY
_pvc storage volume list --pool testing _pvc storage volume list --pool testing
_pvc storage volume snapshot add testing testerX asnapshotX _pvc storage volume snapshot add testing testerX asnapshotX
@ -142,6 +165,14 @@ _pvc storage pool remove --yes testing
_pvc vm stop --yes testx _pvc vm stop --yes testx
_pvc vm remove --yes testx _pvc vm remove --yes testx
_pvc provisioner profile remove --yes test
_pvc provisioner script remove --yes script-test
_pvc provisioner template system remove --yes system-test
_pvc provisioner template network remove --yes network-test
_pvc provisioner template storage remove --yes storage-test
popd
time_end=$(date +%s) time_end=$(date +%s)
echo echo