Merge lp:~suligap/conn-check/proxy_url-fix into lp:conn-check

Proposed by Przemysław Suliga
Status: Merged
Approved by: Przemysław Suliga
Approved revision: 143
Merged at revision: 143
Proposed branch: lp:~suligap/conn-check/proxy_url-fix
Merge into: lp:conn-check
Diff against target: 92 lines (+54/-1)
4 files modified
CHANGELOG (+7/-0)
conn_check/checks.py (+3/-0)
conn_check/version.txt (+1/-1)
tests.py (+43/-0)
To merge this branch: bzr merge lp:~suligap/conn-check/proxy_url-fix
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini Approve
Review via email: mp+398182@code.launchpad.net

Commit message

Fixed tcp subcheck creation for the http check if proxy_url is set

Description of the change

Fixed handling of the proxy_url http check setting. It now correctly creates its tcp subcheck, pointed at the configured proxy instead of the target url host.

To post a comment you must log in.
Revision history for this message
Maximiliano Bertacchini (maxiberta) wrote :

LGTM!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CHANGELOG'
--- CHANGELOG 2018-06-13 16:39:38 +0000
+++ CHANGELOG 2021-02-17 11:29:08 +0000
@@ -1,6 +1,13 @@
1ChangeLog for conn-check1ChangeLog for conn-check
2========================2========================
33
41.5.2 (TBD)
5------------------
6
7 - Fixed handling of the proxy_url http check setting. It now correctly creates
8 its tcp subcheck, pointed at the configured proxy instead of the target url
9 host.
10
41.5.1 (2018-06-07)111.5.1 (2018-06-07)
5------------------12------------------
613
714
=== modified file 'conn_check/checks.py'
--- conn_check/checks.py 2018-06-04 09:26:14 +0000
+++ conn_check/checks.py 2021-02-17 11:29:08 +0000
@@ -222,6 +222,9 @@
222 timeout = kwargs.get('timeout', None)222 timeout = kwargs.get('timeout', None)
223 expected_code = int(expected_code)223 expected_code = int(expected_code)
224224
225 if proxy_url:
226 proxy_host, proxy_port, _ = extract_host_port(proxy_url)
227
225 if proxy_host:228 if proxy_host:
226 subchecks.append(make_tcp_check(proxy_host, proxy_port,229 subchecks.append(make_tcp_check(proxy_host, proxy_port,
227 timeout=timeout))230 timeout=timeout))
228231
=== modified file 'conn_check/version.txt'
--- conn_check/version.txt 2018-06-13 16:39:38 +0000
+++ conn_check/version.txt 2021-02-17 11:29:08 +0000
@@ -1,1 +1,1 @@
11.5.111.5.2
22
=== modified file 'tests.py'
--- tests.py 2018-06-04 14:15:00 +0000
+++ tests.py 2021-02-17 11:29:08 +0000
@@ -149,6 +149,49 @@
149 self.assertThat(wrapped.subchecks[1],149 self.assertThat(wrapped.subchecks[1],
150 FunctionCheckMatcher('', 'GET https://localhost/'))150 FunctionCheckMatcher('', 'GET https://localhost/'))
151151
152 def test_make_http_check_proxy_url(self):
153 result = make_http_check(
154 'http://localhost/', proxy_url='http://my.proxy:3128/')
155 self.assertIsInstance(result, PrefixCheckWrapper)
156 self.assertEqual(result.prefix, 'http:http://localhost/:')
157 wrapped = result.wrapped
158 self.assertIsInstance(wrapped, MultiCheck)
159 self.assertIs(wrapped.strategy, sequential_strategy)
160 self.assertEqual(len(wrapped.subchecks), 2)
161 self.assertThat(wrapped.subchecks[0],
162 FunctionCheckMatcher('tcp:my.proxy:3128', 'my.proxy:3128'))
163 self.assertThat(wrapped.subchecks[1],
164 FunctionCheckMatcher('', 'GET http://localhost/'))
165
166 def test_make_http_check_proxy_host_port(self):
167 result = make_http_check(
168 'http://localhost/', proxy_host='my.proxy', proxy_port='8080')
169 self.assertIsInstance(result, PrefixCheckWrapper)
170 self.assertEqual(result.prefix, 'http:http://localhost/:')
171 wrapped = result.wrapped
172 self.assertIsInstance(wrapped, MultiCheck)
173 self.assertIs(wrapped.strategy, sequential_strategy)
174 self.assertEqual(len(wrapped.subchecks), 2)
175 self.assertThat(wrapped.subchecks[0],
176 FunctionCheckMatcher('tcp:my.proxy:8080', 'my.proxy:8080'))
177 self.assertThat(wrapped.subchecks[1],
178 FunctionCheckMatcher('', 'GET http://localhost/'))
179
180 def test_make_http_check_proxy_url_overrides_proxy_host_port(self):
181 result = make_http_check(
182 'http://localhost/', proxy_url='http://my.proxy:3128/',
183 proxy_host='host-proxy', proxy_port=8080)
184 self.assertIsInstance(result, PrefixCheckWrapper)
185 self.assertEqual(result.prefix, 'http:http://localhost/:')
186 wrapped = result.wrapped
187 self.assertIsInstance(wrapped, MultiCheck)
188 self.assertIs(wrapped.strategy, sequential_strategy)
189 self.assertEqual(len(wrapped.subchecks), 2)
190 self.assertThat(wrapped.subchecks[0],
191 FunctionCheckMatcher('tcp:my.proxy:3128', 'my.proxy:3128'))
192 self.assertThat(wrapped.subchecks[1],
193 FunctionCheckMatcher('', 'GET http://localhost/'))
194
152 def test_make_amqp_check(self):195 def test_make_amqp_check(self):
153 result = make_amqp_check('localhost', 8080, 'foo',196 result = make_amqp_check('localhost', 8080, 'foo',
154 'bar', use_tls=True, vhost='/')197 'bar', use_tls=True, vhost='/')

Subscribers

People subscribed via source and target branches