| OLD | NEW |
| (Empty) |
| 1 # Copyright (c) 2011 Reza Lotun http://reza.lotun.name | |
| 2 # All rights reserved. | |
| 3 # | |
| 4 # Permission is hereby granted, free of charge, to any person obtaining a | |
| 5 # copy of this software and associated documentation files (the | |
| 6 # "Software"), to deal in the Software without restriction, including | |
| 7 # without limitation the rights to use, copy, modify, merge, publish, dis- | |
| 8 # tribute, sublicense, and/or sell copies of the Software, and to permit | |
| 9 # persons to whom the Software is furnished to do so, subject to the fol- | |
| 10 # lowing conditions: | |
| 11 # | |
| 12 # The above copyright notice and this permission notice shall be included | |
| 13 # in all copies or substantial portions of the Software. | |
| 14 # | |
| 15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
| 16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- | |
| 17 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT | |
| 18 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |
| 19 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| 20 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |
| 21 # IN THE SOFTWARE. | |
| 22 | |
| 23 """ | |
| 24 Some unit tests for the AutoscaleConnection | |
| 25 """ | |
| 26 | |
| 27 import unittest | |
| 28 import time | |
| 29 from boto.ec2.autoscale import AutoScaleConnection | |
| 30 from boto.ec2.autoscale.activity import Activity | |
| 31 from boto.ec2.autoscale.group import AutoScalingGroup, ProcessType | |
| 32 from boto.ec2.autoscale.launchconfig import LaunchConfiguration | |
| 33 from boto.ec2.autoscale.policy import AdjustmentType, MetricCollectionTypes, Sca
lingPolicy | |
| 34 from boto.ec2.autoscale.scheduled import ScheduledUpdateGroupAction | |
| 35 from boto.ec2.autoscale.instance import Instance | |
| 36 | |
| 37 class AutoscaleConnectionTest(unittest.TestCase): | |
| 38 | |
| 39 def test_basic(self): | |
| 40 # NB: as it says on the tin these are really basic tests that only | |
| 41 # (lightly) exercise read-only behaviour - and that's only if you | |
| 42 # have any autoscale groups to introspect. It's useful, however, to | |
| 43 # catch simple errors | |
| 44 | |
| 45 print '--- running %s tests ---' % self.__class__.__name__ | |
| 46 c = AutoScaleConnection() | |
| 47 | |
| 48 self.assertTrue(repr(c).startswith('AutoScaleConnection')) | |
| 49 | |
| 50 groups = c.get_all_groups() | |
| 51 for group in groups: | |
| 52 self.assertTrue(type(group), AutoScalingGroup) | |
| 53 | |
| 54 # get activities | |
| 55 activities = group.get_activities() | |
| 56 | |
| 57 for activity in activities: | |
| 58 self.assertEqual(type(activity), Activity) | |
| 59 | |
| 60 # get launch configs | |
| 61 configs = c.get_all_launch_configurations() | |
| 62 for config in configs: | |
| 63 self.assertTrue(type(config), LaunchConfiguration) | |
| 64 | |
| 65 # get policies | |
| 66 policies = c.get_all_policies() | |
| 67 for policy in policies: | |
| 68 self.assertTrue(type(policy), ScalingPolicy) | |
| 69 | |
| 70 # get scheduled actions | |
| 71 actions = c.get_all_scheduled_actions() | |
| 72 for action in actions: | |
| 73 self.assertTrue(type(action), ScheduledUpdateGroupAction) | |
| 74 | |
| 75 # get instances | |
| 76 instances = c.get_all_autoscaling_instances() | |
| 77 for instance in instances: | |
| 78 self.assertTrue(type(instance), Instance) | |
| 79 | |
| 80 # get all scaling process types | |
| 81 ptypes = c.get_all_scaling_process_types() | |
| 82 for ptype in ptypes: | |
| 83 self.assertTrue(type(ptype), ProcessType) | |
| 84 | |
| 85 # get adjustment types | |
| 86 adjustments = c.get_all_adjustment_types() | |
| 87 for adjustment in adjustments: | |
| 88 self.assertTrue(type(adjustment), AdjustmentType) | |
| 89 | |
| 90 # get metrics collection types | |
| 91 types = c.get_all_metric_collection_types() | |
| 92 self.assertTrue(type(types), MetricCollectionTypes) | |
| 93 | |
| 94 print '--- tests completed ---' | |
| 95 | |
| OLD | NEW |