Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: third_party/boto/tests/integration/route53/test_health_check.py

Issue 698893003: Update checked in version of gsutil to version 4.6 (Closed) Base URL: http://dart.googlecode.com/svn/third_party/gsutil/
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 # Copyright (c) 2014 Tellybug, Matt Millar
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
23 from tests.integration.route53 import Route53TestCase
24
25 from boto.route53.healthcheck import HealthCheck
26 from boto.route53.record import ResourceRecordSets
27
28 class TestRoute53HealthCheck(Route53TestCase):
29 def test_create_health_check(self):
30 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTP", resour ce_path="/testing")
31 result = self.conn.create_health_check(hc)
32 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Type'], 'HTTP')
33 self.assertEquals(result[u'CreateHealthCheckResponse'][
34 u'HealthCheck'][u'HealthCheckConfig'][u'IPAddress'], ' 54.217.7.118')
35 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Port'], '80')
36 self.assertEquals(result[u'CreateHealthCheckResponse'][
37 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'] , '/testing')
38 self.conn.delete_health_check(result['CreateHealthCheckResponse']['Healt hCheck']['Id'])
39
40 def test_create_https_health_check(self):
41 hc = HealthCheck(ip_addr="54.217.7.118", port=443, hc_type="HTTPS", reso urce_path="/testing")
42 result = self.conn.create_health_check(hc)
43 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Type'], 'HTTPS')
44 self.assertEquals(result[u'CreateHealthCheckResponse'][
45 u'HealthCheck'][u'HealthCheckConfig'][u'IPAddress'], ' 54.217.7.118')
46 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Port'], '443')
47 self.assertEquals(result[u'CreateHealthCheckResponse'][
48 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'] , '/testing')
49 self.assertFalse('FullyQualifiedDomainName' in result[u'CreateHealthChec kResponse'][u'HealthCheck'][u'HealthCheckConfig'])
50 self.conn.delete_health_check(result['CreateHealthCheckResponse']['Healt hCheck']['Id'])
51
52 def test_create_https_health_check_fqdn(self):
53 hc = HealthCheck(ip_addr=None, port=443, hc_type="HTTPS", resource_path= "/", fqdn="google.com")
54 result = self.conn.create_health_check(hc)
55 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Type'], 'HTTPS')
56 self.assertEquals(result[u'CreateHealthCheckResponse'][
57 u'HealthCheck'][u'HealthCheckConfig'][u'FullyQualified DomainName'], 'google.com')
58 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Port'], '443')
59 self.assertEquals(result[u'CreateHealthCheckResponse'][
60 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'] , '/')
61 self.assertFalse('IPAddress' in result[u'CreateHealthCheckResponse'][u'H ealthCheck'][u'HealthCheckConfig'])
62 self.conn.delete_health_check(result['CreateHealthCheckResponse']['Healt hCheck']['Id'])
63
64 def test_create_and_list_health_check(self):
65 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTP", resour ce_path="/testing")
66 result1 = self.conn.create_health_check(hc)
67 hc = HealthCheck(ip_addr="54.217.7.119", port=80, hc_type="HTTP", resour ce_path="/testing")
68 result2 = self.conn.create_health_check(hc)
69 result = self.conn.get_list_health_checks()
70 self.assertTrue(len(result['ListHealthChecksResponse']['HealthChecks']) > 1)
71 self.conn.delete_health_check(result1['CreateHealthCheckResponse']['Heal thCheck']['Id'])
72 self.conn.delete_health_check(result2['CreateHealthCheckResponse']['Heal thCheck']['Id'])
73
74 def test_delete_health_check(self):
75 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTP", resour ce_path="/testing")
76 result = self.conn.create_health_check(hc)
77 hc_id = result['CreateHealthCheckResponse']['HealthCheck']['Id']
78 result = self.conn.get_list_health_checks()
79 found = False
80 for hc in result['ListHealthChecksResponse']['HealthChecks']:
81 if hc['Id'] == hc_id:
82 found = True
83 break
84 self.assertTrue(found)
85 result = self.conn.delete_health_check(hc_id)
86 result = self.conn.get_list_health_checks()
87 for hc in result['ListHealthChecksResponse']['HealthChecks']:
88 self.assertFalse(hc['Id'] == hc_id)
89
90 def test_create_health_check_string_match(self):
91 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTP_STR_MATC H", resource_path="/testing", string_match="test")
92 result = self.conn.create_health_check(hc)
93 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Type'], 'HTTP_STR_MATCH')
94 self.assertEquals(result[u'CreateHealthCheckResponse'][
95 u'HealthCheck'][u'HealthCheckConfig'][u'IPAddress'], ' 54.217.7.118')
96 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Port'], '80')
97 self.assertEquals(result[u'CreateHealthCheckResponse'][
98 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'] , '/testing')
99 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'SearchString'], 'test')
100 self.conn.delete_health_check(result['CreateHealthCheckResponse']['Healt hCheck']['Id'])
101
102 def test_create_health_check_https_string_match(self):
103 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTPS_STR_MAT CH", resource_path="/testing", string_match="test")
104 result = self.conn.create_health_check(hc)
105 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Type'], 'HTTPS_STR_MATCH')
106 self.assertEquals(result[u'CreateHealthCheckResponse'][
107 u'HealthCheck'][u'HealthCheckConfig'][u'IPAddress'], ' 54.217.7.118')
108 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'Port'], '80')
109 self.assertEquals(result[u'CreateHealthCheckResponse'][
110 u'HealthCheck'][u'HealthCheckConfig'][u'ResourcePath'] , '/testing')
111 self.assertEquals(result[u'CreateHealthCheckResponse'][u'HealthCheck'][u 'HealthCheckConfig'][u'SearchString'], 'test')
112 self.conn.delete_health_check(result['CreateHealthCheckResponse']['Healt hCheck']['Id'])
113
114 def test_create_resource_record_set(self):
115 hc = HealthCheck(ip_addr="54.217.7.118", port=80, hc_type="HTTP", resour ce_path="/testing")
116 result = self.conn.create_health_check(hc)
117 records = ResourceRecordSets(
118 connection=self.conn, hosted_zone_id=self.zone.id, comment='Create D NS entry for test')
119 change = records.add_change('CREATE', 'unittest.%s.' % self.base_domain, 'A', ttl=30, identifier='test',
120 weight=1, health_check=result['CreateHealthC heckResponse']['HealthCheck']['Id'])
121 change.add_value("54.217.7.118")
122 records.commit()
123
124 records = ResourceRecordSets(self.conn, self.zone.id)
125 deleted = records.add_change('DELETE', "unittest.%s." % self.base_domain , "A", ttl=30, identifier='test',
126 weight=1, health_check=result['CreateHealthC heckResponse']['HealthCheck']['Id'])
127 deleted.add_value('54.217.7.118')
128 records.commit()
129
130 def test_create_health_check_invalid_request_interval(self):
131 """Test that health checks cannot be created with an invalid
132 'request_interval'.
133
134 """
135 with self.assertRaises(AttributeError):
136 HealthCheck(**self.health_check_params(request_interval=5))
137
138 def test_create_health_check_invalid_failure_threshold(self):
139 """
140 Test that health checks cannot be created with an invalid
141 'failure_threshold'.
142 """
143 with self.assertRaises(AttributeError):
144 HealthCheck(**self.health_check_params(failure_threshold=0))
145 with self.assertRaises(AttributeError):
146 HealthCheck(**self.health_check_params(failure_threshold=11))
147
148 def test_create_health_check_request_interval(self):
149 hc_params = self.health_check_params(request_interval=10)
150 hc = HealthCheck(**hc_params)
151 result = self.conn.create_health_check(hc)
152 hc_config = (result[u'CreateHealthCheckResponse']
153 [u'HealthCheck'][u'HealthCheckConfig'])
154 self.assertEquals(hc_config[u'RequestInterval'],
155 unicode(hc_params['request_interval']))
156 self.conn.delete_health_check(result['CreateHealthCheckResponse']['Healt hCheck']['Id'])
157
158 def test_create_health_check_failure_threshold(self):
159 hc_params = self.health_check_params(failure_threshold=1)
160 hc = HealthCheck(**hc_params)
161 result = self.conn.create_health_check(hc)
162 hc_config = (result[u'CreateHealthCheckResponse']
163 [u'HealthCheck'][u'HealthCheckConfig'])
164 self.assertEquals(hc_config[u'FailureThreshold'],
165 unicode(hc_params['failure_threshold']))
166 self.conn.delete_health_check(result['CreateHealthCheckResponse']['Healt hCheck']['Id'])
167
168 def health_check_params(self, **kwargs):
169 params = {
170 'ip_addr': "54.217.7.118",
171 'port': 80,
172 'hc_type': 'HTTP',
173 'resource_path': '/testing',
174 }
175 params.update(kwargs)
176 return params
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698