You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.1 KiB
84 lines
2.1 KiB
|
8 years ago
|
#!/usr/bin/env bats
|
||
|
|
|
||
|
8 years ago
|
load vmdir
|
||
|
8 years ago
|
load vmname
|
||
|
8 years ago
|
|
||
|
|
@test "Check for help usage message" {
|
||
|
|
run kvm-install-vm
|
||
|
|
[[ "${lines[0]}" =~ "NAME" ]]
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
@test "Test create with no hostname" {
|
||
|
|
run kvm-install-vm create
|
||
|
|
[[ "${lines[0]}" =~ "NAME" ]]
|
||
|
|
}
|
||
|
|
|
||
|
|
@test "Test create with options and no hostname" {
|
||
|
|
run kvm-install-vm create -t debian9 -d 20
|
||
|
|
[[ "${lines[0]}" =~ "Please specify a single host to create." ]]
|
||
|
|
}
|
||
|
|
|
||
|
|
@test "Test remove with no hostname" {
|
||
|
|
run kvm-install-vm remove
|
||
|
|
[[ "${lines[0]}" =~ "NAME" ]]
|
||
|
|
}
|
||
|
|
|
||
|
6 years ago
|
@test "Install VM (CentOS8) - $VMNAME" {
|
||
|
8 years ago
|
run kvm-install-vm create $VMNAME
|
||
|
|
[ "$status" -eq 0 ]
|
||
|
|
}
|
||
|
|
|
||
|
|
@test "Check running VM state" {
|
||
|
|
run bash -c "virsh -q domstate $VMNAME"
|
||
|
|
[ "$output" = "running" ]
|
||
|
|
}
|
||
|
|
|
||
|
|
@test "Check libvirt-nss hostname resolution" {
|
||
|
8 years ago
|
run sleep 45
|
||
|
8 years ago
|
run ping -c 1 $VMNAME
|
||
|
|
[ "$status" -eq 0 ]
|
||
|
|
[[ "${lines[-2]}" =~ "1 packets transmitted, 1 received," ]]
|
||
|
|
}
|
||
|
|
|
||
|
|
@test "Check cloud-init package is removed" {
|
||
|
8 years ago
|
run ssh -o StrictHostKeyChecking=no centos@$VMNAME rpm -q cloud-init
|
||
|
8 years ago
|
[[ "$output" =~ "package cloud-init is not installed" ]]
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
@test "Attach disk to VM without specifying target" {
|
||
|
|
run bash -c "kvm-install-vm attach-disk -d 1 $VMNAME"
|
||
|
|
[ "$status" -eq 2 ]
|
||
|
8 years ago
|
[[ "${lines[0]}" =~ "ERR: You must specify a target device" ]]
|
||
|
8 years ago
|
}
|
||
|
|
|
||
|
|
@test "Attach disk to VM without specifying disk size" {
|
||
|
|
run bash -c "kvm-install-vm attach-disk -t vdb $VMNAME"
|
||
|
|
[ "$status" -eq 2 ]
|
||
|
|
[[ "${lines[0]}" =~ "You must specify a size" ]]
|
||
|
|
}
|
||
|
|
|
||
|
|
@test "Attach disk to VM" {
|
||
|
|
run bash -c "kvm-install-vm attach-disk -d 1 -t vdb $VMNAME"
|
||
|
|
[ "$status" -eq 0 ]
|
||
|
|
}
|
||
|
|
|
||
|
|
@test "Check block list for VM" {
|
||
|
8 years ago
|
run bash -c "grep ^vdb <(virsh domblklist $VMNAME)"
|
||
|
8 years ago
|
[ "$status" -eq 0 ]
|
||
|
|
}
|
||
|
|
|
||
|
8 years ago
|
@test "Delete VM - $VMNAME" {
|
||
|
|
run bash -c "kvm-install-vm remove $VMNAME"
|
||
|
|
[ "$status" -eq 0 ]
|
||
|
|
}
|
||
|
|
|
||
|
|
@test "Check destroyed VM state" {
|
||
|
|
run bash -c "virsh -q domstate $VMNAME"
|
||
|
|
[[ "$output" =~ "error: failed to get domain '$VMNAME'" ]]
|
||
|
|
}
|
||
|
8 years ago
|
|
||
|
|
@test "Check destroyed VM files" {
|
||
|
8 years ago
|
run bash -c "ls ${VMDIR}/${VMNAME}"
|
||
|
8 years ago
|
[[ "$output" =~ "No such file or directory" ]]
|
||
|
|
}
|