azure-cli-dev-tools
azure-cli-dev-tools copied to clipboard
assertion failure: management.azure.com != api-dogfood.resources.windows-int.net
I'm recording tests against another a test Azure Cloud instance. When I try to playback the tests, I get host assertion failures like:
E 1 - (<Request (GET) https://api-dogfood.resources.windows-int.net/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmware000001/providers/Microsoft.AVS/privateClouds/cloud1?api-version=2019-08-09-preview>).
E Matchers succeeded : ['method', 'scheme', 'port', 'path', '_custom_request_query_matcher']
E Matchers failed :
E host - assertion failure :
E management.azure.com != api-dogfood.resources.windows-int.net
See them here. They are from this pull request: https://github.com/Azure/az-vmware-cli/pull/42 .
How do I disable the host assertion?
Have you ran tests in live mode and playback again?
@haroldrandom Yes, I ran it in live mode and the tests pass after about 10 minutes with azdev test VmwareScenarioTest --live
. I then run azdev test VmwareScenarioTest
and I get that error locally as well in CI for https://github.com/Azure/az-vmware-cli/pull/31.
I dug into this a bit. The scenario base tests use vcr. There is a host matcher, but I'm not sure how to disable it. The configuration of VCR looks to be done in base.py here.
I made this workaround:
class VmwareScenarioTest(ScenarioTest):
def setUp(self):
# https://vcrpy.readthedocs.io/en/latest/configuration.html#request-matching
self.vcr.match_on=['scheme', 'method', 'path', 'query'] # not 'host', 'port'
super(VmwareScenarioTest, self).setUp()