115 lines
3.5 KiB
YAML
115 lines
3.5 KiB
YAML
---
|
|
# Copyright 2015, 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.
|
|
|
|
# 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"
|
|
extra_args: >-
|
|
{{ gnocchi_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }}
|
|
{{ pip_install_options | default('') }}
|
|
|
|
- name: Check the gnocchi-api
|
|
uri:
|
|
url: "{{ gnocchi_api }}"
|
|
status_code: 200,300
|
|
|
|
- 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
|
|
changed_when: false
|
|
|
|
- name: set token
|
|
set_fact:
|
|
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"
|