Add functional tests to elk_metrics_6x
Change-Id: Ia997aa0a9b9388be0e8f72b633b3b9cc25b4429c Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
c27afdda6a
commit
47aff12e6c
@ -25,7 +25,7 @@ OpenStack-Ansible Integration
|
|||||||
|
|
||||||
These playbooks can be used as standalone inventory or as an integrated part of
|
These playbooks can be used as standalone inventory or as an integrated part of
|
||||||
an OpenStack-Ansible deployment. For a simple example of standalone inventory,
|
an OpenStack-Ansible deployment. For a simple example of standalone inventory,
|
||||||
see ``inventory.example.yml``.
|
see [test-inventory.yml](tests/inventory/test-inventory.yml).
|
||||||
|
|
||||||
|
|
||||||
Optional | Load balancer configuration
|
Optional | Load balancer configuration
|
||||||
@ -528,3 +528,36 @@ If everything goes bad, you can clean up with the following command
|
|||||||
|
|
||||||
openstack-ansible /opt/openstack-ansible-ops/elk_metrics_6x/site.yml -e 'elk_package_state="absent"' --tags package_install
|
openstack-ansible /opt/openstack-ansible-ops/elk_metrics_6x/site.yml -e 'elk_package_state="absent"' --tags package_install
|
||||||
openstack-ansible /opt/openstack-ansible/playbooks/lxc-containers-destroy.yml --limit elk_all
|
openstack-ansible /opt/openstack-ansible/playbooks/lxc-containers-destroy.yml --limit elk_all
|
||||||
|
|
||||||
|
|
||||||
|
Local testing
|
||||||
|
-------------
|
||||||
|
|
||||||
|
To test these playbooks within a local environment you will need a single server
|
||||||
|
with at leasts 8GiB of RAM and 40GiB of storage on root. Running an `m1.medium`
|
||||||
|
(openstack) flavor size is generally enough to get an environment online.
|
||||||
|
|
||||||
|
To run the local functional tests execute the `run-tests.sh` script out of the
|
||||||
|
tests directory. This will create a 4 node elasaticsearch cluster, 1 kibana node
|
||||||
|
with an elasticsearch coordination process, and 1 APM node. The beats will be
|
||||||
|
deployed to the environment as if this was a production installation.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
tests/run-tests.sh
|
||||||
|
|
||||||
|
|
||||||
|
After the test build is completed the cluster will test it's layout and ensure
|
||||||
|
processes are functioning normally. Logs for the cluster can be found at
|
||||||
|
`/tmp/elk-metrics-6x-logs`.
|
||||||
|
|
||||||
|
To rerun the playbooks after a test build, source the `tests/manual-test.rc`
|
||||||
|
file and follow the onscreen instructions.
|
||||||
|
|
||||||
|
To clean-up a test environment and start from a bare server slate the
|
||||||
|
`run-cleanup.sh` script can be used. This script is distructive and will purge
|
||||||
|
all `elk_metrics_6x` related services within the local test environment.
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
tests/run-cleanup.sh
|
0
elk_metrics_6x/bootstrap-embedded-ansible.sh
Normal file → Executable file
0
elk_metrics_6x/bootstrap-embedded-ansible.sh
Normal file → Executable file
@ -1,5 +1,9 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- name: Refresh minimal facts
|
||||||
|
setup:
|
||||||
|
gather_subset: '!all,!any,network,virtual'
|
||||||
|
|
||||||
# storage node count is equal to the cluster size
|
# storage node count is equal to the cluster size
|
||||||
- name: Node count fact
|
- name: Node count fact
|
||||||
set_fact:
|
set_fact:
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
- name: Set memory fact to half
|
- name: Set memory fact to half
|
||||||
set_fact:
|
set_fact:
|
||||||
h_mem: "{{ (ansible_memtotal_mb | int) // 2 }}"
|
h_mem: "{{ (ansible_memtotal_mb | int) // 2 }}"
|
||||||
|
when:
|
||||||
|
- h_mem is not defined
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
retries: 3
|
retries: 3
|
||||||
delay: 2
|
delay: 2
|
||||||
with_items:
|
with_items:
|
||||||
|
- gcc
|
||||||
- git
|
- git
|
||||||
- libsystemd-dev
|
- libsystemd-dev
|
||||||
tags:
|
tags:
|
||||||
|
@ -14,11 +14,21 @@
|
|||||||
- include_tasks: common_task_data_node_hosts.yml
|
- include_tasks: common_task_data_node_hosts.yml
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Set quarter memory fact
|
- name: Set quarter memory fact
|
||||||
set_fact:
|
set_fact:
|
||||||
q_mem: "{{ (ansible_memtotal_mb | int) // 4 }}"
|
q_mem: "{{ (ansible_memtotal_mb | int) // 4 }}"
|
||||||
|
when:
|
||||||
|
- q_mem is not defined
|
||||||
|
tags:
|
||||||
|
- always
|
||||||
|
|
||||||
|
- name: Set processor cores fact
|
||||||
|
set_fact:
|
||||||
q_storage: "{{ ansible_processor_cores }}"
|
q_storage: "{{ ansible_processor_cores }}"
|
||||||
|
when:
|
||||||
|
- q_storage is not defined
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
|
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
---
|
|
||||||
|
|
||||||
################################## ALL HOSTS ##################################
|
|
||||||
all:
|
|
||||||
hosts:
|
|
||||||
# Local host
|
|
||||||
localhost:
|
|
||||||
ansible_connection: local
|
|
||||||
|
|
||||||
################################## REQUIRED ###################################
|
|
||||||
logging01:
|
|
||||||
ansible_host: 172.16.27.100
|
|
||||||
ansible_user: root
|
|
||||||
|
|
||||||
############################## OPTIONAL TARGETS ###############################
|
|
||||||
target1:
|
|
||||||
ansible_host: 172.16.27.200
|
|
||||||
ansible_user: root
|
|
||||||
|
|
||||||
vars: {}
|
|
||||||
|
|
||||||
|
|
||||||
################################### GROUPS ####################################
|
|
||||||
|
|
||||||
# The hosts group is used to target physical host machines. Enter all physical
|
|
||||||
# host machines here.
|
|
||||||
hosts:
|
|
||||||
hosts:
|
|
||||||
target1:
|
|
||||||
|
|
||||||
# This is the location where elasticsearch(s) and logstash(s) will live.
|
|
||||||
elastic-logstash:
|
|
||||||
hosts:
|
|
||||||
logging01:
|
|
||||||
|
|
||||||
# This is the location where kibana(s) will live
|
|
||||||
kibana:
|
|
||||||
hosts:
|
|
||||||
logging01:
|
|
||||||
|
|
||||||
# These groups are all optional groups used within the stack to agment the data
|
|
||||||
# collection in an OpenStack environment.
|
|
||||||
ceph-mon: {}
|
|
||||||
galera_all: {}
|
|
||||||
nova_compute: {}
|
|
||||||
haproxy_all: {}
|
|
||||||
horizon_all: {}
|
|
||||||
memcached_all: {}
|
|
||||||
rabbitmq_all: {}
|
|
||||||
shared-infra_hosts: {}
|
|
||||||
utility_all: {}
|
|
@ -24,8 +24,8 @@
|
|||||||
- "--dashboards"
|
- "--dashboards"
|
||||||
register: templates
|
register: templates
|
||||||
until: templates is success
|
until: templates is success
|
||||||
retries: 3
|
retries: 5
|
||||||
delay: 2
|
delay: 5
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- beat-setup
|
- beat-setup
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
- "--dashboards"
|
- "--dashboards"
|
||||||
register: templates
|
register: templates
|
||||||
until: templates is success
|
until: templates is success
|
||||||
retries: 3
|
retries: 5
|
||||||
delay: 2
|
delay: 5
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- beat-setup
|
- beat-setup
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
- "--dashboards"
|
- "--dashboards"
|
||||||
register: templates
|
register: templates
|
||||||
until: templates is success
|
until: templates is success
|
||||||
retries: 3
|
retries: 5
|
||||||
delay: 2
|
delay: 5
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- beat-setup
|
- beat-setup
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
- "--dashboards"
|
- "--dashboards"
|
||||||
register: templates
|
register: templates
|
||||||
until: templates is success
|
until: templates is success
|
||||||
retries: 3
|
retries: 5
|
||||||
delay: 2
|
delay: 5
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- beat-setup
|
- beat-setup
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
-e -v
|
-e -v
|
||||||
register: templates
|
register: templates
|
||||||
until: templates is success
|
until: templates is success
|
||||||
retries: 3
|
retries: 5
|
||||||
delay: 2
|
delay: 5
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- beat-setup
|
- beat-setup
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
- "--dashboards"
|
- "--dashboards"
|
||||||
register: templates
|
register: templates
|
||||||
until: templates is success
|
until: templates is success
|
||||||
retries: 3
|
retries: 5
|
||||||
delay: 2
|
delay: 5
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- beat-setup
|
- beat-setup
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
- "--dashboards"
|
- "--dashboards"
|
||||||
register: templates
|
register: templates
|
||||||
until: templates is success
|
until: templates is success
|
||||||
retries: 3
|
retries: 5
|
||||||
delay: 2
|
delay: 5
|
||||||
|
|
||||||
tags:
|
tags:
|
||||||
- beat-setup
|
- beat-setup
|
||||||
|
@ -258,7 +258,8 @@ filebeat.modules:
|
|||||||
# If true, all fields created by this module are prefixed with
|
# If true, all fields created by this module are prefixed with
|
||||||
# `osquery.result`. Set to false to copy the fields in the root
|
# `osquery.result`. Set to false to copy the fields in the root
|
||||||
# of the document. The default is true.
|
# of the document. The default is true.
|
||||||
var.use_namespace: true
|
# NOTE(cloudull): This option is commented out because it is broken
|
||||||
|
#var.use_namespace: true
|
||||||
|
|
||||||
#----------------------------- PostgreSQL Module -----------------------------
|
#----------------------------- PostgreSQL Module -----------------------------
|
||||||
#- module: postgresql
|
#- module: postgresql
|
||||||
|
101
elk_metrics_6x/tests/_container-setup.yml
Normal file
101
elk_metrics_6x/tests/_container-setup.yml
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2018, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
- name: Setup host for nspawn
|
||||||
|
hosts: physical_hosts
|
||||||
|
connection: local
|
||||||
|
become: true
|
||||||
|
vars:
|
||||||
|
nspawn_networks:
|
||||||
|
nspawn_address:
|
||||||
|
bridge: "nspawn0"
|
||||||
|
private_device: true
|
||||||
|
enable_dhcp: true
|
||||||
|
dhcp_range: 10.100.101.2,10.100.101.129
|
||||||
|
address: 10.100.101.1
|
||||||
|
netmask: 255.255.255.0
|
||||||
|
macvlan_mode: bridge
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Show host facts
|
||||||
|
debug:
|
||||||
|
var: hostvars
|
||||||
|
|
||||||
|
- name: First ensure apt cache is always refreshed
|
||||||
|
apt:
|
||||||
|
update_cache: yes
|
||||||
|
when:
|
||||||
|
- ansible_pkg_mgr == 'apt'
|
||||||
|
|
||||||
|
- name: Ensure root ssh key
|
||||||
|
user:
|
||||||
|
name: "{{ ansible_env.USER | default('root') }}"
|
||||||
|
generate_ssh_key: "yes"
|
||||||
|
ssh_key_bits: 2048
|
||||||
|
ssh_key_file: ".ssh/id_rsa"
|
||||||
|
|
||||||
|
- name: Get root ssh key
|
||||||
|
slurp:
|
||||||
|
src: '~/.ssh/id_rsa.pub'
|
||||||
|
register: _root_ssh_key
|
||||||
|
|
||||||
|
- name: Prepare container ssh key fact
|
||||||
|
set_fact:
|
||||||
|
nspawn_container_ssh_key: "{{ _root_ssh_key['content'] | b64decode }}"
|
||||||
|
|
||||||
|
- name: Ensure public ssh key is in authorized_keys
|
||||||
|
authorized_key:
|
||||||
|
user: "{{ ansible_env.USER | default('root') }}"
|
||||||
|
key: "{{ nspawn_container_ssh_key }}"
|
||||||
|
manage_dir: no
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: "systemd_networkd"
|
||||||
|
systemd_networkd_prefix: "elk_metrics_6x"
|
||||||
|
systemd_interface_cleanup: true
|
||||||
|
systemd_run_networkd: true
|
||||||
|
systemd_netdevs:
|
||||||
|
- NetDev:
|
||||||
|
Name: dummy0
|
||||||
|
Kind: dummy
|
||||||
|
- NetDev:
|
||||||
|
Name: br-mgmt
|
||||||
|
Kind: bridge
|
||||||
|
systemd_networks:
|
||||||
|
- interface: "dummy0"
|
||||||
|
bridge: "br-mgmt"
|
||||||
|
- interface: "br-mgmt"
|
||||||
|
address: "172.29.236.1"
|
||||||
|
netmask: "255.255.255.0"
|
||||||
|
|
||||||
|
- role: "nspawn_hosts"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Create container(s)
|
||||||
|
hosts: all_containers
|
||||||
|
gather_facts: false
|
||||||
|
become: true
|
||||||
|
pre_tasks:
|
||||||
|
- name: Show container facts
|
||||||
|
debug:
|
||||||
|
var: hostvars
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: "nspawn_container_create"
|
||||||
|
|
||||||
|
post_tasks:
|
||||||
|
- name: Rescan quotas
|
||||||
|
command: "btrfs quota rescan -w /var/lib/machines"
|
||||||
|
delegate_to: "{{ physical_host }}"
|
33
elk_metrics_6x/tests/ansible-role-requirements.yml
Normal file
33
elk_metrics_6x/tests/ansible-role-requirements.yml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
---
|
||||||
|
- name: apt_package_pinning
|
||||||
|
scm: git
|
||||||
|
src: https://git.openstack.org/openstack/openstack-ansible-apt_package_pinning
|
||||||
|
version: master
|
||||||
|
- name: config_template
|
||||||
|
scm: git
|
||||||
|
src: https://git.openstack.org/openstack/ansible-config_template
|
||||||
|
version: master
|
||||||
|
- name: nspawn_container_create
|
||||||
|
scm: git
|
||||||
|
src: https://git.openstack.org/openstack/openstack-ansible-nspawn_container_create
|
||||||
|
version: master
|
||||||
|
- name: nspawn_hosts
|
||||||
|
scm: git
|
||||||
|
src: https://git.openstack.org/openstack/openstack-ansible-nspawn_hosts
|
||||||
|
version: master
|
||||||
|
- name: plugins
|
||||||
|
scm: git
|
||||||
|
src: https://git.openstack.org/openstack/openstack-ansible-plugins
|
||||||
|
version: master
|
||||||
|
- name: systemd_mount
|
||||||
|
scm: git
|
||||||
|
src: https://git.openstack.org/openstack/ansible-role-systemd_mount
|
||||||
|
version: master
|
||||||
|
- name: systemd_networkd
|
||||||
|
scm: git
|
||||||
|
src: https://git.openstack.org/openstack/ansible-role-systemd_networkd
|
||||||
|
version: master
|
||||||
|
- name: systemd_service
|
||||||
|
scm: git
|
||||||
|
src: https://git.openstack.org/openstack/ansible-role-systemd_service
|
||||||
|
version: master
|
140
elk_metrics_6x/tests/functional.yml
Normal file
140
elk_metrics_6x/tests/functional.yml
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2018, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
- import_playbook: run-setup.yml
|
||||||
|
|
||||||
|
- name: Basic setup
|
||||||
|
hosts: "all"
|
||||||
|
become: true
|
||||||
|
|
||||||
|
environment:
|
||||||
|
# ZUUL_PROJECT is used by tests/get-ansible-role-requirements to
|
||||||
|
# determine when CI provided repos should be used.
|
||||||
|
ZUUL_PROJECT: "{{ zuul.project.short_name }}"
|
||||||
|
ANSIBLE_PACKAGE: "{{ ansible_package | default('') }}"
|
||||||
|
ANSIBLE_HOST_KEY_CHECKING: "False"
|
||||||
|
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test.log"
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Create swap file
|
||||||
|
command: "dd if=/dev/zero of=/swap.img bs=1M count=4096"
|
||||||
|
args:
|
||||||
|
creates: /swap.img
|
||||||
|
register: swap_create
|
||||||
|
|
||||||
|
- name: Format the swap file
|
||||||
|
command: mkswap /swap.img
|
||||||
|
when:
|
||||||
|
- swap_create is changed
|
||||||
|
tags:
|
||||||
|
- swap-format
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Enable swap file
|
||||||
|
command: swapon /swap.img
|
||||||
|
failed_when: false
|
||||||
|
tags:
|
||||||
|
- swap-format
|
||||||
|
- skip_ansible_lint
|
||||||
|
|
||||||
|
- name: Set system swappiness
|
||||||
|
sysctl:
|
||||||
|
name: vm.swappiness
|
||||||
|
value: 10
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Flush iptables rules
|
||||||
|
command: "{{ item }}"
|
||||||
|
args:
|
||||||
|
creates: "/tmp/elk-metrics-6x-logs/iptables.flushed"
|
||||||
|
with_items:
|
||||||
|
- "iptables -F"
|
||||||
|
- "iptables -X"
|
||||||
|
- "iptables -t nat -F"
|
||||||
|
- "iptables -t nat -X"
|
||||||
|
- "iptables -t mangle -F"
|
||||||
|
- "iptables -t mangle -X"
|
||||||
|
- "iptables -P INPUT ACCEPT"
|
||||||
|
- "iptables -P FORWARD ACCEPT"
|
||||||
|
- "iptables -P OUTPUT ACCEPT"
|
||||||
|
- "touch /tmp/elk-metrics-6x-logs/iptables.flushed"
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Run embedded ansible installation
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
command: "./bootstrap-embedded-ansible.sh"
|
||||||
|
args:
|
||||||
|
chdir: "src/{{ current_test_repo }}/elk_metrics_6x"
|
||||||
|
|
||||||
|
- name: Run ansible-galaxy
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
command: "/root/ansible25/bin/ansible-galaxy install --force -r ansible-role-requirements.yml"
|
||||||
|
args:
|
||||||
|
chdir: "src/{{ current_test_repo }}/elk_metrics_6x/tests"
|
||||||
|
|
||||||
|
- name: Install netaddr
|
||||||
|
pip:
|
||||||
|
name: netaddr
|
||||||
|
virtualenv: "/root/ansible25"
|
||||||
|
|
||||||
|
- name: Run environment setup
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
command: "/root/ansible25/bin/ansible-playbook -i inventory/test-inventory.yml -e @test-vars.yml _container-setup.yml"
|
||||||
|
environment:
|
||||||
|
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action"
|
||||||
|
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection"
|
||||||
|
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-container-setup.log"
|
||||||
|
args:
|
||||||
|
chdir: "src/{{ current_test_repo }}/elk_metrics_6x/tests"
|
||||||
|
|
||||||
|
- name: Wait 15 seconds
|
||||||
|
command: "sleep 15"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Log all facts
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
command: "/root/ansible25/bin/ansible -m setup -i tests/inventory/test-inventory.yml all"
|
||||||
|
environment:
|
||||||
|
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action"
|
||||||
|
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection"
|
||||||
|
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-facts.log"
|
||||||
|
args:
|
||||||
|
chdir: "src/{{ current_test_repo }}/elk_metrics_6x"
|
||||||
|
|
||||||
|
- name: Run functional test
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
command: "/root/ansible25/bin/ansible-playbook -i tests/inventory/test-inventory.yml -e @tests/test-vars.yml site.yml"
|
||||||
|
environment:
|
||||||
|
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action"
|
||||||
|
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection"
|
||||||
|
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-deployment.log"
|
||||||
|
args:
|
||||||
|
chdir: "src/{{ current_test_repo }}/elk_metrics_6x"
|
||||||
|
|
||||||
|
- name: Show cluster state
|
||||||
|
become: yes
|
||||||
|
become_user: root
|
||||||
|
command: "/root/ansible25/bin/ansible-playbook -i tests/inventory/test-inventory.yml -e @tests/test-vars.yml showElasticCluster.yml"
|
||||||
|
environment:
|
||||||
|
ANSIBLE_ACTION_PLUGINS: "/root/ansible25/repositories/ansible-config_template/action"
|
||||||
|
ANSIBLE_CONNECTION_PLUGINS: "/root/ansible25/repositories/openstack-ansible-plugins/connection"
|
||||||
|
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test-show-cluster.log"
|
||||||
|
args:
|
||||||
|
chdir: "src/{{ current_test_repo }}/elk_metrics_6x"
|
59
elk_metrics_6x/tests/inventory/test-inventory.yml
Normal file
59
elk_metrics_6x/tests/inventory/test-inventory.yml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
---
|
||||||
|
# The hosts group is used to target physical host machines. Enter all physical
|
||||||
|
# host machines here.
|
||||||
|
hosts:
|
||||||
|
children:
|
||||||
|
physical_hosts:
|
||||||
|
hosts:
|
||||||
|
localhost:
|
||||||
|
ansible_host: 127.0.0.1
|
||||||
|
ansible_user: root
|
||||||
|
vars:
|
||||||
|
physical_host: localhost
|
||||||
|
container_networks:
|
||||||
|
management_address:
|
||||||
|
address: "172.29.236.1"
|
||||||
|
netmask: "255.255.255.0"
|
||||||
|
bridge: "br-mgmt"
|
||||||
|
|
||||||
|
|
||||||
|
all_containers:
|
||||||
|
vars:
|
||||||
|
physical_host: localhost
|
||||||
|
container_tech: nspawn
|
||||||
|
container_networks:
|
||||||
|
management_address:
|
||||||
|
address: "{{ ansible_host }}"
|
||||||
|
netmask: "255.255.255.0"
|
||||||
|
bridge: "br-mgmt"
|
||||||
|
|
||||||
|
children:
|
||||||
|
elastic-logstash:
|
||||||
|
hosts:
|
||||||
|
elastic0:
|
||||||
|
ansible_host: 172.29.236.100
|
||||||
|
ansible_user: root
|
||||||
|
|
||||||
|
elastic1:
|
||||||
|
ansible_host: 172.29.236.101
|
||||||
|
ansible_user: root
|
||||||
|
|
||||||
|
elastic2:
|
||||||
|
ansible_host: 172.29.236.102
|
||||||
|
ansible_user: root
|
||||||
|
|
||||||
|
elastic3:
|
||||||
|
ansible_host: 172.29.236.103
|
||||||
|
ansible_user: root
|
||||||
|
|
||||||
|
kibana:
|
||||||
|
hosts:
|
||||||
|
kibana0:
|
||||||
|
ansible_host: 172.29.236.110
|
||||||
|
ansible_user: root
|
||||||
|
|
||||||
|
apm-server:
|
||||||
|
hosts:
|
||||||
|
apm0:
|
||||||
|
ansible_host: 172.29.236.120
|
||||||
|
ansible_user: root
|
16
elk_metrics_6x/tests/manual-test.rc
Normal file
16
elk_metrics_6x/tests/manual-test.rc
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
export ANSIBLE_HOST_KEY_CHECKING="False"
|
||||||
|
export ANSIBLE_ROLES_PATH="${HOME}/ansible25/repositories/roles"
|
||||||
|
export ANSIBLE_ACTION_PLUGINS="${HOME}/ansible25/repositories/roles/config_template/action"
|
||||||
|
export ANSIBLE_CONNECTION_PLUGINS="${HOME}/ansible25/repositories/roles/plugins/connection"
|
||||||
|
export ANSIBLE_LOG_PATH="/tmp/elk-metrics-6x-logs/ansible-elk-test.log"
|
||||||
|
|
||||||
|
if [[ ! -d "/tmp/elk-metrics-6x-logs" ]]; then
|
||||||
|
mkdir -pv "/tmp/elk-metrics-6x-logs"
|
||||||
|
chmod 0777 "/tmp/elk-metrics-6x-logs"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "To build a test environment run the following:"
|
||||||
|
echo -e "# /root/ansible25/bin/ansible-playbook -i tests/inventory/test-inventory.yml tests/test.yml --limit localhost\n"
|
||||||
|
|
||||||
|
echo "Run manual functional tests by executing the following:"
|
||||||
|
echo -e "# /root/ansible25/bin/ansible-playbook -i tests/inventory/test-inventory.yml site.yml\n"
|
27
elk_metrics_6x/tests/post-run.yml
Normal file
27
elk_metrics_6x/tests/post-run.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2018, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
- import_playbook: run-setup.yml
|
||||||
|
|
||||||
|
- name: Run post tasks
|
||||||
|
hosts: "all"
|
||||||
|
tasks:
|
||||||
|
- name: Copy logs back to the executor
|
||||||
|
synchronize:
|
||||||
|
src: "/tmp/elk-metrics-6x-logs"
|
||||||
|
dest: "{{ zuul.executor.log_root }}/"
|
||||||
|
mode: pull
|
||||||
|
rsync_opts:
|
||||||
|
- "--quiet"
|
56
elk_metrics_6x/tests/run-cleanup.sh
Executable file
56
elk_metrics_6x/tests/run-cleanup.sh
Executable file
@ -0,0 +1,56 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2018, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export TEST_DIR="$(readlink -f $(dirname ${0})/../../)"
|
||||||
|
|
||||||
|
# Stop beat processes
|
||||||
|
pushd "${TEST_DIR}/elk_metrics_6x"
|
||||||
|
for i in $(ls -1 install*beat.yml); do
|
||||||
|
LOWER_BEAT="$(echo "${i}" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
BEAT_PARTIAL="$(echo ${LOWER_BEAT} | awk -F'.' '{print $1}')"
|
||||||
|
BEAT="$(echo ${BEAT_PARTIAL} | awk -F'install' '{print $2}')"
|
||||||
|
echo "Stopping ${BEAT}"
|
||||||
|
(systemctl stop "${BEAT}" || true) &
|
||||||
|
apt remove --purge -y "${BEAT}" || true
|
||||||
|
if [[ -d "/etc/${BEAT}" ]]; then
|
||||||
|
rm -rf "/etc/${BEAT}"
|
||||||
|
fi
|
||||||
|
if [[ -d "/var/lib/${BEAT}" ]]; then
|
||||||
|
rm -rf "/var/lib/${BEAT}"
|
||||||
|
fi
|
||||||
|
if [[ -d "/etc/systemd/system/${BEAT}.service.d" ]]; then
|
||||||
|
rm -rf "/etc/systemd/system/${BEAT}.service.d"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
popd
|
||||||
|
|
||||||
|
for i in $(grep -lri elastic /etc/apt/sources.list.d/); do
|
||||||
|
rm "${i}"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Stop and remove containers
|
||||||
|
for i in {1..3}; do
|
||||||
|
if machinectl list-images | grep -v ubuntu | awk '/sub/ {print $1}' | xargs -n 1 machinectl kill; then
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for i in {1..3}; do
|
||||||
|
if machinectl list-images | grep -v ubuntu | awk '/sub/ {print $1}' | xargs -n 1 machinectl remove; then
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
49
elk_metrics_6x/tests/run-setup.yml
Normal file
49
elk_metrics_6x/tests/run-setup.yml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2018, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
- name: Zuul facts
|
||||||
|
hosts: "all"
|
||||||
|
tasks:
|
||||||
|
- name: Set zuul fact
|
||||||
|
set_fact:
|
||||||
|
zuul:
|
||||||
|
project:
|
||||||
|
canonical_name: "openstack-ansible-ops"
|
||||||
|
short_name: "ops"
|
||||||
|
executor:
|
||||||
|
log_root: "{{ ansible_env.HOME }}/elk-test-logs"
|
||||||
|
when:
|
||||||
|
- zuul is not defined
|
||||||
|
|
||||||
|
- name: Print zuul fact
|
||||||
|
debug: var=zuul
|
||||||
|
|
||||||
|
- name: Set current test repo (cross-repo)
|
||||||
|
set_fact:
|
||||||
|
current_test_repo: "git.openstack.org/{{ osa_test_repo }}"
|
||||||
|
when:
|
||||||
|
- osa_test_repo is defined
|
||||||
|
|
||||||
|
- name: Set current test repo (non-cross-repo)
|
||||||
|
set_fact:
|
||||||
|
current_test_repo: "{{ zuul.project.canonical_name }}"
|
||||||
|
when:
|
||||||
|
- osa_test_repo is not defined
|
||||||
|
|
||||||
|
post_tasks:
|
||||||
|
- name: Ensure the log directory exists
|
||||||
|
file:
|
||||||
|
path: "/tmp/elk-metrics-6x-logs"
|
||||||
|
state: directory
|
39
elk_metrics_6x/tests/run-tests.sh
Executable file
39
elk_metrics_6x/tests/run-tests.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Copyright 2018, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -ve
|
||||||
|
|
||||||
|
export TEST_DIR="$(readlink -f $(dirname ${0})/../../)"
|
||||||
|
|
||||||
|
pushd "${HOME}"
|
||||||
|
if [[ ! -d "src" ]]; then
|
||||||
|
mkdir src
|
||||||
|
fi
|
||||||
|
pushd src
|
||||||
|
ln -sf "${TEST_DIR}"
|
||||||
|
popd
|
||||||
|
popd
|
||||||
|
|
||||||
|
source ${TEST_DIR}/elk_metrics_6x/tests/manual-test.rc
|
||||||
|
|
||||||
|
bash -v "${TEST_DIR}/elk_metrics_6x/bootstrap-embedded-ansible.sh"
|
||||||
|
|
||||||
|
${HOME}/ansible25/bin/ansible-galaxy install --force \
|
||||||
|
--roles-path="${HOME}/ansible25/repositories/roles" \
|
||||||
|
--role-file="${TEST_DIR}/elk_metrics_6x/tests/ansible-role-requirements.yml"
|
||||||
|
|
||||||
|
${HOME}/ansible25/bin/ansible-playbook -i 'localhost,' \
|
||||||
|
-vv \
|
||||||
|
${TEST_DIR}/elk_metrics_6x/tests/test.yml
|
27
elk_metrics_6x/tests/test-vars.yml
Normal file
27
elk_metrics_6x/tests/test-vars.yml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2018, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
physical_host: localhost
|
||||||
|
|
||||||
|
# NOTE(cloudnull): Test configs used to minimize the impact of a
|
||||||
|
# multi-node install with limited resources.
|
||||||
|
q_storage: 1
|
||||||
|
q_mem: 128
|
||||||
|
h_mem: 512
|
||||||
|
|
||||||
|
osa_test_repo: "openstack/openstack-ansible-ops"
|
||||||
|
|
||||||
|
# Set the data interface to a known value
|
||||||
|
elastic_data_interface: "{{ (inventory_hostname == 'localhost') | ternary('mv-mgmt', 'mv-mv-mgmt') }}"
|
17
elk_metrics_6x/tests/test.yml
Normal file
17
elk_metrics_6x/tests/test.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2018, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
- import_playbook: functional.yml
|
||||||
|
- import_playbook: testLayout.yml
|
@ -1,8 +1,14 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
|
- import_playbook: run-setup.yml
|
||||||
|
|
||||||
- name: Test host layout
|
- name: Test host layout
|
||||||
hosts: localhost
|
hosts: localhost
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
environment:
|
||||||
|
ANSIBLE_LOG_PATH: "/tmp/elk-metrics-6x-logs/ansible-elk-test.log"
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
storage_node_count: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
|
storage_node_count: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
|
||||||
expected_masters: [1, 1, 3, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 9, 9, 9, 9, 11]
|
expected_masters: [1, 1, 3, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 9, 9, 9, 9, 11]
|
||||||
|
25
zuul.d/jobs.yaml
Normal file
25
zuul.d/jobs.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
# Copyright 2018, Rackspace US, Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
- job:
|
||||||
|
name: "openstack-ansible-ops:elk_metrics_6x"
|
||||||
|
parent: base
|
||||||
|
description: "Runs a gate test on the elk_metrics_6x project."
|
||||||
|
run: "elk_metrics_6x/tests/test.yml"
|
||||||
|
post-run: "elk_metrics_6x/tests/post-run.yml"
|
||||||
|
files:
|
||||||
|
- ^elk_metrics_6x/.*
|
||||||
|
vars:
|
||||||
|
osa_test_repo: "openstack/openstack-ansible-ops"
|
@ -15,3 +15,9 @@
|
|||||||
- project:
|
- project:
|
||||||
templates:
|
templates:
|
||||||
- openstack-ansible-role-jobs
|
- openstack-ansible-role-jobs
|
||||||
|
check:
|
||||||
|
jobs:
|
||||||
|
- "openstack-ansible-ops:elk_metrics_6x"
|
||||||
|
gate:
|
||||||
|
jobs:
|
||||||
|
- "openstack-ansible-ops:elk_metrics_6x"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user