Skip to content

[TestProxy] Run test with testproxy for mgmt SDK

Jiefeng Chen edited this page Feb 24, 2022 · 13 revisions

Getting Started - Run test with testproxy for mgmt SDK

Prerequisites

  • Python 3.7 or later is required

  • Docker

  • create virtual environment

    python -m venv venv
    .\venv-dev\Scripts\Activate.ps1
    
  • prepare SDK repo if needed

    git clone https://github.com/Azure/azure-sdk-for-python.git
    
  • prepare TestProxy if needed. (more details)

    Run the following command to download and run the docker image with Testproxy.

    .\eng\common\testproxy\docker-start-proxy.ps1 "start"
    

How to Run Test

  • Setting environment variables

    run following command

    set AZURE_TENANT_ID="xxxxxxxxxxxxxxxx"
    set AZURE_CLIENT_ID="xxxxxxxxxxxxxxxx"
    set AZURE_CLIENT_SECRET="xxxxxxxxxxxxxxxx"
    set AZURE_SUBSCRIPTION_ID="xxxxxxxxxxxxxxxx"
    
  • Setting the necessary configuration

    1. Copy mgmt_settings_real_.py tools\azure-sdk-tools\devtools_testutils and name it mgmt_settings_real.py

    2. Change the SUBSCRIPTION_ID, CLIENT_ID, CLIENT_SECRET, TENANT_ID variables on lines 13 to 18 of this file.

  • Preparation dependence

    Go to the directory for test.Like this:D:\azure-sdk-for-python\sdk\servicebus\azure-mgmt-servicebus

    And run command:

    pip install -r dev_requirements.txt
    pip install -e .
    
  • Add test proxy certificate

    Copy certificate to cacert.pem in venv\Lib\site-packages\certifi\

  • Then run test command. Like this:

    (venv) D:\azure-sdk-for-python\sdk\servicebus\azure-mgmt-servicebus>pytest tests
    
  • Check the test results MicrosoftTeams-image (4)

  • Complete migration guide

    FYR: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/test_proxy_migration_guide.md#guide-for-migrating-to-the-test-proxy-from-vcrpy

Clone this wiki locally