OLD | NEW |
(Empty) | |
| 1 # Copyright (c) 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved |
| 2 # |
| 3 # Permission is hereby granted, free of charge, to any person obtaining a |
| 4 # copy of this software and associated documentation files (the |
| 5 # "Software"), to deal in the Software without restriction, including |
| 6 # without limitation the rights to use, copy, modify, merge, publish, dis- |
| 7 # tribute, sublicense, and/or sell copies of the Software, and to permit |
| 8 # persons to whom the Software is furnished to do so, subject to the fol- |
| 9 # lowing conditions: |
| 10 # |
| 11 # The above copyright notice and this permission notice shall be included |
| 12 # in all copies or substantial portions of the Software. |
| 13 # |
| 14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL- |
| 16 # ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT |
| 17 # SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
| 18 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 20 # IN THE SOFTWARE. |
| 21 # |
| 22 import time |
| 23 from tests.unit import unittest |
| 24 |
| 25 from boto.elasticache import layer1 |
| 26 from boto.exception import BotoServerError |
| 27 |
| 28 |
| 29 class TestElastiCacheConnection(unittest.TestCase): |
| 30 def setUp(self): |
| 31 self.elasticache = layer1.ElastiCacheConnection() |
| 32 |
| 33 def wait_until_cluster_available(self, cluster_id): |
| 34 timeout = time.time() + 600 |
| 35 while time.time() < timeout: |
| 36 response = self.elasticache.describe_cache_clusters(cluster_id) |
| 37 status = response['DescribeCacheClustersResponse']\ |
| 38 ['DescribeCacheClustersResult']\ |
| 39 ['CacheClusters'][0]['CacheClusterStatus'] |
| 40 if status == 'available': |
| 41 break |
| 42 time.sleep(5) |
| 43 else: |
| 44 self.fail('Timeout waiting for cache cluster %r' |
| 45 'to become available.' % cluster_id) |
| 46 |
| 47 def test_create_delete_cache_cluster(self): |
| 48 cluster_id = 'cluster-id2' |
| 49 self.elasticache.create_cache_cluster( |
| 50 cluster_id, 1, 'cache.t1.micro', 'memcached') |
| 51 self.wait_until_cluster_available(cluster_id) |
| 52 |
| 53 self.elasticache.delete_cache_cluster(cluster_id) |
| 54 timeout = time.time() + 600 |
| 55 while time.time() < timeout: |
| 56 try: |
| 57 self.elasticache.describe_cache_clusters(cluster_id) |
| 58 except BotoServerError: |
| 59 break |
| 60 time.sleep(5) |
| 61 else: |
| 62 self.fail('Timeout waiting for cache cluster %s' |
| 63 'to be deleted.' % cluster_id) |
| 64 |
| 65 |
| 66 if __name__ == '__main__': |
| 67 unittest.main() |
OLD | NEW |