From ede95b9b42b936f6772ea22a5aa45e7c55b1bd5f Mon Sep 17 00:00:00 2001 From: pkomarov Date: Tue, 7 May 2019 11:29:58 +0300 Subject: [PATCH] Add infrared plugin to tobiko Work is based on Arie's initial IR-tobiko plugin, thanks ...:) Change-Id: I9dfa8a87e8ca8623d347b06e1818612ea66c5580 --- infrared/README.md | 11 +++++++ infrared/install.yml | 27 ----------------- infrared/main.yml | 19 ++++++++++-- infrared/tasks/configure.yml | 34 +++++++++++++++++++++ infrared/tasks/install.yml | 33 ++++++++++++++++++++ infrared/tasks/run.yml | 6 ++++ infrared/tasks/templates/os-faults.yaml.j2 | 35 ++++++++++++++++++++++ infrared/tasks/templates/tobiko.conf.j2 | 10 +++++++ infrared/plugin.spec => plugin.spec | 18 +++++++---- 9 files changed, 158 insertions(+), 35 deletions(-) create mode 100644 infrared/README.md delete mode 100644 infrared/install.yml create mode 100644 infrared/tasks/configure.yml create mode 100644 infrared/tasks/install.yml create mode 100644 infrared/tasks/run.yml create mode 100644 infrared/tasks/templates/os-faults.yaml.j2 create mode 100644 infrared/tasks/templates/tobiko.conf.j2 rename infrared/plugin.spec => plugin.spec (62%) diff --git a/infrared/README.md b/infrared/README.md new file mode 100644 index 000000000..1a8b875c0 --- /dev/null +++ b/infrared/README.md @@ -0,0 +1,11 @@ +# Tobiko + +Tobiko InfraRed Plugin + +Tobiko was created for testing OpenStack Upgrades. +You can find the official project right [here](https://github.com/openstack/tobiko) + + +## Usage + + infrared tobiko --tests neutron diff --git a/infrared/install.yml b/infrared/install.yml deleted file mode 100644 index d6b6ecdce..000000000 --- a/infrared/install.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -- name: Install Tobiko - hosts: undercloud - any_errors_fatal: true - gather_facts: yes - tasks: - - name: Install required packages - become: yes - yum: - name: "{{ item }}" - state: present - with_items: - - 'python-virtualenv' - - 'git' - - - name: Create Virtualenv - vars: - packages: ['pip', 'setuptools', 'pbr', 'tox'] - pip: - virtualenv: "{{ test.venv }}" - name: "{{ packages }}" - state: latest - - - name: Create virtual env for Tobiko test cases - shell: | - "source {{ test.venv }}/bin/activate" - "tox -e {{ test.environment }} --notest" diff --git a/infrared/main.yml b/infrared/main.yml index d57b5a3d8..971e4cebf 100644 --- a/infrared/main.yml +++ b/infrared/main.yml @@ -1,3 +1,16 @@ ---- -- import_playbook: install.yml - when: test.install|default(False) +- name: Tobiko Tests Main + hosts: undercloud + gather_facts: yes + any_errors_fatal: yes + tasks: + + - name: Install Tobiko + include_tasks: tasks/install.yml + + - name: Set up environment configurations + include_tasks: tasks/configure.yml + + - name: Run Tobiko + include_tasks: tasks/run.yml + when: + - test.tests is defined diff --git a/infrared/tasks/configure.yml b/infrared/tasks/configure.yml new file mode 100644 index 000000000..a919a4109 --- /dev/null +++ b/infrared/tasks/configure.yml @@ -0,0 +1,34 @@ +- name: Create os-faults configuration file + template: + src: "templates/os-faults.yaml.j2" + dest: "~/os-faults.yaml" + mode: 0755 + +- name: Set up Overcloud resources wget cirros img + shell: | + source "{{ test.overcloudrc }}" + wget -c http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img + +- name: Set up Overcloud resources create cirros img + shell: | + source "{{ test.overcloudrc }}" + openstack image create cirros \ + --file cirros-0.4.0-x86_64-disk.img \ + --disk-format qcow2 \ + --container-format bare \ + --public + +- name: Set up Overcloud resources create m.tiny flavor + shell: | + source "{{ test.overcloudrc }}" + openstack flavor create --vcpus 1 --ram 64 --disk 1 m1.tiny + +- name: Set up Overcloud resources create ssh keys + shell: | + test -f ~/.ssh/id_rsa||ssh-keygen -f ~/.ssh/id_rsa -P '' + +- name: Create tobiko configuration file + template: + src: "templates/tobiko.conf.j2" + dest: "{{ test.dir }}/tobiko.conf" + mode: 0755 diff --git a/infrared/tasks/install.yml b/infrared/tasks/install.yml new file mode 100644 index 000000000..17168cbde --- /dev/null +++ b/infrared/tasks/install.yml @@ -0,0 +1,33 @@ +- name: Install pip using get-pip.py + become: yes + shell: | + curl https://bootstrap.pypa.io/get-pip.py | python + +- name: Install required packages + become: yes + vars: + required_packages: ['python-virtualenv', 'git', 'gcc', 'python-devel'] + yum: + name: "{{ required_packages }}" + state: present + +- name: Clone Tobiko project + git: + repo: 'https://review.opendev.org/x/tobiko' + dest: "{{ test.dir }}" + +- name: Create Virtualenv + vars: + packages: ['pip', 'setuptools', 'tox'] + pip: + virtualenv: "{{ test.venv }}" + name: "{{ packages }}" + state: latest + +- name: Install Tobiko + pip: + chdir: "{{ test.dir }}" + name: "." + virtualenv: "{{ test.venv }}" + editable: true + extra_args: "-c https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt -r {{ test.dir }}/requirements.txt" diff --git a/infrared/tasks/run.yml b/infrared/tasks/run.yml new file mode 100644 index 000000000..fb1a56865 --- /dev/null +++ b/infrared/tasks/run.yml @@ -0,0 +1,6 @@ +- name: Run Tobiko Tests + shell: | + cd "{{ test.dir }}" + source "{{ test.overcloudrc }}" + source "{{ test.venv }}/bin/activate" + tox -e "{{ test.tests }}" diff --git a/infrared/tasks/templates/os-faults.yaml.j2 b/infrared/tasks/templates/os-faults.yaml.j2 new file mode 100644 index 000000000..e55350dfc --- /dev/null +++ b/infrared/tasks/templates/os-faults.yaml.j2 @@ -0,0 +1,35 @@ +cloud_management: + driver: universal + +node_discover: + driver: node_list + args: +{% for host_name in groups.overcloud_nodes|sort %} + - fqdn: {{ host_name }} + ip: {{ hostvars[host_name]['ansible_host'] }} + auth: + username: heat-admin + private_key_file: /home/stack/.ssh/id_rsa + become: true +{% endfor %} + +services: + openvswitch: + driver: system_service + args: + service_name: openvswitch + grep: openvswitch + +containers: + neutron_ovs_agent: + driver: docker_container + args: + container_name: neutron_ovs_agent + neutron_metadata_agent: + driver: docker_container + args: + container_name: neutron_metadata_agent + neutron_api: + driver: docker_container + args: + container_name: neutron_api diff --git a/infrared/tasks/templates/tobiko.conf.j2 b/infrared/tasks/templates/tobiko.conf.j2 new file mode 100644 index 000000000..202a294e8 --- /dev/null +++ b/infrared/tasks/templates/tobiko.conf.j2 @@ -0,0 +1,10 @@ +[DEFAULT] +debug = true +log_file = tobiko.log +log_dir = . +[nova] +image = cirros +flavor = m1.tiny +key_file=~/.ssh/id_rsa +[neutron] +floating_network = public diff --git a/infrared/plugin.spec b/plugin.spec similarity index 62% rename from infrared/plugin.spec rename to plugin.spec index 883e864a7..cc72bd68c 100644 --- a/infrared/plugin.spec +++ b/plugin.spec @@ -1,6 +1,7 @@ --- config: plugin_type: test + entry_point: ./infrared/main.yml subparsers: tobiko: @@ -15,16 +16,23 @@ subparsers: Install Tobiko - title: Install Options options: - env: - type: Value - help: | - The tox environment to use dir: type: Value + default: "{{ ansible_env.HOME }}/tobiko" help: | The directory where Tobiko will be installed and used + overcloudrc: + type: Value + default: "{{ ansible_env.HOME }}/overcloudrc" + help: | + The path to the overcloudrc file venv: type: Value - default: '~/tobiko_venv' + default: "{{ ansible_env.HOME }}/tobiko_venv" help: | path of existing virtual environment + tests: + type: Value + help: | + The set of tests to execute + default: neutron