From e3f8f86b083aa7acc05e5a5ad09f040aef220115 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Tue, 9 Aug 2016 16:41:10 -0400 Subject: [PATCH] Fix DHCP test scenario It appears that test nodes, once are explicitly powered off, depending on libvirt, may completely vanish. As we only test at the end of the process if we've observed additional DHCP leases, we should move to only defining the VMs such that they are powered on when the sequence is ready, not in advance of the test sequence. Moving to defining instead of creating does improve the overall efficency of the sequence as no processes are spawning suddenly using CPU and RAM during the start of the test. This also allows us to remove and correct ansible virt module invocations. The ansible virt module is an extra module, not a core module, at least on Ubuntu Trusty, cannot have it's requirements installed via pip. Change-Id: I8948ba5a941384fdcacebcdfe9b6fd4fe8384cb1 Depends-On: I01885c397ed1e020aae306db1656678b26306532 --- .../files/create_vm_nodes-for-role.sh | 4 +++- playbooks/test-bifrost.yaml | 11 +---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh b/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh index 5b4d890cf..6be9af1c8 100755 --- a/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh +++ b/playbooks/roles/bifrost-create-vm-nodes/files/create_vm_nodes-for-role.sh @@ -197,7 +197,9 @@ function create_node { " echo ${vm_xml} > /tmp/vm.xml - virsh create /tmp/vm.xml 2>&1 >/dev/null + # NOTE(TheJulia): the create command powers on a VM that has been defined, + # where as define creates the VM, but does not change the power state. + virsh define /tmp/vm.xml 2>&1 >/dev/null if [ $? != 0 ] then echo "failed to create VM $NAME" >&2 diff --git a/playbooks/test-bifrost.yaml b/playbooks/test-bifrost.yaml index b6c3a228c..1228f792d 100644 --- a/playbooks/test-bifrost.yaml +++ b/playbooks/test-bifrost.yaml @@ -16,13 +16,6 @@ # in the interest of keeping the active memory footprint small, # should stop all of the VMs in advance, so we can proceed with # install and initial deploy. - - name: Attempt to stop all test VMs - virt: - name: "testvm{{ item }}" - command: "stop" - state: shutdown - with_sequence: start=1 end={{ test_vm_num_nodes | default('5') }} - ignore_errors: yes - name: Remove pre-existing leases file file: path=/var/lib/misc/dnsmasq.leases state=absent - hosts: localhost @@ -129,9 +122,7 @@ # validate that the dhcp config is working as expected and not # serving these requests. - name: Power on remaining test VMs - virt: - name: "testvm{{ item }}" - command: "start" + command: virsh start testvm{{item}} with_sequence: start=4 end={{ test_vm_num_nodes | default('5') }} ignore_errors: yes when: inventory_dhcp | bool == true