diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 911dc5e68b..8476016f38 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -210,6 +210,7 @@ enable_murano: "no" enable_neutron_lbaas: "no" enable_neutron_qos: "no" enable_swift: "no" +enable_tempest: "no" ironic_keystone_user: "ironic" neutron_keystone_user: "neutron" diff --git a/ansible/inventory/all-in-one b/ansible/inventory/all-in-one index 53a8940afb..3a2e6ce979 100644 --- a/ansible/inventory/all-in-one +++ b/ansible/inventory/all-in-one @@ -87,6 +87,10 @@ control [ceilometer:children] control +# Tempest +[tempest:children] +control + # Additional control implemented here. These groups allow you to control which # services run on which hosts at a per-service level. # diff --git a/ansible/inventory/multinode b/ansible/inventory/multinode index 6b98a2dd26..4d08cba778 100644 --- a/ansible/inventory/multinode +++ b/ansible/inventory/multinode @@ -99,6 +99,10 @@ control [ceilometer:children] control +# Tempest +[tempest:children] +control + # Additional control implemented here. These groups allow you to control which # services run on which hosts at a per-service level. # diff --git a/ansible/roles/tempest/defaults/main.yml b/ansible/roles/tempest/defaults/main.yml new file mode 100644 index 0000000000..cebab6c55a --- /dev/null +++ b/ansible/roles/tempest/defaults/main.yml @@ -0,0 +1,23 @@ +--- +project_name: "tempest" + + +######## +# Docker +######## +tempest_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-tempest" +tempest_tag: "{{ openstack_release }}" +tempest_image_full: "{{ tempest_image }}:{{ tempest_tag }}" + + +########################### +# Tempest Required Resource +########################### +image_url: "http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img" + +tempest_image_id: +tempest_image_alt_id: "{{ tempest_image_id }}" +tempest_flavor_ref_id: +tempest_flavor_ref_alt_id: "{{ tempest_flavor_ref_id }}" +tempest_public_network_id: +tempest_floating_network_name: diff --git a/ansible/roles/tempest/meta/main.yml b/ansible/roles/tempest/meta/main.yml new file mode 100644 index 0000000000..6b4fff8fef --- /dev/null +++ b/ansible/roles/tempest/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - { role: common } diff --git a/ansible/roles/tempest/tasks/config.yml b/ansible/roles/tempest/tasks/config.yml new file mode 100644 index 0000000000..3375790f90 --- /dev/null +++ b/ansible/roles/tempest/tasks/config.yml @@ -0,0 +1,26 @@ +--- +- name: Ensuring config directories exist + file: + path: "{{ node_config_directory }}/{{ item }}" + state: "directory" + recurse: yes + with_items: + - "tempest" + +- name: Copying over config.json files for services + template: + src: "{{ item }}.json.j2" + dest: "{{ node_config_directory }}/{{ item }}/config.json" + with_items: + - "tempest" + +- name: Copying over tempest.conf + merge_configs: + vars: + project_name: "tempest" + sources: + - "{{ role_path }}/templates/tempest.conf.j2" + - "{{ node_custom_config }}/tempest.conf" + dest: "{{ node_config_directory }}/{{ item }}/tempest.conf" + with_items: + - "tempest" diff --git a/ansible/roles/tempest/tasks/deploy.yml b/ansible/roles/tempest/tasks/deploy.yml new file mode 100644 index 0000000000..1f16915ad9 --- /dev/null +++ b/ansible/roles/tempest/tasks/deploy.yml @@ -0,0 +1,4 @@ +--- +- include: config.yml + +- include: start.yml diff --git a/ansible/roles/tempest/tasks/do_reconfigure.yml b/ansible/roles/tempest/tasks/do_reconfigure.yml new file mode 100644 index 0000000000..4aa7c3082e --- /dev/null +++ b/ansible/roles/tempest/tasks/do_reconfigure.yml @@ -0,0 +1,64 @@ +--- +- name: Ensuring the containers up + kolla_docker: + name: "{{ item.name }}" + action: "get_container_state" + register: container_state + failed_when: container_state.Running == false + when: inventory_hostname in groups[item.group] + with_items: + - { name: tempest, group: tempest} + +- include: config.yml + +- name: Check the configs + command: docker exec {{ item.name }} /usr/local/bin/kolla_set_configs --check + changed_when: false + failed_when: false + register: check_results + when: inventory_hostname in groups[item.group] + with_items: + - { name: tempest, group: tempest} + +# NOTE(jeffrey4l): when config_strategy == 'COPY_ALWAYS' +# and container env['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE', +# just remove the container and start again +- name: Containers config strategy + kolla_docker: + name: "{{ item.name }}" + action: "get_container_env" + register: container_envs + when: inventory_hostname in groups[item.group] + with_items: + - { name: tempest, group: tempest} + +- name: Remove the containers + kolla_docker: + name: "{{ item[0]['name'] }}" + action: "remove_container" + register: remove_containers + when: + - config_strategy == "COPY_ONCE" or item[1]['KOLLA_CONFIG_STRATEGY'] == 'COPY_ONCE' + - item[2]['rc'] == 1 + - inventory_hostname in groups[item[0]['group']] + with_together: + - [{ name: tempest, group: tempest}] + - container_envs.results + - check_results.results + +- include: start.yml + when: remove_containers.changed + +- name: Restart containers + kolla_docker: + name: "{{ item[0]['name'] }}" + action: "restart_container" + when: + - config_strategy == 'COPY_ALWAYS' + - item[1]['KOLLA_CONFIG_STRATEGY'] != 'COPY_ONCE' + - item[2]['rc'] == 1 + - inventory_hostname in groups[item[0]['group']] + with_together: + - [{ name: tempest, group: tempest}] + - container_envs.results + - check_results.results diff --git a/ansible/roles/tempest/tasks/main.yml b/ansible/roles/tempest/tasks/main.yml new file mode 100644 index 0000000000..b017e8b4ad --- /dev/null +++ b/ansible/roles/tempest/tasks/main.yml @@ -0,0 +1,2 @@ +--- +- include: "{{ action }}.yml" diff --git a/ansible/roles/tempest/tasks/reconfigure.yml b/ansible/roles/tempest/tasks/reconfigure.yml new file mode 100644 index 0000000000..66933249bb --- /dev/null +++ b/ansible/roles/tempest/tasks/reconfigure.yml @@ -0,0 +1,3 @@ +--- +- include: do_reconfigure.yml + serial: "30%" diff --git a/ansible/roles/tempest/tasks/start.yml b/ansible/roles/tempest/tasks/start.yml new file mode 100644 index 0000000000..97b6552c54 --- /dev/null +++ b/ansible/roles/tempest/tasks/start.yml @@ -0,0 +1,11 @@ +--- +- name: Starting tempest container + kolla_docker: + action: "start_container" + common_options: "{{ docker_common_options }}" + image: "{{ tempest_image_full }}" + name: "tempest" + volumes: + - "{{ node_config_directory }}/tempest/:{{ container_config_directory }}/:ro" + - "/etc/localtime:/etc/localtime:ro" + - "kolla_logs:/var/log/kolla/" diff --git a/ansible/roles/tempest/tasks/upgrade.yml b/ansible/roles/tempest/tasks/upgrade.yml new file mode 100644 index 0000000000..1f16915ad9 --- /dev/null +++ b/ansible/roles/tempest/tasks/upgrade.yml @@ -0,0 +1,4 @@ +--- +- include: config.yml + +- include: start.yml diff --git a/ansible/roles/tempest/templates/tempest.conf.j2 b/ansible/roles/tempest/templates/tempest.conf.j2 new file mode 100644 index 0000000000..ebf16ee3c7 --- /dev/null +++ b/ansible/roles/tempest/templates/tempest.conf.j2 @@ -0,0 +1,74 @@ +[DEFAULT] +debug = {{ openstack_logging_debug }} +log_file = tempest.log +use_stderr = False +log_dir = /var/log/kolla/tempest/ + +[auth] +admin_username = admin +admin_password = {{ keystone_admin_password }} +admin_project_name = admin +admin_domain_name = default + + +[dashboard] +dashboard_url = {{ internal_protocol }}://{{ kolla_internal_fqdn }} +login_url = {{ internal_protocol }}://{{ kolla_internal_fqdn }}/auth/login/ + +[service_available] +cinder = {{ enable_cinder }} +neutron = {{ enable_neutron }} +glance = {{ enable_glance }} +swift = {{ enable_swift }} +nova = {{ enable_nova }} +heat = {{ enable_heat }} +horizon = {{ enable_horizon }} +ceilometer = {{ enable_ceilometer }} + +[compute] +max_microversion = latest +image_ref = {{ tempest_image_id }} +image_ref_alt = {{ tempest_image_alt_id }} +flavor_ref = {{ tempest_flavor_ref_id }} +flavor_ref_alt = {{ tempest_flavor_ref_alt_id }} +region = {{ openstack_region_name }} + +[dashboard] +dashboard_url = {{ internal_protocol }}://{{ kolla_internal_fqdn }}/ +login_url = {{ internal_protocol }}://{{ kolla_internal_fqdn }}/auth/login + +[identity] +region = {{ openstack_region_name }} +auth_version = v3 +uri = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }}/v2.0 +uri_v3 = {{ internal_protocol }}://{{ kolla_internal_fqdn }}:{{ keystone_admin_port }}/v3 + +[image] +region = {{ openstack_region_name }} +http_image = {{ image_url }} + +[network] +region = {{ openstack_region_name }} +public_router_id = +public_network_id = {{ tempest_public_network_id }} +floating_network_name = {{ tempest_floating_network_name }} +project_networks_reachable = false + +[network-feature-enabled] +ipv6 = false + +[object-storage] +region = {{ openstack_region_name }} + +[orchestration] +region = {{ openstack_region_name }} + +[volume] +region = {{ openstack_region_name }} + +[volume-feature-enabled] +api_v1 = False + +[validation] +image_ssh_user = cirros +image_ssh_password = cubswin:) diff --git a/ansible/roles/tempest/templates/tempest.json.j2 b/ansible/roles/tempest/templates/tempest.json.j2 new file mode 100644 index 0000000000..3ff5ea788e --- /dev/null +++ b/ansible/roles/tempest/templates/tempest.json.j2 @@ -0,0 +1,11 @@ +{ + "command": "sleep infinity", + "config_files":[ + { + "source": "{{ container_config_directory }}/tempest.conf", + "dest": "/etc/tempest/tempest.conf", + "owner": "root", + "perm": "0600" + } + ] +} diff --git a/ansible/site.yml b/ansible/site.yml index 98305cfdc3..89c075c404 100644 --- a/ansible/site.yml +++ b/ansible/site.yml @@ -238,3 +238,10 @@ - { role: ceilometer, tags: ceilometer, when: enable_ceilometer | bool } + +- hosts: + - tempest + roles: + - { role: tempest, + tags: tempest, + when: enable_tempest | bool } diff --git a/ansible/tempest.yml b/ansible/tempest.yml new file mode 100644 index 0000000000..ef8db8b30d --- /dev/null +++ b/ansible/tempest.yml @@ -0,0 +1,6 @@ +- hosts: + - tempest + roles: + - { role: tempest, + tags: tempest, + when: enable_tempest | bool } diff --git a/docker/tempest/Dockerfile.j2 b/docker/tempest/Dockerfile.j2 index dc7a04f7b8..8b389116dd 100644 --- a/docker/tempest/Dockerfile.j2 +++ b/docker/tempest/Dockerfile.j2 @@ -25,6 +25,11 @@ RUN ln -s tempest-source/* tempest \ && /var/lib/kolla/venv/bin/pip --no-cache-dir install --upgrade -c requirements/upper-constraints.txt /tempest \ && mkdir -p /etc/tempest /var/log/tempest /etc/tempest/tempest_lock +WORKDIR /tempest + {% endif %} +COPY extend_start.sh /usr/local/bin/kolla_extend_start +RUN chmod 755 /usr/local/bin/kolla_extend_start + {{ include_footer }} diff --git a/docker/tempest/extend_start.sh b/docker/tempest/extend_start.sh new file mode 100644 index 0000000000..48397041f1 --- /dev/null +++ b/docker/tempest/extend_start.sh @@ -0,0 +1,8 @@ +#! /bin/bash + +if [[ ! -d "/var/log/kolla/tempest" ]]; then + mkdir -p /var/log/kolla/tempest +fi +if [[ $(stat -c %a /var/log/kolla/tempest) != "755" ]]; then + chmod 755 /var/log/kolla/tempest +fi diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index 42f725dca9..7cc7b52a1c 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -124,6 +124,7 @@ neutron_external_interface: "eth1" #enable_neutron_lbaas: "no" #enable_neutron_qos: "no" #enable_swift: "no" +#enable_tempest: "no" # Control usage of ceph per service. This allows to configure external ceph # when ceph is not deployed by Kolla. @@ -175,3 +176,16 @@ neutron_external_interface: "eth1" # selected then swift_devices_name should specify a pattern which would match to # filesystems' labels prepared for swift. #swift_devices_name: "KOLLA_SWIFT_DATA" + + +################################################ +# Tempest - The OpenStack Integration Test Suite +################################################ +# following value must be set when enable tempest +tempest_image_id: +tempest_flavor_ref_id: +tempest_public_network_id: +tempest_floating_network_name: + +# tempest_image_alt_id: "{{ tempest_image_id }}" +# tempest_flavor_ref_alt_id: "{{ tempest_flavor_ref_id }}" diff --git a/releasenotes/notes/ansible-tempest-44edbca4436f3c19.yaml b/releasenotes/notes/ansible-tempest-44edbca4436f3c19.yaml new file mode 100644 index 0000000000..a12be3d99a --- /dev/null +++ b/releasenotes/notes/ansible-tempest-44edbca4436f3c19.yaml @@ -0,0 +1,3 @@ +--- +features: + - Implement Ansible Tempest role