From 3d625fe840a3d94fab7709ce675d18b055542a63 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Fri, 24 Sep 2021 17:54:05 -0700 Subject: [PATCH 1/2] Use urljoin to concatenate URLs --- .../perfstress_tests/perf_stress_test.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py b/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py index 87531c43b14b..48eb1290d649 100644 --- a/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py +++ b/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py @@ -6,6 +6,11 @@ import os import aiohttp +try: + from urllib.parse import urljoin +except ImportError: + from urlparse import urljoin + from ._policies import PerfTestProxyPolicy @@ -67,7 +72,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 @@ -91,20 +96,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"] From 7e622987aa46f15ed0ff166962df03ac454e5471 Mon Sep 17 00:00:00 2001 From: Mike Harder Date: Mon, 4 Oct 2021 14:11:01 -0700 Subject: [PATCH 2/2] Remove Python2 import - Perf framework only supports Python3 --- .../src/azure_devtools/perfstress_tests/perf_stress_test.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py b/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py index 48eb1290d649..9aec37ca8954 100644 --- a/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py +++ b/tools/azure-devtools/src/azure_devtools/perfstress_tests/perf_stress_test.py @@ -6,11 +6,7 @@ import os import aiohttp -try: - from urllib.parse import urljoin -except ImportError: - from urlparse import urljoin - +from urllib.parse import urljoin from ._policies import PerfTestProxyPolicy