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
1=== modified file 'CHANGELOG'
2--- CHANGELOG 2018-06-13 16:39:38 +0000
3+++ CHANGELOG 2021-02-17 11:29:08 +0000
4@@ -1,6 +1,13 @@
5 ChangeLog for conn-check
6 ========================
7
8+1.5.2 (TBD)
9+------------------
10+
11+ - Fixed handling of the proxy_url http check setting. It now correctly creates
12+ its tcp subcheck, pointed at the configured proxy instead of the target url
13+ host.
14+
15 1.5.1 (2018-06-07)
16 ------------------
17
18
19=== modified file 'conn_check/checks.py'
20--- conn_check/checks.py 2018-06-04 09:26:14 +0000
21+++ conn_check/checks.py 2021-02-17 11:29:08 +0000
22@@ -222,6 +222,9 @@
23 timeout = kwargs.get('timeout', None)
24 expected_code = int(expected_code)
25
26+ if proxy_url:
27+ proxy_host, proxy_port, _ = extract_host_port(proxy_url)
28+
29 if proxy_host:
30 subchecks.append(make_tcp_check(proxy_host, proxy_port,
31 timeout=timeout))
32
33=== modified file 'conn_check/version.txt'
34--- conn_check/version.txt 2018-06-13 16:39:38 +0000
35+++ conn_check/version.txt 2021-02-17 11:29:08 +0000
36@@ -1,1 +1,1 @@
37-1.5.1
38+1.5.2
39
40=== modified file 'tests.py'
41--- tests.py 2018-06-04 14:15:00 +0000
42+++ tests.py 2021-02-17 11:29:08 +0000
43@@ -149,6 +149,49 @@
44 self.assertThat(wrapped.subchecks[1],
45 FunctionCheckMatcher('', 'GET https://localhost/'))
46
47+ def test_make_http_check_proxy_url(self):
48+ result = make_http_check(
49+ 'http://localhost/', proxy_url='http://my.proxy:3128/')
50+ self.assertIsInstance(result, PrefixCheckWrapper)
51+ self.assertEqual(result.prefix, 'http:http://localhost/:')
52+ wrapped = result.wrapped
53+ self.assertIsInstance(wrapped, MultiCheck)
54+ self.assertIs(wrapped.strategy, sequential_strategy)
55+ self.assertEqual(len(wrapped.subchecks), 2)
56+ self.assertThat(wrapped.subchecks[0],
57+ FunctionCheckMatcher('tcp:my.proxy:3128', 'my.proxy:3128'))
58+ self.assertThat(wrapped.subchecks[1],
59+ FunctionCheckMatcher('', 'GET http://localhost/'))
60+
61+ def test_make_http_check_proxy_host_port(self):
62+ result = make_http_check(
63+ 'http://localhost/', proxy_host='my.proxy', proxy_port='8080')
64+ self.assertIsInstance(result, PrefixCheckWrapper)
65+ self.assertEqual(result.prefix, 'http:http://localhost/:')
66+ wrapped = result.wrapped
67+ self.assertIsInstance(wrapped, MultiCheck)
68+ self.assertIs(wrapped.strategy, sequential_strategy)
69+ self.assertEqual(len(wrapped.subchecks), 2)
70+ self.assertThat(wrapped.subchecks[0],
71+ FunctionCheckMatcher('tcp:my.proxy:8080', 'my.proxy:8080'))
72+ self.assertThat(wrapped.subchecks[1],
73+ FunctionCheckMatcher('', 'GET http://localhost/'))
74+
75+ def test_make_http_check_proxy_url_overrides_proxy_host_port(self):
76+ result = make_http_check(
77+ 'http://localhost/', proxy_url='http://my.proxy:3128/',
78+ proxy_host='host-proxy', proxy_port=8080)
79+ self.assertIsInstance(result, PrefixCheckWrapper)
80+ self.assertEqual(result.prefix, 'http:http://localhost/:')
81+ wrapped = result.wrapped
82+ self.assertIsInstance(wrapped, MultiCheck)
83+ self.assertIs(wrapped.strategy, sequential_strategy)
84+ self.assertEqual(len(wrapped.subchecks), 2)
85+ self.assertThat(wrapped.subchecks[0],
86+ FunctionCheckMatcher('tcp:my.proxy:3128', 'my.proxy:3128'))
87+ self.assertThat(wrapped.subchecks[1],
88+ FunctionCheckMatcher('', 'GET http://localhost/'))
89+
90 def test_make_amqp_check(self):
91 result = make_amqp_check('localhost', 8080, 'foo',
92 'bar', use_tls=True, vhost='/')

Subscribers

People subscribed via source and target branches