Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: using default_scheduler_url as a mounting point for not root pat… #3216

Merged
merged 5 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion luigi/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ def _urljoin(base, url):
"""
Join relative URLs to base URLs like urllib.parse.urljoin but support
arbitrary URIs (esp. 'http+unix://').
base part is fixed or mounted point, every url contains full base part.
"""
parsed = urlparse(base)
scheme = parsed.scheme
return urlparse(
urljoin(parsed._replace(scheme='http').geturl(), url)
urljoin(parsed._replace(scheme='http').geturl(), parsed.path + (url if url[0] == '/' else '/' + url))
)._replace(scheme=scheme).geturl()


Expand Down
8 changes: 8 additions & 0 deletions test/rpc_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def testUrlArgumentVariations(self):
s._fetch(suffix, '{}')
fetcher.fetch.assert_called_once_with('http://zorg.com/api/123', '{}', 42)

def testUrlArgumentVariationsNotRoot(self):
for url in ['http://zorg.com/subpath', 'http://zorg.com/subpath/']:
for suffix in ['api/123', '/api/123']:
s = luigi.rpc.RemoteScheduler(url, 42)
with mock.patch.object(s, '_fetcher') as fetcher:
s._fetch(suffix, '{}')
fetcher.fetch.assert_called_once_with('http://zorg.com/subpath/api/123', '{}', 42)

def get_work(self, fetcher_side_effect):
scheduler = luigi.rpc.RemoteScheduler('http://zorg.com', 42)
scheduler._rpc_retry_wait = 1 # shorten wait time to speed up tests
Expand Down