From 3e058bff06199ea7f057d72ed01ca4d979f83f4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 12 Oct 2017 23:41:02 +0200 Subject: [PATCH] ci: reboot with ansible instead of vagrant reload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit vagrant is serialized and takes a lot of time compare to simple reboot. See the benchmarks below for 3 VMs: [leseb@rick docker]$ time ANSIBLE_SSH_ARGS="-F /home/leseb/reproduce-ci/tmp.zgGC7d5mIC/build/workspace/ceph-ansible/tests/functional/centos/7/docker/vagrant_ssh_config" ansible-playbook -i /home/leseb/reproduce-ci/tmp.zgGC7d5mIC/build/workspace/ceph-ansible/tests/functional/centos/7/docker/hosts reboot.yml PLAY [mons] **************************************************************************************************************************************************************************************************** TASK [Gathering Facts] ***************************************************************************************************************************************************************************************** ok: [mon1] ok: [mon2] ok: [mon0] TASK [restart machine] ***************************************************************************************************************************************************************************************** changed: [mon2] changed: [mon1] changed: [mon0] TASK [wait for server to boot] ********************************************************************************************************************************************************************************* ok: [mon2 -> localhost] ok: [mon0 -> localhost] ok: [mon1 -> localhost] TASK [uptime] ************************************************************************************************************************************************************************************************** changed: [mon2] changed: [mon0] changed: [mon1] PLAY RECAP ***************************************************************************************************************************************************************************************************** mon0 : ok=4 changed=2 unreachable=0 failed=0 mon1 : ok=4 changed=2 unreachable=0 failed=0 mon2 : ok=4 changed=2 unreachable=0 failed=0 real 0m35.112s user 0m5.737s sys 0m1.849s [leseb@rick docker]$ time vagrant reload ==> mon0: Halting domain... ==> mon0: Starting domain. ==> mon0: Waiting for domain to get an IP address... ==> mon0: Waiting for SSH to become available... ==> mon0: Creating shared folders metadata... ==> mon0: Rsyncing folder: /home/leseb/reproduce-ci/tmp.zgGC7d5mIC/build/workspace/ceph-ansible/tests/functional/centos/7/docker/ => /home/vagrant/sync ==> mon0: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> mon0: flag to force provisioning. Provisioners marked to run always will still run. ==> mon1: Halting domain... ==> mon1: Starting domain. ==> mon1: Waiting for domain to get an IP address... ==> mon1: Waiting for SSH to become available... ==> mon1: Creating shared folders metadata... ==> mon1: Rsyncing folder: /home/leseb/reproduce-ci/tmp.zgGC7d5mIC/build/workspace/ceph-ansible/tests/functional/centos/7/docker/ => /home/vagrant/sync ==> mon1: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> mon1: flag to force provisioning. Provisioners marked to run always will still run. ==> mon2: Halting domain... ==> mon2: Starting domain. ==> mon2: Waiting for domain to get an IP address... ==> mon2: Waiting for SSH to become available... ==> mon2: Creating shared folders metadata... ==> mon2: Rsyncing folder: /home/leseb/reproduce-ci/tmp.zgGC7d5mIC/build/workspace/ceph-ansible/tests/functional/centos/7/docker/ => /home/vagrant/sync ==> mon2: Machine already provisioned. Run `vagrant provision` or use the `--provision` ==> mon2: flag to force provisioning. Provisioners marked to run always will still run. real 1m31.850s user 0m7.387s sys 0m0.796s Reboot via Ansible: 0m35.112s Reboot via vagrant: 1m31.850s We save 1/3 time. Signed-off-by: Sébastien Han --- tests/functional/reboot.yml | 16 ++++++++++++++++ tox.ini | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/functional/reboot.yml diff --git a/tests/functional/reboot.yml b/tests/functional/reboot.yml new file mode 100644 index 000000000..dbefdef4c --- /dev/null +++ b/tests/functional/reboot.yml @@ -0,0 +1,16 @@ +--- +- hosts: all + gather_facts: true + tasks: + # why sleep 2? see here: https://github.com/ansible/ansible/issues/14413 + - name: reboot the machines + shell: sleep 2 && shutdown -r now + become: yes + async: 1 + poll: 0 + + - name: waiting 3 minutes for the machines to come back + local_action: wait_for host={{ ansible_default_ipv4.address }} port=22 state=started delay=30 timeout=180 + + - name: uptime + command: uptime diff --git a/tox.ini b/tox.ini index 94a6ca5dc..e2bd044dd 100644 --- a/tox.ini +++ b/tox.ini @@ -224,7 +224,7 @@ commands= testinfra -n 8 --sudo -v --connection=ansible --ansible-inventory={changedir}/hosts {toxinidir}/tests/functional/tests # reboot all vms - vagrant reload --no-provision + ansible-playbook -vv -i {changedir}/hosts {toxinidir}/tests/functional/reboot.yml # wait 2 minutes for services to be ready sleep 120