Functional testing for the role gate
Simple REST API based functional testing for gnocchi will now be run during the gate. Change-Id: Ied96bca01cd3e6f47f2d75505d516b1eafbc7429 Closes-Bug: #1624521
This commit is contained in:
parent
d704118857
commit
30bb3111cd
|
@ -63,7 +63,7 @@ releasenotes/build
|
|||
# Test temp files
|
||||
tests/plugins
|
||||
tests/playbooks
|
||||
tests/test.retry
|
||||
tests/*.retry
|
||||
|
||||
# Vagrant artifacts
|
||||
.vagrant
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
Vagrant.configure(2) do |config|
|
||||
config.vm.box = "ubuntu/trusty64"
|
||||
config.vm.provider "virtualbox" do |v|
|
||||
v.memory = 2048
|
||||
v.cpus = 2
|
||||
end
|
||||
config.vm.provision "shell", inline: <<-SHELL
|
||||
sudo su -
|
||||
cd /vagrant
|
||||
|
|
|
@ -3,3 +3,4 @@
|
|||
path: /etc/ansible
|
||||
scm: git
|
||||
version: master
|
||||
|
||||
|
|
|
@ -30,4 +30,4 @@ export ANSIBLE_SSH_ARGS="-o ControlMaster=no \
|
|||
-o ForwardAgent=yes"
|
||||
|
||||
echo "Run manual functional tests by executing the following:"
|
||||
echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml -e \"rolename=$(pwd)\""
|
||||
echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml"
|
||||
|
|
|
@ -42,3 +42,7 @@
|
|||
src: https://git.openstack.org/openstack/openstack-ansible-os_ceilometer
|
||||
scm: git
|
||||
version: master
|
||||
- name: "openstack_hosts"
|
||||
src: "https://github.com/openstack/openstack-ansible-openstack_hosts"
|
||||
scm: git
|
||||
version: "master"
|
||||
|
|
|
@ -13,29 +13,100 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Very basic testing using examples from http://gnocchi.xyz/rest.html
|
||||
|
||||
- name: Playbook for functional testing of gnocchi
|
||||
hosts: gnocchi_all
|
||||
user: root
|
||||
gather_facts: false
|
||||
vars:
|
||||
gnocchi_api: "http://localhost:{{ gnocchi_service_port }}"
|
||||
tasks:
|
||||
- name: Install openstackclient
|
||||
pip:
|
||||
name: "python-openstackclient"
|
||||
|
||||
- name: Check the gnocchi-api
|
||||
uri:
|
||||
url: "http://localhost:{{ gnocchi_service_port }}"
|
||||
url: "{{ gnocchi_api }}"
|
||||
status_code: 200,300
|
||||
- name: Set gnocchi_volume_name fact
|
||||
|
||||
- name: Validate that auth is required
|
||||
uri:
|
||||
url: "{{ gnocchi_api }}/v1/status"
|
||||
status_code: 401
|
||||
|
||||
- name: Get auth token
|
||||
shell: >
|
||||
. /root/openrc && openstack token issue --format yaml | awk '/^id\:/ {print $2}'
|
||||
register: get_keystone_token
|
||||
|
||||
- name: set token
|
||||
set_fact:
|
||||
gnocchi_volume_name: "functional-volume-{{ 100|random }}"
|
||||
- name: Create gnocchi volume
|
||||
shell: |
|
||||
. /root/openrc
|
||||
{{ gnocchi_bin }}/gnocchi create --name {{ gnocchi_volume_name }} 1
|
||||
- name: Verify volume goes active
|
||||
shell: |
|
||||
. /root/openrc
|
||||
{{ gnocchi_bin }}/gnocchi show {{ gnocchi_volume_name }} | grep available
|
||||
register: volume_status
|
||||
until: volume_status|success
|
||||
retries: 5
|
||||
delay: 5
|
||||
keystone_token: "{{ get_keystone_token.stdout }}"
|
||||
|
||||
- name: Create a metric
|
||||
uri:
|
||||
url: "{{ gnocchi_api }}/v1/metric"
|
||||
method: POST
|
||||
body: '{ "archive_policy_name": "high" }'
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
X-Auth-Token: "{{ keystone_token }}"
|
||||
return_content: True
|
||||
status_code: 201
|
||||
register: metric_create
|
||||
|
||||
- debug:
|
||||
var: metric_create
|
||||
|
||||
- name: Add measures
|
||||
uri:
|
||||
url: "{{ gnocchi_api }}/v1/metric/{{ metric_create.json.id }}/measures"
|
||||
method: POST
|
||||
body: '[ { "timestamp": "2014-10-06T14:33:57", "value": 43.1 }, { "timestamp": "2014-10-06T14:34:12", "value": 12 }, { "timestamp": "2014-10-06T14:34:20", "value": 2 } ]'
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
X-Auth-Token: "{{ keystone_token }}"
|
||||
return_content: True
|
||||
status_code: 202
|
||||
|
||||
- name: Retrieve the measures
|
||||
uri:
|
||||
url: "{{ gnocchi_api }}/v1/metric/{{ metric_create.json.id }}/measures?refresh=true"
|
||||
method: GET
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
X-Auth-Token: "{{ keystone_token }}"
|
||||
return_content: True
|
||||
status_code: 200
|
||||
register: measures_retrieval
|
||||
|
||||
- debug:
|
||||
var: measures_retrieval
|
||||
|
||||
- name: Ensure we got some measures back
|
||||
assert:
|
||||
that:
|
||||
- "measures_retrieval.json | length >= 1"
|
||||
|
||||
- name: Retrieve the archive policies
|
||||
uri:
|
||||
url: "{{ gnocchi_api }}/v1/archive_policy"
|
||||
method: GET
|
||||
headers:
|
||||
Content-Type: "application/json"
|
||||
X-Auth-Token: "{{ keystone_token }}"
|
||||
return_content: True
|
||||
status_code: 200
|
||||
register: policies_retrieval
|
||||
|
||||
- debug:
|
||||
var: policies_retrieval
|
||||
|
||||
- name: Ensure we have at least 3 archive policies
|
||||
assert:
|
||||
that:
|
||||
- "policies_retrieval.json | length >= 3"
|
||||
vars_files:
|
||||
- test-vars.yml
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
delegate_to: "{{ groups['galera_all'][0] }}"
|
||||
when: inventory_hostname == groups['gnocchi_all'][0]
|
||||
roles:
|
||||
- role: "{{ rolename | basename }}"
|
||||
- role: "os_gnocchi"
|
||||
vars_files:
|
||||
- playbooks/test-vars.yml
|
||||
- test-vars.yml
|
||||
|
|
|
@ -5,3 +5,6 @@ gnocchi_service_password: "secrete"
|
|||
gnocchi_galera_address: "{{ hostvars[groups['galera_all'][0]]['ansible_host'] }}"
|
||||
gnocchi_use_mod_wsgi: true
|
||||
gnocchi_ssl_external: false
|
||||
gnocchi_service_port: 8041
|
||||
gnocchi_venv_tag: untagged
|
||||
gnocchi_bin: "/openstack/venvs/gnocchi-{{ gnocchi_venv_tag }}/bin"
|
||||
|
|
|
@ -26,5 +26,4 @@
|
|||
- include: test-install-gnocchi.yml
|
||||
|
||||
# Test Gnocchi
|
||||
# coming soon
|
||||
#- include: test-gnocchi-functional.yml
|
||||
- include: test-gnocchi-functional.yml
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -139,7 +139,6 @@ commands =
|
|||
ansible-playbook -i {toxinidir}/tests/inventory \
|
||||
--syntax-check \
|
||||
--list-tasks \
|
||||
-e "rolename={toxinidir}" \
|
||||
{toxinidir}/tests/test.yml
|
||||
|
||||
|
||||
|
@ -185,7 +184,6 @@ setenv =
|
|||
commands =
|
||||
{[testenv:ansible]commands}
|
||||
ansible-playbook -i {toxinidir}/tests/inventory \
|
||||
-e "rolename={toxinidir}" \
|
||||
-e "install_test_packages=True" \
|
||||
{toxinidir}/tests/test.yml -vvvv
|
||||
{[testenv:func_logs]commands}
|
||||
|
|
Loading…
Reference in New Issue