aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJeffrey Zhang <zhang.lei.fly@gmail.com>2017-10-20 13:50:21 +0800
committerJeffrey Zhang <zhang.lei.fly@gmail.com>2017-10-26 09:58:29 +0800
commitcdd125117f0ca65300b608734caa2eb36779fcea (patch)
tree14c197edc7e0a7a1cdb54d2996261c5375842821 /tests
parente2301f071717deb2a708c416cea8549dbdc07b02 (diff)
downloadkolla-ansible-cdd125117f0ca65300b608734caa2eb36779fcea.tar.gz
kolla-ansible-cdd125117f0ca65300b608734caa2eb36779fcea.zip
Optimize zuul v3 jobs
- move check container failure from post.yml to run.yml - add binary related jobs - use static kolla-ansible src dir, which is helpful for kolla project to use. - generate correct /etc/hosts by using private ip address and hostname - fix the wrong api interface in global.yml file Change-Id: Idfdee6dfe18f0fa2d4f984df59b57553122ce298
Diffstat (limited to 'tests')
-rw-r--r--tests/get_logs.sh17
-rw-r--r--tests/pre.yml11
-rw-r--r--tests/run.yml35
3 files changed, 35 insertions, 28 deletions
diff --git a/tests/get_logs.sh b/tests/get_logs.sh
index 81961ad7c..486b54a26 100644
--- a/tests/get_logs.sh
+++ b/tests/get_logs.sh
@@ -2,22 +2,6 @@
set +o errexit
-check_failure() {
- # All docker container's status are created, restarting, running, removing,
- # paused, exited and dead. Containers without running status are treated as
- # failure. removing is added in docker 1.13, just ignore it now.
- failed_containers=$(docker ps -a --format "{{.Names}}" \
- --filter status=created \
- --filter status=restarting \
- --filter status=paused \
- --filter status=exited \
- --filter status=dead)
-
- if [[ -n "$failed_containers" ]]; then
- exit 1;
- fi
-}
-
copy_logs() {
LOG_DIR=/tmp/logs
@@ -82,4 +66,3 @@ copy_logs() {
}
copy_logs
-check_failure
diff --git a/tests/pre.yml b/tests/pre.yml
index dd614b89c..e111d691a 100644
--- a/tests/pre.yml
+++ b/tests/pre.yml
@@ -2,6 +2,12 @@
vars:
logs_dir: "/tmp/logs"
tasks:
+ - name: Install dbus for debian system
+ apt: name=dbus
+ when:
+ - ansible_os_family == 'Debian'
+ become: true
+
- name: Ensure /tmp/logs/ dir
file:
path: "{{ logs_dir }}"
@@ -18,3 +24,8 @@
- "system_logs"
- "kolla"
- "ansible"
+
+ - name: set new hostname based on ansible inventory file
+ hostname:
+ name: "{{ inventory_hostname }}"
+ become: true
diff --git a/tests/run.yml b/tests/run.yml
index 25eae0b2e..f1adf6982 100644
--- a/tests/run.yml
+++ b/tests/run.yml
@@ -3,6 +3,8 @@
vars:
kolla_inventory_path: "/etc/kolla/inventory"
logs_dir: "/tmp/logs"
+ kolla_ansible_src_dir: "src/{{ zuul.project.canonical_hostname }}/openstack/kolla-ansible"
+ kolla_ansible_full_src_dir: "{{ zuul.executor.work_root }}/{{ kolla_ansible_src_dir }}"
tasks:
- name: ensure /etc/kolla exists
file:
@@ -14,12 +16,12 @@
- set_fact:
nodes: |
{% for host in hostvars %}
- {{ host }} ansible_host={{ hostvars[host]['ansible_host'] }} ansible_become=true ansible_user={{ hostvars[host]['ansible_user'] }}
+ {{ host }} ansible_host={{ hostvars[host]['nodepool']['private_ipv4'] }} ansible_become=true ansible_user={{ hostvars[host]['ansible_user'] }}
{% endfor %}
- name: copy default ansible kolla-ansible inventory
copy:
- src: "{{ zuul.executor.work_root }}/{{ zuul.project.src_dir }}/ansible/inventory/all-in-one"
+ src: "{{ kolla_ansible_full_src_dir }}/ansible/inventory/all-in-one"
dest: "{{ kolla_inventory_path }}"
delegate_to: "primary"
@@ -30,12 +32,23 @@
replace: "{{ nodes }}"
delegate_to: "primary"
- - name: generate global.yml file
+ # FIXME: in multi node env, api_interface may be different on each node.
+ - name: detect api_interface_name variable
vars:
- api_interface_name: "{{ hostvars['primary']['ansible_default_ipv4'].alias }}"
- api_interface_address: "{{ hostvars['primary']['nodepool']['private_ipv4'] }}"
+ ansible_interface_name: "ansible_{{ item.replace('-', '_') }}"
+ api_interface_address: "{{ hostvars[inventory_hostname]['nodepool']['private_ipv4'] }}"
+ set_fact:
+ api_interface_name: "{{ item }}"
+ api_interface_address: "{{ api_interface_address }}"
+ when:
+ - hostvars[inventory_hostname][ansible_interface_name]['ipv4'] is defined
+ - hostvars[inventory_hostname][ansible_interface_name]['ipv4']['address'] == api_interface_address
+ with_items: "{{ ansible_interfaces }}"
+ delegate_to: "primary"
+
+ - name: generate global.yml file
template:
- src: "{{ zuul.executor.work_root }}/{{ zuul.project.src_dir }}/tests/templates/globals-default.j2"
+ src: "{{ kolla_ansible_full_src_dir }}/tests/templates/globals-default.j2"
dest: /etc/kolla/globals.yml
delegate_to: "primary"
@@ -49,23 +62,23 @@
- name: generate config overrides
template:
- src: "{{ zuul.executor.work_root }}/{{ zuul.project.src_dir }}/tests/templates/nova-compute-overrides.j2"
+ src: "{{ kolla_ansible_full_src_dir }}/tests/templates/nova-compute-overrides.j2"
dest: /etc/kolla/config/nova/nova-compute.conf
delegate_to: "primary"
- name: copy passwords.yml file
copy:
- src: "{{ zuul.executor.work_root }}/{{ zuul.project.src_dir }}/etc/kolla/passwords.yml"
+ src: "{{ kolla_ansible_full_src_dir }}/etc/kolla/passwords.yml"
dest: /etc/kolla/passwords.yml
delegate_to: "primary"
- name: install kolla-ansible requirements
pip:
- requirements: "{{ ansible_env.HOME }}/{{ zuul.project.src_dir }}/requirements.txt"
+ requirements: "{{ ansible_env.HOME }}/{{ kolla_ansible_src_dir }}/requirements.txt"
become: true
- name: generate passwords
- shell: "{{ zuul.project.src_dir }}/tools/generate_passwords.py"
+ shell: "{{ kolla_ansible_src_dir }}/tools/generate_passwords.py"
delegate_to: "primary"
- shell:
@@ -78,6 +91,6 @@
tools/setup_gate.sh
executable: /bin/bash
- chdir: "{{ zuul.project.src_dir }}"
+ chdir: "{{ kolla_ansible_src_dir }}"
delegate_to: "primary"
environment: '{{ zuul | zuul_legacy_vars }}'