azure-cli-dev-tools icon indicating copy to clipboard operation
azure-cli-dev-tools copied to clipboard

assertion failure: management.azure.com != api-dogfood.resources.windows-int.net

Open ctaggart opened this issue 4 years ago • 4 comments

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?

ctaggart avatar Jun 09 '20 19:06 ctaggart

Have you ran tests in live mode and playback again?

haroldrandom avatar Jun 11 '20 09:06 haroldrandom

@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.

ctaggart avatar Jun 15 '20 15:06 ctaggart

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.

ctaggart avatar Jun 15 '20 16:06 ctaggart

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()

ctaggart avatar Jun 15 '20 18:06 ctaggart