From: Alex Ermolov Date: Thu, 1 Oct 2015 12:16:59 +0000 (+0300) Subject: Testing automation harness using Ansible X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=05ad66dfcf652580fc3843012c3691648dc926ac;p=tools%2Fsustaining.git Testing automation harness using Ansible Change-Id: I53f5b4ad66dea90c14b21dd6e7e8e98e82133ca3 --- diff --git a/jenkins/testing_automation/ansible/install.yml b/jenkins/testing_automation/ansible/install.yml new file mode 100644 index 0000000..9145df3 --- /dev/null +++ b/jenkins/testing_automation/ansible/install.yml @@ -0,0 +1,64 @@ +- hosts: jenkins + + vars: + jenkins_user: jenkins + jobs_dir: /home/{{ jenkins_user }}/workspace + rally_job_name: rally + tempest_job_name: tempest + patching_job_name: patch_environment + + tasks: + + - name: Rally | upload inventory + copy: src=inventory.ini dest={{ jobs_dir }}/{{ rally_job_name }} + + - name: Rally | upload playbooks + copy: src=playbooks/{{ item }} dest={{ jobs_dir }}/{{ rally_job_name }} + with_items: + - cleanup_test_vm.yml + - common_vars.yml + - perform_rally.yml + - recreate_pubnet.yml + - fix_ssh_config.yml + + - name: Rally | mkdir contrib + file: path={{ jobs_dir }}/{{ rally_job_name }}/contrib state=directory + + - name: Rally | upload contrib + copy: src=playbooks/contrib/{{ item }} dest={{ jobs_dir }}/{{ rally_job_name }}/contrib + with_items: + - instance_dd_test.sh + - openrc + - rally-mos.yaml + - template_centos.xml + - template_ubuntu.xml + - testing-network_pub.xml + + - name: Tempest | upload inventory + copy: src=inventory.ini dest={{ jobs_dir }}/{{ tempest_job_name }} + + - name: Tempest | upload playbooks + copy: src=playbooks/{{ item }} dest={{ jobs_dir }}/{{ tempest_job_name }} + with_items: + - common_vars.yml + - perform_tempest.yml + - recreate_pubnet.yml + - fix_ssh_config.yml + - cleanup_knownhosts.yml + + - name: Tempest | mkdir contrib + file: path={{ jobs_dir }}/{{ tempest_job_name }}/contrib state=directory + + - name: Tempest | upload contrib + copy: src=playbooks/contrib/{{ item }} dest={{ jobs_dir }}/{{ tempest_job_name }}/contrib + with_items: + - tempest-tmux + + - name: Patching | upload inventory + copy: src=inventory.ini dest={{ jobs_dir }}/{{ patching_job_name }} + + - name: Patching | upload playbooks + copy: src=playbooks/{{ item }} dest={{ jobs_dir }}/{{ patching_job_name }} + with_items: + - common_vars.yml + - patch_environment.yml diff --git a/jenkins/testing_automation/ansible/inventory-local.ini b/jenkins/testing_automation/ansible/inventory-local.ini new file mode 100644 index 0000000..c801a83 --- /dev/null +++ b/jenkins/testing_automation/ansible/inventory-local.ini @@ -0,0 +1,2 @@ +[jenkins] +cz7377.bud.mirantis.net ansible_ssh_user=jenkins ansible_ssh_pass=slave \ No newline at end of file diff --git a/jenkins/testing_automation/ansible/inventory.ini b/jenkins/testing_automation/ansible/inventory.ini new file mode 100644 index 0000000..c41a415 --- /dev/null +++ b/jenkins/testing_automation/ansible/inventory.ini @@ -0,0 +1 @@ +localhost ansible_connection=local ansible_sudo_pass=slave diff --git a/jenkins/testing_automation/ansible/playbooks/cleanup_knownhosts.yml b/jenkins/testing_automation/ansible/playbooks/cleanup_knownhosts.yml new file mode 100644 index 0000000..513713b --- /dev/null +++ b/jenkins/testing_automation/ansible/playbooks/cleanup_knownhosts.yml @@ -0,0 +1,11 @@ +- hosts: localhost + + tasks: + + - include_vars: common_vars.yml + + - name: patch ssh config to turn off known_hosts hashing + lineinfile: + dest={{ home_dir }}/.ssh/known_hosts + regexp="{{ master_node_ip }}" + state=absent diff --git a/jenkins/testing_automation/ansible/playbooks/cleanup_test_vm.yml b/jenkins/testing_automation/ansible/playbooks/cleanup_test_vm.yml new file mode 100644 index 0000000..0a665db --- /dev/null +++ b/jenkins/testing_automation/ansible/playbooks/cleanup_test_vm.yml @@ -0,0 +1,17 @@ +- hosts: localhost + + tasks: + + - include_vars: common_vars.yml + + - name: destroy vm + virt: command=destroy name={{ vm_to_destroy }} + ignore_errors: True + + - name: undefine vm + virt: command=undefine name={{ vm_to_destroy }} + ignore_errors: True + + - name: remove disk image + shell: virsh vol-delete --pool {{ storage_pool }} {{ vm_to_destroy }}.img + ignore_errors: True diff --git a/jenkins/testing_automation/ansible/playbooks/common_vars.yml b/jenkins/testing_automation/ansible/playbooks/common_vars.yml new file mode 100644 index 0000000..d1e630f --- /dev/null +++ b/jenkins/testing_automation/ansible/playbooks/common_vars.yml @@ -0,0 +1,16 @@ +home_dir: /home/jenkins +vm_template_xml_path: "{{ home_dir }}/workspace/templates" +libvirt_images_path: /var/lib/libvirt/images/ +qemu_uri: qemu:///system +storage_pool: default +iso_path: "{{ home_dir }}/workspace/iso/" +default_dist: ubuntu +default_pub_subnet: testing-network_pub +vm_template_name: template +test_login: tester +test_password: test +ubuntu_iso: ubuntu-14.04.3-server-amd64.iso +centos_iso: CentOS-6.6-x86_64-minimal.iso +host_key_checking: False +report_filename: rally_report.html +rally_report_path: "{{ home_dir }}/workspace/rally/" diff --git a/jenkins/build_vm/contrib/instance_dd_test.sh b/jenkins/testing_automation/ansible/playbooks/contrib/instance_dd_test.sh similarity index 100% rename from jenkins/build_vm/contrib/instance_dd_test.sh rename to jenkins/testing_automation/ansible/playbooks/contrib/instance_dd_test.sh diff --git a/jenkins/build_vm/contrib/openrc b/jenkins/testing_automation/ansible/playbooks/contrib/openrc similarity index 100% rename from jenkins/build_vm/contrib/openrc rename to jenkins/testing_automation/ansible/playbooks/contrib/openrc diff --git a/jenkins/build_vm/contrib/rally-mos.yaml b/jenkins/testing_automation/ansible/playbooks/contrib/rally-mos.yaml similarity index 100% rename from jenkins/build_vm/contrib/rally-mos.yaml rename to jenkins/testing_automation/ansible/playbooks/contrib/rally-mos.yaml diff --git a/jenkins/testing_automation/ansible/playbooks/contrib/tempest-tmux b/jenkins/testing_automation/ansible/playbooks/contrib/tempest-tmux new file mode 100755 index 0000000..21193bc --- /dev/null +++ b/jenkins/testing_automation/ansible/playbooks/contrib/tempest-tmux @@ -0,0 +1,6 @@ +#!/bin/sh + +tmux new-session -d +tmux send-keys -t 0 'cd mos-tempest-runner' enter +tmux send-keys -t 0 './rejoin.sh' enter +tmux send-keys -t 0 'run_tests' enter \ No newline at end of file diff --git a/jenkins/testing_automation/ansible/playbooks/contrib/template_centos.xml b/jenkins/testing_automation/ansible/playbooks/contrib/template_centos.xml new file mode 100644 index 0000000..4389129 --- /dev/null +++ b/jenkins/testing_automation/ansible/playbooks/contrib/template_centos.xml @@ -0,0 +1,97 @@ + + testing_vm_centos + 176a7835-9c14-4859-9f96-934b0d0ff2ee + 8388608 + 8388608 + 4 + + /machine + + + hvm + + + + + + + + + + + + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + + +
+ + + + + + + + +
+ + + +
+ + + + + + +
+ + + + + + + +
+ + + + + + + + + + + + + + + + +