Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KsenijaS committed May 3, 2024
1 parent aa21294 commit 83b7a51
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
17 changes: 12 additions & 5 deletions tests/unittests/sources/azure/test_imds.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ def test_headers_cb(self):
headers = imds.headers_cb(self.default_url)
assert list(headers.keys()) == ["Metadata", "x-ms-client-request-id"]
assert headers.get("Metadata") == "true"
uuid = headers.get("x-ms-client-request-id")
match = re.search(
"^[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-"
"[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}$",
uuid,
)
assert match


class TestFetchMetadataWithApiFallback:
Expand Down Expand Up @@ -179,7 +186,7 @@ def test_basic(
mock.call(
self.default_url,
timeout=self.timeout,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
exception_cb=mock.ANY,
infinite=True,
log_req_resp=True,
Expand Down Expand Up @@ -224,15 +231,15 @@ def test_basic_fallback(
mock.call(
self.default_url,
timeout=self.timeout,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
exception_cb=mock.ANY,
infinite=True,
log_req_resp=True,
),
mock.call(
self.fallback_url,
timeout=self.timeout,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
exception_cb=mock.ANY,
infinite=True,
log_req_resp=True,
Expand Down Expand Up @@ -590,7 +597,7 @@ def test_non_json_repsonse(
mock.call(
self.default_url,
timeout=self.timeout,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
exception_cb=mock.ANY,
infinite=True,
log_req_resp=True,
Expand Down Expand Up @@ -677,7 +684,7 @@ def test_basic(
mock.call(
self.url,
timeout=self.timeout,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
exception_cb=mock.ANY,
infinite=True,
log_req_resp=False,
Expand Down
36 changes: 18 additions & 18 deletions tests/unittests/sources/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -3749,7 +3749,7 @@ def test_no_pps(self):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
timeout=30,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
exception_cb=mock.ANY,
infinite=True,
log_req_resp=True,
Expand Down Expand Up @@ -3828,7 +3828,7 @@ def test_stale_pps(self, pps_type):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand All @@ -3837,7 +3837,7 @@ def test_stale_pps(self, pps_type):
"http://169.254.169.254/metadata/reprovisiondata?"
"api-version=2019-06-01",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
log_req_resp=False,
infinite=True,
timeout=30,
Expand All @@ -3846,7 +3846,7 @@ def test_stale_pps(self, pps_type):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand Down Expand Up @@ -3891,7 +3891,7 @@ def test_running_pps(self):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand All @@ -3900,7 +3900,7 @@ def test_running_pps(self):
"http://169.254.169.254/metadata/reprovisiondata?"
"api-version=2019-06-01",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
log_req_resp=False,
infinite=True,
timeout=30,
Expand All @@ -3909,7 +3909,7 @@ def test_running_pps(self):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand Down Expand Up @@ -4009,7 +4009,7 @@ def test_savable_pps(self):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand All @@ -4018,7 +4018,7 @@ def test_savable_pps(self):
"http://169.254.169.254/metadata/reprovisiondata?"
"api-version=2019-06-01",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
log_req_resp=False,
infinite=True,
timeout=30,
Expand All @@ -4027,7 +4027,7 @@ def test_savable_pps(self):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand Down Expand Up @@ -4167,7 +4167,7 @@ def test_savable_pps_early_unplug(self, fabric_side_effect):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand All @@ -4176,7 +4176,7 @@ def test_savable_pps_early_unplug(self, fabric_side_effect):
"http://169.254.169.254/metadata/reprovisiondata?"
"api-version=2019-06-01",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=False,
timeout=30,
Expand All @@ -4185,7 +4185,7 @@ def test_savable_pps_early_unplug(self, fabric_side_effect):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand Down Expand Up @@ -4279,7 +4279,7 @@ def test_recovery_pps(self, pps_type):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand All @@ -4288,7 +4288,7 @@ def test_recovery_pps(self, pps_type):
"http://169.254.169.254/metadata/reprovisiondata?"
"api-version=2019-06-01",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=False,
timeout=30,
Expand All @@ -4297,7 +4297,7 @@ def test_recovery_pps(self, pps_type):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand Down Expand Up @@ -4405,7 +4405,7 @@ def test_os_disk_pps(self, mock_sleep, subp_side_effect):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
exception_cb=mock.ANY,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
infinite=True,
log_req_resp=True,
timeout=30,
Expand Down Expand Up @@ -4468,7 +4468,7 @@ def test_imds_failure_results_in_provisioning_failure(self):
"http://169.254.169.254/metadata/instance?"
"api-version=2021-08-01&extended=true",
timeout=30,
headers_cb=mock.ANY,
headers_cb=imds.headers_cb,
exception_cb=mock.ANY,
infinite=True,
log_req_resp=True,
Expand Down

0 comments on commit 83b7a51

Please sign in to comment.