~ubuntu-branches/ubuntu/wily/heat/wily

« back to all changes in this revision

Viewing changes to heat/tests/autoscaling/test_heat_scaling_policy.py

  • Committer: Package Import Robot
  • Author(s): Corey Bryant
  • Date: 2015-08-19 08:11:50 UTC
  • mfrom: (1.1.27)
  • Revision ID: package-import@ubuntu.com-20150819081150-m969fd35xn8bdmfu
Tags: 1:5.0.0~b2-0ubuntu1
* New upstream milestone for OpenStack Liberty.
* d/control: Align (build-)depends with upstream.
* d/p/fix-requirements.patch: Dropped. No longer needed.
* d/p/fixup-assert-regex.patch: Rebased.
* d/rules: Remove .eggs directory in override_dh_auto_clean.

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
        self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
131
131
        return rsrc
132
132
 
133
 
    def test_is_in_progress(self):
 
133
    def test_cooldown_is_in_progress_toosoon(self):
134
134
        t = template_format.parse(as_template)
135
135
        stack = utils.parse_stack(t, params=as_params)
136
136
        pol = self.create_scaling_policy(t, stack, 'my-policy')
137
137
 
138
138
        now = timeutils.utcnow()
139
 
        previous_meta = {now.isoformat(): 'ChangeInCapacity : 1'}
140
 
        self.patchobject(pol, 'metadata_get', return_value=previous_meta)
141
 
        self.assertTrue(pol._cooldown_inprogress())
142
 
 
143
 
    def test_not_in_progress(self):
 
139
        previous_meta = {'cooldown': {
 
140
            now.isoformat(): 'ChangeInCapacity : 1'}}
 
141
        self.patchobject(pol, 'metadata_get', return_value=previous_meta)
 
142
        self.assertTrue(pol._cooldown_inprogress())
 
143
 
 
144
    def test_cooldown_is_in_progress_scaling_unfinished(self):
 
145
        t = template_format.parse(as_template)
 
146
        stack = utils.parse_stack(t, params=as_params)
 
147
        pol = self.create_scaling_policy(t, stack, 'my-policy')
 
148
 
 
149
        previous_meta = {'scaling_in_progress': True}
 
150
        self.patchobject(pol, 'metadata_get', return_value=previous_meta)
 
151
        self.assertTrue(pol._cooldown_inprogress())
 
152
 
 
153
    def test_cooldown_not_in_progress(self):
144
154
        t = template_format.parse(as_template)
145
155
        stack = utils.parse_stack(t, params=as_params)
146
156
        pol = self.create_scaling_policy(t, stack, 'my-policy')
147
157
 
148
158
        awhile_ago = timeutils.utcnow() - datetime.timedelta(seconds=100)
149
 
        previous_meta = {awhile_ago.isoformat(): 'ChangeInCapacity : 1'}
 
159
        previous_meta = {
 
160
            'cooldown': {
 
161
                awhile_ago.isoformat(): 'ChangeInCapacity : 1'
 
162
            },
 
163
            'scaling_in_progress': False
 
164
        }
150
165
        self.patchobject(pol, 'metadata_get', return_value=previous_meta)
151
166
        self.assertFalse(pol._cooldown_inprogress())
152
167
 
161
176
        pol = self.create_scaling_policy(t, stack, 'my-policy')
162
177
 
163
178
        now = timeutils.utcnow()
164
 
        previous_meta = {now.isoformat(): 'ChangeInCapacity : 1'}
 
179
        previous_meta = {'cooldown': {
 
180
            now.isoformat(): 'ChangeInCapacity : 1'}}
165
181
        self.patchobject(pol, 'metadata_get', return_value=previous_meta)
166
182
        self.assertFalse(pol._cooldown_inprogress())
167
183
 
177
193
        pol = self.create_scaling_policy(t, stack, 'my-policy')
178
194
 
179
195
        now = timeutils.utcnow()
180
 
        previous_meta = {now.isoformat(): 'ChangeInCapacity : 1'}
 
196
        previous_meta = {'cooldown': {
 
197
            now.isoformat(): 'ChangeInCapacity : 1'}}
181
198
        self.patchobject(pol, 'metadata_get', return_value=previous_meta)
182
199
        self.assertFalse(pol._cooldown_inprogress())
183
200
 
191
208
        meta_set = self.patchobject(pol, 'metadata_set')
192
209
        self.patchobject(timeutils, 'utcnow', return_value=nowish)
193
210
        pol._cooldown_timestamp(reason)
194
 
        meta_set.assert_called_once_with({nowish.isoformat(): reason})
 
211
        meta_set.assert_called_once_with(
 
212
            {'cooldown': {nowish.isoformat(): reason},
 
213
             'scaling_in_progress': False})
195
214
 
196
215
 
197
216
class ScalingPolicyAttrTest(common.HeatTestCase):