diff --git a/README.rst b/README.rst index cc1654043..5a9350a0b 100644 --- a/README.rst +++ b/README.rst @@ -374,18 +374,17 @@ Testing with a single command A simple ``scripts/test-bifrost.sh`` script can be utilized to install pre-requisite software packages, Ansible, and then execute the -test-bifrost.yaml playbook in order to provide a single step testing -mechanism. +``test-bifrost-create-vm.yaml`` and ``test-bifrost.yaml`` playbooks in order +to provide a single step testing mechanism. -The playbook utilized by the script, -``playbooks/test-bifrost-dynamic.yaml``, is a single playbook that -will create a local virtual machine, save a baremetal.csv file out, -and then utilize it to execute the remaining roles. Two additional -roles are invoked by this playbook which enables Ansible to connect to -the new nodes by adding them to the inventory, and then logging into -the remote machine via the user's ssh host key. Once that has -successfully occurred, additional roles will unprovision the host(s) -and delete them from ironic. +``playbooks/test-bifrost-create-vm.yaml`` creates one or more VMs for +testing and saves out a baremetal.csv file which is used by +``playbooks/test-bifrost.yaml`` to execute the remaining roles. Two +additional roles are invoked by this playbook which enables Ansible to +connect to the new nodes by adding them to the inventory, and then +logging into the remote machine via the user's ssh host key. Once +that has successfully occurred, additional roles will unprovision the +host(s) and delete them from ironic. Command:: diff --git a/playbooks/roles/bifrost-test-vm/defaults/main.yml b/playbooks/roles/bifrost-test-vm/defaults/main.yml index df15a33e4..9663a8112 100644 --- a/playbooks/roles/bifrost-test-vm/defaults/main.yml +++ b/playbooks/roles/bifrost-test-vm/defaults/main.yml @@ -1,2 +1,3 @@ --- # defaults file for bifrost-test-vm +deprecated_test_playbook: false diff --git a/playbooks/roles/bifrost-test-vm/tasks/main.yml b/playbooks/roles/bifrost-test-vm/tasks/main.yml index 20ea80b2a..574ea6229 100644 --- a/playbooks/roles/bifrost-test-vm/tasks/main.yml +++ b/playbooks/roles/bifrost-test-vm/tasks/main.yml @@ -12,6 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. --- +- name: > + "WARNING - This playbook will be removed in the Ocata + release. Please use test-bifrost.yaml." + set_fact: + deprecated: true + when: deprecated_test_playbook | bool == true - name: > "Execute ping step to verify connectivity and login to the host. If this fails, the configdrive may not have loaded." diff --git a/playbooks/test-bifrost-dhcp.yaml b/playbooks/test-bifrost-dhcp.yaml index 5f7932b97..969e41d72 100644 --- a/playbooks/test-bifrost-dhcp.yaml +++ b/playbooks/test-bifrost-dhcp.yaml @@ -105,7 +105,7 @@ any_errors_fatal: yes max_fail_percentage: 0 roles: - - role: bifrost-test-vm + - { role: bifrost-test-vm, deprecated_test_playbook: true } - hosts: baremetal connection: local name: "Unprovisions the test node" diff --git a/playbooks/test-bifrost-dynamic.yaml b/playbooks/test-bifrost-dynamic.yaml index 149cf9b72..e41ed3ed5 100644 --- a/playbooks/test-bifrost-dynamic.yaml +++ b/playbooks/test-bifrost-dynamic.yaml @@ -12,6 +12,7 @@ become: no gather_facts: yes pre_tasks: + - debug: msg="WARNING - This playbook will be deprecated in a future release. Please use test-bifrost.yaml." - name: "Set ci_testing_zuul if it appears we are running in upstream OpenStack CI" set_fact: ci_testing: true @@ -85,7 +86,7 @@ gather_facts: no remote_user: "{{ testing_user }}" roles: - - role: bifrost-test-vm + - { role: bifrost-test-vm, deprecated_test_playbook: true } - hosts: baremetal connection: local name: "Unprovisions the test node" diff --git a/playbooks/test-bifrost.yaml b/playbooks/test-bifrost.yaml new file mode 100644 index 000000000..b6c3a228c --- /dev/null +++ b/playbooks/test-bifrost.yaml @@ -0,0 +1,155 @@ +# Example command line to use: +# Create a VM: +# ansible-playbook -vvvv -i inventory/localhost test-bifrost-create-vm.yaml +# Set BIFROST_INVENTORY_SOURCE +# export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.csv +# Execute the installation and VM startup test. +# ansible-playbook -vvvv -i inventory/bifrost_inventory.py test-bifrost.yaml -e use_cirros=true -e testing_user=cirros +--- +- hosts: localhost + connection: local + name: "Setting pre-test conditions" + become: yes + ignore_errors: yes + tasks: + # NOTE(TheJulia): While the test was created to run with five VMs, + # 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 + connection: local + name: "Executes install, enrollment, and testing in one playbook" + become: no + gather_facts: yes + pre_tasks: + - name: "Set ci_testing_zuul if it appears we are running in upstream OpenStack CI" + set_fact: + ci_testing: true + ci_testing_zuul: true + ironic_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/ironic" + ironicclient_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/python-ironicclient" + shade_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack-infra/shade" + dib_git_url: "/opt/git/openstack/diskimage-builder" + # TODO(TheJulia) Fix the above paths to be consistent, because the NV job gets the dib + # folder cloned, while the gate job does not. Likely need to work out a semi-hybrid + # solution. + when: lookup('env', 'ZUUL_BRANCH') | length > 0 + - name: "Set ci_testing_zuul_changes if ZUUL_CHANGES is set" + set_fact: + ci_testing_zuul_changes: true + when: lookup('env', 'ZUUL_CHANGES') | length > 0 + - name: "Override the ipv4_gateway setting" + set_fact: + ipv4_gateway: "192.168.122.1" + roles: + - { role: bifrost-prep-for-install, when: skip_install is not defined } + - { role: bifrost-openstack-ci-prep, when: ci_testing_zuul is defined } + environment: + http_proxy: "{{ lookup('env','http_proxy') }}" + https_proxy: "{{ lookup('env','https_proxy') }}" +- hosts: localhost + connection: local + name: "Executes install, enrollment, and testing in one playbook" + become: yes + gather_facts: yes + pre_tasks: + - name: "Collect process list if running in a CI System" + command: ps aux + when: ci_testing is defined + - name: "Collect list of listening network sockets if running in a CI system" + shell: netstat -apn|grep LISTEN + when: ci_testing is defined + roles: + - role: bifrost-ironic-install + cleaning: false + testing: true + # NOTE(TheJulia): While the next step creates a ramdisk, some elements + # do not support ramdisk-image-create as they invoke steps to cleanup + # the ramdisk which causes ramdisk-image-create to believe it failed. + - { role: bifrost-create-dib-image, dib_imagename: "{{ http_boot_folder }}/ipa", build_ramdisk: false, dib_os_element: "{{ ipa_dib_os_element|default('debian') }}", dib_os_release: "jessie", dib_elements: "ironic-agent {{ ipa_extra_dib_elements | default('') }}", when: create_ipa_image | bool == true } + - { role: bifrost-create-dib-image, dib_imagetype: "qcow2", dib_imagename: "{{deploy_image}}", dib_os_element: "debian", dib_os_release: "jessie", dib_elements: "vm serial-console simple-init {{ extra_dib_elements|default('') }}", when: create_image_via_dib | bool == true and transform_boot_image | bool == false } + environment: + http_proxy: "{{ lookup('env','http_proxy') }}" + https_proxy: "{{ lookup('env','https_proxy') }}" +- hosts: baremetal + name: "Enroll node with Ironic" + become: no + connection: local + roles: + - role: ironic-enroll-dynamic + - { role: ironic-inspect-node, when: inspect_nodes | default('false') | bool == true } +- hosts: baremetal + vars: + multinode_testing: "{{ inventory_dhcp | bool == true }}" + name: "Create configuration drive files and deploy machines." + become: no + connection: local + roles: + - role: bifrost-configdrives-dynamic + - role: bifrost-deploy-nodes-dynamic + - role: bifrost-prepare-for-test-dynamic + serial: 1 +# The testvm Host group is added by bifrost-prepare-for-test based +# on the contents of the CSV file. +- hosts: test + name: "Tests connectivity to the VM" + become: no + gather_facts: no + remote_user: "{{ testing_user }}" + serial: 1 + any_errors_fatal: yes + max_fail_percentage: 0 + roles: + - role: bifrost-test-vm +- hosts: baremetal + connection: local + name: "Unprovisions the test node" + become: no + gather_facts: no + roles: + - role: bifrost-unprovision-node-dynamic + - role: ironic-delete-dynamic +# The following tasks are intended to test DHCP functionality +- hosts: localhost + connection: local + name: "Executes DHCP test script" + become: yes + tasks: + # NOTE(TheJulia): Moved the power ON of the excess VMs until after + # the other test VMs have been shutdown, in order to explicitly + # 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" + with_sequence: start=4 end={{ test_vm_num_nodes | default('5') }} + ignore_errors: yes + when: inventory_dhcp | bool == true + - name: Wait 30 seconds + pause: + seconds: 30 + when: inventory_dhcp | bool == true +- hosts: localhost + connection: local + name: "Executes DHCP test script" + become: yes + gather_facts: yes + vars: + inventory_dhcp: "{{ inventory_dhcp | bool == true }}" + inventory_dhcp_static_ip: "{{ inventory_dhcp_static_ip | bool == true }}" + roles: + - { role: bifrost-test-dhcp, when: inventory_dhcp | bool == true } + environment: + http_proxy: "{{ lookup('env','http_proxy') }}" + https_proxy: "{{ lookup('env','https_proxy') }}" + diff --git a/releasenotes/notes/merge-test-playbooks-aeabc7a614cbce29.yaml b/releasenotes/notes/merge-test-playbooks-aeabc7a614cbce29.yaml new file mode 100644 index 000000000..b8320e7c8 --- /dev/null +++ b/releasenotes/notes/merge-test-playbooks-aeabc7a614cbce29.yaml @@ -0,0 +1,12 @@ +--- + +upgrade: + - A new test playbook, test-bifrost.yaml, has been added. + This playbook merges the functionality of the existing + test-bifrost-dynamic.yaml and test-bifrost-dhcp.yaml + playbooks. + +deprecations: + - test-bifrost-dynamic.yaml and test-bifrost-dhcp.yaml + have been superseded by test-bifrost.yaml and will be + removed in the Ocata release. diff --git a/scripts/test-bifrost.sh b/scripts/test-bifrost.sh index 4f2165c06..71360a21a 100755 --- a/scripts/test-bifrost.sh +++ b/scripts/test-bifrost.sh @@ -26,7 +26,7 @@ VM_MEMORY_SIZE="3072" TEST_VM_NUM_NODES=1 USE_CIRROS=true TESTING_USER=cirros -TEST_PLAYBOOK="test-bifrost-dynamic.yaml" +TEST_PLAYBOOK="test-bifrost.yaml" USE_INSPECTOR=true INSPECT_NODES=true INVENTORY_DHCP=false @@ -70,7 +70,6 @@ if [ ${USE_DHCP} = "true" ]; then VM_MEMORY_SIZE="1024" ENABLE_INSPECTOR=false INSPECT_NODES=false - TEST_PLAYBOOK="test-bifrost-dhcp.yaml" TEST_VM_NUM_NODES=5 INVENTORY_DHCP=true INVENTORY_DHCP_STATIC_IP=true