Skip to content

Commit

Permalink
[Perf Framework] Use urljoin to concatenate URLs (#20899)
Browse files Browse the repository at this point in the history
- Existing code fails if `test_proxy` option ends with `/`
  • Loading branch information
mikeharder authored Oct 4, 2021
1 parent 2e111fa commit aeacef5
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import aiohttp

from urllib.parse import urljoin
from ._policies import PerfTestProxyPolicy


Expand Down Expand Up @@ -67,7 +68,7 @@ async def stop_playback(self):
"x-recording-id": self._recording_id,
"x-purge-inmemory-recording": "true"
}
url = self.args.test_proxy + "/playback/stop"
url = urljoin(self.args.test_proxy, "/playback/stop")
async with self._session.post(url, headers=headers) as resp:
assert resp.status == 200

Expand All @@ -91,20 +92,20 @@ async def run_async(self):
raise Exception("run_async must be implemented for {}".format(self.__class__.__name__))

async def _start_recording(self):
url = self.args.test_proxy + "/record/start"
url = urljoin(self.args.test_proxy, "/record/start")
async with self._session.post(url) as resp:
assert resp.status == 200
self._recording_id = resp.headers["x-recording-id"]

async def _stop_recording(self):
headers = {"x-recording-id": self._recording_id}
url = self.args.test_proxy + "/record/stop"
url = urljoin(self.args.test_proxy, "/record/stop")
async with self._session.post(url, headers=headers) as resp:
assert resp.status == 200

async def _start_playback(self):
headers = {"x-recording-id": self._recording_id}
url = self.args.test_proxy + "/playback/start"
url = urljoin(self.args.test_proxy, "/playback/start")
async with self._session.post(url, headers=headers) as resp:
assert resp.status == 200
self._recording_id = resp.headers["x-recording-id"]
Expand Down

0 comments on commit aeacef5

Please sign in to comment.