Mehdi Abaakouk | 8008151 | 2015-07-29 19:03:26 +0200 | [diff] [blame] | 1 | defaults: |
| 2 | request_headers: |
| 3 | x-auth-token: $ENVIRON['ADMIN_TOKEN'] |
| 4 | |
| 5 | tests: |
| 6 | - name: list alarms none |
| 7 | desc: Lists alarms, none yet exist |
| 8 | url: $ENVIRON['AODH_SERVICE_URL']/v2/alarms |
| 9 | method: GET |
| 10 | response_strings: |
| 11 | - "[]" |
| 12 | |
| 13 | - name: list servers none |
| 14 | desc: List servers, none yet exists |
| 15 | url: $ENVIRON['NOVA_SERVICE_URL']/servers |
| 16 | method: GET |
| 17 | response_strings: |
| 18 | - "[]" |
| 19 | |
| 20 | - name: create stack |
| 21 | desc: Create an autoscaling stack |
| 22 | url: $ENVIRON['HEAT_SERVICE_URL']/stacks |
| 23 | method: POST |
| 24 | request_headers: |
| 25 | content-type: application/json |
| 26 | data: |
| 27 | stack_name: integration_test |
| 28 | template: |
| 29 | heat_template_version: "2013-05-23" |
| 30 | description: Integration Test AutoScaling with heat+ceilometer+gnocchi+aodh |
| 31 | resources: |
| 32 | asg: |
| 33 | type: OS::Heat::AutoScalingGroup |
| 34 | properties: |
| 35 | min_size: 1 |
| 36 | max_size: 3 |
| 37 | resource: |
| 38 | type: OS::Nova::Server |
| 39 | properties: |
| 40 | networks: |
| 41 | - network: "private" |
| 42 | flavor: m1.tiny |
| 43 | image: $ENVIRON['GLANCE_IMAGE_NAME'] |
| 44 | metadata: |
| 45 | "metering.server_group": {get_param: "OS::stack_id"} |
| 46 | user_data_format: RAW |
| 47 | user_data: | |
| 48 | #!/bin/sh |
| 49 | echo "Loading CPU" |
| 50 | set -v |
| 51 | cat /dev/urandom > /dev/null |
| 52 | web_server_scaleup_policy: |
| 53 | type: OS::Heat::ScalingPolicy |
| 54 | properties: |
| 55 | adjustment_type: change_in_capacity |
| 56 | auto_scaling_group_id: {get_resource: asg} |
| 57 | cooldown: 2 |
| 58 | scaling_adjustment: 1 |
| 59 | cpu_alarm_high: |
| 60 | type: OS::Ceilometer::GnocchiAggregationByResourcesAlarm |
| 61 | properties: |
| 62 | description: Scale-up if the mean CPU > 10% on 1 minute |
| 63 | metric: cpu_util |
| 64 | aggregation_method: mean |
| 65 | granularity: 60.0 |
| 66 | evaluation_periods: 1 |
| 67 | threshold: 10 |
| 68 | comparison_operator: gt |
| 69 | alarm_actions: |
| 70 | - {get_attr: [web_server_scaleup_policy, alarm_url]} |
| 71 | resource_type: instance |
| 72 | query: |
| 73 | str_replace: |
| 74 | template: '{"=": {"server_group": "stack_id"}}' |
| 75 | params: |
| 76 | stack_id: {get_param: "OS::stack_id"} |
| 77 | # TODO(sileht): create some other kind of kind alarm just to ensure |
| 78 | # heat and aodh API are in sync |
| 79 | status: 201 |
| 80 | |
| 81 | - name: waiting for stack creation |
| 82 | desc: Wait for the second event on the stack resource, it can be a success or failure |
| 83 | url: $ENVIRON['HEAT_SERVICE_URL']/stacks/integration_test/events?resource_name=integration_test |
| 84 | redirects: true |
| 85 | method: GET |
| 86 | status: 200 |
| 87 | poll: |
| 88 | count: 300 |
| 89 | delay: 1 |
| 90 | response_json_paths: |
| 91 | $.events[1].resource_name: integration_test |
| 92 | |
| 93 | - name: control stack status |
| 94 | desc: Checks the stack have been created successfully |
| 95 | url: $ENVIRON['HEAT_SERVICE_URL']/stacks/integration_test |
| 96 | redirects: true |
| 97 | method: GET |
| 98 | status: 200 |
Mehdi Abaakouk | 383becb | 2015-08-21 08:16:29 +0000 | [diff] [blame] | 99 | poll: |
| 100 | count: 5 |
| 101 | delay: 1 |
Mehdi Abaakouk | 8008151 | 2015-07-29 19:03:26 +0200 | [diff] [blame] | 102 | response_json_paths: |
| 103 | $.stack.stack_status: "CREATE_COMPLETE" |
| 104 | |
| 105 | - name: list servers |
| 106 | desc: Wait the autoscaling stack grow to three servers |
| 107 | url: $ENVIRON['NOVA_SERVICE_URL']/servers/detail |
| 108 | method: GET |
| 109 | poll: |
Mehdi Abaakouk | 383becb | 2015-08-21 08:16:29 +0000 | [diff] [blame] | 110 | count: 600 |
Mehdi Abaakouk | 8008151 | 2015-07-29 19:03:26 +0200 | [diff] [blame] | 111 | delay: 1 |
| 112 | response_json_paths: |
| 113 | $.servers[0].metadata.'metering.server_group': $RESPONSE['$.stack.id'] |
| 114 | $.servers[1].metadata.'metering.server_group': $RESPONSE['$.stack.id'] |
| 115 | $.servers[2].metadata.'metering.server_group': $RESPONSE['$.stack.id'] |
| 116 | $.servers[0].status: ACTIVE |
| 117 | $.servers[1].status: ACTIVE |
| 118 | $.servers[2].status: ACTIVE |
| 119 | |
| 120 | - name: check gnocchi resources |
| 121 | desc: Check the gnocchi resources for this three servers exists |
| 122 | url: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/resource/instance |
| 123 | method: GET |
Mehdi Abaakouk | 383becb | 2015-08-21 08:16:29 +0000 | [diff] [blame] | 124 | poll: |
| 125 | count: 30 |
| 126 | delay: 1 |
Mehdi Abaakouk | 8008151 | 2015-07-29 19:03:26 +0200 | [diff] [blame] | 127 | response_strings: |
| 128 | - '"id": "$RESPONSE["$.servers[0].id"]"' |
| 129 | - '"id": "$RESPONSE["$.servers[1].id"]"' |
| 130 | - '"id": "$RESPONSE["$.servers[2].id"]"' |
| 131 | |
| 132 | - name: check alarm |
| 133 | desc: Check the aodh alarm and its state |
| 134 | url: $ENVIRON['AODH_SERVICE_URL']/v2/alarms |
| 135 | method: GET |
| 136 | response_strings: |
| 137 | - "integration_test-cpu_alarm_high-" |
| 138 | response_json_paths: |
| 139 | $[0].state: alarm |
| 140 | |
| 141 | - name: get stack location |
| 142 | desc: Get the stack location |
| 143 | url: $ENVIRON['HEAT_SERVICE_URL']/stacks/integration_test |
| 144 | method: GET |
| 145 | status: 302 |
| 146 | |
| 147 | - name: delete stack |
| 148 | desc: Delete the stack |
| 149 | url: $LOCATION |
| 150 | method: DELETE |
| 151 | status: 204 |
| 152 | |
| 153 | - name: get deleted stack |
| 154 | desc: Check the stack have been deleted |
| 155 | url: $ENVIRON['HEAT_SERVICE_URL']/stacks/integration_test |
| 156 | redirects: true |
| 157 | method: GET |
| 158 | poll: |
| 159 | count: 240 |
| 160 | delay: 1 |
| 161 | status: 404 |
| 162 | |
| 163 | - name: list alarms deleted |
| 164 | desc: List alarms, no more exist |
| 165 | url: $ENVIRON['AODH_SERVICE_URL']/v2/alarms |
| 166 | method: GET |
| 167 | response_strings: |
| 168 | - "[]" |
| 169 | |
| 170 | - name: list servers deleted |
| 171 | desc: List servers, no more exists |
| 172 | url: $ENVIRON['NOVA_SERVICE_URL']/servers |
| 173 | method: GET |
| 174 | response_strings: |
| 175 | - "[]" |