Browse Source

Updated bats tests.

- Use env var for VM name
- Added check for hostname resolution via libvirt-nss
- Added check for clout-init package removal
pull/6/head
Giovanni Torres 8 years ago
parent
commit
39496f42f9
  1. 26
      tests/check_options.bats
  2. 41
      tests/check_script.bats

26
tests/check_options.bats

@ -1,26 +0,0 @@
#!/usr/bin/env bats
@test "Check for help usage message" {
run kvm-install-vm
[[ "$output" =~ "NAME" ]]
}
@test "Install VM - batstestvm" {
run bash -c "kvm-install-vm create batstestvm"
[ "$status" -eq 0 ]
}
@test "Check running VM state" {
run bash -c "virsh -q domstate batstestvm"
[ "$output" = "running" ]
}
@test "Delete VM - batstestvm" {
run bash -c "kvm-install-vm remove batstestvm"
[ "$status" -eq 0 ]
}
@test "Check destroyed VM state" {
run bash -c "virsh -q domstate batstestvm"
[[ "$output" =~ "error: failed to get domain 'batstestvm'" ]]
}

41
tests/check_script.bats

@ -0,0 +1,41 @@
#!/usr/bin/env bats
VMNAME=batstestvm
@test "Check for help usage message" {
run kvm-install-vm
[ "$status" -eq 1 ]
[[ "${lines[0]}" =~ "NAME" ]]
}
@test "Install VM - $VMNAME" {
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" {
run sleep 10
run ping -c 1 $VMNAME
[ "$status" -eq 0 ]
[[ "${lines[-2]}" =~ "1 packets transmitted, 1 received," ]]
}
@test "Check cloud-init package is removed" {
run ssh -o StrictHostKeyChecking=no $VMNAME rpm -q cloud-init
[[ "$output" =~ "package cloud-init is not installed" ]]
}
@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'" ]]
}
Loading…
Cancel
Save